提交 ec831580 编写于 作者: qq_18203925's avatar qq_18203925

后端整合

上级 733408cc
智慧宿舍
Smart dormitory
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.4/apache-maven-3.8.4-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /usr/local/etc/mavenrc ] ; then
. /usr/local/etc/mavenrc
fi
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`\\unset -f command; \\command -v java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
$MAVEN_DEBUG_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %WRAPPER_JAR% ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%"=="on" pause
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.7</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>edu.fzu</groupId>
<artifactId>dormitory</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>dormitory</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.9</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.28</version>
</dependency>
<dependency>
<groupId>com.topfoxs</groupId>
<artifactId>topfox-core</artifactId>
<version>1.2.10</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>5.3.19</version>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.2</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-typehandlers-jsr310</artifactId>
<version>1.0.2</version>
</dependency>
<dependency>
<groupId>com.alipay.sdk</groupId>
<artifactId>alipay-sdk-java</artifactId>
<version>4.23.0.ALL</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.36</version>
</dependency>
</dependencies>
<build>
<!-- 如果不添加此节点mybatis的mapper.xml文件不会被引用 -->
<resources>
<!-- src/main/java目录下的配置文件 -->
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<!-- src/main/resources目录下的配置文件 -->
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>
\ No newline at end of file
package edu.fzu.dormitory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.transaction.annotation.EnableTransactionManagement;
@SpringBootApplication
@EnableTransactionManagement
public class DormitoryApplication {
public static void main(String[] args) {
SpringApplication.run(DormitoryApplication.class, args);
}
}
package edu.fzu.dormitory.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface Permession {
PermessionType permession() default PermessionType.Admin;
}
\ No newline at end of file
package edu.fzu.dormitory.annotation;
public enum PermessionType {
Admin, SuperAdmin;
}
package edu.fzu.dormitory.aspect;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
import javax.servlet.http.HttpSession;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.stereotype.Component;
import edu.fzu.dormitory.annotation.Permession;
import edu.fzu.dormitory.annotation.PermessionType;
import edu.fzu.dormitory.pojo.Administrator;
import edu.fzu.dormitory.utils.Constant;
@Aspect
@Component
public class PermessionCheckAspect {
@Pointcut("@annotation(edu.fzu.dormitory.annotation.Permession) *")
public void pointCut() {
};
@Around("pointCut()")
public Object permissionCheck(ProceedingJoinPoint joinPoint) throws Throwable {
Signature signature = joinPoint.getSignature();
MethodSignature methodSignature = (MethodSignature) signature;
Method targetMethod = methodSignature.getMethod();
Permession requestPermession = null;
for (Annotation a : targetMethod.getAnnotations())
if (a instanceof Permession)
requestPermession = (Permession) a;
if (requestPermession == null)
return Constant.Deny;
Object[] params = joinPoint.getArgs();
HttpSession session = (HttpSession) params[0];
Administrator admin = (Administrator) session.getAttribute("admin");
if (admin == null)
return Constant.Deny;
PermessionType pType = PermessionType.values()[admin.getPermession()];
if (pType != PermessionType.SuperAdmin && pType != requestPermession.permession())
return Constant.Deny;
return joinPoint.proceed();
}
}
\ No newline at end of file
package edu.fzu.dormitory.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class CorsConfig implements WebMvcConfigurer {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOriginPatterns("*")
.allowedMethods("GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS")
.allowCredentials(true)
.maxAge(3600)
.allowedHeaders("*");
}
}
\ No newline at end of file
package edu.fzu.dormitory.controller;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import edu.fzu.dormitory.pojo.Administrator;
import edu.fzu.dormitory.service.AdminService;
@RestController
@RequestMapping(value = "/admin")
public class AdminController {
@Resource
AdminService adminService;
@RequestMapping(value = "/update", method = RequestMethod.POST)
public Map<String, Object> update(HttpSession session, @RequestBody Administrator administrator) {
return adminService.update(session, administrator);
}
@RequestMapping(value = "/myInfo", method = RequestMethod.GET)
public Map<String, Object> myInfo(HttpSession session) {
return adminService.myInfo(session);
}
@RequestMapping(value = "/search", method = RequestMethod.POST)
public Map<String, Object> search(HttpSession session, @RequestBody Administrator administrator) {
return adminService.search(session, administrator);
}
@RequestMapping(value = "/delete", method = RequestMethod.GET)
public Map<String, Object> delete(HttpSession session, Administrator administrator) {
return adminService.delete(session, administrator);
}
@RequestMapping(value = "/login", method = RequestMethod.POST)
public Map<String, Object> login(HttpSession session, @RequestBody Administrator administrator) {
return adminService.login(session, administrator);
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Map<String, Object> add(HttpSession session, @RequestBody Administrator administrator) {
return adminService.add(session, administrator);
}
}
package edu.fzu.dormitory.controller;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import edu.fzu.dormitory.service.BuildingService;
@RestController
@RequestMapping(value = "/admin/building")
public class BuildingController {
@Resource
BuildingService buildingService;
@RequestMapping(value = "/search", method = RequestMethod.POST)
public Map<String, Object> search(HttpSession session, @RequestBody Map<String, Object> data) {
return buildingService.search(session, data);
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Map<String, Object> add(HttpSession session, @RequestBody Map<String, Object> data) {
return buildingService.add(session, data);
}
@RequestMapping(value = "/addList", method = RequestMethod.POST)
public Map<String, Object> addList(HttpSession session, @RequestBody Map<String, Object> data) {
return buildingService.addList(session, data);
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
public Map<String, Object> update(HttpSession session, @RequestBody Map<String, Object> data) {
return buildingService.update(session, data);
}
@RequestMapping(value = "/addDormitory", method = RequestMethod.POST)
public Map<String, Object> addDormitories(HttpSession session, @RequestBody Map<String, Object> data) {
return buildingService.addDormitories(session, data);
}
@RequestMapping(value = "/findBuildingId", method = RequestMethod.GET)
public Map<String, Object> findBuildingId(HttpSession session) {
return buildingService.findBuildingId(session);
}
@RequestMapping(value = "/findRoomId", method = RequestMethod.POST)
public Map<String, Object> findRoomId(HttpSession session, @RequestBody Map<String, Object> data) {
return buildingService.findRoomId(session, data);
}
}
package edu.fzu.dormitory.controller;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import edu.fzu.dormitory.pojo.CareTaker;
import edu.fzu.dormitory.service.CareTakerService;
@RestController
@RequestMapping(value = "/admin/caretaker")
public class CareTakerController {
@Resource
CareTakerService careTakerService;
@RequestMapping(value = "/search", method = RequestMethod.POST)
public Map<String, Object> search(HttpSession session, @RequestBody CareTaker careTaker) {
return careTakerService.search(session, careTaker);
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Map<String, Object> add(HttpSession session, @RequestBody CareTaker careTaker) {
return careTakerService.add(session, careTaker);
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
public Map<String, Object> update(HttpSession session, @RequestBody CareTaker careTaker) {
return careTakerService.update(session, careTaker);
}
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@SuppressWarnings("unchecked")
public Map<String, Object> delete(HttpSession session, @RequestBody Map<String, Object> data) {
return careTakerService.delete(session, (List<Integer>) data.get("id"));
}
@RequestMapping(value = "/addList", method = RequestMethod.POST)
public Map<String, Object> addList(HttpSession session, @RequestBody Map<String, Object> data) {
return careTakerService.addList(session, data);
}
}
package edu.fzu.dormitory.controller;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import edu.fzu.dormitory.pojo.Complaint;
import edu.fzu.dormitory.service.ComplaintService;
@RestController
@RequestMapping(value = "/admin/complaint")
public class ComplaintController {
@Resource
ComplaintService complaintService;
@RequestMapping(value = "/search", method = RequestMethod.POST)
public Map<String, Object> search(HttpSession session, @RequestBody Map<String, Object> data) {
return complaintService.search(session, data);
}
@RequestMapping(value = "/response", method = RequestMethod.POST)
public Map<String, Object> update(HttpSession session, @RequestBody Complaint complaint) {
return complaintService.update(session, complaint);
}
}
\ No newline at end of file
package edu.fzu.dormitory.controller;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import edu.fzu.dormitory.service.DormitoryRepairService;
@RestController
@RequestMapping(value = "/admin/repair")
public class DormitoryRepairController {
@Resource
DormitoryRepairService dormitoryRepairService;
@RequestMapping(value = "/search", method = RequestMethod.POST)
public Map<String, Object> search(HttpSession session, @RequestBody Map<String, Object> data) {
return dormitoryRepairService.search(session, data);
}
@RequestMapping(value = "/type", method = RequestMethod.GET)
Map<String, Object> search(HttpSession session) {
return dormitoryRepairService.getTypeList(session);
}
}
package edu.fzu.dormitory.controller;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import edu.fzu.dormitory.service.FileService;
@RestController
public class FileController {
@Resource
FileService fileService;
@RequestMapping(value = "/upload", method = RequestMethod.POST)
Map<String, Object> upload(@RequestPart MultipartFile file) {
return fileService.upload(file);
}
}
package edu.fzu.dormitory.controller;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import edu.fzu.dormitory.service.MainPageService;
@RestController
@RequestMapping(value = "/admin")
public class MainPageController {
@Resource
MainPageService mainPageService;
@RequestMapping(value = "/mainPageData", method = RequestMethod.GET)
public Map<String, Object> getMainPageData(HttpSession session) {
return mainPageService.getMainPageData(session);
}
}
package edu.fzu.dormitory.controller;
import edu.fzu.dormitory.pojo.PaymentRecord;
import edu.fzu.dormitory.pojo.PaymentTask;
import edu.fzu.dormitory.service.PaymentService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Map;
@RestController
@RequestMapping(value = "/admin/charge")
public class PaymentController {
@Resource
PaymentService paymentService;
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Map<String, Object> addPaymentTask(HttpSession session, @RequestBody PaymentTask paymentTask) {
return paymentService.addPaymentTask(session, paymentTask);
}
@RequestMapping(value = "/delete", method = RequestMethod.POST)
public Map<String, Object> deletePaymentTask(HttpSession session, @RequestBody PaymentTask paymentTask) {
return paymentService.deletePaymentTask(session, paymentTask);
}
@RequestMapping(value = "/status", method = RequestMethod.GET)
public Map<String, Object> getStatus(HttpSession session, PaymentTask paymentTask) {
return paymentService.getStatus(session, paymentTask);
}
@RequestMapping(value = "/detail", method = RequestMethod.GET)
public Map<String, Object> getPaymentRecordDetail(HttpSession session, PaymentRecord paymentRecord) {
return paymentService.getPaymentRecordDetail(session, paymentRecord);
}
@RequestMapping(value = "/search", method = RequestMethod.POST)
public Map<String, Object> searchPaymentTask(HttpSession session, @RequestBody PaymentTask paymentTask) {
return paymentService.searchPaymentTask(session, paymentTask);
}
@RequestMapping(value = "/addDetail", method = RequestMethod.POST)
public Map<String, Object> addDetail(HttpSession session, @RequestBody Map<String, Object> args) {
return paymentService.addDetail(session, args);
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
public Map<String, Object> update(HttpSession session, @RequestBody PaymentTask paymentTask) {
return paymentService.update(session, paymentTask);
}
}
package edu.fzu.dormitory.controller;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import edu.fzu.dormitory.service.PublicRepairService;
@RestController
@RequestMapping(value = "/admin/publicFacilitiesRepair")
public class PublicRepairRecordController {
@Resource
PublicRepairService publicRepairService;
@RequestMapping(value = "/search", method = RequestMethod.POST)
Map<String, Object> search(HttpSession session, @RequestBody Map<String, Object> data) {
return publicRepairService.search(session, data);
}
@RequestMapping(value = "/type", method = RequestMethod.GET)
Map<String, Object> search(HttpSession session) {
return publicRepairService.getTypeList(session);
}
}
package edu.fzu.dormitory.controller;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import edu.fzu.dormitory.pojo.Repairer;
import edu.fzu.dormitory.service.RepairerService;
@RestController
@RequestMapping(value = "/admin/repairer")
public class RepairerController {
@Resource
RepairerService repairerService;
@RequestMapping(value = "/search", method = RequestMethod.POST)
public Map<String, Object> search(HttpSession session, @RequestBody Repairer repairer) {
return repairerService.search(session, repairer);
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Map<String, Object> add(HttpSession session, @RequestBody Repairer repairer) {
return repairerService.add(session, repairer);
}
@RequestMapping(value = "/addList", method = RequestMethod.POST)
public Map<String, Object> addList(HttpSession session, @RequestBody Map<String, Object> data) {
return repairerService.addList(session, data);
}
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@SuppressWarnings("unchecked")
public Map<String, Object> delete(HttpSession session, @RequestBody Map<String, Object> data) {
return repairerService.delete(session, (List<Integer>) data.get("id"));
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
public Map<String, Object> update(HttpSession session, @RequestBody Repairer repairer) {
return repairerService.update(session, repairer);
}
@RequestMapping(value = "/type", method = RequestMethod.GET)
public Map<String, Object> repairTypeList(HttpSession session) {
return repairerService.getRepairTypeList(session);
}
}
package edu.fzu.dormitory.controller;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import edu.fzu.dormitory.pojo.SignInTask;
import edu.fzu.dormitory.pojo.SignInTaskRecord;
import edu.fzu.dormitory.service.SignInTaskService;
@RestController
@RequestMapping(value = "/admin/signIn")
public class SignInController {
@Resource
SignInTaskService signInTaskService;
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Map<String, Object> add(HttpSession session, @RequestBody SignInTask signInTask) {
return signInTaskService.add(session, signInTask);
}
@RequestMapping(value = "/search", method = RequestMethod.POST)
public Map<String, Object> search(HttpSession session, @RequestBody SignInTask signInTask) {
return signInTaskService.search(session, signInTask);
}
@RequestMapping(value = "/detail", method = RequestMethod.POST)
public Map<String, Object> detail(HttpSession session, @RequestBody SignInTaskRecord signInTaskRecord) {
return signInTaskService.detail(session, signInTaskRecord);
}
@RequestMapping(value = "/status", method = RequestMethod.GET)
public Map<String, Object> getStatus(HttpSession session, SignInTask signInTask) {
return signInTaskService.getStatus(session, signInTask);
}
}
package edu.fzu.dormitory.controller;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import edu.fzu.dormitory.service.StudentService;
@RestController
@RequestMapping(value = "/admin/student")
public class StudentController {
@Resource
StudentService studentService;
@RequestMapping(value = "/search", method = RequestMethod.POST)
public Map<String, Object> search(HttpSession session, @RequestBody Map<String, Object> data) {
return studentService.search(session, data);
}
@RequestMapping(value = "/update", method = RequestMethod.POST)
public Map<String, Object> update(HttpSession session, @RequestBody Map<String, Object> data) {
return studentService.update(session, data);
}
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@SuppressWarnings("unchecked")
public Map<String, Object> delete(HttpSession session, @RequestBody Map<String, Object> data) {
return studentService.delete(session, (List<Integer>) data.get("id"));
}
@RequestMapping(value = "/college", method = RequestMethod.GET)
public Map<String, Object> getCollege(HttpSession session) {
return studentService.getCollege(session);
}
@RequestMapping(value = "/add", method = RequestMethod.POST)
public Map<String, Object> add(HttpSession session, @RequestBody Map<String, Object> data) {
return studentService.add(session, data);
}
@RequestMapping(value = "/addList", method = RequestMethod.POST)
public Map<String, Object> addList(HttpSession session, @RequestBody Map<String, Object> data) {
return studentService.addList(session, data);
}
}
package edu.fzu.dormitory.dao;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import edu.fzu.dormitory.pojo.Administrator;
@Mapper
public interface AdministratorMapper {
@SelectProvider(type = edu.fzu.dormitory.dao.AdministratorSQLProvider.class, method = "select")
List<Administrator> findAdmin(Administrator administrator);
@Insert("insert into dormitory_sys.administrator values(0,#{username},#{password},#{tel},#{name},#{salt}, 0)")
int insert(Administrator administrator);
@UpdateProvider(type = edu.fzu.dormitory.dao.AdministratorSQLProvider.class, method = "update")
int update(Administrator administrator);
@Delete("delete from dormitory_sys.administrator where id = #{id}")
int delete(Administrator administrator);
@Update("update dormitory_sys.administrator set permession = #{permession} where id = #{id})")
int changePermession(Administrator administrator);
}
package edu.fzu.dormitory.dao;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.stereotype.Component;
import edu.fzu.dormitory.pojo.Administrator;
@Component
public class AdministratorSQLProvider {
public String update(Administrator administrator) {
return new SQL() {
{
UPDATE("dormitory_sys.administrator");
if (administrator.getPassword() != null)
SET("password=#{password}");
if (administrator.getName() != null)
SET("name=#{name}");
if (administrator.getTel() != null)
SET("tel=#{tel}");
WHERE("id=#{id}");
}
}.toString();
}
public String select(Administrator administrator) {
return new SQL() {
{
SELECT("id,username,password,tel,name,salt,permession");
FROM("dormitory_sys.administrator");
if (administrator.getId() != null)
WHERE("id=#{id}");
if (administrator.getUsername() != null)
WHERE("username=#{username}");
if (administrator.getName() != null)
WHERE("name=#{name}");
if (administrator.getTel() != null)
WHERE("tel=#{tel}");
if (administrator.getPermession() != null)
WHERE("permession=#{permession}");
}
}.toString();
}
}
package edu.fzu.dormitory.dao;
import java.util.List;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import edu.fzu.dormitory.pojo.Building;
@Mapper
public interface BuildingMapper {
@SelectProvider(type = edu.fzu.dormitory.dao.BuildingSQLProvider.class, method = "select")
@Results({ @Result(id = true, column = "id", property = "id"),
@Result(column = "cno", property = "caretaker.cno"),
@Result(column = "caretakerName", property = "caretaker.name"),
@Result(column = "tel", property = "caretaker.tel")
})
List<Building> findBuilding(Building building);
@Insert("insert into building values(0,#{bid},#{caretaker.cno},#{area})")
int add(Building building);
@UpdateProvider(type = edu.fzu.dormitory.dao.BuildingSQLProvider.class, method = "update")
int update(Building building);
@Insert("<script> insert into dormitory_sys.building values <foreach collection = 'buildings' index = 'index' item = 'item' open = '' separator = ',' close = ''> (0,#{item.bid},#{item.cno},#{item.area}) </foreach> </script>")
int addBuildingList(List<Building> buildings);
@Select("select bid from building")
List<Integer> findBuildingId();
@Select("select rid from dormitory where bid = #{bid}")
List<Integer> findRoomId(Integer bid);
}
package edu.fzu.dormitory.dao;
import org.apache.ibatis.jdbc.SQL;
import edu.fzu.dormitory.pojo.Building;
public class BuildingSQLProvider {
public String select(Building building) {
return new SQL() {
{
SELECT("building.id,building.bid,count(dormitory.id) as rcount,area,caretaker.cno,caretaker.name as caretakerName, caretaker.tel");
FROM("(building left join dormitory on building.bid = dormitory.bid), caretaker");
if (building.getId() != null)
WHERE("building.id=#{id}");
if (building.getBid() != null)
WHERE("building.bid=#{bid}");
if (building.getCaretaker() != null && building.getCaretaker().getCno() != null)
WHERE("building.cno=#{caretaker.cno}");
if (building.getArea() != null)
WHERE("area=#{area}");
WHERE("building.cno = caretaker.cno");
GROUP_BY("building.bid");
}
}.toString();
}
public String update(Building building) {
return new SQL() {
{
UPDATE("building");
if (building.getBid() != null)
SET("bid=#{bid}");
if (building.getArea() != null)
SET("area=#{area}");
if (building.getCaretaker() != null && building.getCaretaker().getCno() != null)
SET("cno=#{caretaker.cno}");
WHERE("id=#{id}");
}
}.toString();
}
}
package edu.fzu.dormitory.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.UpdateProvider;
import edu.fzu.dormitory.pojo.CareTaker;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
@Mapper
public interface CareTakerMapper {
List<CareTaker> findCareTaker(CareTaker careTaker);
@UpdateProvider(type = edu.fzu.dormitory.dao.CareTakerSQLProvider.class, method = "update")
int update(CareTaker careTaker);
@Insert("insert into dormitory_sys.caretaker values(0,#{cno},#{name},#{sex},#{starttime},#{endtime},#{tel})")
int add(CareTaker careTaker);
@Delete("<script> delete from dormitory_sys.caretaker where id in <foreach collection = 'id' index = 'index' item = 'item' open = '(' separator = ',' close = ')'> #{item} </foreach> </script>")
int delete(List<Integer> id);
@Insert("<script> insert into dormitory_sys.caretaker values <foreach collection = 'careTakers' index = 'index' item = 'item' open = '' separator = ',' close = ''> (0,#{item.cno},#{item.name},#{item.sex},#{item.starttime},#{item.endtime},#{item.tel}) </foreach> </script>")
int addCareTakerList(List<CareTaker> careTakers);
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="edu.fzu.dormitory.dao.CareTakerMapper">
<resultMap id="findCareTakerResultMap" type="edu.fzu.dormitory.pojo.CareTaker">
<id property="id" column="id" />
<result property="starttime" column="starttime" />
<result property="endtime" column="endtime" />
<result property="tel" column="tel" />
<result property="endtime" column="endtime" />
<result property="cno" column="cno" />
<result property="sex" column="sex" />
<result property="name" column="name" />
<collection property="buildings" ofType="edu.fzu.dormitory.pojo.Building">
<id property="id" column="building_id" />
<result property="cid" column="cid" />
<result property="bid" column="bid" />
<result property="area" column="area" />
</collection>
</resultMap>
<select id="findCareTaker" parameterType="edu.fzu.dormitory.pojo.CareTaker" resultMap="findCareTakerResultMap">
select caretaker.id,caretaker.cno,name,sex,starttime,endtime,tel,building.id as building_id ,building.bid,building.area
from dormitory_sys.caretaker left join dormitory_sys.building on caretaker.cno = building.cno
<where>
<if test="id!=null">
caretaker.id=#{id}
</if>
<if test="cno!=null">
caretaker.cno=#{cno}
</if>
<if test="name!=null">
name=#{name}
</if>
<if test="sex!=null">
sex=#{sex}
</if>
<if test="starttime!=null">
starttime=#{starttime}
</if>
<if test="endtime!=null">
endtime=#{endtime}
</if>
<if test="tel!=null">
caretaker.tel=#{tel}
</if>
<if test="bid!=null">
building.bid=#{bid}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
package edu.fzu.dormitory.dao;
import org.apache.ibatis.jdbc.SQL;
import edu.fzu.dormitory.pojo.CareTaker;
public class CareTakerSQLProvider {
public String select(CareTaker careTaker) {
return new SQL() {
{
SELECT("caretaker.id,cno,name,sex,starttime,endtime,tel,building.id,building.cno,building.area");
FROM("dormitory_sys.caretaker,dormitory_sys.building");
if (careTaker.getId() != null)
WHERE("id=#{id}");
if (careTaker.getCno() != null)
WHERE("cno=#{cno}");
if (careTaker.getName() != null)
WHERE("name=#{name}");
if (careTaker.getSex() != null)
WHERE("sex=#{sex}");
if (careTaker.getStarttime() != null)
WHERE("starttime<=TIME(#{starttime})");
if (careTaker.getEndtime() != null)
WHERE("endtime>=TIME(#{endtime})");
if (careTaker.getTel() != null)
WHERE("tel=#{tel}");
WHERE("caretaker.cno=building.cno");
}
}.toString();
}
public String update(CareTaker careTaker) {
return new SQL() {
{
UPDATE("dormitory_sys.caretaker");
if (careTaker.getName() != null)
SET("name=#{name}");
if (careTaker.getSex() != null)
SET("sex=#{sex}");
if (careTaker.getStarttime() != null)
SET("starttime=TIME(#{starttime})");
if (careTaker.getEndtime() != null)
SET("endtime=TIME(#{endtime})");
if (careTaker.getTel() != null)
SET("tel=#{tel}");
WHERE("cno=#{cno}");
}
}.toString();
}
}
package edu.fzu.dormitory.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import edu.fzu.dormitory.pojo.College;
@Mapper
public interface CollegeMapper {
@Select("select id, name from dormitory_sys.college where id = #{id}")
College findCollege(College college);
@Select("select id, name from dormitory_sys.college")
List<College> findAll();
}
\ No newline at end of file
package edu.fzu.dormitory.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import edu.fzu.dormitory.pojo.Complaint;
@Mapper
public interface ComplaintMapper {
@SelectProvider(type = edu.fzu.dormitory.dao.ComplaintSQLProvider.class, method = "select")
@Results({ @Result(id = true, column = "id", property = "id"),
@Result(column = "sno", property = "student.sno"),
@Result(column = "studentName", property = "student.name"),
@Result(column = "tel", property = "student.tel")
})
List<Complaint> findComplaint(Complaint complaint);
@Update("update complaint set response=#{response}, status = 1 where id=#{id}")
int update(Complaint complaint);
}
package edu.fzu.dormitory.dao;
import org.apache.ibatis.jdbc.SQL;
import edu.fzu.dormitory.pojo.Complaint;
public class ComplaintSQLProvider {
public String select(Complaint complaint) {
return new SQL() {
{
SELECT("complaint.id, student.sno, student.name as studentName, complaint.describe, complaint.status, submittime, image, response, student.tel");
FROM("complaint, student");
WHERE("complaint.sno = student.sno");
if (complaint.getStudent() != null && complaint.getStudent().getSno() != null)
WHERE("complaint.sno=#{student.sno}");
if (complaint.getStatus() != null)
WHERE("complaint.status=#{status}");
}
}.toString();
}
}
package edu.fzu.dormitory.dao;
import java.util.List;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import edu.fzu.dormitory.pojo.Dormitory;
import edu.fzu.dormitory.pojo.StudentCount;
@Mapper
public interface DormitoryMapper {
@SelectProvider(type = edu.fzu.dormitory.dao.DormitorySQLProvider.class, method = "select")
List<Dormitory> findDormitory(Dormitory dormitory);
@Update("update dormitory_sys.dormitory set count = count + 1 where id=#{id}")
int increaseCount(Dormitory dormitory);
@Update("update dormitory_sys.dormitory set count = count - 1 where id=#{id}")
int decreaseCount(Dormitory dormitory);
@Select("select bid, sum(count) as count from dormitory group by bid")
List<StudentCount> countStudent();
@Update("<script> update dormitory_sys.dormitory set count = count - 1 where id in <foreach collection = 'id' index = 'index' item = 'item' open = '(' separator = ',' close = ')'> #{item} </foreach> </script>")
int decreaseCountList(List<Integer> id);
@Insert("<script> insert into dormitory_sys.dormitory values <foreach collection = 'dormitories' index = 'index' item = 'item' open = '' separator = ',' close = ''> (0,#{item.bid},#{item.rid},#{item.maxcount},0) </foreach> </script>")
int addDormitories(List<Dormitory> dormitories);
}
\ No newline at end of file
package edu.fzu.dormitory.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import edu.fzu.dormitory.pojo.DormitoryRepairRecord;
@Mapper
public interface DormitoryRepairRecordMapper {
@SelectProvider(type = edu.fzu.dormitory.dao.DormitoryRepairRecordSQLProvider.class, method = "select")
@Results({ @Result(id = true, column = "id", property = "id"),
@Result(column = "did", property = "dormitory.id"),
@Result(column = "bid", property = "dormitory.bid"),
@Result(column = "rid", property = "dormitory.rid"),
@Result(column = "repairTypeId", property = "repairType.id"),
@Result(column = "repairTypeName", property = "repairType.name"),
@Result(column = "wno", property = "repairer.wno"),
@Result(column = "repairerName", property = "repairer.name"),
@Result(column = "sno", property = "student.sno"),
@Result(column = "studentName", property = "student.name"),
@Result(column = "tel", property = "student.tel")
})
List<DormitoryRepairRecord> findRepairRecord(DormitoryRepairRecord dormitoryRepairRecord);
}
package edu.fzu.dormitory.dao;
import org.apache.ibatis.jdbc.SQL;
import edu.fzu.dormitory.pojo.DormitoryRepairRecord;
public class DormitoryRepairRecordSQLProvider {
public String select(DormitoryRepairRecord dormitoryRepairRecord) {
return new SQL() {
{
SELECT("dormitory_repair.id, student.sno, student.name as studentName, repairer.wno, repairer.name as repairerName, submittime, dormitory_repair.describe, image, dormitory_repair.status, other, dormitory.id as did, dormitory.bid, dormitory.rid, repairtype.id as repairTypeId, repairtype.name as repairTypeName, student.tel");
FROM("dormitory_repair, repairtype, dormitory, student, repairer");
WHERE("dormitory_repair.did = dormitory.id and repairType = repairtype.id and dormitory_repair.sno = student.sno and dormitory_repair.wno = repairer.wno");
if (dormitoryRepairRecord.getDormitory() != null
&& dormitoryRepairRecord.getDormitory().getBid() != null)
WHERE("bid=#{dormitory.bid}");
if (dormitoryRepairRecord.getRepairType() != null
&& dormitoryRepairRecord.getRepairType().getId() != null)
WHERE("repairType=#{repairType.id}");
if (dormitoryRepairRecord.getStudent() != null && dormitoryRepairRecord.getStudent().getSno() != null)
WHERE("dormitory_repair.sno=#{student.sno}");
}
}.toString();
}
}
package edu.fzu.dormitory.dao;
import org.apache.ibatis.jdbc.SQL;
import edu.fzu.dormitory.pojo.Dormitory;
public class DormitorySQLProvider {
public String select(Dormitory dormitory) {
return new SQL() {
{
SELECT("id,bid,rid,maxcount,count");
FROM("dormitory_sys.dormitory");
if (dormitory.getId() != null)
WHERE("id=#{id}");
if (dormitory.getBid() != null)
WHERE("bid=#{bid}");
if (dormitory.getRid() != null)
WHERE("rid=#{rid}");
}
}.toString();
}
}
package edu.fzu.dormitory.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import edu.fzu.dormitory.pojo.ComplaintCount;
import edu.fzu.dormitory.pojo.PeopleCount;
@Mapper
public interface MainPageDataMapper {
@Select("select count(*) from building")
int getBCount();
@Select("select count(*) from dormitory")
int getRCount();
@Select("select sum(count) from dormitory")
int getPCount();
@Select("select area, sum(count) as count from dormitory, building where dormitory.bid = building.bid group by area")
List<PeopleCount> getPeopleData();
@Select("select MONTH(submittime) as month, count(*) as count from complaint where YEAR(submittime)=YEAR(now()) group by MONTH(submittime)")
List<ComplaintCount> getComplaintCount();
}
package edu.fzu.dormitory.dao;
import edu.fzu.dormitory.pojo.PaymentRecord;
import edu.fzu.dormitory.pojo.PaymentTask;
import org.apache.ibatis.annotations.*;
import java.util.List;
import java.util.Map;
@Mapper
public interface PaymentRecordMapper {
@Select("select count(id) as finished, bid from dormitory_sys.payment_record where pid = #{id} and status = 1 group by bid")
List<Map<String, Object>> getFinishedPerBuilding(PaymentTask paymentTask);
@Select("select count(id) as countAll, bid from dormitory_sys.payment_record where pid = #{id} group by bid")
List<Map<String, Object>> getAllPerBuilding(PaymentTask paymentTask);
@Select("select alltable.bid, finished,countAll from( \n" +
"select count(id) as countAll, bid from dormitory_sys.payment_record where pid = #{id} group by bid\n" +
") as alltable left join (\n" +
"select count(id) as finished, bid from dormitory_sys.payment_record where pid = #{id} and status = 1 group by bid\n"
+
") as finishedtable \n" +
"on alltable.bid = finishedtable.bid")
List<Map<String, Object>> getStatus(PaymentTask paymentTask);
@SelectProvider(value = edu.fzu.dormitory.dao.PaymentRecordSQLProvieder.class, method = "select")
List<PaymentRecord> select(PaymentRecord paymentRecord);
@Insert("<script> insert into dormitory_sys.payment_record values <foreach collection = 'paymentRecords' index = 'index' item = 'item' open = '' separator = ',' close = ''> (0,#{item.bid},#{item.pid},#{item.rid},0,null,#{item.money}) </foreach> </script>")
int addDetail(List<PaymentRecord> paymentRecords);
@Delete("delete from dormitory_sys.payment_record where pid = #{id}")
int delete(PaymentTask paymentTask);
}
package edu.fzu.dormitory.dao;
import edu.fzu.dormitory.pojo.PaymentRecord;
import org.apache.ibatis.jdbc.SQL;
public class PaymentRecordSQLProvieder {
public String select(PaymentRecord paymentRecord) {
return new SQL() {
{
SELECT("*");
FROM("dormitory_sys.payment_record");
if (paymentRecord.getPid() != null)
WHERE("pid=#{pid}");
if (paymentRecord.getBid() != null)
WHERE("bid=#{bid}");
if (paymentRecord.getStatus() != null)
WHERE("status=#{status}");
}
}.toString();
}
}
package edu.fzu.dormitory.dao;
import edu.fzu.dormitory.pojo.PaymentTask;
import org.apache.ibatis.annotations.*;
import java.util.List;
@Mapper
public interface PaymentTaskMapper {
@Insert("INSERT INTO `dormitory_sys`.`payment_task` (`name`, `starttime`, `endtime`, `admin`) VALUES (#{name}, #{startTime}, #{endTime}, #{admin})")
int insert(PaymentTask paymentTask);
@Delete("delete from dormitory_sys.payment_task where id = #{id}")
int delete(PaymentTask paymentTask);
@SelectProvider(value = edu.fzu.dormitory.dao.PaymentTaskSQLProvider.class, method = "select")
List<PaymentTask> select(PaymentTask paymentTask);
@UpdateProvider(value = edu.fzu.dormitory.dao.PaymentTaskSQLProvider.class, method = "update")
int update(PaymentTask paymentTask);
}
package edu.fzu.dormitory.dao;
import edu.fzu.dormitory.pojo.PaymentTask;
import org.apache.ibatis.jdbc.SQL;
public class PaymentTaskSQLProvider {
public String select(PaymentTask paymentTask) {
return new SQL() {
{
SELECT("payment_task.id, payment_task.name, payment_task.starttime, payment_task.endtime, administrator.name as adminName");
FROM("dormitory_sys.payment_task, dormitory_sys.administrator");
if (paymentTask.getAdmin() != null)
WHERE("admin=#{admin}");
if (paymentTask.getName() != null)
WHERE("name=#{name}");
if (paymentTask.getStartTime() != null)
WHERE("starttime=#{startTime}");
if (paymentTask.getEndTime() != null)
WHERE("endtime=#{endTime}");
WHERE("payment_task.admin = administrator.id");
}
}.toString();
}
public String update(PaymentTask paymentTask) {
return new SQL() {
{
UPDATE("dormitory_sys.payment_task");
if (paymentTask.getName() != null)
SET("name=#{name}");
if (paymentTask.getStartTime() != null)
SET("starttime=#{startTime}");
if (paymentTask.getEndTime() != null)
SET("endtime=#{endTime}");
WHERE("id=#{id}");
}
}.toString();
}
}
package edu.fzu.dormitory.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import edu.fzu.dormitory.pojo.PublicRepairRecord;
@Mapper
public interface PublicRepairRecordMapper {
@SelectProvider(type = edu.fzu.dormitory.dao.PublicRepairRecordSQLProvider.class, method = "select")
@Results({ @Result(id = true, column = "id", property = "id"),
@Result(column = "wno", property = "repairer.wno"),
@Result(column = "repairerName", property = "repairer.name"),
@Result(column = "repairTypeId", property = "repairType.id"),
@Result(column = "repairTypeName", property = "repairType.name"),
@Result(column = "cno", property = "careTaker.cno"),
@Result(column = "caretakerName", property = "careTaker.name"),
@Result(column = "tel", property = "careTaker.tel")
})
List<PublicRepairRecord> findPublicRepairRecord(PublicRepairRecord publicRepairRecord);
}
package edu.fzu.dormitory.dao;
import org.apache.ibatis.jdbc.SQL;
import edu.fzu.dormitory.pojo.PublicRepairRecord;
public class PublicRepairRecordSQLProvider {
public String select(PublicRepairRecord publicRepairRecord) {
return new SQL() {
{
SELECT("public_repair.id, bid, public_repair.describe, public_repair.status, repairer.wno, repairer.name as repairerName, image, other, status, submittime, caretaker.cno, caretaker.name as caretakerName, repairtype.id as repairTypeId, repairtype.name as repairTypeName, caretaker.tel");
FROM("public_repair, repairer, caretaker, repairtype");
WHERE("public_repair.cno = caretaker.cno and repairer.wno = public_repair.wno and repairtype.id = repairtype");
if (publicRepairRecord.getCareTaker() != null && publicRepairRecord.getCareTaker().getCno() != null)
WHERE("public_repair.cno=#{careTaker.cno}");
if (publicRepairRecord.getRepairType() != null && publicRepairRecord.getRepairType().getId() != null)
WHERE("repairtype=#{repairType.id}");
if (publicRepairRecord.getStatus() != null)
WHERE("status=#{status}");
if (publicRepairRecord.getBid() != null)
WHERE("public_repair.bid = #{bid}");
}
}.toString();
}
}
package edu.fzu.dormitory.dao;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import edu.fzu.dormitory.pojo.RepairType;
@Mapper
public interface RepairTypeMapper {
@Select("select id,name from dormitory_sys.repairtype")
List<RepairType> findAll();
@Select("select id,name from dormitory_sys.repairtype where id=#{id}")
List<RepairType> findRepairType(RepairType repairType);
@Select("select id,name from dormitory_sys.repairtype where type = 0")
List<RepairType> findDormitoryRepairType();
@Select("select id,name from dormitory_sys.repairtype where type = 1")
List<RepairType> findPublicRepairType();
}
package edu.fzu.dormitory.dao;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import edu.fzu.dormitory.pojo.Repairer;
@Mapper
public interface RepairerMapper {
@SelectProvider(type = edu.fzu.dormitory.dao.RepairerSQLProvider.class, method = "select")
@Results({ @Result(id = true, column = "id", property = "id"),
@Result(column = "repairtypeid", property = "repairtypeid"),
@Result(column = "repairtypeid", property = "repairType.id"),
@Result(column = "rname", property = "repairType.name")
})
List<Repairer> findRepairer(Repairer repairer);
@UpdateProvider(type = edu.fzu.dormitory.dao.RepairerSQLProvider.class, method = "update")
int update(Repairer repairer);
@Insert("insert into dormitory_sys.repairer values(0,#{wno},#{name},#{sex},#{tel},#{repairtypeid},#{starttime},#{endtime})")
int add(Repairer repairer);
@Delete("<script> delete from dormitory_sys.repairer where id in <foreach collection = 'id' index = 'index' item = 'item' open = '(' separator = ',' close = ')'> #{item} </foreach> </script>")
int delete(List<Integer> id);
@Insert("<script> insert into dormitory_sys.repairer values <foreach collection = 'repairers' index = 'index' item = 'item' open = '' separator = ',' close = ''> (0,#{item.wno},#{item.name},#{item.sex},#{item.tel},#{item.repairtypeid},#{item.starttime},#{item.endtime}) </foreach> </script>")
int addRepairerList(List<Repairer> repairers);
}
package edu.fzu.dormitory.dao;
import org.apache.ibatis.jdbc.SQL;
import edu.fzu.dormitory.pojo.Repairer;
public class RepairerSQLProvider {
public String select(Repairer repairer) {
return new SQL() {
{
SELECT("repairer.id,wno,repairer.name,sex,tel,repairtypeid,starttime,endtime,repairtype.name as rname");
FROM("dormitory_sys.repairer, dormitory_sys.repairtype");
if (repairer.getId() != null)
WHERE("id=#{id}");
if (repairer.getWno() != null)
WHERE("wno=#{wno}");
if (repairer.getName() != null)
WHERE("name=#{name}");
if (repairer.getSex() != null)
WHERE("sex=#{sex}");
if (repairer.getStarttime() != null)
WHERE("starttime<=TIME(#{starttime})");
if (repairer.getEndtime() != null)
WHERE("endtime>=TIME(#{endtime})");
if (repairer.getTel() != null)
WHERE("tel=#{tel}");
if (repairer.getRepairtypeid() != null)
WHERE("repairtypeid=#{repairtypeid}");
WHERE("repairer.repairtypeid=repairtype.id");
}
}.toString();
}
public String update(Repairer repairer) {
return new SQL() {
{
UPDATE("dormitory_sys.repairer");
if (repairer.getName() != null)
SET("name=#{name}");
if (repairer.getSex() != null)
SET("sex=#{sex}");
if (repairer.getStarttime() != null)
SET("starttime=TIME(#{starttime})");
if (repairer.getEndtime() != null)
SET("endtime=TIME(#{endtime})");
if (repairer.getTel() != null)
SET("tel=#{tel}");
if (repairer.getRepairtypeid() != null)
SET("repairtypeid=#{repairtypeid}");
WHERE("wno=#{wno}");
}
}.toString();
}
}
package edu.fzu.dormitory.dao;
import java.util.List;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import edu.fzu.dormitory.pojo.SignInTask;
import edu.fzu.dormitory.pojo.SignInTaskRecord;
import edu.fzu.dormitory.pojo.StudentCount;
@Mapper
public interface SignInTaskMapper {
@Insert("insert into signin_task values(0,#{starttime},#{endtime},#{name},#{cycle},#{location},#{admin},#{college},#{bid},#{longitude},#{latitude})")
int add(SignInTask signInTask);
@SelectProvider(type = edu.fzu.dormitory.dao.SignInTaskSQLProvider.class, method = "select")
List<SignInTask> findSignInTask(SignInTask signInTask);
@SelectProvider(type = edu.fzu.dormitory.dao.SignInTaskSQLProvider.class, method = "detail")
List<SignInTaskRecord> detail(SignInTaskRecord signInTaskRecord);
@Select("select dormitory.bid, count(*) as count from signin_record, student, dormitory where signin_record.sno=student.sno and student.did=dormitory.id and signin_record.tid=#{id} group by dormitory.bid")
List<StudentCount> getStatus(SignInTask signInTask);
}
package edu.fzu.dormitory.dao;
import org.apache.ibatis.jdbc.SQL;
import edu.fzu.dormitory.pojo.SignInTask;
import edu.fzu.dormitory.pojo.SignInTaskRecord;
public class SignInTaskSQLProvider {
public String select(SignInTask signInTask) {
return new SQL() {
{
SELECT("id,admin,name,starttime,endtime,location,cycle,longitude,latitude");
FROM("dormitory_sys.signin_task");
if (signInTask.getId() != null)
WHERE("id=#{id}");
if (signInTask.getName() != null)
WHERE("name=#{name}");
if (signInTask.getStarttime() != null)
WHERE("starttime<=#{starttime}");
if (signInTask.getEndtime() != null)
WHERE("endtime>=#{endtime}");
if (signInTask.getLocation() != null)
WHERE("location=#{location}");
if (signInTask.getCycle() != null)
WHERE("cycle=#{cycle}");
if (signInTask.getBid() != null)
WHERE("bid=#{bid}");
if (signInTask.getCollege() != null)
WHERE("college=#{college}");
WHERE("starttime<=now()");
}
}.toString();
}
public String detail(SignInTaskRecord signInTaskRecord) {
return new SQL() {
{
SELECT("signin_record.id, student.sno, student.name, signin_record.submittime, dormitory.bid, dormitory.rid, student.bed");
FROM("(student left join signin_record on student.sno = signin_record.sno and signin_record.tid = #{tid}), dormitory");
WHERE("student.did = dormitory.id");
if (signInTaskRecord.getBid() != null)
WHERE("dormitory.bid=#{bid}");
if (signInTaskRecord.getStatus() != null) {
if (signInTaskRecord.getStatus() == 0)
WHERE("signin_record.submittime is null");
else
WHERE("signin_record.submittime is not null");
}
}
}.toString();
}
}
package edu.fzu.dormitory.dao;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.annotations.Results;
import edu.fzu.dormitory.pojo.Student;
@Mapper
public interface StudentMapper {
@SelectProvider(type = edu.fzu.dormitory.dao.StudentSQLProvider.class, method = "select")
@Results({ @Result(id = true, column = "id", property = "id"),
@Result(column = "cid", property = "cid"),
@Result(column = "did", property = "did"),
@Result(column = "did", property = "dormitory.id"),
@Result(column = "bid", property = "dormitory.bid"),
@Result(column = "rid", property = "dormitory.rid"),
@Result(column = "count", property = "dormitory.count"),
@Result(column = "maxcount", property = "dormitory.maxcount"),
@Result(column = "cid", property = "college.id"),
@Result(column = "cname", property = "college.name")
})
List<Student> findStudent(Student student);
@UpdateProvider(type = edu.fzu.dormitory.dao.StudentSQLProvider.class, method = "update")
int update(Student student);
@Delete("<script> delete from dormitory_sys.student where id in <foreach collection = 'id' index = 'index' item = 'item' open = '(' separator = ',' close = ')'> #{item} </foreach> </script>")
int detele(List<Integer> id);
@Insert("insert into dormitory_sys.student values(0,#{sno},#{name},#{idcard},#{cid},#{tel},#{did},#{bed},#{sex})")
int add(Student student);
@Insert("<script> insert into dormitory_sys.student values <foreach collection = 'students' index = 'index' item = 'item' open = '' separator = ',' close = ''> (0,#{item.sno},#{item.name},#{item.idcard},#{item.cid},#{item.tel},#{item.did},#{item.bed},#{item.sex}) </foreach> </script>")
int addStudentList(List<Student> students);
}
package edu.fzu.dormitory.dao;
import org.apache.ibatis.jdbc.SQL;
import org.springframework.stereotype.Component;
import edu.fzu.dormitory.pojo.Student;
@Component
public class StudentSQLProvider {
public String select(Student student) {
return new SQL() {
{
SELECT("student.id as id,sno,student.name as name,idcard,sex,tel,bed,dormitory.id as did,dormitory.bid,dormitory.rid,college.id as cid,college.name as cname,count,maxcount");
FROM("dormitory_sys.student,dormitory_sys.dormitory,dormitory_sys.college");
if (student.getId() != null)
WHERE("student.id=#{id}");
if (student.getSno() != null)
WHERE("sno=#{sno}");
if (student.getName() != null)
WHERE("name=#{name}");
if (student.getIdcard() != null)
WHERE("idcard=#{idcard}");
if (student.getCid() != null)
WHERE("cid=#{cid}");
if (student.getDid() == null) {
if (student.getDormitory() != null) {
if (student.getDormitory().getBid() != null)
WHERE("dormitory.bid=#{dormitory.bid}");
if (student.getDormitory().getRid() != null)
WHERE("dormitory.rid=#{dormitory.rid}");
}
} else
WHERE("did=#{did}");
if (student.getSex() != null)
WHERE("sex=#{sex}");
if (student.getTel() != null)
WHERE("tel=#{tel}");
if (student.getBed() != null)
WHERE("bed=#{bed}");
WHERE("dormitory.id=did and college.id=cid");
}
}.toString();
}
public String update(Student student) {
return new SQL() {
{
UPDATE("dormitory_sys.student");
if (student.getName() != null)
SET("name=#{name}");
if (student.getDormitory() != null)
SET("did=#{did}");
if (student.getSex() != null)
SET("sex=#{sex}");
if (student.getCid() != null)
SET("cid=#{cid}");
if (student.getBed() != null)
SET("bed=#{bed}");
if (student.getIdcard() != null)
SET("idcard=#{idcard}");
if (student.getTel() != null)
SET("tel=#{tel}");
WHERE("sno=#{sno}");
}
}.toString();
}
}
package edu.fzu.dormitory.filter;
import java.io.IOException;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.filter.OncePerRequestFilter;
@Component
public class TestFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws ServletException, IOException {
System.out.println(request.getSession().getId());
filterChain.doFilter(request, response);
}
}
package edu.fzu.dormitory.pojo;
import lombok.Data;
@Data
public class Administrator {
private Integer id, permession;
private String username, password, tel, name, salt;
}
package edu.fzu.dormitory.pojo;
import lombok.Data;
@Data
public class Building {
private Integer id, bid, rcount, area, cno;
private CareTaker caretaker;
}
package edu.fzu.dormitory.pojo;
import java.sql.Time;
import java.util.List;
import lombok.Data;
@Data
public class CareTaker {
private Integer id, cno, bid, sex;
private String name, tel;
private Time starttime, endtime;
private List<Building> buildings;
}
package edu.fzu.dormitory.pojo;
import lombok.Data;
@Data
public class College {
private Integer id;
private String name;
}
package edu.fzu.dormitory.pojo;
import java.sql.Timestamp;
import lombok.Data;
@Data
public class Complaint {
private Integer id, status;
private String describe, image, response;
private Timestamp submittime;
private Student student;
}
package edu.fzu.dormitory.pojo;
import lombok.Data;
@Data
public class ComplaintCount {
private Integer month;
private Long count;
}
package edu.fzu.dormitory.pojo;
import lombok.Data;
@Data
public class Dormitory {
private Integer id, bid, rid, maxcount, count;
}
package edu.fzu.dormitory.pojo;
import java.sql.Timestamp;
import lombok.Data;
@Data
public class DormitoryRepairRecord {
private Integer id, status;
private Timestamp submittime;
private String image, describe, other;
private Dormitory dormitory;
private RepairType repairType;
private Repairer repairer;
private Student student;
}
package edu.fzu.dormitory.pojo;
import lombok.Data;
import java.sql.Timestamp;
@Data
public class PaymentRecord {
private Integer id, bid, pid, rid, status;
private Timestamp submitTime;
private Double money;
}
package edu.fzu.dormitory.pojo;
import lombok.Data;
import java.sql.Timestamp;
@Data
public class PaymentTask {
private Integer id, admin;
private String adminName;
private String name;
private Timestamp startTime, endTime;
}
package edu.fzu.dormitory.pojo;
import lombok.Data;
@Data
public class PeopleCount {
private Integer area;
private Long count;
}
package edu.fzu.dormitory.pojo;
import java.sql.Timestamp;
import lombok.Data;
@Data
public class PublicRepairRecord {
private Integer id, bid, status;
private RepairType repairType;
private CareTaker careTaker;
private Repairer repairer;
private String describe, image, other;
private Timestamp submittime;
}
package edu.fzu.dormitory.pojo;
import lombok.Data;
@Data
public class RepairType {
private Integer id;
private String name;
}
package edu.fzu.dormitory.pojo;
import java.sql.Time;
import lombok.Data;
@Data
public class Repairer {
private Integer id, wno, sex, repairtypeid;
private Time starttime, endtime;
private String tel, name;
private RepairType repairType;
}
package edu.fzu.dormitory.pojo;
import java.sql.Timestamp;
import lombok.Data;
@Data
public class SignInTask {
private String name;
private Integer location, id, admin, cycle, college, bid;
private Timestamp starttime, endtime;
private Double longitude, latitude;
}
package edu.fzu.dormitory.pojo;
import java.sql.Timestamp;
import lombok.Data;
@Data
public class SignInTaskRecord {
private Integer tid, bid, rid, sno, status, bed;
private String name;
private Timestamp submittime;
}
package edu.fzu.dormitory.pojo;
import lombok.Data;
@Data
public class Student {
private Integer id, sno, cid, did, sex, bed;
private String name, idcard, tel;
private College college;
private Dormitory dormitory;
}
package edu.fzu.dormitory.pojo;
import lombok.Data;
@Data
public class StudentCount {
private Integer bid;
private Long count;
}
package edu.fzu.dormitory.service;
import java.util.Map;
import javax.servlet.http.HttpSession;
import edu.fzu.dormitory.pojo.Administrator;
public interface AdminService {
public Map<String, Object> login(HttpSession session, Administrator administrator);
public Map<String, Object> add(HttpSession session, Administrator administrator);
public Map<String, Object> update(HttpSession session, Administrator administrator);
public Map<String, Object> myInfo(HttpSession session);
public Map<String, Object> delete(HttpSession session, Administrator administrator);
public Map<String, Object> search(HttpSession session, Administrator administrator);
public Map<String, Object> changePermession(HttpSession session, Administrator administrator);
}
package edu.fzu.dormitory.service;
import java.util.Map;
import javax.servlet.http.HttpSession;
public interface BuildingService {
public Map<String, Object> search(HttpSession session, Map<String, Object> data);
public Map<String, Object> add(HttpSession session, Map<String, Object> data);
public Map<String, Object> addList(HttpSession session, Map<String, Object> data);
public Map<String, Object> update(HttpSession session, Map<String, Object> data);
public Map<String, Object> addDormitories(HttpSession session, Map<String, Object> data);
public Map<String, Object> findRoomId(HttpSession session, Map<String, Object> data);
public Map<String, Object> findBuildingId(HttpSession session);
}
package edu.fzu.dormitory.service;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
import edu.fzu.dormitory.pojo.CareTaker;
public interface CareTakerService {
public Map<String, Object> search(HttpSession session, CareTaker careTaker);
public Map<String, Object> update(HttpSession session, CareTaker careTaker);
public Map<String, Object> delete(HttpSession session, List<Integer> id);
public Map<String, Object> add(HttpSession session, CareTaker careTaker);
public Map<String, Object> addList(HttpSession session, Map<String, Object> data);
}
package edu.fzu.dormitory.service;
import java.util.Map;
import javax.servlet.http.HttpSession;
import edu.fzu.dormitory.pojo.Complaint;
public interface ComplaintService {
public Map<String, Object> search(HttpSession session, Map<String, Object> data);
public Map<String, Object> update(HttpSession session, Complaint complaint);
}
package edu.fzu.dormitory.service;
import java.util.Map;
import javax.servlet.http.HttpSession;
public interface DormitoryRepairService {
public Map<String, Object> search(HttpSession session, Map<String, Object> data);
public Map<String, Object> getTypeList(HttpSession session);
}
package edu.fzu.dormitory.service;
import java.util.Map;
import org.springframework.web.multipart.MultipartFile;
public interface FileService {
Map<String, Object> upload(MultipartFile file);
}
package edu.fzu.dormitory.service;
import java.util.Map;
import javax.servlet.http.HttpSession;
public interface MainPageService {
public Map<String, Object> getMainPageData(HttpSession session);
}
package edu.fzu.dormitory.service;
import edu.fzu.dormitory.pojo.PaymentRecord;
import edu.fzu.dormitory.pojo.PaymentTask;
import javax.servlet.http.HttpSession;
import java.util.Map;
public interface PaymentService {
public Map<String, Object> addPaymentTask(HttpSession session, PaymentTask paymentTask);
public Map<String, Object> deletePaymentTask(HttpSession session, PaymentTask paymentTask);
public Map<String, Object> getStatus(HttpSession session, PaymentTask paymentTask);
public Map<String, Object> searchPaymentTask(HttpSession session, PaymentTask paymentTask);
public Map<String, Object> getPaymentRecordDetail(HttpSession session, PaymentRecord paymentRecord);
public Map<String, Object> addDetail(HttpSession session, Map<String, Object> args);
public Map<String, Object> update(HttpSession session, PaymentTask paymentTask);
}
package edu.fzu.dormitory.service;
import java.util.Map;
import javax.servlet.http.HttpSession;
public interface PublicRepairService {
public Map<String, Object> search(HttpSession session, Map<String, Object> data);
public Map<String, Object> getTypeList(HttpSession session);
}
package edu.fzu.dormitory.service;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
import edu.fzu.dormitory.pojo.Repairer;
public interface RepairerService {
public Map<String, Object> search(HttpSession session, Repairer repairer);
public Map<String, Object> update(HttpSession session, Repairer repairer);
public Map<String, Object> add(HttpSession session, Repairer repairer);
public Map<String, Object> delete(HttpSession session, List<Integer> id);
public Map<String, Object> getRepairTypeList(HttpSession session);
public Map<String, Object> addList(HttpSession session, Map<String, Object> data);
}
package edu.fzu.dormitory.service;
import java.util.Map;
import javax.servlet.http.HttpSession;
import edu.fzu.dormitory.pojo.SignInTask;
import edu.fzu.dormitory.pojo.SignInTaskRecord;
public interface SignInTaskService {
public Map<String, Object> add(HttpSession session, SignInTask signInTask);
public Map<String, Object> search(HttpSession session, SignInTask signInTask);
public Map<String, Object> detail(HttpSession session, SignInTaskRecord signInTaskRecord);
public Map<String, Object> getStatus(HttpSession session, SignInTask signInTask);
}
package edu.fzu.dormitory.service;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpSession;
public interface StudentService {
public Map<String, Object> search(HttpSession session, Map<String, Object> data);
public Map<String, Object> update(HttpSession session, Map<String, Object> data);
public Map<String, Object> delete(HttpSession session, List<Integer> id);
public Map<String, Object> getCollege(HttpSession session);
public Map<String, Object> add(HttpSession session, Map<String, Object> data);
public Map<String, Object> addList(HttpSession session, Map<String, Object> data);
}
package edu.fzu.dormitory.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Service;
import edu.fzu.dormitory.annotation.Permession;
import edu.fzu.dormitory.annotation.PermessionType;
import edu.fzu.dormitory.dao.AdministratorMapper;
import edu.fzu.dormitory.pojo.Administrator;
import edu.fzu.dormitory.service.AdminService;
import edu.fzu.dormitory.utils.Constant;
import edu.fzu.dormitory.utils.PasswordEncryptor;
@Service
public class AdminServiceImpl implements AdminService {
@Resource
AdministratorMapper mapper;
@Resource
PasswordEncryptor encryptor;
@Override
public Map<String, Object> login(HttpSession session, Administrator administrator) {
String username = administrator.getUsername();
String password = administrator.getPassword();
if (username == null || username.isEmpty() || password == null || password.isEmpty())
return Constant.Failed;
Administrator temp = new Administrator();
temp.setUsername(administrator.getUsername());
List<Administrator> result = mapper.findAdmin(temp);
if (result == null)
return Constant.Failed;
for (Administrator a : result) {
password = encryptor.encrypt(administrator.getPassword(), a.getSalt()).get("password");
if (password.equals(a.getPassword())) {
session.setAttribute("admin", a);
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("username", a.getUsername());
put("tel", a.getTel());
put("name", a.getName());
}
};
}
}
return Constant.Failed;
}
@Override
@Permession(permession = PermessionType.SuperAdmin)
public Map<String, Object> add(HttpSession session, Administrator administrator) {
String password = administrator.getPassword();
Administrator temp = new Administrator();
temp.setUsername(administrator.getUsername());
Map<String, String> enc = encryptor.encrypt(password, null);
administrator.setPassword(enc.get("password"));
administrator.setSalt(enc.get("salt"));
int count = mapper.insert(administrator);
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> update(HttpSession session, Administrator administrator) {
Administrator loggedUser = (Administrator) session.getAttribute("admin");
administrator.setId(loggedUser.getId());
if (administrator.getPassword() != null) {
String password = administrator.getPassword();
password = encryptor.encrypt(password, loggedUser.getSalt()).get("password");
administrator.setPassword(password);
}
int count = mapper.update(administrator);
if (count != 1)
return Constant.Failed;
administrator = mapper.findAdmin(administrator).get(0);
session.setAttribute("admin", administrator);
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.SuperAdmin)
public Map<String, Object> delete(HttpSession session, Administrator administrator) {
Administrator loggedUser = (Administrator) session.getAttribute("admin");
if (administrator.getId() == null || administrator.getId() == loggedUser.getId())
return Constant.Failed;
int count = mapper.delete(administrator);
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> search(HttpSession session, Administrator administrator) {
List<Administrator> result = mapper.findAdmin(administrator);
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", new ArrayList<Map<String, Object>>() {
{
for (Administrator administrator : result) {
add(new HashMap<String, Object>() {
{
put("id", administrator.getId());
put("username", administrator.getUsername());
put("name", administrator.getName());
put("tel", administrator.getTel());
put("permession", administrator.getPermession());
}
});
}
}
});
}
};
}
@Override
@Permession(permession = PermessionType.SuperAdmin)
public Map<String, Object> changePermession(HttpSession session, Administrator administrator) {
if (administrator.getId() == null || administrator.getPermession() == null)
return Constant.Failed;
int count = mapper.changePermession(administrator);
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> myInfo(HttpSession session) {
Administrator administrator = (Administrator) session.getAttribute("admin");
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", new HashMap<String, Object>() {
{
put("name", administrator.getName());
put("tel", administrator.getTel());
put("username", administrator.getUsername());
}
});
}
};
}
}
package edu.fzu.dormitory.service.impl;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import edu.fzu.dormitory.annotation.Permession;
import edu.fzu.dormitory.annotation.PermessionType;
import edu.fzu.dormitory.dao.BuildingMapper;
import edu.fzu.dormitory.dao.DormitoryMapper;
import edu.fzu.dormitory.pojo.Building;
import edu.fzu.dormitory.pojo.CareTaker;
import edu.fzu.dormitory.pojo.Dormitory;
import edu.fzu.dormitory.service.BuildingService;
import edu.fzu.dormitory.utils.Constant;
@Service
public class BuildingServiceImpl implements BuildingService {
@Resource
BuildingMapper buildingMapper;
@Resource
DormitoryMapper dormitoryMapper;
private Building mapToBuilding(Map<String, Object> data) {
Building building = new Building();
if (data.get("id") != null)
building.setId((Integer) data.get("id"));
if (data.get("cno") != null) {
building.setCaretaker(new CareTaker());
building.getCaretaker().setCno((Integer) data.get("cno"));
}
if (data.get("area") != null)
building.setArea((Integer) data.get("area"));
if (data.get("bid") != null)
building.setBid((Integer) data.get("bid"));
return building;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> search(HttpSession session, Map<String, Object> data) {
Building building = mapToBuilding(data);
List<Building> result = buildingMapper.findBuilding(building);
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
result.sort(new Comparator<Building>() {
@Override
public int compare(Building o1, Building o2) {
if (o1.getBid() < o2.getBid())
return -1;
else if (o1.getBid() > o2.getBid())
return 1;
return 0;
}
});
put("data", new ArrayList<Map<String, Object>>() {
{
for (Building b : result) {
add(new HashMap<String, Object>() {
{
put("id", b.getId());
put("bid", b.getBid());
put("rcount", b.getRcount());
put("area", b.getArea());
put("manager", b.getCaretaker().getName());
put("tel", b.getCaretaker().getTel());
}
});
}
}
});
}
};
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> add(HttpSession session, Map<String, Object> data) {
Building building = mapToBuilding(data);
int count = buildingMapper.add(building);
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> update(HttpSession session, Map<String, Object> data) {
Building building = mapToBuilding(data);
int count = buildingMapper.update(building);
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
@Transactional
public Map<String, Object> addDormitories(HttpSession session, Map<String, Object> data) {
if (data.get("bid") == null || data.get("fileUrl") == null)
return Constant.Failed;
Integer bid = (Integer) data.get("bid");
String url = (String) data.get("fileUrl");
int count = 0;
String filePath = Constant.ResourcesDirection + url.substring(url.lastIndexOf("/") + 1);
List<Dormitory> dormitories = new ArrayList<Dormitory>();
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(new FileInputStream(filePath), StandardCharsets.UTF_8))) {
String row = null;
while ((row = reader.readLine()) != null) {
String[] s = row.split(" ");
Dormitory dormitory = new Dormitory();
dormitory.setBid(bid);
dormitory.setRid(Integer.valueOf(s[0]));
dormitory.setMaxcount(Integer.valueOf(s[1]));
dormitories.add(dormitory);
}
if (dormitories.size() > 0)
count = dormitoryMapper.addDormitories(dormitories);
} catch (IOException e) {
return Constant.Failed;
}
if (count != dormitories.size())
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
@Transactional
public Map<String, Object> addList(HttpSession session, Map<String, Object> data) {
if (data.get("fileUrl") == null)
return Constant.Failed;
String url = (String) data.get("fileUrl");
int count = 0;
String filePath = Constant.ResourcesDirection + url.substring(url.lastIndexOf("/") + 1);
List<Building> buildings = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(new FileInputStream(filePath), StandardCharsets.UTF_8))) {
String line = null;
while ((line = reader.readLine()) != null) {
String[] s = line.split(" ");
Building building = new Building();
building.setBid(Integer.valueOf(s[0]));
building.setCno(Integer.valueOf(s[1]));
building.setArea(Integer.valueOf(s[2]));
buildings.add(building);
}
count = buildingMapper.addBuildingList(buildings);
} catch (IOException e) {
e.printStackTrace();
return Constant.Failed;
} catch (PersistenceException e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Constant.Confilct;
}
if (count != buildings.size())
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> findBuildingId(HttpSession session) {
List<Integer> result = buildingMapper.findBuildingId();
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", new ArrayList<Map<String, Object>>() {
{
for (Integer b : result) {
add(new HashMap<String, Object>() {
{
put("bid", b);
}
});
}
}
});
}
};
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> findRoomId(HttpSession session, Map<String, Object> data) {
if (data.get("bid") == null)
return Constant.Failed;
List<Integer> result = buildingMapper.findRoomId((Integer) data.get("bid"));
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", new ArrayList<Map<String, Object>>() {
{
for (Integer r : result) {
add(new HashMap<String, Object>() {
{
put("rid", r);
}
});
}
}
});
}
};
}
}
package edu.fzu.dormitory.service.impl;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.sql.Time;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import edu.fzu.dormitory.annotation.Permession;
import edu.fzu.dormitory.annotation.PermessionType;
import edu.fzu.dormitory.dao.CareTakerMapper;
import edu.fzu.dormitory.pojo.Building;
import edu.fzu.dormitory.pojo.CareTaker;
import edu.fzu.dormitory.service.CareTakerService;
import edu.fzu.dormitory.utils.Constant;
@Service
public class CareTakerServiceImpl implements CareTakerService {
@Resource
CareTakerMapper mapper;
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> search(HttpSession session, CareTaker careTaker) {
List<CareTaker> result = mapper.findCareTaker(careTaker);
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", new ArrayList<Map<String, Object>>() {
{
DateFormat df = new SimpleDateFormat("HH:mm:ss");
for (CareTaker c : result)
add(new HashMap<String, Object>() {
{
put("id", c.getId());
put("cno", c.getCno());
put("name", c.getName());
put("sex", c.getSex());
put("starttime", df.format(c.getStarttime()));
put("endtime", df.format(c.getEndtime()));
put("tel", c.getTel());
put("bid", new ArrayList<Integer>() {
{
for (Building b : c.getBuildings())
add(b.getBid());
}
});
}
});
}
});
}
};
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> update(HttpSession session, CareTaker careTaker) {
if (careTaker.getCno() == null)
return Constant.Failed;
int count = mapper.update(careTaker);
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
@Transactional
public Map<String, Object> delete(HttpSession session, List<Integer> id) {
if (id == null)
return Constant.Failed;
int count = mapper.delete(id);
if (count != id.size())
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> add(HttpSession session, CareTaker careTaker) {
int count = 0;
try {
count = mapper.add(careTaker);
} catch (DuplicateKeyException | PersistenceException e) {
return Constant.Confilct;
}
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
@Override
@Transactional
@Permession(permession = PermessionType.Admin)
public Map<String, Object> addList(HttpSession session, Map<String, Object> data) {
if (data.get("fileUrl") == null)
return Constant.Failed;
String url = (String) data.get("fileUrl");
int count = 0;
String filePath = Constant.ResourcesDirection + url.substring(url.lastIndexOf("/") + 1);
List<CareTaker> careTakers = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(new FileInputStream(filePath), StandardCharsets.UTF_8))) {
String line = null;
while ((line = reader.readLine()) != null) {
String[] s = line.split(" ");
CareTaker careTaker = new CareTaker();
careTaker.setCno(Integer.valueOf(s[0]));
careTaker.setName(s[1]);
careTaker.setSex(Integer.valueOf(s[2]));
careTaker.setStarttime(Time.valueOf(s[3]));
careTaker.setEndtime(Time.valueOf(s[4]));
careTaker.setTel(s[5]);
careTakers.add(careTaker);
}
count = mapper.addCareTakerList(careTakers);
} catch (IOException e) {
e.printStackTrace();
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Constant.Failed;
} catch (DuplicateKeyException | PersistenceException e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Constant.Confilct;
}
if (count != careTakers.size())
return Constant.Failed;
return Constant.Success;
}
}
package edu.fzu.dormitory.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Service;
import edu.fzu.dormitory.annotation.Permession;
import edu.fzu.dormitory.annotation.PermessionType;
import edu.fzu.dormitory.dao.ComplaintMapper;
import edu.fzu.dormitory.pojo.Complaint;
import edu.fzu.dormitory.pojo.Student;
import edu.fzu.dormitory.service.ComplaintService;
import edu.fzu.dormitory.utils.Constant;
@Service
public class ComplaintServiceImpl implements ComplaintService {
@Resource
ComplaintMapper mapper;
private Complaint mapToComplaint(Map<String, Object> data) {
Complaint complaint = new Complaint();
if (data.get("sno") != null) {
complaint.setStudent(new Student());
complaint.getStudent().setSno((Integer) data.get("sno"));
}
if (data.get("status") != null)
complaint.setStatus((Integer) data.get("status"));
return complaint;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> search(HttpSession session, Map<String, Object> data) {
Complaint complaint = mapToComplaint(data);
List<Complaint> result = mapper.findComplaint(complaint);
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", new ArrayList<Map<String, Object>>() {
{
for (Complaint c : result) {
add(new HashMap<String, Object>() {
{
put("id", c.getId());
put("sname", c.getStudent().getName());
put("describe", c.getDescribe());
put("time", c.getSubmittime());
put("status", c.getStatus());
put("tel", c.getStudent().getTel());
put("image", c.getImage());
put("response", c.getResponse());
}
});
}
}
});
}
};
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> update(HttpSession session, Complaint complaint) {
int count = mapper.update(complaint);
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
}
package edu.fzu.dormitory.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Service;
import edu.fzu.dormitory.annotation.Permession;
import edu.fzu.dormitory.annotation.PermessionType;
import edu.fzu.dormitory.dao.DormitoryRepairRecordMapper;
import edu.fzu.dormitory.dao.RepairTypeMapper;
import edu.fzu.dormitory.pojo.Dormitory;
import edu.fzu.dormitory.pojo.DormitoryRepairRecord;
import edu.fzu.dormitory.pojo.RepairType;
import edu.fzu.dormitory.pojo.Student;
import edu.fzu.dormitory.service.DormitoryRepairService;
import edu.fzu.dormitory.utils.Constant;
@Service
public class DormitoryRepairServiceImpl implements DormitoryRepairService {
@Resource
DormitoryRepairRecordMapper dormitoryRepairRecordMapper;
@Resource
RepairTypeMapper repairTypeMapper;
private DormitoryRepairRecord mapToRecord(Map<String, Object> data) {
DormitoryRepairRecord dormitoryRepairRecord = new DormitoryRepairRecord();
if (data.get("bid") != null) {
dormitoryRepairRecord.setDormitory(new Dormitory());
dormitoryRepairRecord.getDormitory().setBid((Integer) data.get("bid"));
}
if (data.get("type") != null) {
dormitoryRepairRecord.setRepairType(new RepairType());
dormitoryRepairRecord.getRepairType().setId((Integer) data.get("type"));
}
if (data.get("sno") != null) {
dormitoryRepairRecord.setStudent(new Student());
dormitoryRepairRecord.getStudent().setSno((Integer) data.get("sno"));
}
return dormitoryRepairRecord;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> search(HttpSession session, Map<String, Object> data) {
DormitoryRepairRecord dormitoryRepairRecord = mapToRecord(data);
List<DormitoryRepairRecord> result = dormitoryRepairRecordMapper.findRepairRecord(dormitoryRepairRecord);
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", new ArrayList<Map<String, Object>>() {
{
for (DormitoryRepairRecord d : result) {
add(new HashMap<String, Object>() {
{
put("id", d.getId());
put("sname", d.getStudent().getName());
put("repairer", d.getRepairer().getName());
put("type", d.getRepairType().getName());
put("bid", d.getDormitory().getBid());
put("rid", d.getDormitory().getRid());
put("describe", d.getDescribe());
put("image", d.getImage());
put("other", d.getOther());
put("time", d.getSubmittime());
put("status", d.getStatus());
put("tel", d.getStudent().getTel());
}
});
}
}
});
}
};
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> getTypeList(HttpSession session) {
List<RepairType> result = repairTypeMapper.findDormitoryRepairType();
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", result);
}
};
}
}
package edu.fzu.dormitory.service.impl;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import edu.fzu.dormitory.service.FileService;
import edu.fzu.dormitory.utils.Constant;
@Service
public class FileServiceImpl implements FileService {
private Boolean checkFile(String suf) {
for (String s : Constant.AcceptFileType)
if (s.equals(suf))
return true;
return false;
}
@Override
public Map<String, Object> upload(MultipartFile file) {
String url = null;
try {
String fileName = file.getOriginalFilename();
String suf = fileName.substring(fileName.lastIndexOf('.'));
if (!checkFile(suf))
return Constant.Failed;
fileName = UUID.randomUUID().toString() + suf;
file.transferTo(new File(Constant.ResourcesDirection + fileName));
url = "http://" + Constant.HostAddress + "/" + fileName;
} catch (IllegalStateException | IOException e) {
return Constant.Failed;
}
Map<String, Object> result = new HashMap<>();
result.put("status", Constant.SuccessCode);
result.put("url", url);
return result;
}
}
package edu.fzu.dormitory.service.impl;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Service;
import edu.fzu.dormitory.annotation.Permession;
import edu.fzu.dormitory.annotation.PermessionType;
import edu.fzu.dormitory.dao.MainPageDataMapper;
import edu.fzu.dormitory.pojo.ComplaintCount;
import edu.fzu.dormitory.pojo.PeopleCount;
import edu.fzu.dormitory.service.MainPageService;
import edu.fzu.dormitory.utils.Constant;
@Service
public class MainPageServiceImpl implements MainPageService {
@Resource
MainPageDataMapper mapper;
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> getMainPageData(HttpSession session) {
int bcount = mapper.getBCount();
int rcount = mapper.getRCount();
int pcount = mapper.getPCount();
List<PeopleCount> peopleData = mapper.getPeopleData();
List<ComplaintCount> complaintCounts = mapper.getComplaintCount();
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", new HashMap<String, Object>() {
{
put("bcount", bcount);
put("pcount", pcount);
put("rcount", rcount);
ArrayList<Integer> area = new ArrayList<>();
ArrayList<Long> people = new ArrayList<>();
peopleData.sort(new Comparator<PeopleCount>() {
@Override
public int compare(PeopleCount o1, PeopleCount o2) {
if (o1.getArea() < o2.getArea())
return -1;
if (o1.getArea() > o2.getArea())
return 1;
return 0;
}
});
for (PeopleCount p : peopleData) {
area.add(p.getArea());
people.add(p.getCount());
}
put("area", area);
put("people", people);
ArrayList<Integer> month = new ArrayList<>();
ArrayList<Long> complaint = new ArrayList<>();
complaintCounts.sort(new Comparator<ComplaintCount>() {
@Override
public int compare(ComplaintCount o1, ComplaintCount o2) {
if (o1.getMonth() < o2.getMonth())
return -1;
if (o1.getMonth() > o2.getMonth())
return 1;
return 0;
}
});
for (ComplaintCount c : complaintCounts) {
month.add(c.getMonth());
complaint.add(c.getCount());
}
put("month", month);
put("rate", complaint);
}
});
}
};
}
}
package edu.fzu.dormitory.service.impl;
import edu.fzu.dormitory.annotation.Permession;
import edu.fzu.dormitory.annotation.PermessionType;
import edu.fzu.dormitory.dao.PaymentRecordMapper;
import edu.fzu.dormitory.dao.PaymentTaskMapper;
import edu.fzu.dormitory.pojo.Administrator;
import edu.fzu.dormitory.pojo.PaymentRecord;
import edu.fzu.dormitory.pojo.PaymentTask;
import edu.fzu.dormitory.service.PaymentService;
import edu.fzu.dormitory.utils.Constant;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.io.*;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class PaymentServiceImpl implements PaymentService {
@Resource
PaymentTaskMapper paymentTaskMapper;
@Resource
PaymentRecordMapper paymentRecordMapper;
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> addPaymentTask(HttpSession session, PaymentTask paymentTask) {
if (paymentTask.getName() == null || paymentTask.getStartTime() == null
|| paymentTask.getEndTime() == null)
return Constant.Failed;
Timestamp startTime = paymentTask.getStartTime();
Timestamp endTime = paymentTask.getEndTime();
if (startTime.getTime() >= endTime.getTime())
return Constant.Failed;
Administrator loggedAdmin = (Administrator) session.getAttribute("admin");
paymentTask.setAdmin(loggedAdmin.getId());
int count = paymentTaskMapper.insert(paymentTask);
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
@Transactional
public Map<String, Object> deletePaymentTask(HttpSession session, PaymentTask paymentTask) {
if (paymentTask.getId() == null)
return Constant.Failed;
int count = paymentTaskMapper.delete(paymentTask);
paymentRecordMapper.delete(paymentTask);
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> getStatus(HttpSession session, PaymentTask paymentTask) {
if (paymentTask.getId() == null)
return Constant.Failed;
List<Map<String, Object>> status = paymentRecordMapper.getStatus(paymentTask);
if (status == null)
return Constant.Failed;
status.sort(new Comparator<Map<String, Object>>() {
@Override
public int compare(Map<String, Object> o1, Map<String, Object> o2) {
Integer bid1 = (Integer) o1.get("bid");
Integer bid2 = (Integer) o2.get("bid");
if (bid1 < bid2)
return -1;
if (bid1 > bid2)
return 1;
return 0;
}
});
List<Integer> bid = new ArrayList<>();
List<Double> data = new ArrayList<>();
for (Map<String, Object> map : status) {
Long finished = (Long) map.get("finished");
if (finished == null) {
finished = 0L;
}
Long countAll = (Long) map.get("countAll");
bid.add((Integer) map.get("bid"));
data.add((finished.doubleValue() / countAll.doubleValue()));
}
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", new HashMap<String, Object>() {
{
put("bid", bid);
put("data", data);
}
});
}
};
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> getPaymentRecordDetail(HttpSession session, PaymentRecord paymentRecord) {
if (paymentRecord.getPid() == null)
return Constant.Failed;
List<PaymentRecord> result = paymentRecordMapper.select(paymentRecord);
if (result == null)
return Constant.Failed;
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", new ArrayList<Map<String, Object>>() {
{
for (PaymentRecord item : result) {
add(new HashMap<String, Object>() {
{
put("id", item.getId());
put("bid", item.getBid());
put("rid", item.getRid());
put("money", item.getMoney());
put("status", item.getStatus());
put("submittime", item.getSubmitTime());
}
});
}
}
});
}
};
}
@Override
@Permession(permession = PermessionType.Admin)
@Transactional
public Map<String, Object> addDetail(HttpSession session, Map<String, Object> args) {
Integer id = (Integer) args.get("id");
String fileUrl = (String) args.get("fileUrl");
if (id == null || fileUrl == null)
return Constant.Failed;
String fileName = fileUrl.substring(fileUrl.lastIndexOf('/') + 1);
String path = Constant.ResourcesDirection + fileName;
List<PaymentRecord> paymentRecords = new ArrayList<>();
int count = 0;
String line = null;
try (BufferedReader bufferedReader = new BufferedReader(new FileReader(path))) {
while ((line = bufferedReader.readLine()) != null) {
line = line.trim();
String[] data = line.split(" ");
int bid = Integer.parseInt(data[0]);
int rid = Integer.parseInt(data[1]);
double money = Double.parseDouble(data[2]);
PaymentRecord temp = new PaymentRecord();
temp.setPid(id);
temp.setBid(bid);
temp.setRid(rid);
temp.setMoney(money);
paymentRecords.add(temp);
}
if (paymentRecords.size() > 0)
count = paymentRecordMapper.addDetail(paymentRecords);
} catch (IOException e) {
return Constant.Failed;
} catch (PersistenceException e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Constant.Confilct;
}
if (count != paymentRecords.size())
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> searchPaymentTask(HttpSession session, PaymentTask paymentTask) {
if (paymentTask == null)
return Constant.Failed;
List<PaymentTask> result = paymentTaskMapper.select(paymentTask);
if (result == null)
return Constant.Failed;
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", new ArrayList<Map<String, Object>>() {
{
for (PaymentTask item : result) {
add(new HashMap<String, Object>() {
{
put("id", item.getId());
put("admin", item.getAdminName());
put("name", item.getName());
put("starttime", item.getStartTime());
put("endtime", item.getEndTime());
}
});
}
}
});
}
};
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> update(HttpSession session, PaymentTask paymentTask) {
if (paymentTask.getId() == null)
return Constant.Failed;
int count = paymentTaskMapper.update(paymentTask);
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
}
package edu.fzu.dormitory.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Service;
import edu.fzu.dormitory.annotation.Permession;
import edu.fzu.dormitory.annotation.PermessionType;
import edu.fzu.dormitory.dao.PublicRepairRecordMapper;
import edu.fzu.dormitory.dao.RepairTypeMapper;
import edu.fzu.dormitory.pojo.CareTaker;
import edu.fzu.dormitory.pojo.PublicRepairRecord;
import edu.fzu.dormitory.pojo.RepairType;
import edu.fzu.dormitory.service.PublicRepairService;
import edu.fzu.dormitory.utils.Constant;
@Service
public class PublicRepairServiceImpl implements PublicRepairService {
@Resource
PublicRepairRecordMapper mapper;
@Resource
RepairTypeMapper repairTypeMapper;
private PublicRepairRecord mapToRecord(Map<String, Object> data) {
PublicRepairRecord publicRepairRecord = new PublicRepairRecord();
if (data.get("cno") != null) {
publicRepairRecord.setCareTaker(new CareTaker());
publicRepairRecord.getCareTaker().setCno((Integer) data.get("cno"));
}
if (data.get("type") != null) {
publicRepairRecord.setRepairType(new RepairType());
publicRepairRecord.getRepairType().setId((Integer) data.get("type"));
}
if (data.get("status") != null)
publicRepairRecord.setStatus((Integer) data.get("status"));
if (data.get("bid") != null)
publicRepairRecord.setBid((Integer) data.get("bid"));
return publicRepairRecord;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> search(HttpSession session, Map<String, Object> data) {
PublicRepairRecord publicRepairRecord = mapToRecord(data);
List<PublicRepairRecord> result = mapper.findPublicRepairRecord(publicRepairRecord);
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", new ArrayList<Map<String, Object>>() {
{
for (PublicRepairRecord p : result) {
add(new HashMap<String, Object>() {
{
put("id", p.getId());
put("cname", p.getCareTaker().getName());
put("repairer", p.getRepairer().getName());
put("tel", p.getCareTaker().getTel());
put("type", p.getRepairType().getName());
put("bid", p.getBid());
put("describe", p.getDescribe());
put("image", p.getImage());
put("other", p.getOther());
put("time", p.getSubmittime());
put("status", p.getStatus());
}
});
}
}
});
}
};
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> getTypeList(HttpSession session) {
List<RepairType> result = repairTypeMapper.findPublicRepairType();
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", result);
}
};
}
}
package edu.fzu.dormitory.service.impl;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.sql.Time;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import edu.fzu.dormitory.annotation.Permession;
import edu.fzu.dormitory.annotation.PermessionType;
import edu.fzu.dormitory.dao.RepairTypeMapper;
import edu.fzu.dormitory.dao.RepairerMapper;
import edu.fzu.dormitory.pojo.RepairType;
import edu.fzu.dormitory.pojo.Repairer;
import edu.fzu.dormitory.service.RepairerService;
import edu.fzu.dormitory.utils.Constant;
@Service
public class RepairerServiceImpl implements RepairerService {
@Resource
RepairerMapper repairMapper;
@Resource
RepairTypeMapper repairTypeMapper;
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> search(HttpSession session, Repairer repairer) {
List<Repairer> result = repairMapper.findRepairer(repairer);
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", new ArrayList<Map<String, Object>>() {
{
DateFormat df = new SimpleDateFormat("HH:mm:ss");
for (Repairer r : result)
add(new HashMap<String, Object>() {
{
put("id", r.getId());
put("wno", r.getWno());
put("name", r.getName());
put("sex", r.getSex());
put("starttime", df.format(r.getStarttime()));
put("endtime", df.format(r.getEndtime()));
put("tel", r.getTel());
put("repairType", r.getRepairType().getName());
}
});
}
});
}
};
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> update(HttpSession session, Repairer repairer) {
if (repairer.getWno() == null)
return Constant.Failed;
int count = repairMapper.update(repairer);
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> add(HttpSession session, Repairer repairer) {
int count = 0;
try {
count = repairMapper.add(repairer);
} catch (DuplicateKeyException | PersistenceException e) {
return Constant.Confilct;
}
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
@Transactional
public Map<String, Object> delete(HttpSession session, List<Integer> id) {
if (id == null)
return Constant.Failed;
int count = repairMapper.delete(id);
if (count != id.size())
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> getRepairTypeList(HttpSession session) {
List<RepairType> result = repairTypeMapper.findAll();
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", result);
}
};
}
@Override
@Transactional
@Permession(permession = PermessionType.Admin)
public Map<String, Object> addList(HttpSession session, Map<String, Object> data) {
if (data.get("fileUrl") == null)
return Constant.Failed;
String url = (String) data.get("fileUrl");
int count = 0;
String filePath = Constant.ResourcesDirection + url.substring(url.lastIndexOf("/") + 1);
List<Repairer> repairers = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(new FileInputStream(filePath), StandardCharsets.UTF_8))) {
String line = null;
while ((line = reader.readLine()) != null) {
String[] s = line.split(" ");
Repairer repairer = new Repairer();
repairer.setWno(Integer.valueOf(s[0]));
repairer.setName(s[1]);
repairer.setSex(Integer.valueOf(s[2]));
repairer.setTel(s[3]);
repairer.setRepairtypeid(Integer.valueOf(s[4]));
repairer.setStarttime(Time.valueOf(s[5]));
repairer.setEndtime(Time.valueOf(s[6]));
repairers.add(repairer);
}
count = repairMapper.addRepairerList(repairers);
} catch (IOException e) {
e.printStackTrace();
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Constant.Failed;
} catch (DuplicateKeyException | PersistenceException e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Constant.Confilct;
}
if (count != repairers.size())
return Constant.Failed;
return Constant.Success;
}
}
package edu.fzu.dormitory.service.impl;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import edu.fzu.dormitory.annotation.Permession;
import edu.fzu.dormitory.annotation.PermessionType;
import edu.fzu.dormitory.dao.DormitoryMapper;
import edu.fzu.dormitory.dao.SignInTaskMapper;
import edu.fzu.dormitory.pojo.Administrator;
import edu.fzu.dormitory.pojo.SignInTask;
import edu.fzu.dormitory.pojo.SignInTaskRecord;
import edu.fzu.dormitory.pojo.StudentCount;
import edu.fzu.dormitory.service.SignInTaskService;
import edu.fzu.dormitory.utils.Constant;
@Service
public class SignInTaskServiceImpl implements SignInTaskService {
@Resource
SignInTaskMapper signInMapper;
@Resource
DormitoryMapper dormitoryMapper;
@Override
@Permession(permession = PermessionType.Admin)
@Transactional
public Map<String, Object> add(HttpSession session, SignInTask signInTask) {
if (signInTask.getLocation() == 1 && (signInTask.getLocation() == null || signInTask.getLatitude() == null))
return Constant.Failed;
signInTask.setCollege(0);
signInTask.setBid(0);
Administrator administrator = (Administrator) session.getAttribute("admin");
signInTask.setAdmin(administrator.getId());
if (signInTask.getCycle() == Constant.NotCycle) {
int count = signInMapper.add(signInTask);
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
int step = (signInTask.getCycle() == Constant.DAY ? 1 : 7);
for (int i = 0; i < Constant.DAYCOUNT; ++i) {
int count = signInMapper.add(signInTask);
long mul = Constant.TIMEMUL * step;
if (count != 1)
return Constant.Failed;
Timestamp start = signInTask.getStarttime();
Timestamp end = signInTask.getEndtime();
start.setTime(start.getTime() + mul);
end.setTime(end.getTime() + mul);
signInTask.setStarttime(start);
signInTask.setEndtime(end);
}
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> search(HttpSession session, SignInTask signInTask) {
List<SignInTask> result = signInMapper.findSignInTask(signInTask);
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", result);
}
};
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> detail(HttpSession session, SignInTaskRecord signInTaskRecord) {
if (signInTaskRecord.getTid() == null)
return Constant.Failed;
List<SignInTaskRecord> result = signInMapper.detail(signInTaskRecord);
for (SignInTaskRecord m : result)
m.setStatus(m.getSubmittime() == null ? 0 : 1);
result.sort(new Comparator<SignInTaskRecord>() {
@Override
public int compare(SignInTaskRecord o1, SignInTaskRecord o2) {
if (o1.getBid() == o2.getBid())
return o1.getRid() < o2.getRid() ? -1 : 1;
return o1.getBed() < o2.getBed() ? -1 : 1;
}
});
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", result);
}
};
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> getStatus(HttpSession session, SignInTask signInTask) {
List<StudentCount> student = dormitoryMapper.countStudent();
List<StudentCount> signIn = signInMapper.getStatus(signInTask);
Map<Integer, Long> signInData = new HashMap<>();
for (StudentCount m : signIn)
signInData.put(m.getBid(), m.getCount());
List<Number> bid = new ArrayList<>();
List<Double> result = new ArrayList<>();
student.sort(new Comparator<StudentCount>() {
@Override
public int compare(StudentCount o1, StudentCount o2) {
if (o1.getBid() < o2.getBid())
return -1;
if (o1.getBid() > o2.getBid())
return 1;
return 0;
}
});
for (StudentCount m : student) {
bid.add(m.getBid());
if (signInData.get(m.getBid()) == null)
result.add(.0);
else
result.add(signInData.get(m.getBid()) * 1.0 / m.getCount());
}
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", new HashMap<String, Object>() {
{
put("bid", bid);
put("data", result);
}
});
}
};
}
}
package edu.fzu.dormitory.service.impl;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.apache.ibatis.exceptions.PersistenceException;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import edu.fzu.dormitory.annotation.Permession;
import edu.fzu.dormitory.annotation.PermessionType;
import edu.fzu.dormitory.dao.BuildingMapper;
import edu.fzu.dormitory.dao.CollegeMapper;
import edu.fzu.dormitory.dao.DormitoryMapper;
import edu.fzu.dormitory.dao.StudentMapper;
import edu.fzu.dormitory.pojo.College;
import edu.fzu.dormitory.pojo.Dormitory;
import edu.fzu.dormitory.pojo.Student;
import edu.fzu.dormitory.service.StudentService;
import edu.fzu.dormitory.utils.Constant;
@Service
public class StudentServiceImpl implements StudentService {
@Resource
StudentMapper studentMapper;
@Resource
DormitoryMapper dormitoryMapper;
@Resource
CollegeMapper collegeMapper;
@Resource
BuildingMapper buildingMapper;
private Student mapToStudent(Map<String, Object> data) {
Student student = new Student();
if (data.get("sno") != null)
student.setSno((Integer) data.get("sno"));
if (data.get("name") != null)
student.setName((String) data.get("name"));
if (data.get("id") != null)
student.setId((Integer) data.get("id"));
if (data.get("sname") != null)
student.setName((String) data.get("name"));
if (data.get("sex") != null)
student.setSex((Integer) data.get("sex"));
if (data.get("cid") != null)
student.setCid((Integer) data.get("cid"));
if (data.get("bid") != null || data.get("rid") != null) {
student.setDormitory(new Dormitory());
student.getDormitory().setBid((Integer) data.get("bid"));
student.getDormitory().setRid((Integer) data.get("rid"));
}
if (data.get("idCard") != null)
student.setIdcard((String) data.get("idCard"));
if (data.get("tel") != null)
student.setTel((String) data.get("tel"));
if (data.get("bed") != null)
student.setBed((Integer) data.get("bed"));
return student;
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> search(HttpSession session, Map<String, Object> data) {
List<Student> result = studentMapper.findStudent(mapToStudent(data));
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", new ArrayList<Map<String, Object>>() {
{
for (Student s : result) {
add(new HashMap<String, Object>() {
{
put("id", s.getId());
put("sno", s.getSno());
put("sname", s.getName());
put("sex", s.getSex());
put("college", s.getCollege().getName());
put("bid", s.getDormitory().getBid());
put("rid", s.getDormitory().getRid());
put("bed", s.getBed());
put("idCard", s.getIdcard());
put("tel", s.getTel());
}
});
}
}
});
}
};
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> update(HttpSession session, Map<String, Object> data) {
Student newStudent = mapToStudent(data);
if (newStudent.getSno() == null)
return Constant.Failed;
if (newStudent.getDormitory() != null || newStudent.getBed() != null) {
Student tempStudent = new Student();
tempStudent.setSno(newStudent.getSno());
List<Student> result = studentMapper.findStudent(tempStudent);
if (result.size() == 0)
return Constant.Failed;
Student oldStudent = result.get(0);
Dormitory dormitory = newStudent.getDormitory();
if (dormitory == null)
dormitory = new Dormitory();
if (dormitory.getBid() == null)
dormitory.setBid(oldStudent.getDormitory().getBid());
if (dormitory.getRid() == null)
dormitory.setRid(oldStudent.getDormitory().getRid());
if (newStudent.getBed() == null)
newStudent.setBed(oldStudent.getBed());
List<Dormitory> temp = dormitoryMapper.findDormitory(dormitory);
if (temp.size() == 0)
return Constant.Failed;
dormitory = temp.get(0);
newStudent.setDid(dormitory.getId());
}
int count = studentMapper.update(newStudent);
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
@Override
@Permession(permession = PermessionType.Admin)
@Transactional
public Map<String, Object> delete(HttpSession session, List<Integer> id) {
if (id == null)
return Constant.Failed;
int count = studentMapper.detele(id);
if (count != id.size())
return Constant.Failed;
return Constant.Success;
}
@Override
public Map<String, Object> getCollege(HttpSession session) {
List<College> result = collegeMapper.findAll();
return new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
put("data", result);
}
};
}
@Override
@Permession(permession = PermessionType.Admin)
public Map<String, Object> add(HttpSession session, Map<String, Object> data) {
Student student = mapToStudent(data);
List<Dormitory> result = dormitoryMapper.findDormitory(student.getDormitory());
if (result.size() == 0)
return Constant.Failed;
student.setDormitory(result.get(0));
student.setDid(result.get(0).getId());
int count = 0;
try {
count = studentMapper.add(student);
} catch (DuplicateKeyException | PersistenceException e) {
return Constant.Confilct;
}
if (count != 1)
return Constant.Failed;
return Constant.Success;
}
@Override
@Transactional
@Permession(permession = PermessionType.Admin)
public Map<String, Object> addList(HttpSession session, Map<String, Object> data) {
if (data.get("fileUrl") == null)
return Constant.Failed;
String url = (String) data.get("fileUrl");
int count = 0;
String filePath = Constant.ResourcesDirection + url.substring(url.lastIndexOf("/") + 1);
List<Student> students = new ArrayList<>();
try (BufferedReader reader = new BufferedReader(
new InputStreamReader(new FileInputStream(filePath), StandardCharsets.UTF_8))) {
String line = null;
while ((line = reader.readLine()) != null) {
String[] s = line.split(" ");
Student student = new Student();
student.setSno(Integer.valueOf(s[0]));
student.setName(s[1]);
student.setSex(Integer.valueOf(s[2]));
student.setCid(Integer.valueOf(s[3]));
student.setDid(Integer.valueOf(s[4]));
student.setBed(Integer.valueOf(s[5]));
student.setIdcard(s[6]);
student.setTel(s[7]);
students.add(student);
}
count = studentMapper.addStudentList(students);
} catch (IOException e) {
e.printStackTrace();
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Constant.Failed;
} catch (DuplicateKeyException | PersistenceException e) {
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return Constant.Confilct;
}
if (count != students.size())
return Constant.Failed;
return Constant.Success;
}
}
package edu.fzu.dormitory.utils;
import java.util.HashMap;
import java.util.Map;
public class Constant {
public final static int SuccessCode = 1000;// 成功
public final static int FailedCode = 1001;// 失败
public final static int ConflictCode = 1002;// 用户名冲突
public final static int PermessionDenyCode = 1003;
public final static String EncryptAlgorithm = "SHA";
public final static int NotCycle = 0;
public final static int DAY = 1;
public final static int WEEK = 2;
public final static int DAYCOUNT = 10;
public final static int TIMEMUL = 86400000;
public final static String[] AcceptFileType = { ".jpg", ".jpeg", ".png", ".txt" };
public final static String ResourcesDirection = "C:\\resources\\";
public final static String HostAddress = "124.223.194.15:19260";
public final static Map<String, Object> Failed = new HashMap<String, Object>() {
{
put("status", Constant.FailedCode);
}
};
public final static Map<String, Object> Deny = new HashMap<String, Object>() {
{
put("status", Constant.PermessionDenyCode);
}
};
public final static Map<String, Object> Confilct = new HashMap<String, Object>() {
{
put("status", Constant.ConflictCode);
}
};
public final static Map<String, Object> Success = new HashMap<String, Object>() {
{
put("status", Constant.SuccessCode);
}
};
}
package edu.fzu.dormitory.utils;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import org.springframework.stereotype.Component;
@Component
public class PasswordEncryptor {
private final static char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E',
'F' };
private static String base = "abcdefghijklmnopqrstuvwxyz!@#$%^&*()_+=?/><";
public String byteArrayToHex(byte[] byteArray) {
char[] resultCharArray = new char[byteArray.length * 2];
int index = 0;
for (byte b : byteArray) {
resultCharArray[index++] = hexDigits[b >>> 4 & 0xf];
resultCharArray[index++] = hexDigits[b & 0xf];
}
return new String(resultCharArray);
}
public static String getRandomString(int length) {
StringBuilder builder = new StringBuilder();
Random random = new Random();
for (int i = 0; i < length; ++i)
builder.append(base.charAt(random.nextInt(base.length())));
return builder.toString();
}
public Map<String, String> encrypt(String password, String salt) {
Map<String, String> result = new HashMap<>();
if (salt == null)
salt = getRandomString(15);
password = password + salt;
byte[] secretBytes = null;
try {
secretBytes = MessageDigest.getInstance(Constant.EncryptAlgorithm).digest(password.getBytes());
password = byteArrayToHex(secretBytes);
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
result.put("password", password);
result.put("salt", salt);
return result;
}
}
server.port=19260
spring.datasource.url=jdbc:mysql://localhost:3306/dormitory_sys
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.web.resources.static-locations=file:C:\\resources
spring.jackson.time-zone=GMT+8
mybatis.mapper-locations=classpath:edu/fzu/dormitory/dao/*.xml
spring.servlet.multipart.maxFileSize=20MB
spring.servlet.multipart.maxRequestSize=25MB
mybatis.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
package edu.fzu.dormitory;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class DormitoryApplicationTests {
@Test
void contextLoads() {
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册