├── .gitignore ├── .mvn └── wrapper │ ├── MavenWrapperDownloader.java │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml └── src ├── main ├── java │ └── com │ │ └── hfut │ │ └── studentmanager │ │ ├── StudentmanagerApplication.java │ │ ├── controller │ │ ├── LoginController.java │ │ ├── StudentController.java │ │ ├── SystemController.java │ │ └── TeacherController.java │ │ ├── filter │ │ └── CorsFilter.java │ │ ├── interceptor │ │ └── LoginHandlerInterceptor.java │ │ ├── mapper │ │ ├── ClazzCourseTeacherMapper.java │ │ ├── ClazzMapper.java │ │ ├── CourseMapper.java │ │ ├── EscoreMapper.java │ │ ├── ExamMapper.java │ │ ├── GradeCourseMapper.java │ │ ├── GradeMapper.java │ │ ├── StudentMapper.java │ │ ├── SystemMapper.java │ │ ├── TeacherMapper.java │ │ └── UserMapper.java │ │ ├── pojo │ │ ├── Clazz.java │ │ ├── ClazzCourseTeacher.java │ │ ├── Course.java │ │ ├── Escore.java │ │ ├── Exam.java │ │ ├── Grade.java │ │ ├── GradeCourse.java │ │ ├── Student.java │ │ ├── System.java │ │ ├── Teacher.java │ │ └── User.java │ │ ├── service │ │ ├── ClazzCourseTeacherService.java │ │ ├── ClazzService.java │ │ ├── CourseService.java │ │ ├── EScoreService.java │ │ ├── ExamService.java │ │ ├── GradeCourseService.java │ │ ├── GradeService.java │ │ ├── StudentService.java │ │ ├── SystemService.java │ │ ├── TeacherService.java │ │ └── UserService.java │ │ └── utils │ │ ├── Message.java │ │ ├── ResultUtils.java │ │ └── jsonBean │ │ ├── JSONClazz.java │ │ ├── JSONCourse.java │ │ ├── JSONExam.java │ │ ├── JSONGrade.java │ │ ├── JSONStudent.java │ │ ├── JSONTeacher.java │ │ └── Score.java └── resources │ ├── application.yml │ └── docs │ └── ssms.sql └── test └── java └── com └── hfut └── studentmanager ├── StudentmanagerApplicationTests.java └── service └── ClazzServiceTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/** 5 | !**/src/test/** 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | .idea/ 19 | /idea/ 20 | *.iws 21 | *.iml 22 | *.ipr 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | 35 | *.class 36 | 37 | #package files 38 | 39 | *.war 40 | *.ear 41 | 42 | #kdiff3 ignore 43 | target/ 44 | 45 | #eclipse ignore 46 | .settings/ 47 | 48 | # temp file 49 | *.log 50 | *.cache 51 | *.diff 52 | *.patch 53 | *.tmp 54 | 55 | #system ignore 56 | .DS_Store 57 | Thumbs.db 58 | -------------------------------------------------------------------------------- /.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | Licensed to the Apache Software Foundation (ASF) under one 3 | or more contributor license agreements. See the NOTICE file 4 | distributed with this work for additional information 5 | regarding copyright ownership. The ASF licenses this file 6 | to you under the Apache License, Version 2.0 (the 7 | "License"); you may not use this file except in compliance 8 | with the License. You may obtain a copy of the License at 9 | 10 | https://www.apache.org/licenses/LICENSE-2.0 11 | 12 | Unless required by applicable law or agreed to in writing, 13 | software distributed under the License is distributed on an 14 | "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | KIND, either express or implied. See the License for the 16 | specific language governing permissions and limitations 17 | under the License. 18 | */ 19 | 20 | import java.io.File; 21 | import java.io.FileInputStream; 22 | import java.io.FileOutputStream; 23 | import java.io.IOException; 24 | import java.net.URL; 25 | import java.nio.channels.Channels; 26 | import java.nio.channels.ReadableByteChannel; 27 | import java.util.Properties; 28 | 29 | public class MavenWrapperDownloader { 30 | 31 | /** 32 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 33 | */ 34 | private static final String DEFAULT_DOWNLOAD_URL = 35 | "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar"; 36 | 37 | /** 38 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 39 | * use instead of the default one. 40 | */ 41 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 42 | ".mvn/wrapper/maven-wrapper.properties"; 43 | 44 | /** 45 | * Path where the maven-wrapper.jar will be saved to. 46 | */ 47 | private static final String MAVEN_WRAPPER_JAR_PATH = 48 | ".mvn/wrapper/maven-wrapper.jar"; 49 | 50 | /** 51 | * Name of the property which should be used to override the default download url for the wrapper. 52 | */ 53 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 54 | 55 | public static void main(String args[]) { 56 | System.out.println("- Downloader started"); 57 | File baseDirectory = new File(args[0]); 58 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 59 | 60 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 61 | // wrapperUrl parameter. 62 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 63 | String url = DEFAULT_DOWNLOAD_URL; 64 | if (mavenWrapperPropertyFile.exists()) { 65 | FileInputStream mavenWrapperPropertyFileInputStream = null; 66 | try { 67 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 68 | Properties mavenWrapperProperties = new Properties(); 69 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 70 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 71 | } catch (IOException e) { 72 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 73 | } finally { 74 | try { 75 | if (mavenWrapperPropertyFileInputStream != null) { 76 | mavenWrapperPropertyFileInputStream.close(); 77 | } 78 | } catch (IOException e) { 79 | // Ignore ... 80 | } 81 | } 82 | } 83 | System.out.println("- Downloading from: : " + url); 84 | 85 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 86 | if (!outputFile.getParentFile().exists()) { 87 | if (!outputFile.getParentFile().mkdirs()) { 88 | System.out.println( 89 | "- ERROR creating output direcrory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 90 | } 91 | } 92 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 93 | try { 94 | downloadFileFromURL(url, outputFile); 95 | System.out.println("Done"); 96 | System.exit(0); 97 | } catch (Throwable e) { 98 | System.out.println("- Error downloading"); 99 | e.printStackTrace(); 100 | System.exit(1); 101 | } 102 | } 103 | 104 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 105 | URL website = new URL(urlString); 106 | ReadableByteChannel rbc; 107 | rbc = Channels.newChannel(website.openStream()); 108 | FileOutputStream fos = new FileOutputStream(destination); 109 | fos.getChannel().transferFrom(rbc, 0, Integer.MAX_VALUE); 110 | fos.close(); 111 | rbc.close(); 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sky1225/studentmanager/5e058cba7c118dc3728f9349c74d0dbe1810deca/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.0/apache-maven-3.6.0-bin.zip 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # studentmanager 2 | 基于springboot的学生成绩管理系统 3 | ## 说明 4 | 端口: 6969 5 | sql文件在src\main\resources\docs\ssms.sql 6 | 数据库连接配置在src\main\resources\application.yml -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # https://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven2 Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ]; then 38 | 39 | if [ -f /etc/mavenrc ]; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ]; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false 51 | darwin=false 52 | mingw=false 53 | case "$(uname)" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true ;; 56 | Darwin*) 57 | darwin=true 58 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 59 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 60 | if [ -z "$JAVA_HOME" ]; then 61 | if [ -x "/usr/libexec/java_home" ]; then 62 | export JAVA_HOME="$(/usr/libexec/java_home)" 63 | else 64 | export JAVA_HOME="/Library/Java/Home" 65 | fi 66 | fi 67 | ;; 68 | esac 69 | 70 | if [ -z "$JAVA_HOME" ]; then 71 | if [ -r /etc/gentoo-release ]; then 72 | JAVA_HOME=$(java-config --jre-home) 73 | fi 74 | fi 75 | 76 | if [ -z "$M2_HOME" ]; then 77 | ## resolve links - $0 may be a link to maven's home 78 | PRG="$0" 79 | 80 | # need this for relative symlinks 81 | while [ -h "$PRG" ]; do 82 | ls=$(ls -ld "$PRG") 83 | link=$(expr "$ls" : '.*-> \(.*\)$') 84 | if expr "$link" : '/.*' >/dev/null; then 85 | PRG="$link" 86 | else 87 | PRG="$(dirname "$PRG")/$link" 88 | fi 89 | done 90 | 91 | saveddir=$(pwd) 92 | 93 | M2_HOME=$(dirname "$PRG")/.. 94 | 95 | # make it fully qualified 96 | M2_HOME=$(cd "$M2_HOME" && pwd) 97 | 98 | cd "$saveddir" 99 | # echo Using m2 at $M2_HOME 100 | fi 101 | 102 | # For Cygwin, ensure paths are in UNIX format before anything is touched 103 | if $cygwin; then 104 | [ -n "$M2_HOME" ] && 105 | M2_HOME=$(cygpath --unix "$M2_HOME") 106 | [ -n "$JAVA_HOME" ] && 107 | JAVA_HOME=$(cygpath --unix "$JAVA_HOME") 108 | [ -n "$CLASSPATH" ] && 109 | CLASSPATH=$(cygpath --path --unix "$CLASSPATH") 110 | fi 111 | 112 | # For Mingw, ensure paths are in UNIX format before anything is touched 113 | if $mingw; then 114 | [ -n "$M2_HOME" ] && 115 | M2_HOME="$( ( 116 | cd "$M2_HOME" 117 | pwd 118 | ))" 119 | [ -n "$JAVA_HOME" ] && 120 | JAVA_HOME="$( ( 121 | cd "$JAVA_HOME" 122 | pwd 123 | ))" 124 | # TODO classpath? 125 | fi 126 | 127 | if [ -z "$JAVA_HOME" ]; then 128 | javaExecutable="$(which javac)" 129 | if [ -n "$javaExecutable" ] && ! [ "$(expr \"$javaExecutable\" : '\([^ ]*\)')" = "no" ]; then 130 | # readlink(1) is not available as standard on Solaris 10. 131 | readLink=$(which readlink) 132 | if [ ! $(expr "$readLink" : '\([^ ]*\)') = "no" ]; then 133 | if $darwin; then 134 | javaHome="$(dirname \"$javaExecutable\")" 135 | javaExecutable="$(cd \"$javaHome\" && pwd -P)/javac" 136 | else 137 | javaExecutable="$(readlink -f \"$javaExecutable\")" 138 | fi 139 | javaHome="$(dirname \"$javaExecutable\")" 140 | javaHome=$(expr "$javaHome" : '\(.*\)/bin') 141 | JAVA_HOME="$javaHome" 142 | export JAVA_HOME 143 | fi 144 | fi 145 | fi 146 | 147 | if [ -z "$JAVACMD" ]; then 148 | if [ -n "$JAVA_HOME" ]; then 149 | if [ -x "$JAVA_HOME/jre/sh/java" ]; then 150 | # IBM's JDK on AIX uses strange locations for the executables 151 | JAVACMD="$JAVA_HOME/jre/sh/java" 152 | else 153 | JAVACMD="$JAVA_HOME/bin/java" 154 | fi 155 | else 156 | JAVACMD="$(which java)" 157 | fi 158 | fi 159 | 160 | if [ ! -x "$JAVACMD" ]; then 161 | echo "Error: JAVA_HOME is not defined correctly." >&2 162 | echo " We cannot execute $JAVACMD" >&2 163 | exit 1 164 | fi 165 | 166 | if [ -z "$JAVA_HOME" ]; then 167 | echo "Warning: JAVA_HOME environment variable is not set." 168 | fi 169 | 170 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 171 | 172 | # traverses directory structure from process work directory to filesystem root 173 | # first directory with .mvn subdirectory is considered project base directory 174 | find_maven_basedir() { 175 | 176 | if [ -z "$1" ]; then 177 | echo "Path not specified to find_maven_basedir" 178 | return 1 179 | fi 180 | 181 | basedir="$1" 182 | wdir="$1" 183 | while [ "$wdir" != '/' ]; do 184 | if [ -d "$wdir"/.mvn ]; then 185 | basedir=$wdir 186 | break 187 | fi 188 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 189 | if [ -d "${wdir}" ]; then 190 | wdir=$( 191 | cd "$wdir/.." 192 | pwd 193 | ) 194 | fi 195 | # end of workaround 196 | done 197 | echo "${basedir}" 198 | } 199 | 200 | # concatenates all lines of a file 201 | concat_lines() { 202 | if [ -f "$1" ]; then 203 | echo "$(tr -s '\n' ' ' <"$1")" 204 | fi 205 | } 206 | 207 | BASE_DIR=$(find_maven_basedir "$(pwd)") 208 | if [ -z "$BASE_DIR" ]; then 209 | exit 1 210 | fi 211 | 212 | ########################################################################################## 213 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 214 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 215 | ########################################################################################## 216 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 217 | if [ "$MVNW_VERBOSE" = true ]; then 218 | echo "Found .mvn/wrapper/maven-wrapper.jar" 219 | fi 220 | else 221 | if [ "$MVNW_VERBOSE" = true ]; then 222 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 223 | fi 224 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 225 | while IFS="=" read key value; do 226 | case "$key" in wrapperUrl) 227 | jarUrl="$value" 228 | break 229 | ;; 230 | esac 231 | done <"$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Downloading from: $jarUrl" 234 | fi 235 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 236 | 237 | if command -v wget >/dev/null; then 238 | if [ "$MVNW_VERBOSE" = true ]; then 239 | echo "Found wget ... using wget" 240 | fi 241 | wget "$jarUrl" -O "$wrapperJarPath" 242 | elif command -v curl >/dev/null; then 243 | if [ "$MVNW_VERBOSE" = true ]; then 244 | echo "Found curl ... using curl" 245 | fi 246 | curl -o "$wrapperJarPath" "$jarUrl" 247 | else 248 | if [ "$MVNW_VERBOSE" = true ]; then 249 | echo "Falling back to using Java to download" 250 | fi 251 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 252 | if [ -e "$javaClass" ]; then 253 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 254 | if [ "$MVNW_VERBOSE" = true ]; then 255 | echo " - Compiling MavenWrapperDownloader.java ..." 256 | fi 257 | # Compiling the Java class 258 | ("$JAVA_HOME/bin/javac" "$javaClass") 259 | fi 260 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | # Running the downloader 262 | if [ "$MVNW_VERBOSE" = true ]; then 263 | echo " - Running MavenWrapperDownloader.java ..." 264 | fi 265 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 266 | fi 267 | fi 268 | fi 269 | fi 270 | ########################################################################################## 271 | # End of extension 272 | ########################################################################################## 273 | 274 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 275 | if [ "$MVNW_VERBOSE" = true ]; then 276 | echo $MAVEN_PROJECTBASEDIR 277 | fi 278 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 279 | 280 | # For Cygwin, switch paths to Windows format before running java 281 | if $cygwin; then 282 | [ -n "$M2_HOME" ] && 283 | M2_HOME=$(cygpath --path --windows "$M2_HOME") 284 | [ -n "$JAVA_HOME" ] && 285 | JAVA_HOME=$(cygpath --path --windows "$JAVA_HOME") 286 | [ -n "$CLASSPATH" ] && 287 | CLASSPATH=$(cygpath --path --windows "$CLASSPATH") 288 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 289 | MAVEN_PROJECTBASEDIR=$(cygpath --path --windows "$MAVEN_PROJECTBASEDIR") 290 | fi 291 | 292 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 293 | 294 | exec "$JAVACMD" \ 295 | $MAVEN_OPTS \ 296 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 297 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 298 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 299 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven2 Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" 124 | FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( 125 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 126 | ) 127 | 128 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 129 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 130 | if exist %WRAPPER_JAR% ( 131 | echo Found %WRAPPER_JAR% 132 | ) else ( 133 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 134 | echo Downloading from: %DOWNLOAD_URL% 135 | powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" 136 | echo Finished downloading %WRAPPER_JAR% 137 | ) 138 | @REM End of extension 139 | 140 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 141 | if ERRORLEVEL 1 goto error 142 | goto end 143 | 144 | :error 145 | set ERROR_CODE=1 146 | 147 | :end 148 | @endlocal & set ERROR_CODE=%ERROR_CODE% 149 | 150 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 151 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 152 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 153 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 154 | :skipRcPost 155 | 156 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 157 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 158 | 159 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 160 | 161 | exit /B %ERROR_CODE% 162 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.2.0.RELEASE 9 | 10 | 11 | com.hfut 12 | studentmanager 13 | 0.0.1-SNAPSHOT 14 | studentmanager 15 | Student Achievement Management System for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-test 30 | test 31 | 32 | 33 | org.junit.vintage 34 | junit-vintage-engine 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.mybatis.spring.boot 42 | mybatis-spring-boot-starter 43 | 1.1.1 44 | 45 | 46 | 47 | mysql 48 | mysql-connector-java 49 | 5.1.21 50 | 51 | 52 | 53 | org.springframework.boot 54 | spring-boot-devtools 55 | true 56 | 57 | 58 | 59 | junit 60 | junit 61 | 4.11 62 | test 63 | 64 | 65 | 66 | com.alibaba 67 | fastjson 68 | 1.2.62 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | org.springframework.boot 77 | spring-boot-maven-plugin 78 | 79 | 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/StudentmanagerApplication.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class StudentmanagerApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(StudentmanagerApplication.class, args); 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/controller/LoginController.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.controller; 2 | 3 | import com.hfut.studentmanager.pojo.User; 4 | import com.hfut.studentmanager.service.UserService; 5 | import com.hfut.studentmanager.utils.Message; 6 | import com.hfut.studentmanager.utils.ResultUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | @RestController 11 | public class LoginController { 12 | 13 | @Autowired 14 | UserService userService; 15 | 16 | @RequestMapping("/") 17 | public String hello(){ 18 | return "你好,访问成功"; 19 | } 20 | 21 | @PostMapping("/login") 22 | public Message login( 23 | @RequestParam("account") String account, 24 | @RequestParam("password") String password 25 | ){ 26 | User user = userService.login(account, password); 27 | if (user == null){ 28 | return ResultUtils.error(404, "登录失败"); 29 | } 30 | return ResultUtils.loginSuccess(user); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/controller/StudentController.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.controller; 2 | 3 | import com.hfut.studentmanager.pojo.*; 4 | import com.hfut.studentmanager.service.*; 5 | import com.hfut.studentmanager.utils.Message; 6 | import com.hfut.studentmanager.utils.ResultUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | import java.util.ArrayList; 11 | import java.util.HashMap; 12 | import java.util.List; 13 | import java.util.Map; 14 | 15 | @RestController 16 | @RequestMapping("/student") 17 | public class StudentController { 18 | 19 | @Autowired 20 | private StudentService studentService; 21 | @Autowired 22 | private ExamService examService; 23 | @Autowired 24 | private GradeService gradeService; 25 | @Autowired 26 | private ClazzService clazzService; 27 | @Autowired 28 | private CourseService courseService; 29 | @Autowired 30 | private EScoreService eScoreService; 31 | @Autowired 32 | private UserService userService; 33 | 34 | @PostMapping("/updatePasswordByStudent") 35 | public Message updatePasswordByStudent(@RequestParam("studentId") String studentId, 36 | @RequestParam("oldPassword") String oldPassword, 37 | @RequestParam("newPassword") String newPassword){ 38 | Student student = studentService.listStudentById(Integer.parseInt(studentId)); 39 | return userService.updatePassword(student.getNumber(), oldPassword, newPassword); 40 | } 41 | 42 | @GetMapping("/listStudentByNumber") 43 | public Message listStudentById(@RequestParam("number") String number){ 44 | Student student = studentService.listStudentByNumber(number); 45 | if (student == null){ 46 | return ResultUtils.error(404, "学生不存在"); 47 | } 48 | Map map = new HashMap<>(); 49 | map.put("id", student.getId()); 50 | map.put("number", student.getNumber()); 51 | map.put("name", student.getName()); 52 | map.put("sex", student.getSex()); 53 | map.put("phone", student.getPhone()); 54 | map.put("qq", student.getQq()); 55 | map.put("clazzId", clazzService.listClazzById(student.getClazzId()).getName()); 56 | map.put("gradeId", gradeService.listGradeById(student.getGradeId()).getName()); 57 | return ResultUtils.success(map); 58 | } 59 | 60 | @GetMapping("/listExamByStudent") 61 | public Message listExamByStudent(@RequestParam("studentId") String studentId){ 62 | Student student = studentService.listStudentById(Integer.parseInt(studentId)); 63 | Integer clazzId = student.getClazzId(); 64 | Integer gradeId = student.getGradeId(); 65 | List> result = new ArrayList<>(); 66 | for (Exam exam: examService.listExamByGradeId(gradeId)){ 67 | Map map = new HashMap<>(); 68 | if (exam.getType().equals(1) || exam.getClazzId().equals(clazzId)){ 69 | map.put("id", exam.getId()); 70 | map.put("name", exam.getName()); 71 | map.put("time", exam.getTime()); 72 | map.put("remark", exam.getRemark()); 73 | map.put("type", exam.getType()); 74 | map.put("grade", gradeService.listGradeById(exam.getGradeId()).getName()); 75 | Clazz clazz = clazzService.listClazzById(exam.getClazzId()); 76 | if (clazz == null){ 77 | map.put("clazz", ""); 78 | }else { 79 | map.put("clazz", clazz.getName()); 80 | } 81 | map.put("course", courseService.listCourseById(exam.getCourseId()).getName()); 82 | Escore escore = eScoreService.listEScoreByExamIdAndStudentId(exam.getId(), Integer.parseInt(studentId)); 83 | if(escore == null){ 84 | map.put("score", ""); 85 | }else { 86 | map.put("score", escore.getScore().toString()); 87 | } 88 | result.add(map); 89 | } 90 | } 91 | return ResultUtils.success(result); 92 | } 93 | 94 | @GetMapping("/listClazzByStudent") 95 | public Message listClazzByStudent(@RequestParam("studentId") String studentId){ 96 | Student student = studentService.listStudentById(Integer.parseInt(studentId)); 97 | if (student == null){ 98 | return ResultUtils.error(404, "学生不存在"); 99 | } 100 | Integer clazzId = student.getClazzId(); 101 | List studentList = studentService.listStudentByClazz(clazzId); 102 | return ResultUtils.success(StudentListToMapList(studentList)); 103 | } 104 | 105 | private List> StudentListToMapList(List studentList){ 106 | if (studentList == null || studentList.size() == 0){ 107 | return null; 108 | } 109 | List> result = new ArrayList<>(); 110 | for (Student student: studentList){ 111 | Map map = new HashMap<>(); 112 | map.put("id", student.getId()); 113 | map.put("number", student.getNumber()); 114 | map.put("name", student.getName()); 115 | map.put("sex", student.getSex()); 116 | map.put("phone", student.getPhone()); 117 | map.put("qq", student.getQq()); 118 | map.put("clazzId", clazzService.listClazzById(student.getClazzId()).getName()); 119 | map.put("gradeId", gradeService.listGradeById(student.getGradeId()).getName()); 120 | result.add(map); 121 | } 122 | return result; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/controller/SystemController.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.controller; 2 | 3 | import com.hfut.studentmanager.pojo.*; 4 | import com.hfut.studentmanager.service.*; 5 | import com.hfut.studentmanager.utils.Message; 6 | import com.hfut.studentmanager.utils.ResultUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.*; 9 | 10 | import javax.servlet.http.HttpServletRequest; 11 | import java.lang.System; 12 | import java.text.ParseException; 13 | import java.text.SimpleDateFormat; 14 | import java.util.*; 15 | 16 | @RestController 17 | @RequestMapping("/system") 18 | public class SystemController { 19 | 20 | @Autowired 21 | private StudentService studentService; 22 | @Autowired 23 | private TeacherService teacherService; 24 | @Autowired 25 | private ExamService examService; 26 | @Autowired 27 | private ClazzService clazzService; 28 | @Autowired 29 | private UserService userService; 30 | @Autowired 31 | private GradeService gradeService; 32 | @Autowired 33 | private CourseService courseService; 34 | @Autowired 35 | private ClazzCourseTeacherService clazzCourseTeacherService; 36 | @Autowired 37 | private GradeCourseService gradeCourseService; 38 | 39 | @PostMapping("updatePasswordByAccount") 40 | public Message updatePasswordByAccount(@RequestParam("account") String account, 41 | @RequestParam("oldPassword") String oldPassword, 42 | @RequestParam("newPassword") String newPassword){ 43 | return userService.updatePassword(account, oldPassword, newPassword); 44 | } 45 | 46 | @GetMapping("/list") 47 | public Message listAll(HttpServletRequest request, @RequestParam("method") String method, 48 | @RequestParam(value = "gradeId", required = false) String gradeId){ 49 | if (method == null){ 50 | return ResultUtils.error(404, "请求参数method为空"); 51 | } 52 | switch (method){ 53 | case "LoginOut": 54 | return loginOut(request); 55 | case "listAllStudent": 56 | List> studentList = StudentListToMapList(studentService.listAllStudent()); 57 | return ResultUtils.success(studentList); 58 | case "listAllTeacher": 59 | List> teacherList = teacherService.listAllTeacher(); 60 | return ResultUtils.success(teacherList); 61 | case "listAllExam": 62 | List> examList = examService.listAllExam(); 63 | return ResultUtils.success(examList); 64 | case "listAllClazz": 65 | List> clazzList = clazzService.listAllClazz(); 66 | return ResultUtils.success(clazzList); 67 | case "listAllGrade": 68 | List> gradeList = gradeService.listAllGrade(); 69 | return ResultUtils.success(gradeList); 70 | case "listAllCourse": 71 | List courseList = courseService.listAllCourse(); 72 | return ResultUtils.success(courseList); 73 | case "listClazzByGradeId": 74 | List clazzListByGrade = clazzService.listClazzByGradeId(Integer.parseInt(gradeId)); 75 | return ResultUtils.success(clazzListByGrade); 76 | case "listCourseByGradeId": 77 | List> gradeCourseList = gradeCourseService.listGradeCourseByGradeId(Integer.parseInt(gradeId)); 78 | return ResultUtils.success(gradeCourseList); 79 | default: 80 | return ResultUtils.error(404, "请求参数method错误"); 81 | } 82 | } 83 | 84 | @PostMapping("/addStudent") 85 | public Message addStudent(@RequestParam(value = "number", required = true) String number, 86 | @RequestParam(value = "name", required = true) String name, 87 | @RequestParam(value = "sex", required = true) String sex, 88 | @RequestParam(value = "phone", required = false) String phone, 89 | @RequestParam(value = "qq", required = false) String qq, 90 | @RequestParam(value = "clazzId", required = true) String clazzId, 91 | @RequestParam(value = "gradeId", required = true) String gradeId){ 92 | User user = new User(); 93 | Student student = new Student(null, number, name, sex, phone, qq, Integer.parseInt(clazzId), Integer.parseInt(gradeId)); 94 | user.setAccount(student.getNumber()); 95 | user.setName(student.getName()); 96 | user.setPassword("111111"); 97 | user.setType(2); 98 | Message addUserResult = userService.addUser(user); 99 | if (!addUserResult.getCode().equals("200")) { 100 | return addUserResult; 101 | } 102 | Message addStudentResult = studentService.addStudent(student); 103 | if (!addStudentResult.getCode().equals("200")){ 104 | return addStudentResult; 105 | } 106 | return ResultUtils.success(); 107 | } 108 | 109 | @PostMapping("/addCourseByTeacher") 110 | public Message addCourseByTeacher(@RequestParam(value = "clazzId", required = true) String cId, 111 | @RequestParam(value = "gradeId", required = true) String gId, 112 | @RequestParam(value = "courseId", required = true) String csId, 113 | @RequestParam(value = "teacherId", required = true) String tId){ 114 | Integer clazzId = Integer.parseInt(cId); 115 | Integer gradeId = Integer.parseInt(gId); 116 | Integer courseId = Integer.parseInt(csId); 117 | Integer teacherId = Integer.parseInt(tId); 118 | ClazzCourseTeacher clazzCourseTeacher = new ClazzCourseTeacher(null, clazzId, gradeId, courseId, teacherId); 119 | return clazzCourseTeacherService.addClazzCourseTeacher(clazzCourseTeacher); 120 | } 121 | 122 | @PostMapping("/addTeacher") 123 | public Message addTeacher(@RequestParam(value = "number", required = true) String number, 124 | @RequestParam(value = "name", required = true) String name, 125 | @RequestParam(value = "sex", required = true) String sex, 126 | @RequestParam(value = "phone", required = false) String phone, 127 | @RequestParam(value = "qq", required = false) String qq){ 128 | User user = new User(); 129 | Teacher teacher = new Teacher(null, number, name, sex, phone, qq); 130 | user.setAccount(teacher.getNumber()); 131 | user.setName(teacher.getName()); 132 | user.setPassword("111111"); 133 | user.setType(3); 134 | Message addUserResult = userService.addUser(user); 135 | if (!addUserResult.getCode().equals("200")) { 136 | return addUserResult; 137 | } 138 | Message addTeacherResult = teacherService.addTeacher(teacher); 139 | if (!addTeacherResult.getCode().equals("200")){ 140 | return addTeacherResult; 141 | } 142 | return ResultUtils.success(); 143 | } 144 | 145 | @PostMapping("/addCourse") 146 | public Message addCourse(@RequestParam(value = "name", required = true) String name){ 147 | Course course = new Course(null, name); 148 | return courseService.addCourse(course); 149 | } 150 | 151 | @PostMapping("/addGrade") 152 | public Message addGrade(@RequestParam(value = "name") String name){ 153 | Grade grade = new Grade(null, name); 154 | return gradeService.addGrade(grade); 155 | } 156 | 157 | @PostMapping("addCourseByGrade") 158 | public Message addCourseByGrade(@RequestParam(value = "gradeId", required = true) String gId, 159 | @RequestParam(value = "courseId", required = true) String cId){ 160 | Integer gradeId = Integer.parseInt(gId); 161 | Integer courseId = Integer.parseInt(cId); 162 | GradeCourse gradeCourse = new GradeCourse(null, gradeId, courseId); 163 | return gradeCourseService.addGradeCourse(gradeCourse); 164 | } 165 | 166 | @PostMapping("addClazz") 167 | public Message addClazz(@RequestParam(value = "name", required = true) String name, 168 | @RequestParam(value = "gradeId", required = true) String gId){ 169 | Integer gradeId = Integer.parseInt(gId); 170 | Clazz clazz = new Clazz(null, name, gradeId); 171 | return clazzService.addClazz(clazz); 172 | } 173 | 174 | @PostMapping("addExam") 175 | public Message addExam(@RequestParam(value = "name", required = true) String name, 176 | @RequestParam(value = "time", required = true) String time, 177 | @RequestParam(value = "remark", required = false) String remark, 178 | @RequestParam(value = "type", required = true) String type, 179 | @RequestParam(value = "gradeId", required = true) String gId, 180 | @RequestParam(value = "clazzId", required = true) String cId, 181 | @RequestParam(value = "courseId", required = true) String csId){ 182 | Date date; 183 | Integer gradeId = Integer.parseInt(gId); 184 | Integer courseId = Integer.parseInt(csId); 185 | if (gradeCourseService.listGradeCourseByGradeIdAndCourseId(gradeId, courseId) == null){ 186 | return ResultUtils.error(404, "该年级下不存在该课程"); 187 | } 188 | Integer clazzId = Integer.parseInt(cId); 189 | try { 190 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); 191 | date = dateFormat.parse(time); 192 | Exam exam = new Exam(null, name, date, remark, Integer.parseInt(type), gradeId, clazzId, courseId); 193 | return examService.addExam(exam); 194 | } catch (ParseException e) { 195 | e.printStackTrace(); 196 | return ResultUtils.error(404, "数据格式错误"); 197 | } 198 | } 199 | 200 | @GetMapping("/delete") 201 | public Message delete(@RequestParam("method") String method, @RequestParam("id") String id){ 202 | switch (method){ 203 | case "deleteTeacher": 204 | return teacherService.deleteTeacher(Integer.parseInt(id)); 205 | case "deleteStudent": 206 | return studentService.deleteStudent(Integer.parseInt(id)); 207 | case "deleteGrade": 208 | return gradeService.deleteGrade(Integer.parseInt(id)); 209 | case "deleteClazz": 210 | return clazzService.deleteClazz(Integer.parseInt(id)); 211 | case "deleteCourse": 212 | return courseService.deleteCourse(Integer.parseInt(id)); 213 | case "deleteExam": 214 | return examService.deleteExam(Integer.parseInt(id)); 215 | default: 216 | return ResultUtils.error(404, "method格式错误"); 217 | 218 | } 219 | } 220 | 221 | private List> StudentListToMapList(List studentList){ 222 | if (studentList == null || studentList.size() == 0){ 223 | return null; 224 | } 225 | List> result = new ArrayList<>(); 226 | for (Student student: studentList){ 227 | Map map = new HashMap<>(); 228 | map.put("id", student.getId()); 229 | map.put("number", student.getNumber()); 230 | map.put("name", student.getName()); 231 | map.put("sex", student.getSex()); 232 | map.put("phone", student.getPhone()); 233 | map.put("qq", student.getQq()); 234 | map.put("clazzId", clazzService.listClazzById(student.getClazzId()).getName()); 235 | map.put("gradeId", gradeService.listGradeById(student.getGradeId()).getName()); 236 | result.add(map); 237 | } 238 | return result; 239 | } 240 | 241 | private Message loginOut(HttpServletRequest request){ 242 | request.getSession().removeAttribute("user"); 243 | return ResultUtils.success(); 244 | } 245 | 246 | } 247 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/controller/TeacherController.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.controller; 2 | 3 | import com.hfut.studentmanager.pojo.*; 4 | import com.hfut.studentmanager.service.*; 5 | import com.hfut.studentmanager.utils.Message; 6 | import com.hfut.studentmanager.utils.ResultUtils; 7 | import com.hfut.studentmanager.utils.jsonBean.Score; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.*; 10 | 11 | import java.lang.System; 12 | import java.util.ArrayList; 13 | import java.util.HashMap; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | @RestController 18 | @RequestMapping("/teacher") 19 | public class TeacherController { 20 | 21 | @Autowired 22 | private ClazzCourseTeacherService clazzCourseTeacherService; 23 | @Autowired 24 | private ExamService examService; 25 | @Autowired 26 | private ClazzService clazzService; 27 | @Autowired 28 | private StudentService studentService; 29 | @Autowired 30 | private EScoreService eScoreService; 31 | @Autowired 32 | private GradeService gradeService; 33 | @Autowired 34 | private CourseService courseService; 35 | @Autowired 36 | private TeacherService teacherService; 37 | @Autowired 38 | private UserService userService; 39 | 40 | @PostMapping("/updatePasswordByTeacher") 41 | public Message updatePasswordByTeacher(@RequestParam("teacherId") String teacherId, 42 | @RequestParam("oldPassword") String oldPassword, 43 | @RequestParam("newPassword") String newPassword){ 44 | Teacher teacher = teacherService.listTeacherById(Integer.parseInt(teacherId)); 45 | return userService.updatePassword(teacher.getNumber(), oldPassword, newPassword); 46 | } 47 | 48 | @GetMapping("/listTeacherByNumber") 49 | public Message listTeacherByNumber(@RequestParam("number") String number){ 50 | Teacher teacher = teacherService.listTeacherByNumber(number); 51 | return ResultUtils.success(teacher); 52 | } 53 | 54 | @GetMapping("/listExam") 55 | public Message listExam(@RequestParam("teacherId") String teacherId){ 56 | //此教师教的所有课程 57 | List clazzCourseTeacherList = clazzCourseTeacherService.listClazzCourseTeacherByTeacherId(Integer.parseInt(teacherId)); 58 | List> result = new ArrayList<>(); 59 | 60 | for (ClazzCourseTeacher clazzCourseTeacher: clazzCourseTeacherList){ 61 | //课程id 62 | Integer courseId = clazzCourseTeacher.getCourseId(); 63 | //班级id 64 | Integer clazzId = clazzCourseTeacher.getClazzId(); 65 | //某门课程发布的考试 66 | for (Exam exam: examService.listExamByCourseId(courseId)){ 67 | Map map = new HashMap<>(); 68 | if (exam.getType().equals(1) || exam.getClazzId().equals(clazzId)){ 69 | map.put("id", exam.getId()); 70 | map.put("name", exam.getName()); 71 | map.put("time", exam.getTime()); 72 | map.put("remark", exam.getRemark()); 73 | map.put("type", exam.getType()); 74 | map.put("grade", gradeService.listGradeById(exam.getGradeId()).getName()); 75 | Clazz clazz = clazzService.listClazzById(exam.getClazzId()); 76 | if (clazz == null){ 77 | map.put("clazz", "年级统考"); 78 | }else { 79 | map.put("clazz", clazz.getName()); 80 | } 81 | 82 | map.put("course", courseService.listCourseById(exam.getCourseId()).getName()); 83 | result.add(map); 84 | } 85 | } 86 | } 87 | return ResultUtils.success(result); 88 | } 89 | 90 | @GetMapping("/listClazzByExam") 91 | public Message listClazzByExam(@RequestParam("examId") String examId){ 92 | Exam exam = examService.listExamById(Integer.parseInt(examId)); 93 | Map result = new HashMap<>(); 94 | List clazzList; 95 | if (exam.getClazzId() != 0){ 96 | clazzList = new ArrayList<>(); 97 | clazzList.add(clazzService.listClazzById(exam.getClazzId())); 98 | }else { 99 | clazzList = clazzService.listClazzByGradeId(exam.getGradeId()); 100 | } 101 | result.put("clazz", clazzList); 102 | return ResultUtils.success(result); 103 | } 104 | 105 | @GetMapping("/listStudentByClazz") 106 | public Message listStudentByClazz(@RequestParam("examId") String examId, 107 | @RequestParam("clazzId") String clazzId){ 108 | List studentList = studentService.listStudentByClazz(Integer.parseInt(clazzId)); 109 | if (studentList == null || studentList.size() == 0) { 110 | return ResultUtils.error(404, "不存在学生"); 111 | } 112 | List> result = new ArrayList<>(); 113 | for (Student student: studentList){ 114 | Map map = new HashMap<>(); 115 | Escore escore = eScoreService.listEScoreByExamIdAndStudentId(Integer.parseInt(examId), student.getId()); 116 | if (escore != null){ 117 | map.put("score", escore.getScore().toString()); 118 | }else { 119 | map.put("score", ""); 120 | } 121 | map.put("studentId", student.getId()); 122 | map.put("number", student.getNumber()); 123 | map.put("name", student.getName()); 124 | map.put("examId", Integer.parseInt(examId)); 125 | result.add(map); 126 | } 127 | return ResultUtils.success(result); 128 | } 129 | 130 | @PostMapping("/addScore") 131 | public Message addScore(@RequestBody List studentScore){ 132 | for (Score score : studentScore) { 133 | Message result = eScoreService.addEScoreByExamIdAndStudentIdAndCourseId(score.getExamId(), score.getStudentId(), 134 | examService.listExamById(score.getExamId()).getCourseId(), Integer.parseInt(score.getScore())); 135 | if (result.getCode().equals("404")){ 136 | return result; 137 | } 138 | } 139 | return ResultUtils.success(); 140 | } 141 | 142 | @GetMapping("/getScore") 143 | public Message getScore(@RequestParam("examId") String examId, 144 | @RequestParam("clazzId") String clazzId){ 145 | List> eScoreList = eScoreService.listESCoreByExamIdAndClazzId(Integer.parseInt(examId), Integer.parseInt(clazzId)); 146 | return ResultUtils.success(eScoreList); 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/filter/CorsFilter.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.filter; 2 | 3 | import org.springframework.http.HttpMethod; 4 | import org.springframework.http.HttpStatus; 5 | import org.springframework.stereotype.Component; 6 | 7 | import javax.servlet.*; 8 | import javax.servlet.http.HttpServletRequest; 9 | import javax.servlet.http.HttpServletResponse; 10 | import java.io.IOException; 11 | 12 | /** 13 | * 负责跨域请求的过滤器 14 | * 15 | * @author 冉子硕 16 | */ 17 | @Component 18 | public class CorsFilter implements Filter { 19 | 20 | @Override 21 | public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { 22 | HttpServletResponse response = (HttpServletResponse) res; 23 | HttpServletRequest request = (HttpServletRequest) req; 24 | 25 | String myOrigin = request.getHeader("origin"); 26 | 27 | response.setHeader("Access-Control-Allow-Origin", myOrigin); 28 | response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE"); 29 | response.setHeader("Access-Control-Max-Age", "3600"); 30 | response.setHeader("Access-Control-Allow-Headers", "Origin, No-Cache, X-Requested-With, If-Modified-Since, " + 31 | "Pragma, Last-Modified, Cache-Control, Expires, Content-Type, X-E4M-With, userId,token"); 32 | response.setHeader("Access-Control-Allow-Credentials", "true"); 33 | response.setHeader("P3P", "CP=\"NON DSP COR CURa ADMa DEVa TAIa PSAa PSDa IVAa IVDa CONa HISa TELa OTPa OUR UNRa IND UNI COM NAV INT DEM CNT PRE LOC\""); 34 | response.setHeader("XDomainRequestAllowed", "1"); 35 | if (HttpMethod.OPTIONS.toString().equals(request.getMethod())) { 36 | response.setStatus(HttpStatus.OK.value()); 37 | return; 38 | } 39 | chain.doFilter(req, res); 40 | } 41 | 42 | @Override 43 | public void init(FilterConfig filterConfig) throws ServletException { 44 | } 45 | 46 | @Override 47 | public void destroy() { 48 | } 49 | 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/interceptor/LoginHandlerInterceptor.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.interceptor; 2 | 3 | import com.hfut.studentmanager.pojo.User; 4 | import org.springframework.web.servlet.HandlerInterceptor; 5 | import org.springframework.web.servlet.ModelAndView; 6 | 7 | import javax.servlet.http.HttpServletRequest; 8 | import javax.servlet.http.HttpServletResponse; 9 | 10 | public class LoginHandlerInterceptor implements HandlerInterceptor { 11 | 12 | @Override 13 | public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception { 14 | User user = (User) request.getSession().getAttribute("user"); 15 | if (user == null){ 16 | //未登录 17 | return false; 18 | } 19 | // 已登录 20 | return true; 21 | } 22 | 23 | @Override 24 | public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception { 25 | 26 | } 27 | 28 | @Override 29 | public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception { 30 | 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/mapper/ClazzCourseTeacherMapper.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.mapper; 2 | 3 | import com.hfut.studentmanager.pojo.ClazzCourseTeacher; 4 | import org.apache.ibatis.annotations.*; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | @Repository 11 | public interface ClazzCourseTeacherMapper { 12 | 13 | @Select("select * from clazz_course_teacher where clazzId=#{clazzCourseTeacher.clazzId} " + 14 | "and gradeId=#{clazzCourseTeacher.gradeId} " + 15 | "and courseId=#{clazzCourseTeacher.courseId} " + 16 | "and teacherId=#{clazzCourseTeacher.teacherId}") 17 | ClazzCourseTeacher findClazzCourseTeacherByClazzIdGradeIdCourseIdTeacherId(@Param("clazzCourseTeacher") ClazzCourseTeacher clazzCourseTeacher); 18 | 19 | @Select("select * from clazz_course_teacher") 20 | List findAllClazzCourseTeacher(); 21 | 22 | @Select("select * from clazz_course_teacher where id=#{id}") 23 | ClazzCourseTeacher findClazzCourseTeacherById(Integer id); 24 | 25 | @Select("select * from clazz_course_teacher where clazzId=#{clazzId}") 26 | List findClazzCourseTeacherByClazzId(Integer clazzId); 27 | 28 | @Select("select * from clazz_course_teacher where teacherId=#{teacherId}") 29 | List findClazzCourseTeacherByTeacherId(Integer teacherId); 30 | 31 | @Select("select * from clazz_course_teacher where courseId=#{courseId}") 32 | List findClazzCourseTeacherByCourseId(Integer courseId); 33 | 34 | @Insert("insert into clazz_course_teacher(clazzId, gradeId, courseId, teacherId) values" + 35 | "(#{clazzId}, #{gradeId}, #{courseId}, #{teacherId})") 36 | boolean insertClazzCourseTeacher(ClazzCourseTeacher clazzCourseTeacher); 37 | 38 | @Delete("delete from clazz_course_teacher where id=#{id}") 39 | boolean deleteClazzCourseTeacher(Integer id); 40 | 41 | @Delete("delete from clazz_course_teacher where gradeId=#{gradeId}") 42 | boolean deleteClazzCourseTeacherByGradeId(Integer gradeId); 43 | 44 | } 45 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/mapper/ClazzMapper.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.mapper; 2 | 3 | import com.hfut.studentmanager.pojo.Clazz; 4 | import org.apache.ibatis.annotations.*; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | @Repository 11 | public interface ClazzMapper { 12 | 13 | @Select("select * from clazz where id=#{id}") 14 | Clazz findClazzById(Integer id); 15 | 16 | @Select("select * from clazz") 17 | List findAllClazz(); 18 | 19 | @Select("select * from clazz where gradeId=#{gradeId}") 20 | List findClazzByGradeId(Integer gradeId); 21 | 22 | @Select("select name from clazz where id=#{id}") 23 | String findNameById(Integer id); 24 | 25 | @Select("select id from clazz where name=#{name} and gradeId=#{gradeId}") 26 | Integer findIdByNameAndGradeId(@Param("name") String name, @Param("gradeId")Integer gradeId); 27 | 28 | @Insert("insert into clazz(name, gradeId) values (#{name}, #{gradeId})") 29 | boolean insertClazz(Clazz clazz); 30 | 31 | @Delete("delete from clazz where id=#{id}") 32 | boolean deleteClazz(Integer id); 33 | 34 | @Delete("delete from clazz where gradeId=#{gradeId}") 35 | boolean deleteClazzByGradeId(Integer gradeId); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/mapper/CourseMapper.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.mapper; 2 | 3 | import com.hfut.studentmanager.pojo.Course; 4 | import org.apache.ibatis.annotations.Delete; 5 | import org.apache.ibatis.annotations.Insert; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.apache.ibatis.annotations.Select; 8 | import org.springframework.stereotype.Repository; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.List; 12 | 13 | @Mapper 14 | @Repository 15 | public interface CourseMapper { 16 | 17 | @Select("select * from course where name=#{name}") 18 | Course findCourseByName(String name); 19 | 20 | @Select("select name from course where id=#{id}") 21 | String findNameById(Integer id); 22 | 23 | @Select("select id from course where name=#{name}") 24 | Integer findIdByName(String name); 25 | 26 | @Select("select * from course") 27 | List findAllCourse(); 28 | 29 | @Select("select * from course where id=#{id}") 30 | Course findCourseById(Integer id); 31 | 32 | @Insert("insert into course(name) values (#{name})") 33 | boolean insertCourse(Course course); 34 | 35 | @Delete("delete from course where id=#{id}") 36 | boolean deleteCourseById(Integer id); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/mapper/EscoreMapper.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.mapper; 2 | 3 | import com.hfut.studentmanager.pojo.Escore; 4 | import org.apache.ibatis.annotations.*; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | @Repository 11 | public interface EscoreMapper { 12 | 13 | // @Select("select * from escore where studentId=#{studentId}") 14 | // List findEscoreByStudentId(Integer studentId); 15 | 16 | @Select("select * from escore") 17 | List findAllEscore(); 18 | 19 | @Select("select * from escore where id=#{id}") 20 | List findEscoreById(Integer id); 21 | 22 | @Select("select * from escore where examId=#{examId} and studentId=#{studentId}") 23 | List findEscoreByExamIdAndStudentId(@Param("examId") Integer examId, @Param("studentId")Integer studentId); 24 | 25 | 26 | @Select("select * from escore where examId=#{examId} and clazzId=#{clazzId}") 27 | List findEscoreByExamIdAndClazzId(@Param("examId") Integer examId, @Param("clazzId")Integer clazzId); 28 | 29 | @Select("select * from escore where examId=#{examId}") 30 | List findEscoreByExamId(Integer examId); 31 | 32 | @Select("select * from escore where clazzId=#{clazzId}") 33 | List findEscoreByClazzId(Integer clazzId); 34 | 35 | @Select("select * from escore where courseId=#{courseId}") 36 | List findEscoreByCourseId(Integer courseId); 37 | 38 | @Select("select * from escore where studentId=#{studentId}") 39 | List findEscoreByStudentId(Integer studentId); 40 | 41 | @Select("select * from escore where gradeId=#{gradeId}") 42 | List findEscoreByGradeId(Integer gradeId); 43 | 44 | @Insert("insert into escore(examId, clazzId, studentId, gradeId, courseId, score) values" + 45 | "(#{escore.examId}, #{escore.clazzId}, #{escore.studentId}, #{escore.gradeId}, #{escore.courseId}, #{escore.score})") 46 | boolean insertEscore(@Param("escore") Escore escore); 47 | 48 | @Delete("delete from escore where id=#{id}") 49 | boolean deleteEscore(Integer id); 50 | 51 | @Delete("delete from escore where studentId=#{studentId}") 52 | boolean deleteEscoreByStudentId(Integer studentId); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/mapper/ExamMapper.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.mapper; 2 | 3 | import com.hfut.studentmanager.pojo.Exam; 4 | import org.apache.ibatis.annotations.Delete; 5 | import org.apache.ibatis.annotations.Insert; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.apache.ibatis.annotations.Select; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import java.util.List; 11 | 12 | @Mapper 13 | @Repository 14 | public interface ExamMapper { 15 | 16 | @Select("select * from exam where courseId=#{courseId}") 17 | List findExamByCourseId(Integer courseId); 18 | 19 | @Select("select * from exam where id=#{id}") 20 | Exam findExamById(Integer id); 21 | 22 | @Select("select * from exam") 23 | List findAllExam(); 24 | 25 | @Select("select * from exam where clazzId=#{clazzId}") 26 | List findExamByClazzId(String clazzId); 27 | 28 | @Select("select * from exam where gradeId=#{gradeId}") 29 | List findExamByGradeId(Integer gradeId); 30 | 31 | @Insert("insert into exam(name, time, remark, type, gradeId, clazzId, courseId) values" + 32 | "(#{name}, #{time}, #{remark}, #{type}, #{gradeId}, #{clazzId}, #{courseId})") 33 | boolean insertExam(Exam exam); 34 | 35 | @Delete("delete from exam where id=#{id}") 36 | boolean deleteExamById(Integer id); 37 | 38 | } 39 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/mapper/GradeCourseMapper.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.mapper; 2 | 3 | import com.hfut.studentmanager.pojo.GradeCourse; 4 | import org.apache.ibatis.annotations.*; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | @Repository 11 | public interface GradeCourseMapper { 12 | 13 | @Select("select * from grade_course where gradeId=#{gradeId} and courseId=#{courseId}") 14 | GradeCourse findGradeCourseByGradeIdAndCourseId(@Param("gradeId") Integer gradeId, @Param("courseId")Integer courseId); 15 | 16 | 17 | @Select("select * from grade_course") 18 | List findAllGradeCourse(); 19 | 20 | @Select("select * from grade_course where gradeId=#{gradeId}") 21 | List findGradeCourseByGradeId(Integer gradeId); 22 | 23 | @Select("select * from grade_course where courseId=#{courseId}") 24 | List findGradeCourseByCourseId(Integer courseId); 25 | 26 | @Insert("insert into grade_course(gradeId, courseId) values " + 27 | "(#{gradeId}, #{courseId})") 28 | boolean insertGradeCourse(GradeCourse gradeCourse); 29 | 30 | @Delete("delete from grade_course where id=#{id}") 31 | boolean deleteGradeCourse(Integer id); 32 | 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/mapper/GradeMapper.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.mapper; 2 | 3 | import com.hfut.studentmanager.pojo.Grade; 4 | import org.apache.ibatis.annotations.Delete; 5 | import org.apache.ibatis.annotations.Insert; 6 | import org.apache.ibatis.annotations.Mapper; 7 | import org.apache.ibatis.annotations.Select; 8 | import org.springframework.stereotype.Repository; 9 | 10 | import javax.annotation.ManagedBean; 11 | import java.util.List; 12 | 13 | @Mapper 14 | @Repository 15 | public interface GradeMapper { 16 | 17 | @Select("select * from grade") 18 | List findAllGrade(); 19 | 20 | @Select("select * from grade where id=#{id}") 21 | Grade findGradeById(Integer id); 22 | 23 | @Select("select name from grade where id=#{id}") 24 | String findNameById(Integer id); 25 | 26 | @Select("select id from grade where name=#{name}") 27 | Integer findIdByName(String name); 28 | 29 | @Insert("insert into grade(name) values (#{name})") 30 | boolean insertGrade(Grade grade); 31 | 32 | @Delete("delete from grade where id=#{id}") 33 | boolean deleteGradeById(Integer id); 34 | } 35 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/mapper/StudentMapper.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.mapper; 2 | 3 | import com.hfut.studentmanager.pojo.Student; 4 | import org.apache.ibatis.annotations.*; 5 | import org.springframework.stereotype.Repository; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.util.List; 9 | 10 | @Mapper 11 | @Repository 12 | public interface StudentMapper { 13 | 14 | @Select("select * from Student where id=#{id}") 15 | Student findStudentById(Integer id); 16 | 17 | @Select("select * from student where number=#{number}") 18 | Student findStudentByNumber(String number); 19 | 20 | @Select("select * from student where name=#{name}") 21 | List findStudentByName(String name); 22 | 23 | @Select("select * from student") 24 | List findAllStudent(); 25 | 26 | @Select("select * from student where clazzId=#{clazzId}") 27 | List findStudentByClazzId(Integer clazzId); 28 | 29 | @Select("select * from student where gradeId=#{gradeId}") 30 | List findStudentByGradeId(Integer gradeId); 31 | 32 | @Insert("insert into student(number, name, sex, phone, qq, clazzId, gradeId) values" + 33 | "(#{number}, #{name}, #{sex}, #{phone}, #{qq}, #{clazzId}, #{gradeId})") 34 | boolean insertStudent(Student student); 35 | 36 | @Update("update student set phone=#{phone}, qq=#{qq}") 37 | boolean updateStudent(Student student); 38 | 39 | @Delete("delete from student where id=#{id}") 40 | boolean deleteStudentById(Integer id); 41 | 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/mapper/SystemMapper.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.mapper; 2 | 3 | import org.apache.ibatis.annotations.Mapper; 4 | import org.apache.ibatis.annotations.Select; 5 | import org.apache.ibatis.annotations.Update; 6 | import org.springframework.stereotype.Repository; 7 | 8 | @Mapper 9 | @Repository 10 | public interface SystemMapper { 11 | 12 | @Select("select * from system") 13 | System findSystem(); 14 | 15 | @Update("update system set schoolName=#{schoolName}, " + 16 | "forbidTeacher=#{forbidTeacher}, " + 17 | "forbidStudent=#{forbidStudent}," + 18 | "noticeTeacher=#{noticeTeacher}," + 19 | "noticeStudent=#{noticeStudent}") 20 | boolean updateSystem(System system); 21 | 22 | } 23 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/mapper/TeacherMapper.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.mapper; 2 | 3 | import com.hfut.studentmanager.pojo.Teacher; 4 | import org.apache.ibatis.annotations.*; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | @Repository 11 | public interface TeacherMapper { 12 | 13 | @Select("select * from teacher where number=#{number}") 14 | Teacher findTeacherByNumber(String number); 15 | 16 | @Select("select * from teacher") 17 | List findAllTeacher(); 18 | 19 | @Select("select * from teacher where id=#{id}") 20 | Teacher findTeacherById(Integer id); 21 | 22 | @Select("select id from teacher where number=#{number}") 23 | Integer findIdByNumber(@Param("number") String number); 24 | 25 | @Insert("insert into teacher(number, name, sex, phone, qq) values" + 26 | "(#{number}, #{name}, #{sex}, #{phone}, #{qq})") 27 | boolean insertTeacher(Teacher teacher); 28 | 29 | @Delete("delete from teacher where id=#{id}") 30 | boolean deleteTeacher(Integer id); 31 | } 32 | 33 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/mapper/UserMapper.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.mapper; 2 | 3 | import com.hfut.studentmanager.pojo.User; 4 | import org.apache.ibatis.annotations.*; 5 | import org.springframework.stereotype.Repository; 6 | 7 | import java.util.List; 8 | 9 | @Mapper 10 | @Repository 11 | public interface UserMapper { 12 | 13 | @Select("select * from user where account=#{account}") 14 | User findUserByAccount(String account); 15 | 16 | @Insert("insert into user(account, password, name, type) values " + 17 | "(#{account}, #{password}, #{name}, #{type})") 18 | boolean insertUser(User user); 19 | 20 | @Update("update user set password=#{password} where account=#{account}") 21 | boolean updateUserPassword(User user); 22 | 23 | @Delete("delete from user where id=#{id}") 24 | boolean deleteUser(Integer id); 25 | 26 | @Delete("delete from user where account=#{account}") 27 | boolean deleteUserByAccount(String account); 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/pojo/Clazz.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.pojo; 2 | 3 | 4 | public class Clazz { 5 | 6 | private Integer id; 7 | private String name; 8 | private Integer gradeId; 9 | 10 | public Clazz() { 11 | } 12 | 13 | public Clazz(Integer id, String name, Integer gradeId) { 14 | this.id = id; 15 | this.name = name; 16 | this.gradeId = gradeId; 17 | } 18 | 19 | public Integer getId() { 20 | return id; 21 | } 22 | 23 | public void setId(Integer id) { 24 | this.id = id; 25 | } 26 | 27 | public String getName() { 28 | return name; 29 | } 30 | 31 | public void setName(String name) { 32 | this.name = name; 33 | } 34 | 35 | public Integer getGradeId() { 36 | return gradeId; 37 | } 38 | 39 | public void setGradeId(Integer gradeId) { 40 | this.gradeId = gradeId; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/pojo/ClazzCourseTeacher.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.pojo; 2 | 3 | 4 | public class ClazzCourseTeacher { 5 | 6 | private Integer id; 7 | private Integer clazzId; 8 | private Integer gradeId; 9 | private Integer courseId; 10 | private Integer teacherId; 11 | 12 | public ClazzCourseTeacher() { 13 | } 14 | 15 | public ClazzCourseTeacher(Integer id, Integer clazzId, Integer gradeId, Integer courseId, Integer teacherId) { 16 | this.id = id; 17 | this.clazzId = clazzId; 18 | this.gradeId = gradeId; 19 | this.courseId = courseId; 20 | this.teacherId = teacherId; 21 | } 22 | 23 | public Integer getId() { 24 | return id; 25 | } 26 | 27 | public void setId(Integer id) { 28 | this.id = id; 29 | } 30 | 31 | public Integer getClazzId() { 32 | return clazzId; 33 | } 34 | 35 | public void setClazzId(Integer clazzId) { 36 | this.clazzId = clazzId; 37 | } 38 | 39 | public Integer getGradeId() { 40 | return gradeId; 41 | } 42 | 43 | public void setGradeId(Integer gradeId) { 44 | this.gradeId = gradeId; 45 | } 46 | 47 | public Integer getCourseId() { 48 | return courseId; 49 | } 50 | 51 | public void setCourseId(Integer courseId) { 52 | this.courseId = courseId; 53 | } 54 | 55 | public Integer getTeacherId() { 56 | return teacherId; 57 | } 58 | 59 | public void setTeacherId(Integer teacherId) { 60 | this.teacherId = teacherId; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/pojo/Course.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.pojo; 2 | 3 | 4 | public class Course { 5 | 6 | private Integer id; 7 | private String name; 8 | 9 | public Course() { 10 | } 11 | 12 | public Course(Integer id, String name) { 13 | this.id = id; 14 | this.name = name; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "Course{" + 20 | "id=" + id + 21 | ", name='" + name + '\'' + 22 | '}'; 23 | } 24 | 25 | public Integer getId() { 26 | return id; 27 | } 28 | 29 | public void setId(Integer id) { 30 | this.id = id; 31 | } 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(String name) { 38 | this.name = name; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/pojo/Escore.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.pojo; 2 | 3 | 4 | public class Escore { 5 | 6 | private Integer id; 7 | private Integer examId; 8 | private Integer clazzId; 9 | private Integer studentId; 10 | private Integer gradeId; 11 | private Integer courseId; 12 | private Integer score; 13 | 14 | public Escore() { 15 | } 16 | 17 | public Escore(Integer id, Integer examId, Integer clazzId, Integer studentId, Integer gradeId, Integer courseId, Integer score) { 18 | this.id = id; 19 | this.examId = examId; 20 | this.clazzId = clazzId; 21 | this.studentId = studentId; 22 | this.gradeId = gradeId; 23 | this.courseId = courseId; 24 | this.score = score; 25 | } 26 | 27 | public Integer getId() { 28 | return id; 29 | } 30 | 31 | public void setId(Integer id) { 32 | this.id = id; 33 | } 34 | 35 | public Integer getExamId() { 36 | return examId; 37 | } 38 | 39 | public void setExamId(Integer examId) { 40 | this.examId = examId; 41 | } 42 | 43 | public Integer getClazzId() { 44 | return clazzId; 45 | } 46 | 47 | public void setClazzId(Integer clazzId) { 48 | this.clazzId = clazzId; 49 | } 50 | 51 | public Integer getStudentId() { 52 | return studentId; 53 | } 54 | 55 | public void setStudentId(Integer studentId) { 56 | this.studentId = studentId; 57 | } 58 | 59 | public Integer getGradeId() { 60 | return gradeId; 61 | } 62 | 63 | public void setGradeId(Integer gradeId) { 64 | this.gradeId = gradeId; 65 | } 66 | 67 | public Integer getCourseId() { 68 | return courseId; 69 | } 70 | 71 | public void setCourseId(Integer courseId) { 72 | this.courseId = courseId; 73 | } 74 | 75 | public Integer getScore() { 76 | return score; 77 | } 78 | 79 | public void setScore(Integer score) { 80 | this.score = score; 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/pojo/Exam.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.pojo; 2 | 3 | 4 | import java.util.Date; 5 | 6 | public class Exam { 7 | 8 | private Integer id; 9 | private String name; 10 | private Date time; 11 | private String remark; 12 | private Integer type; 13 | private Integer gradeId; 14 | private Integer clazzId; 15 | private Integer courseId; 16 | 17 | public Exam() { 18 | } 19 | 20 | public Exam(Integer id, String name, Date time, String remark, Integer type, Integer gradeId, Integer clazzId, Integer courseId) { 21 | this.id = id; 22 | this.name = name; 23 | this.time = time; 24 | this.remark = remark; 25 | this.type = type; 26 | this.gradeId = gradeId; 27 | this.clazzId = clazzId; 28 | this.courseId = courseId; 29 | } 30 | 31 | public Integer getId() { 32 | return id; 33 | } 34 | 35 | public void setId(Integer id) { 36 | this.id = id; 37 | } 38 | 39 | public String getName() { 40 | return name; 41 | } 42 | 43 | public void setName(String name) { 44 | this.name = name; 45 | } 46 | 47 | public Date getTime() { 48 | return time; 49 | } 50 | 51 | public void setTime(Date time) { 52 | this.time = time; 53 | } 54 | 55 | public String getRemark() { 56 | return remark; 57 | } 58 | 59 | public void setRemark(String remark) { 60 | this.remark = remark; 61 | } 62 | 63 | public Integer getType() { 64 | return type; 65 | } 66 | 67 | public void setType(Integer type) { 68 | this.type = type; 69 | } 70 | 71 | public Integer getGradeId() { 72 | return gradeId; 73 | } 74 | 75 | public void setGradeId(Integer gradeId) { 76 | this.gradeId = gradeId; 77 | } 78 | 79 | public Integer getClazzId() { 80 | return clazzId; 81 | } 82 | 83 | public void setClazzId(Integer clazzId) { 84 | this.clazzId = clazzId; 85 | } 86 | 87 | public Integer getCourseId() { 88 | return courseId; 89 | } 90 | 91 | public void setCourseId(Integer courseId) { 92 | this.courseId = courseId; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/pojo/Grade.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.pojo; 2 | 3 | 4 | public class Grade { 5 | 6 | private Integer id; 7 | private String name; 8 | 9 | public Grade() { 10 | } 11 | 12 | public Grade(Integer id, String name) { 13 | this.id = id; 14 | this.name = name; 15 | } 16 | 17 | @Override 18 | public String toString() { 19 | return "Grade{" + 20 | "id=" + id + 21 | ", name='" + name + '\'' + 22 | '}'; 23 | } 24 | 25 | public Integer getId() { 26 | return id; 27 | } 28 | 29 | public void setId(Integer id) { 30 | this.id = id; 31 | } 32 | 33 | public String getName() { 34 | return name; 35 | } 36 | 37 | public void setName(String name) { 38 | this.name = name; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/pojo/GradeCourse.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.pojo; 2 | 3 | 4 | public class GradeCourse { 5 | 6 | private Integer id; 7 | private Integer gradeId; 8 | private Integer courseId; 9 | 10 | public GradeCourse() { 11 | } 12 | 13 | public GradeCourse(Integer id, Integer gradeId, Integer courseId) { 14 | this.id = id; 15 | this.gradeId = gradeId; 16 | this.courseId = courseId; 17 | } 18 | 19 | public Integer getId() { 20 | return id; 21 | } 22 | 23 | public void setId(Integer id) { 24 | this.id = id; 25 | } 26 | 27 | public Integer getGradeId() { 28 | return gradeId; 29 | } 30 | 31 | public void setGradeId(Integer gradeId) { 32 | this.gradeId = gradeId; 33 | } 34 | 35 | public Integer getCourseId() { 36 | return courseId; 37 | } 38 | 39 | public void setCourseId(Integer courseId) { 40 | this.courseId = courseId; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/pojo/Student.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.pojo; 2 | 3 | import org.springframework.context.annotation.Bean; 4 | import org.springframework.stereotype.Component; 5 | 6 | @Component 7 | public class Student { 8 | 9 | private Integer id; 10 | private String number; 11 | private String name; 12 | private String sex; 13 | private String phone; 14 | private String qq; 15 | private Integer clazzId; 16 | private Integer gradeId; 17 | 18 | public Student() { 19 | } 20 | 21 | public Student(Integer id, String number, String name, String sex, String phone, String qq, Integer clazzId, Integer gradeId) { 22 | this.id = id; 23 | this.number = number; 24 | this.name = name; 25 | this.sex = sex; 26 | this.phone = phone; 27 | this.qq = qq; 28 | this.clazzId = clazzId; 29 | this.gradeId = gradeId; 30 | } 31 | 32 | @Override 33 | public String toString() { 34 | return "Student{" + 35 | "id=" + id + 36 | ", number='" + number + '\'' + 37 | ", name='" + name + '\'' + 38 | ", sex='" + sex + '\'' + 39 | ", phone='" + phone + '\'' + 40 | ", qq='" + qq + '\'' + 41 | ", clazzId=" + clazzId + 42 | ", gradeId=" + gradeId + 43 | '}'; 44 | } 45 | 46 | public Integer getId() { 47 | return id; 48 | } 49 | 50 | public void setId(Integer id) { 51 | this.id = id; 52 | } 53 | 54 | public String getNumber() { 55 | return number; 56 | } 57 | 58 | public void setNumber(String number) { 59 | this.number = number; 60 | } 61 | 62 | public String getName() { 63 | return name; 64 | } 65 | 66 | public void setName(String name) { 67 | this.name = name; 68 | } 69 | 70 | public String getSex() { 71 | return sex; 72 | } 73 | 74 | public void setSex(String sex) { 75 | this.sex = sex; 76 | } 77 | 78 | public String getPhone() { 79 | return phone; 80 | } 81 | 82 | public void setPhone(String phone) { 83 | this.phone = phone; 84 | } 85 | 86 | public String getQq() { 87 | return qq; 88 | } 89 | 90 | public void setQq(String qq) { 91 | this.qq = qq; 92 | } 93 | 94 | public Integer getClazzId() { 95 | return clazzId; 96 | } 97 | 98 | public void setClazzId(Integer clazzId) { 99 | this.clazzId = clazzId; 100 | } 101 | 102 | public Integer getGradeId() { 103 | return gradeId; 104 | } 105 | 106 | public void setGradeId(Integer gradeId) { 107 | this.gradeId = gradeId; 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/pojo/System.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.pojo; 2 | 3 | 4 | public class System { 5 | 6 | private Integer id; 7 | private String schoolName; 8 | private Integer forbidTeacher; 9 | private Integer forbidStudent; 10 | private String noticeTeacher; 11 | private String noticeStudent; 12 | 13 | public Integer getId() { 14 | return id; 15 | } 16 | 17 | public void setId(Integer id) { 18 | this.id = id; 19 | } 20 | 21 | public String getSchoolName() { 22 | return schoolName; 23 | } 24 | 25 | public void setSchoolName(String schoolName) { 26 | this.schoolName = schoolName; 27 | } 28 | 29 | public Integer getForbidTeacher() { 30 | return forbidTeacher; 31 | } 32 | 33 | public void setForbidTeacher(Integer forbidTeacher) { 34 | this.forbidTeacher = forbidTeacher; 35 | } 36 | 37 | public Integer getForbidStudent() { 38 | return forbidStudent; 39 | } 40 | 41 | public void setForbidStudent(Integer forbidStudent) { 42 | this.forbidStudent = forbidStudent; 43 | } 44 | 45 | public String getNoticeTeacher() { 46 | return noticeTeacher; 47 | } 48 | 49 | public void setNoticeTeacher(String noticeTeacher) { 50 | this.noticeTeacher = noticeTeacher; 51 | } 52 | 53 | public String getNoticeStudent() { 54 | return noticeStudent; 55 | } 56 | 57 | public void setNoticeStudent(String noticeStudent) { 58 | this.noticeStudent = noticeStudent; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/pojo/Teacher.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.pojo; 2 | 3 | 4 | public class Teacher { 5 | 6 | private Integer id; 7 | private String number; 8 | private String name; 9 | private String sex; 10 | private String phone; 11 | private String qq; 12 | 13 | public Teacher() { 14 | } 15 | 16 | public Teacher(Integer id, String number, String name, String sex, String phone, String qq) { 17 | this.id = id; 18 | this.number = number; 19 | this.name = name; 20 | this.sex = sex; 21 | this.phone = phone; 22 | this.qq = qq; 23 | } 24 | 25 | public Integer getId() { 26 | return id; 27 | } 28 | 29 | public void setId(Integer id) { 30 | this.id = id; 31 | } 32 | 33 | public String getNumber() { 34 | return number; 35 | } 36 | 37 | public void setNumber(String number) { 38 | this.number = number; 39 | } 40 | 41 | 42 | public String getName() { 43 | return name; 44 | } 45 | 46 | public void setName(String name) { 47 | this.name = name; 48 | } 49 | 50 | 51 | public String getSex() { 52 | return sex; 53 | } 54 | 55 | public void setSex(String sex) { 56 | this.sex = sex; 57 | } 58 | 59 | 60 | public String getPhone() { 61 | return phone; 62 | } 63 | 64 | public void setPhone(String phone) { 65 | this.phone = phone; 66 | } 67 | 68 | 69 | public String getQq() { 70 | return qq; 71 | } 72 | 73 | public void setQq(String qq) { 74 | this.qq = qq; 75 | } 76 | 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/pojo/User.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.pojo; 2 | 3 | 4 | public class User { 5 | 6 | private Integer id; 7 | private String account; 8 | private String password; 9 | private String name; 10 | private Integer type; // 用户类型 1 -- 管理员 2 -- 学生 3 -- 教师 11 | 12 | public Integer getId() { 13 | return id; 14 | } 15 | 16 | public void setId(Integer id) { 17 | this.id = id; 18 | } 19 | 20 | public String getAccount() { 21 | return account; 22 | } 23 | 24 | public void setAccount(String account) { 25 | this.account = account; 26 | } 27 | 28 | public String getPassword() { 29 | return password; 30 | } 31 | 32 | public void setPassword(String password) { 33 | this.password = password; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name; 42 | } 43 | 44 | public Integer getType() { 45 | return type; 46 | } 47 | 48 | public void setType(Integer type) { 49 | this.type = type; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/service/ClazzCourseTeacherService.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.service; 2 | 3 | import com.hfut.studentmanager.mapper.*; 4 | import com.hfut.studentmanager.pojo.ClazzCourseTeacher; 5 | import com.hfut.studentmanager.utils.Message; 6 | import com.hfut.studentmanager.utils.ResultUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | import org.springframework.transaction.interceptor.TransactionAspectSupport; 11 | 12 | import java.util.List; 13 | 14 | @Service 15 | public class ClazzCourseTeacherService { 16 | 17 | @Autowired 18 | ClazzCourseTeacherMapper clazzCourseTeacherMapper; 19 | @Autowired 20 | TeacherMapper teacherMapper; 21 | @Autowired 22 | CourseMapper courseMapper; 23 | @Autowired 24 | ClazzMapper clazzMapper; 25 | @Autowired 26 | GradeMapper gradeMapper; 27 | 28 | public List listClazzCourseTeacherByTeacherId(Integer teacherId){ 29 | return clazzCourseTeacherMapper.findClazzCourseTeacherByTeacherId(teacherId); 30 | } 31 | 32 | @Transactional 33 | public Message addClazzCourseTeacher(ClazzCourseTeacher clazzCourseTeacher){ 34 | if (teacherMapper.findTeacherById(clazzCourseTeacher.getTeacherId()) == null){ 35 | return ResultUtils.error(404, "教师不存在"); 36 | } 37 | if (courseMapper.findCourseById(clazzCourseTeacher.getCourseId()) == null){ 38 | return ResultUtils.error(404, "该课程不存在"); 39 | } 40 | if (clazzMapper.findClazzById(clazzCourseTeacher.getClazzId()) == null){ 41 | return ResultUtils.error(404, "该班级不存在"); 42 | } 43 | if (gradeMapper.findGradeById(clazzCourseTeacher.getGradeId()) == null){ 44 | return ResultUtils.error(404, "该年级不存在"); 45 | } 46 | if (clazzCourseTeacherMapper.findClazzCourseTeacherByClazzIdGradeIdCourseIdTeacherId(clazzCourseTeacher) != null){ 47 | return ResultUtils.error(404, "该教师的该课程已存在"); 48 | } 49 | if(!clazzCourseTeacherMapper.insertClazzCourseTeacher(clazzCourseTeacher)){ 50 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 51 | return ResultUtils.error(404, "插入课程失败"); 52 | } 53 | return ResultUtils.success(); 54 | } 55 | 56 | @Transactional 57 | public Message deleteClazzCourseTeacher(Integer id){ 58 | if (clazzCourseTeacherMapper.findClazzCourseTeacherById(id) == null){ 59 | return ResultUtils.error(404, "教师所教课程不存在"); 60 | } 61 | if (!clazzCourseTeacherMapper.deleteClazzCourseTeacher(id)){ 62 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 63 | return ResultUtils.error(404, "该课程删除失败"); 64 | } 65 | return ResultUtils.success(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/service/ClazzService.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.service; 2 | 3 | import com.hfut.studentmanager.mapper.ClazzCourseTeacherMapper; 4 | import com.hfut.studentmanager.mapper.ClazzMapper; 5 | import com.hfut.studentmanager.mapper.GradeMapper; 6 | import com.hfut.studentmanager.mapper.StudentMapper; 7 | import com.hfut.studentmanager.pojo.Clazz; 8 | import com.hfut.studentmanager.pojo.ClazzCourseTeacher; 9 | import com.hfut.studentmanager.utils.Message; 10 | import com.hfut.studentmanager.utils.ResultUtils; 11 | import com.hfut.studentmanager.utils.jsonBean.JSONClazz; 12 | import org.springframework.beans.factory.annotation.Autowired; 13 | import org.springframework.stereotype.Service; 14 | import org.springframework.transaction.annotation.Transactional; 15 | import org.springframework.transaction.interceptor.TransactionAspectSupport; 16 | 17 | import java.util.ArrayList; 18 | import java.util.HashMap; 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | @Service 23 | public class ClazzService { 24 | 25 | @Autowired 26 | private ClazzMapper clazzMapper; 27 | @Autowired 28 | private GradeMapper gradeMapper; 29 | @Autowired 30 | private ClazzCourseTeacherMapper clazzCourseTeacherMapper; 31 | @Autowired 32 | private StudentMapper studentMapper; 33 | 34 | public Clazz listClazzById(Integer id){ 35 | return clazzMapper.findClazzById(id); 36 | } 37 | 38 | public List> listAllClazz(){ 39 | List clazzList = clazzMapper.findAllClazz(); 40 | List> result = new ArrayList<>(); 41 | for (Clazz clazz: clazzList){ 42 | Map map = new HashMap<>(); 43 | map.put("id", clazz.getId()); 44 | map.put("name", clazz.getName()); 45 | map.put("grade", gradeMapper.findNameById(clazz.getGradeId())); 46 | result.add(map); 47 | } 48 | return result; 49 | } 50 | 51 | public List listClazzByGradeId(Integer gradeId){ 52 | return clazzMapper.findClazzByGradeId(gradeId); 53 | } 54 | 55 | @Transactional 56 | public Message addClazz(Clazz clazz){ 57 | if (clazzMapper.findIdByNameAndGradeId(clazz.getName(), clazz.getGradeId()) != null){ 58 | return ResultUtils.error(404, "要添加的班级已存在"); 59 | } 60 | if (!clazzMapper.insertClazz(clazz)){ 61 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 62 | return ResultUtils.error(404, "插入班级失败"); 63 | } 64 | return ResultUtils.success(); 65 | } 66 | 67 | @Transactional 68 | public Message deleteClazz(Integer id){ 69 | Clazz clazz = clazzMapper.findClazzById(id); 70 | if (clazz == null){ 71 | return ResultUtils.error(404, "要删除的班级不存在"); 72 | } 73 | if (!(studentMapper.findStudentByClazzId(id) == null 74 | || studentMapper.findStudentByClazzId(id) != null && studentMapper.findStudentByClazzId(id).size() == 0)){ 75 | return ResultUtils.error(404, "要删除的班级下还存在学生,删除失败"); 76 | } 77 | List clazzCourseTeacherList = clazzCourseTeacherMapper.findClazzCourseTeacherByClazzId(id); 78 | for (ClazzCourseTeacher clazzCourseTeacher: clazzCourseTeacherList){ 79 | if (!clazzCourseTeacherMapper.deleteClazzCourseTeacher(clazzCourseTeacher.getId())){ 80 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 81 | return ResultUtils.error(404, "删除班级对应课程失败"); 82 | } 83 | } 84 | if (!clazzMapper.deleteClazz(id)){ 85 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 86 | return ResultUtils.error(404, "删除班级失败"); 87 | 88 | } 89 | return ResultUtils.success(); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/service/CourseService.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.service; 2 | 3 | import com.hfut.studentmanager.mapper.CourseMapper; 4 | import com.hfut.studentmanager.mapper.GradeCourseMapper; 5 | import com.hfut.studentmanager.pojo.Course; 6 | import com.hfut.studentmanager.utils.Message; 7 | import com.hfut.studentmanager.utils.ResultUtils; 8 | import org.apache.ibatis.cache.decorators.TransactionalCache; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Transactional; 12 | import org.springframework.transaction.interceptor.TransactionAspectSupport; 13 | 14 | import java.util.List; 15 | 16 | @Service 17 | public class CourseService { 18 | 19 | @Autowired 20 | private CourseMapper courseMapper; 21 | @Autowired 22 | private GradeCourseMapper gradeCourseMapper; 23 | 24 | public List listAllCourse(){ 25 | return courseMapper.findAllCourse(); 26 | } 27 | 28 | public Course listCourseById(Integer id){ 29 | return courseMapper.findCourseById(id); 30 | } 31 | 32 | @Transactional 33 | public Message addCourse(Course course){ 34 | Course course1 = courseMapper.findCourseByName(course.getName()); 35 | if ( course1 != null){ 36 | System.out.println(course1); 37 | return ResultUtils.error(404, "课程已存在"); 38 | } 39 | if (!courseMapper.insertCourse(course)){ 40 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 41 | return ResultUtils.error(404, "课程添加失败"); 42 | } 43 | return ResultUtils.success("添加课程成功"); 44 | } 45 | 46 | @Transactional 47 | public Message deleteCourse(Integer id) { 48 | Course course = courseMapper.findCourseById(id); 49 | if (course == null) { 50 | return ResultUtils.error(404, "要删除的课程不存在"); 51 | } 52 | if (!(gradeCourseMapper.findGradeCourseByCourseId(id) == null 53 | || gradeCourseMapper.findGradeCourseByCourseId(id) != null && gradeCourseMapper.findGradeCourseByCourseId(id).size() == 0)) { 54 | return ResultUtils.error(404, "有年级存在该课程,删除失败"); 55 | } 56 | if (!courseMapper.deleteCourseById(id)) { 57 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 58 | return ResultUtils.error(404, "删除课程失败"); 59 | } 60 | return ResultUtils.success(); 61 | } 62 | 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/service/EScoreService.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.service; 2 | 3 | import com.hfut.studentmanager.mapper.EscoreMapper; 4 | import com.hfut.studentmanager.mapper.StudentMapper; 5 | import com.hfut.studentmanager.pojo.Escore; 6 | import com.hfut.studentmanager.pojo.Student; 7 | import com.hfut.studentmanager.utils.Message; 8 | import com.hfut.studentmanager.utils.ResultUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Transactional; 12 | import org.springframework.transaction.interceptor.TransactionAspectSupport; 13 | 14 | import java.util.ArrayList; 15 | import java.util.HashMap; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | @Service 20 | public class EScoreService { 21 | 22 | @Autowired 23 | private EscoreMapper escoreMapper; 24 | @Autowired 25 | private StudentMapper studentMapper; 26 | 27 | 28 | @Transactional 29 | public Message addEScoreByExamIdAndStudentIdAndCourseId(Integer examId, Integer studentId, Integer courseId, Integer score){ 30 | for (Escore escore: escoreMapper.findEscoreByExamIdAndStudentId(examId, studentId)){ 31 | escoreMapper.deleteEscore(escore.getId()); 32 | } 33 | Student student = studentMapper.findStudentById(studentId); 34 | if (student == null){ 35 | return ResultUtils.error(404, "要添加成绩的学生不存在"); 36 | } 37 | Escore escore = new Escore(null, examId, student.getClazzId(), student.getId(), student.getGradeId(), courseId, score); 38 | if (!escoreMapper.insertEscore(escore)){ 39 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 40 | return ResultUtils.error(404, "学生‘" + student.getName() + "’成绩添加失败"); 41 | } 42 | return ResultUtils.success(); 43 | } 44 | 45 | public Escore listEScoreByExamIdAndStudentId(Integer examId, Integer studentId){ 46 | List escoreList = escoreMapper.findEscoreByExamIdAndStudentId(examId, studentId); 47 | if (escoreList == null || escoreList != null && escoreList.size() == 0){ 48 | return null; 49 | } 50 | return escoreList.get(0); 51 | } 52 | 53 | public List> listESCoreByExamIdAndClazzId(Integer examId, Integer clazzId){ 54 | List escoreList = escoreMapper.findEscoreByExamIdAndClazzId(examId, clazzId); 55 | List> result = new ArrayList<>(); 56 | if (escoreList == null || escoreList != null && escoreList.size() == 0){ 57 | return result; 58 | } 59 | for (Escore escore: escoreList){ 60 | Map map = new HashMap<>(); 61 | map.put("id", escore.getId()); 62 | map.put("number", studentMapper.findStudentById(escore.getStudentId()).getNumber()); 63 | map.put("student", studentMapper.findStudentById(escore.getStudentId()).getName()); 64 | map.put("score", escore.getScore()); 65 | result.add(map); 66 | } 67 | return result; 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/service/ExamService.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.service; 2 | 3 | import com.hfut.studentmanager.mapper.*; 4 | import com.hfut.studentmanager.pojo.Exam; 5 | import com.hfut.studentmanager.pojo.Grade; 6 | import com.hfut.studentmanager.utils.Message; 7 | import com.hfut.studentmanager.utils.ResultUtils; 8 | import com.hfut.studentmanager.utils.jsonBean.JSONExam; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Transactional; 12 | import org.springframework.transaction.interceptor.TransactionAspectSupport; 13 | 14 | import java.text.DateFormat; 15 | import java.text.SimpleDateFormat; 16 | import java.util.Date; 17 | import java.util.ArrayList; 18 | import java.util.HashMap; 19 | import java.util.List; 20 | import java.util.Map; 21 | 22 | @Service 23 | public class ExamService { 24 | 25 | @Autowired 26 | private ExamMapper examMapper; 27 | @Autowired 28 | private GradeMapper gradeMapper; 29 | @Autowired 30 | private ClazzMapper clazzMapper; 31 | @Autowired 32 | private CourseMapper courseMapper; 33 | @Autowired 34 | private GradeCourseMapper gradeCourseMapper; 35 | @Autowired 36 | private EscoreMapper escoreMapper; 37 | 38 | public Exam listExamById(Integer id){ 39 | return examMapper.findExamById(id); 40 | } 41 | 42 | public List listExamByGradeId(Integer gradeId){ 43 | return examMapper.findExamByGradeId(gradeId); 44 | } 45 | 46 | public List listExamByCourseId(Integer courseId){ 47 | return examMapper.findExamByCourseId(courseId); 48 | } 49 | 50 | public List> listAllExam(){ 51 | List examList = examMapper.findAllExam(); 52 | List> result = new ArrayList<>(); 53 | for (Exam exam: examList){ 54 | Map map = new HashMap<>(); 55 | map.put("id", exam.getId()); 56 | map.put("name", exam.getName()); 57 | map.put("time", exam.getTime()); 58 | map.put("remark", exam.getRemark()); 59 | map.put("type", exam.getType()); 60 | map.put("grade", gradeMapper.findNameById(exam.getGradeId())); 61 | map.put("clazz", clazzMapper.findNameById(exam.getClazzId())); 62 | map.put("course", courseMapper.findNameById(exam.getCourseId())); 63 | result.add(map); 64 | } 65 | return result; 66 | } 67 | 68 | @Transactional 69 | public Message addExam(Exam exam){ 70 | if (!examMapper.insertExam(exam)){ 71 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 72 | return ResultUtils.error(404, "添加考试失败"); 73 | } 74 | return ResultUtils.success(); 75 | } 76 | 77 | @Transactional 78 | public Message deleteExam(Integer id){ 79 | Exam exam = examMapper.findExamById(id); 80 | if (exam == null){ 81 | return ResultUtils.error(404, "要删除的考试不存在"); 82 | } 83 | if (!(escoreMapper.findEscoreByExamId(id) == null || escoreMapper.findEscoreByExamId(id) != null && escoreMapper.findEscoreByExamId(id).size() == 0)){ 84 | return ResultUtils.error(404, "要删除的考试下存在学生成绩,删除失败"); 85 | } 86 | if (!examMapper.deleteExamById(id)){ 87 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 88 | return ResultUtils.error(404, "删除考试失败"); 89 | } 90 | return ResultUtils.success(); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/service/GradeCourseService.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.service; 2 | 3 | import com.hfut.studentmanager.mapper.CourseMapper; 4 | import com.hfut.studentmanager.mapper.GradeCourseMapper; 5 | import com.hfut.studentmanager.mapper.GradeMapper; 6 | import com.hfut.studentmanager.pojo.GradeCourse; 7 | import com.hfut.studentmanager.utils.Message; 8 | import com.hfut.studentmanager.utils.ResultUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Transactional; 12 | import org.springframework.transaction.interceptor.TransactionAspectSupport; 13 | 14 | import java.util.ArrayList; 15 | import java.util.HashMap; 16 | import java.util.List; 17 | import java.util.Map; 18 | 19 | @Service 20 | public class GradeCourseService { 21 | 22 | @Autowired 23 | private GradeCourseMapper gradeCourseMapper; 24 | @Autowired 25 | private CourseMapper courseMapper; 26 | @Autowired 27 | private GradeMapper gradeMapper; 28 | 29 | public GradeCourse listGradeCourseByGradeIdAndCourseId(Integer gradeId, Integer courseId){ 30 | return gradeCourseMapper.findGradeCourseByGradeIdAndCourseId(gradeId, courseId); 31 | } 32 | 33 | public List> listGradeCourseByGradeId(Integer gradeId){ 34 | List> result = new ArrayList<>(); 35 | for (GradeCourse gradeCourse: gradeCourseMapper.findGradeCourseByGradeId(gradeId)){ 36 | Map map = new HashMap<>(); 37 | map.put("id", gradeCourse.getId()); 38 | map.put("gradeId", gradeCourse.getGradeId()); 39 | map.put("course", courseMapper.findNameById(gradeCourse.getCourseId())); 40 | map.put("courseId", gradeCourse.getCourseId()); 41 | result.add(map); 42 | } 43 | return result; 44 | } 45 | 46 | @Transactional 47 | public Message addGradeCourse(GradeCourse gradeCourse){ 48 | if (courseMapper.findCourseById(gradeCourse.getCourseId()) == null){ 49 | return ResultUtils.error(404, "该课程不存在"); 50 | } 51 | if (gradeMapper.findGradeById(gradeCourse.getGradeId()) == null){ 52 | return ResultUtils.error(404, "该年级不存在"); 53 | } 54 | if (gradeCourseMapper.findGradeCourseByGradeIdAndCourseId(gradeCourse.getGradeId(), gradeCourse.getCourseId()) != null){ 55 | return ResultUtils.error(404, "该年级的该课程已存在"); 56 | } 57 | if (!gradeCourseMapper.insertGradeCourse(gradeCourse)){ 58 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 59 | return ResultUtils.error(404, "添加该年级课程失败"); 60 | } 61 | return ResultUtils.success(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/service/GradeService.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.service; 2 | 3 | import com.hfut.studentmanager.mapper.*; 4 | import com.hfut.studentmanager.pojo.*; 5 | import com.hfut.studentmanager.utils.Message; 6 | import com.hfut.studentmanager.utils.ResultUtils; 7 | import com.hfut.studentmanager.utils.jsonBean.JSONGrade; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | import org.springframework.transaction.annotation.Transactional; 11 | import org.springframework.transaction.interceptor.TransactionAspectSupport; 12 | 13 | import java.lang.System; 14 | import java.util.*; 15 | 16 | @Service 17 | public class GradeService { 18 | 19 | @Autowired 20 | private GradeMapper gradeMapper; 21 | @Autowired 22 | private GradeCourseMapper gradeCourseMapper; 23 | @Autowired 24 | private CourseMapper courseMapper; 25 | @Autowired 26 | private ClazzMapper clazzMapper; 27 | @Autowired 28 | private ClazzCourseTeacherMapper clazzCourseTeacherMapper; 29 | @Autowired 30 | private StudentMapper studentMapper; 31 | 32 | public Grade listGradeById(Integer id){ 33 | return gradeMapper.findGradeById(id); 34 | } 35 | 36 | public List> listAllGrade() { 37 | List gradeList = gradeMapper.findAllGrade(); 38 | List> result = new ArrayList<>(); 39 | for (Grade grade: gradeList){ 40 | Map map = new HashMap<>(); 41 | map.put("id", grade.getId()); 42 | map.put("name", grade.getName()); 43 | List gradeCourseList = gradeCourseMapper.findGradeCourseByGradeId(grade.getId()); 44 | if (!(gradeCourseList == null || gradeCourseList != null && gradeCourseList.size() == 0)){ 45 | StringBuffer courseNames = new StringBuffer("/ "); 46 | for (GradeCourse gradeCourse: gradeCourseList){ 47 | courseNames.append(courseMapper.findNameById(gradeCourse.getCourseId()) + " / "); 48 | } 49 | map.put("courseNames", courseNames.toString()); 50 | }else { 51 | map.put("courseNames", ""); 52 | } 53 | result.add(map); 54 | } 55 | return result; 56 | } 57 | 58 | @Transactional 59 | public Message addGrade(Grade grade){ 60 | if (gradeMapper.findIdByName(grade.getName()) != null){ 61 | return ResultUtils.error(404, "该年级已存在"); 62 | } 63 | if (!gradeMapper.insertGrade(grade)){ 64 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 65 | return ResultUtils.error(404, "年级添加失败"); 66 | } 67 | return ResultUtils.success(); 68 | } 69 | 70 | /** 71 | * 根据年级id删除年级,若该年级还存在班级或学生,删除失败 72 | * @param id 年级id 73 | * @return 删除结果 74 | */ 75 | @Transactional 76 | public Message deleteGrade(Integer id){ 77 | Grade grade = gradeMapper.findGradeById(id); 78 | if (grade == null){ 79 | return ResultUtils.error(404, "年级不存在"); 80 | } 81 | if (!(clazzMapper.findClazzByGradeId(id) == null || clazzMapper.findClazzByGradeId(id) != null && clazzMapper.findClazzByGradeId(id).size() == 0)){ 82 | return ResultUtils.error(404, "该年级下还存在班级,删除失败"); 83 | } 84 | if (!(studentMapper.findStudentByGradeId(id) == null || studentMapper.findStudentByGradeId(id) != null && studentMapper.findStudentByGradeId(id).size() == 0)){ 85 | return ResultUtils.error(404, "该年级下还存在学生,删除失败"); 86 | } 87 | if (!(gradeCourseMapper.findGradeCourseByGradeId(id) == null || gradeCourseMapper.findGradeCourseByGradeId(id) != null && gradeCourseMapper.findGradeCourseByGradeId(id).size() == 0)){ 88 | return ResultUtils.error(404, "该年级下还存在课程,删除失败"); 89 | } 90 | if (!gradeMapper.deleteGradeById(id)){ 91 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 92 | return ResultUtils.error(404, "删除年级失败"); 93 | } 94 | return ResultUtils.success(); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/service/StudentService.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.service; 2 | 3 | import com.hfut.studentmanager.mapper.*; 4 | import com.hfut.studentmanager.pojo.Student; 5 | import com.hfut.studentmanager.utils.Message; 6 | import com.hfut.studentmanager.utils.ResultUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | import org.springframework.transaction.interceptor.TransactionAspectSupport; 11 | 12 | import java.util.ArrayList; 13 | import java.util.HashMap; 14 | import java.util.List; 15 | import java.util.Map; 16 | 17 | @Service 18 | public class StudentService { 19 | 20 | @Autowired 21 | private StudentMapper studentMapper; 22 | @Autowired 23 | private ClazzMapper clazzMapper; 24 | @Autowired 25 | private GradeMapper gradeMapper; 26 | @Autowired 27 | private UserMapper userMapper; 28 | @Autowired 29 | private EscoreMapper escoreMapper; 30 | 31 | public Student listStudentById(Integer id){ 32 | return studentMapper.findStudentById(id); 33 | } 34 | 35 | public Student listStudentByNumber(String number){ 36 | return studentMapper.findStudentByNumber(number); 37 | } 38 | 39 | public List listStudentByClazz(Integer clazzId){ 40 | return studentMapper.findStudentByClazzId(clazzId); 41 | } 42 | 43 | public List listAllStudent(){ 44 | return studentMapper.findAllStudent(); 45 | } 46 | 47 | @Transactional 48 | public Message addStudent(Student student){ 49 | if (studentMapper.findStudentByNumber(student.getNumber()) != null){ 50 | return ResultUtils.error(404, "要添加学生的该学号已存在"); 51 | } 52 | if (!studentMapper.insertStudent(student)){ 53 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 54 | return ResultUtils.error(404, "此学生添加失败"); 55 | } 56 | return ResultUtils.success("学生信息添加成功"); 57 | } 58 | 59 | @Transactional 60 | public Message deleteStudent(Integer id){ 61 | Student student = studentMapper.findStudentById(id); 62 | if (student == null){ 63 | return ResultUtils.error(404, "此学生不存在,删除失败"); 64 | } 65 | if (!(escoreMapper.findEscoreByStudentId(id) == null || escoreMapper.findEscoreByStudentId(id) != null && escoreMapper.findEscoreByStudentId(id).size() == 0)){ 66 | if (!escoreMapper.deleteEscoreByStudentId(id)){ 67 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 68 | return ResultUtils.error(404, "删除失败"); 69 | } 70 | } 71 | if (!userMapper.deleteUserByAccount(student.getNumber()) || !studentMapper.deleteStudentById(id)){ 72 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 73 | return ResultUtils.error(404, "删除失败"); 74 | } 75 | return ResultUtils.success(); 76 | } 77 | 78 | 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/service/SystemService.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.service; 2 | 3 | import com.hfut.studentmanager.mapper.SystemMapper; 4 | import com.hfut.studentmanager.utils.Message; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class SystemService { 10 | 11 | @Autowired 12 | private SystemMapper systemMapper; 13 | 14 | public System listSystemInfo(){ 15 | return systemMapper.findSystem(); 16 | } 17 | // public Message updateSystem() 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/service/TeacherService.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.service; 2 | 3 | import com.hfut.studentmanager.mapper.*; 4 | import com.hfut.studentmanager.pojo.ClazzCourseTeacher; 5 | import com.hfut.studentmanager.pojo.Course; 6 | import com.hfut.studentmanager.pojo.Teacher; 7 | import com.hfut.studentmanager.utils.Message; 8 | import com.hfut.studentmanager.utils.ResultUtils; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.stereotype.Service; 11 | import org.springframework.transaction.annotation.Transactional; 12 | import org.springframework.transaction.interceptor.TransactionAspectSupport; 13 | 14 | import java.util.*; 15 | 16 | @Service 17 | public class TeacherService { 18 | 19 | @Autowired 20 | private TeacherMapper teacherMapper; 21 | @Autowired 22 | private ClazzCourseTeacherMapper clazzCourseTeacherMapper; 23 | @Autowired 24 | private ClazzMapper clazzMapper; 25 | @Autowired 26 | private GradeMapper gradeMapper; 27 | @Autowired 28 | private UserMapper userMapper; 29 | @Autowired 30 | private CourseMapper courseMapper; 31 | @Autowired 32 | private GradeCourseMapper gradeCourseMapper; 33 | 34 | public Teacher listTeacherById(Integer id){ 35 | return teacherMapper.findTeacherById(id); 36 | } 37 | 38 | public Teacher listTeacherByNumber(String number){ 39 | return teacherMapper.findTeacherByNumber(number); 40 | } 41 | 42 | public List> listAllTeacher(){ 43 | List teacherList = teacherMapper.findAllTeacher(); 44 | if (teacherList == null || teacherList.size() == 0){ 45 | return null; 46 | } 47 | List> result = new ArrayList<>(); 48 | for (Teacher teacher: teacherList){ 49 | Map map = new HashMap<>(); 50 | map.put("id", teacher.getId()); 51 | map.put("number", teacher.getNumber()); 52 | map.put("name", teacher.getName()); 53 | map.put("phone", teacher.getPhone()); 54 | map.put("qq", teacher.getQq()); 55 | map.put("sex", teacher.getSex()); 56 | 57 | List clazzCourseTeacherList = clazzCourseTeacherMapper.findClazzCourseTeacherByTeacherId(teacher.getId()); 58 | StringBuffer courses = new StringBuffer(); 59 | for (ClazzCourseTeacher clazzCourseTeacher: clazzCourseTeacherList){ 60 | Integer courseId = clazzCourseTeacher.getCourseId(); 61 | Integer gradeId = clazzCourseTeacher.getGradeId(); 62 | Integer clazzId = clazzCourseTeacher.getClazzId(); 63 | String courseName = courseMapper.findNameById(courseId); 64 | String gradeName = gradeMapper.findNameById(gradeId); 65 | String clazzName = clazzMapper.findNameById(clazzId); 66 | courses.append("[" + gradeName + " " + clazzName + " " + courseName + "]" + " "); 67 | } 68 | map.put("courses", courses); 69 | result.add(map); 70 | } 71 | return result; 72 | } 73 | 74 | 75 | @Transactional 76 | public Message addTeacher(Teacher teacher){ 77 | if (teacherMapper.findIdByNumber(teacher.getNumber()) != null){ 78 | return ResultUtils.error(404, "该教师工号已存在"); 79 | } 80 | if (!teacherMapper.insertTeacher(teacher)){ 81 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 82 | return ResultUtils.error(404, "插入教师失败"); 83 | } 84 | return ResultUtils.success("插入教师成功"); 85 | } 86 | 87 | @Transactional 88 | public Message deleteTeacher(Integer id){ 89 | Teacher teacher = teacherMapper.findTeacherById(id); 90 | if(teacher == null){ 91 | return ResultUtils.error(404, "要删除的教师不存在"); 92 | } 93 | for (ClazzCourseTeacher clazzCourseTeacher: clazzCourseTeacherMapper.findClazzCourseTeacherByTeacherId(id)){ 94 | if (!clazzCourseTeacherMapper.deleteClazzCourseTeacher(clazzCourseTeacher.getId())){ 95 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 96 | return ResultUtils.error(404, "删除教师所教课程'" + courseMapper.findNameById(clazzCourseTeacher.getCourseId()) + "'失败"); 97 | } 98 | } 99 | if (userMapper.deleteUserByAccount(teacher.getNumber()) && teacherMapper.deleteTeacher(id)){ 100 | return ResultUtils.success(); 101 | } 102 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 103 | return ResultUtils.error(404, "删除失败"); 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/service/UserService.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.service; 2 | 3 | import com.hfut.studentmanager.mapper.UserMapper; 4 | import com.hfut.studentmanager.pojo.User; 5 | import com.hfut.studentmanager.utils.Message; 6 | import com.hfut.studentmanager.utils.ResultUtils; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | import org.springframework.transaction.annotation.Transactional; 10 | import org.springframework.transaction.interceptor.TransactionAspectSupport; 11 | 12 | @Service 13 | public class UserService { 14 | 15 | @Autowired 16 | private UserMapper userMapper; 17 | 18 | public User login(String account, String password){ 19 | User user = userMapper.findUserByAccount(account); 20 | if (user == null || !password.equals(user.getPassword())){ 21 | return null; 22 | } 23 | return user; 24 | } 25 | 26 | @Transactional 27 | public Message addUser(User user){ 28 | if (userMapper.findUserByAccount(user.getAccount()) != null){ 29 | return ResultUtils.error(404, "用户已存在"); 30 | } 31 | if (!userMapper.insertUser(user)){ 32 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 33 | return ResultUtils.error(404, "用户注册失败"); 34 | } 35 | return ResultUtils.success("注册成功"); 36 | } 37 | 38 | @Transactional 39 | public Message updatePassword(String account, String oldPassword, String newPassword){ 40 | User user = userMapper.findUserByAccount(account); 41 | if (user == null){ 42 | return ResultUtils.error(404, "用户不存在"); 43 | } 44 | if (!user.getPassword().equals(oldPassword)){ 45 | return ResultUtils.error(404, "密码错误"); 46 | } 47 | user.setPassword(newPassword); 48 | if (!userMapper.updateUserPassword(user)){ 49 | TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); 50 | return ResultUtils.error(404, "密码修改失败"); 51 | } 52 | return ResultUtils.success(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/utils/Message.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.utils; 2 | 3 | import com.fasterxml.jackson.annotation.JsonInclude; 4 | 5 | @JsonInclude(JsonInclude.Include.NON_NULL) 6 | public class Message { 7 | private String code; 8 | private String msg; 9 | private Object data; 10 | 11 | @Override 12 | public String toString() { 13 | return "Message{" + 14 | "code='" + code + '\'' + 15 | ", msg='" + msg + '\'' + 16 | ", data='" + data + '\'' + 17 | '}'; 18 | } 19 | 20 | public String getCode() { 21 | return code; 22 | } 23 | 24 | public void setCode(String code) { 25 | this.code = code; 26 | } 27 | 28 | public String getMsg() { 29 | return msg; 30 | } 31 | 32 | public void setMsg(String msg) { 33 | this.msg = msg; 34 | } 35 | 36 | public Object getData() { 37 | return data; 38 | } 39 | 40 | public void setData(Object data) { 41 | this.data = data; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/utils/ResultUtils.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.utils; 2 | 3 | import com.hfut.studentmanager.pojo.User; 4 | 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | 8 | public class ResultUtils { 9 | private ResultUtils() { 10 | } 11 | 12 | /** 13 | * 登录验证成功的返回信息 14 | * @param user 成功登录的用户 15 | * @return 16 | */ 17 | public static Message loginSuccess(User user) { 18 | Map map = new HashMap<>(); 19 | map.put("name", user.getName()); 20 | map.put("type", user.getType()); 21 | map.put("account", user.getAccount()); 22 | Message message = new Message(); 23 | message.setMsg("登录成功"); 24 | message.setCode("200"); 25 | message.setData(map); 26 | return message; 27 | } 28 | 29 | public static Message success(Object object) { 30 | Message message = new Message(); 31 | message.setCode("200"); 32 | message.setMsg("请求成功"); 33 | message.setData(object); 34 | return message; 35 | } 36 | 37 | public static Message success() { 38 | Message message = new Message(); 39 | message.setCode("200"); 40 | message.setMsg("请求成功"); 41 | return message; 42 | } 43 | 44 | public static Message success(String string) { 45 | Message message = new Message(); 46 | message.setCode("200"); 47 | message.setMsg(string); 48 | return message; 49 | } 50 | 51 | public static Message error(Integer code, String resultMessage) { 52 | Message message = new Message(); 53 | message.setCode(code.toString()); 54 | message.setMsg(resultMessage); 55 | return message; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/utils/jsonBean/JSONClazz.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.utils.jsonBean; 2 | 3 | public class JSONClazz { 4 | private Integer id; 5 | private String name; 6 | private String grade; 7 | 8 | public Integer getId() { 9 | return id; 10 | } 11 | 12 | public void setId(Integer id) { 13 | this.id = id; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public void setName(String name) { 21 | this.name = name; 22 | } 23 | 24 | public String getGrade() { 25 | return grade; 26 | } 27 | 28 | public void setGrade(String grade) { 29 | this.grade = grade; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/utils/jsonBean/JSONCourse.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.utils.jsonBean; 2 | 3 | public class JSONCourse { 4 | private Integer id; 5 | private String grade; 6 | private String clazz; 7 | private String course; 8 | 9 | public Integer getId() { 10 | return id; 11 | } 12 | 13 | public void setId(Integer id) { 14 | this.id = id; 15 | } 16 | 17 | public String getGrade() { 18 | return grade; 19 | } 20 | 21 | public void setGrade(String grade) { 22 | this.grade = grade; 23 | } 24 | 25 | public String getClazz() { 26 | return clazz; 27 | } 28 | 29 | public void setClazz(String clazz) { 30 | this.clazz = clazz; 31 | } 32 | 33 | public String getCourse() { 34 | return course; 35 | } 36 | 37 | public void setCourse(String course) { 38 | this.course = course; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/utils/jsonBean/JSONExam.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.utils.jsonBean; 2 | 3 | 4 | public class JSONExam { 5 | private Integer id; 6 | private String name; 7 | private String time; 8 | private String remark; 9 | private Integer type; 10 | private String grade; 11 | private String clazz; 12 | private String course; 13 | 14 | public Integer getId() { 15 | return id; 16 | } 17 | 18 | public void setId(Integer id) { 19 | this.id = id; 20 | } 21 | 22 | public String getName() { 23 | return name; 24 | } 25 | 26 | public void setName(String name) { 27 | this.name = name; 28 | } 29 | 30 | public String getTime() { 31 | return time; 32 | } 33 | 34 | public void setTime(String time) { 35 | this.time = time; 36 | } 37 | 38 | public String getRemark() { 39 | return remark; 40 | } 41 | 42 | public void setRemark(String remark) { 43 | this.remark = remark; 44 | } 45 | 46 | public Integer getType() { 47 | return type; 48 | } 49 | 50 | public void setType(Integer type) { 51 | this.type = type; 52 | } 53 | 54 | public String getGrade() { 55 | return grade; 56 | } 57 | 58 | public void setGrade(String grade) { 59 | this.grade = grade; 60 | } 61 | 62 | public String getClazz() { 63 | return clazz; 64 | } 65 | 66 | public void setClazz(String clazz) { 67 | this.clazz = clazz; 68 | } 69 | 70 | public String getCourse() { 71 | return course; 72 | } 73 | 74 | public void setCourse(String course) { 75 | this.course = course; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/utils/jsonBean/JSONGrade.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.utils.jsonBean; 2 | 3 | import java.util.Arrays; 4 | 5 | public class JSONGrade { 6 | 7 | private Integer id; 8 | private String name; 9 | private String[] courses; 10 | 11 | @Override 12 | public String toString() { 13 | return "JSONGrade{" + 14 | "id=" + id + 15 | ", name='" + name + '\'' + 16 | ", courses=" + Arrays.toString(courses) + 17 | '}'; 18 | } 19 | 20 | public Integer getId() { 21 | return id; 22 | } 23 | 24 | public void setId(Integer id) { 25 | this.id = id; 26 | } 27 | 28 | public String getName() { 29 | return name; 30 | } 31 | 32 | public void setName(String name) { 33 | this.name = name; 34 | } 35 | 36 | public String[] getCourses() { 37 | return courses; 38 | } 39 | 40 | public void setCourses(String[] courses) { 41 | this.courses = courses; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/utils/jsonBean/JSONStudent.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.utils.jsonBean; 2 | 3 | public class JSONStudent { 4 | private Integer id; 5 | private String number; 6 | private String name; 7 | private String sex; 8 | private String phone; 9 | private String qq; 10 | private String clazz; 11 | private String grade; 12 | 13 | public JSONStudent() { 14 | } 15 | 16 | public JSONStudent(Integer id, String number, String name, String sex, String phone, String qq, String clazz, String grade) { 17 | this.id = id; 18 | this.number = number; 19 | this.name = name; 20 | this.sex = sex; 21 | this.phone = phone; 22 | this.qq = qq; 23 | this.clazz = clazz; 24 | this.grade = grade; 25 | } 26 | 27 | @Override 28 | public String toString() { 29 | return "JSONStudent{" + 30 | "id=" + id + 31 | ", number='" + number + '\'' + 32 | ", name='" + name + '\'' + 33 | ", sex='" + sex + '\'' + 34 | ", phone='" + phone + '\'' + 35 | ", qq='" + qq + '\'' + 36 | ", clazz='" + clazz + '\'' + 37 | ", grade='" + grade + '\'' + 38 | '}'; 39 | } 40 | 41 | public Integer getId() { 42 | return id; 43 | } 44 | 45 | public void setId(Integer id) { 46 | this.id = id; 47 | } 48 | 49 | public String getNumber() { 50 | return number; 51 | } 52 | 53 | public void setNumber(String number) { 54 | this.number = number; 55 | } 56 | 57 | public String getName() { 58 | return name; 59 | } 60 | 61 | public void setName(String name) { 62 | this.name = name; 63 | } 64 | 65 | public String getSex() { 66 | return sex; 67 | } 68 | 69 | public void setSex(String sex) { 70 | this.sex = sex; 71 | } 72 | 73 | public String getPhone() { 74 | return phone; 75 | } 76 | 77 | public void setPhone(String phone) { 78 | this.phone = phone; 79 | } 80 | 81 | public String getQq() { 82 | return qq; 83 | } 84 | 85 | public void setQq(String qq) { 86 | this.qq = qq; 87 | } 88 | 89 | public String getClazz() { 90 | return clazz; 91 | } 92 | 93 | public void setClazz(String clazz) { 94 | this.clazz = clazz; 95 | } 96 | 97 | public String getGrade() { 98 | return grade; 99 | } 100 | 101 | public void setGrade(String grade) { 102 | this.grade = grade; 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/utils/jsonBean/JSONTeacher.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.utils.jsonBean; 2 | 3 | import com.hfut.studentmanager.pojo.Course; 4 | 5 | import java.util.List; 6 | 7 | public class JSONTeacher { 8 | 9 | private Integer id; 10 | private String number; 11 | private String name; 12 | private String sex; 13 | private String phone; 14 | private String qq; 15 | 16 | public JSONTeacher() { 17 | } 18 | 19 | public JSONTeacher(Integer id, String number, String name, String sex, String phone, String qq) { 20 | this.id = id; 21 | this.number = number; 22 | this.name = name; 23 | this.sex = sex; 24 | this.phone = phone; 25 | this.qq = qq; 26 | } 27 | 28 | public Integer getId() { 29 | return id; 30 | } 31 | 32 | public void setId(Integer id) { 33 | this.id = id; 34 | } 35 | 36 | public String getNumber() { 37 | return number; 38 | } 39 | 40 | public void setNumber(String number) { 41 | this.number = number; 42 | } 43 | 44 | public String getName() { 45 | return name; 46 | } 47 | 48 | public void setName(String name) { 49 | this.name = name; 50 | } 51 | 52 | public String getSex() { 53 | return sex; 54 | } 55 | 56 | public void setSex(String sex) { 57 | this.sex = sex; 58 | } 59 | 60 | public String getPhone() { 61 | return phone; 62 | } 63 | 64 | public void setPhone(String phone) { 65 | this.phone = phone; 66 | } 67 | 68 | public String getQq() { 69 | return qq; 70 | } 71 | 72 | public void setQq(String qq) { 73 | this.qq = qq; 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /src/main/java/com/hfut/studentmanager/utils/jsonBean/Score.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.utils.jsonBean; 2 | 3 | public class Score { 4 | private Integer studentId; 5 | private String score; 6 | private String number; 7 | private String name; 8 | private Integer examId; 9 | 10 | @Override 11 | public String toString() { 12 | return "Score{" + 13 | "studentId=" + studentId + 14 | ", score='" + score + '\'' + 15 | ", number='" + number + '\'' + 16 | ", name='" + name + '\'' + 17 | ", examId=" + examId + 18 | '}'; 19 | } 20 | 21 | public Integer getStudentId() { 22 | return studentId; 23 | } 24 | 25 | public void setStudentId(Integer studentId) { 26 | this.studentId = studentId; 27 | } 28 | 29 | public String getScore() { 30 | return score; 31 | } 32 | 33 | public void setScore(String score) { 34 | this.score = score; 35 | } 36 | 37 | public String getNumber() { 38 | return number; 39 | } 40 | 41 | public void setNumber(String number) { 42 | this.number = number; 43 | } 44 | 45 | public String getName() { 46 | return name; 47 | } 48 | 49 | public void setName(String name) { 50 | this.name = name; 51 | } 52 | 53 | public Integer getExamId() { 54 | return examId; 55 | } 56 | 57 | public void setExamId(Integer examId) { 58 | this.examId = examId; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 6969 3 | servlet: 4 | context-path: /studentmanager 5 | spring: 6 | datasource: 7 | url: jdbc:mysql://localhost:3306/ssms?useUnicode=true&characterEncoding=UTF-8 8 | username: root 9 | password: root 10 | driver-class-name: com.mysql.jdbc.Driver 11 | jpa: 12 | hibernate: 13 | ddl-auto: update 14 | -------------------------------------------------------------------------------- /src/main/resources/docs/ssms.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat Premium Data Transfer 3 | 4 | Source Server : root 5 | Source Server Type : MySQL 6 | Source Server Version : 50617 7 | Source Host : localhost:3306 8 | Source Schema : ssms 9 | 10 | Target Server Type : MySQL 11 | Target Server Version : 50617 12 | File Encoding : 65001 13 | 14 | Date: 19/11/2019 11:38:20 15 | */ 16 | 17 | SET NAMES utf8mb4; 18 | SET FOREIGN_KEY_CHECKS = 0; 19 | 20 | -- ---------------------------- 21 | -- Table structure for clazz 22 | -- ---------------------------- 23 | DROP TABLE IF EXISTS `clazz`; 24 | CREATE TABLE `clazz` ( 25 | `id` int(11) NOT NULL AUTO_INCREMENT, 26 | `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 27 | `gradeId` int(11) NULL DEFAULT NULL, 28 | PRIMARY KEY (`id`) USING BTREE, 29 | INDEX `gid_clazz_FK`(`gradeId`) USING BTREE, 30 | CONSTRAINT `gradeid_clazz_FK` FOREIGN KEY (`gradeId`) REFERENCES `grade` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT 31 | ) ENGINE = InnoDB AUTO_INCREMENT = 18 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Compact; 32 | 33 | -- ---------------------------- 34 | -- Records of clazz 35 | -- ---------------------------- 36 | INSERT INTO `clazz` VALUES (14, '1班', 4); 37 | INSERT INTO `clazz` VALUES (15, '2班', 4); 38 | INSERT INTO `clazz` VALUES (16, '3班', 4); 39 | INSERT INTO `clazz` VALUES (17, '1班', 5); 40 | 41 | -- ---------------------------- 42 | -- Table structure for clazz_course_teacher 43 | -- ---------------------------- 44 | DROP TABLE IF EXISTS `clazz_course_teacher`; 45 | CREATE TABLE `clazz_course_teacher` ( 46 | `id` int(11) NOT NULL AUTO_INCREMENT, 47 | `clazzId` int(11) NULL DEFAULT NULL, 48 | `gradeId` int(11) NULL DEFAULT NULL, 49 | `courseId` int(11) NULL DEFAULT NULL, 50 | `teacherId` int(11) NULL DEFAULT NULL, 51 | PRIMARY KEY (`id`) USING BTREE, 52 | INDEX `clazzid_cct_FK`(`clazzId`) USING BTREE, 53 | INDEX `tid_cct_FK`(`teacherId`) USING BTREE, 54 | INDEX `courseid_cct_FK`(`courseId`) USING BTREE, 55 | INDEX `gradeid_cct_FK`(`gradeId`) USING BTREE, 56 | CONSTRAINT `clazzid_cct_FK` FOREIGN KEY (`clazzId`) REFERENCES `clazz` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT, 57 | CONSTRAINT `teacherid_cct_FK` FOREIGN KEY (`teacherId`) REFERENCES `teacher` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT 58 | ) ENGINE = InnoDB AUTO_INCREMENT = 25 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Compact; 59 | 60 | -- ---------------------------- 61 | -- Records of clazz_course_teacher 62 | -- ---------------------------- 63 | INSERT INTO `clazz_course_teacher` VALUES (22, 14, 4, 11, 16); 64 | INSERT INTO `clazz_course_teacher` VALUES (23, 14, 4, 13, 17); 65 | INSERT INTO `clazz_course_teacher` VALUES (24, 16, 4, 20, 18); 66 | 67 | -- ---------------------------- 68 | -- Table structure for course 69 | -- ---------------------------- 70 | DROP TABLE IF EXISTS `course`; 71 | CREATE TABLE `course` ( 72 | `id` int(11) NOT NULL AUTO_INCREMENT, 73 | `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 74 | PRIMARY KEY (`id`) USING BTREE 75 | ) ENGINE = InnoDB AUTO_INCREMENT = 22 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Compact; 76 | 77 | -- ---------------------------- 78 | -- Records of course 79 | -- ---------------------------- 80 | INSERT INTO `course` VALUES (11, '数学'); 81 | INSERT INTO `course` VALUES (13, '软件体系结构'); 82 | INSERT INTO `course` VALUES (14, 'C语言'); 83 | INSERT INTO `course` VALUES (15, '统一建模语言UML'); 84 | INSERT INTO `course` VALUES (16, '软件需求分析'); 85 | INSERT INTO `course` VALUES (17, '网络及其计算'); 86 | INSERT INTO `course` VALUES (18, '工程经济学'); 87 | INSERT INTO `course` VALUES (19, '软件构造'); 88 | INSERT INTO `course` VALUES (20, '软件安全'); 89 | INSERT INTO `course` VALUES (21, 'C'); 90 | 91 | -- ---------------------------- 92 | -- Table structure for escore 93 | -- ---------------------------- 94 | DROP TABLE IF EXISTS `escore`; 95 | CREATE TABLE `escore` ( 96 | `id` int(11) NOT NULL AUTO_INCREMENT, 97 | `examId` int(11) NULL DEFAULT NULL, 98 | `clazzId` int(11) NULL DEFAULT NULL, 99 | `studentId` int(11) NULL DEFAULT NULL, 100 | `gradeId` int(11) NULL DEFAULT NULL, 101 | `courseId` int(11) NULL DEFAULT NULL, 102 | `score` int(5) NULL DEFAULT NULL, 103 | PRIMARY KEY (`id`) USING BTREE, 104 | INDEX `eid_escore_FK`(`examId`) USING BTREE, 105 | INDEX `sid_escore_FK`(`studentId`) USING BTREE, 106 | INDEX `clazzid_escore_FK`(`clazzId`) USING BTREE, 107 | INDEX `courseid_escore_FK`(`courseId`) USING BTREE, 108 | INDEX `gradeid_escore_FK`(`gradeId`) USING BTREE, 109 | CONSTRAINT `clazzid_escore_FK` FOREIGN KEY (`clazzId`) REFERENCES `clazz` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT, 110 | CONSTRAINT `courseid_escore_FK` FOREIGN KEY (`courseId`) REFERENCES `grade_course` (`courseid`) ON DELETE RESTRICT ON UPDATE RESTRICT, 111 | CONSTRAINT `examid_escore_FK` FOREIGN KEY (`examId`) REFERENCES `exam` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT, 112 | CONSTRAINT `gradeid_escore_FK` FOREIGN KEY (`gradeId`) REFERENCES `grade_course` (`gradeid`) ON DELETE RESTRICT ON UPDATE RESTRICT, 113 | CONSTRAINT `studentid_escore_FK` FOREIGN KEY (`studentId`) REFERENCES `student` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT 114 | ) ENGINE = InnoDB AUTO_INCREMENT = 228 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Compact; 115 | 116 | -- ---------------------------- 117 | -- Records of escore 118 | -- ---------------------------- 119 | INSERT INTO `escore` VALUES (226, 3, 14, 92, 4, 11, 100); 120 | INSERT INTO `escore` VALUES (227, 3, 14, 93, 4, 11, 98); 121 | 122 | -- ---------------------------- 123 | -- Table structure for exam 124 | -- ---------------------------- 125 | DROP TABLE IF EXISTS `exam`; 126 | CREATE TABLE `exam` ( 127 | `id` int(11) NOT NULL AUTO_INCREMENT, 128 | `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 129 | `time` date NULL DEFAULT NULL, 130 | `remark` varchar(200) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 131 | `type` tinyint(2) NULL DEFAULT 1, 132 | `gradeId` int(11) NULL DEFAULT NULL, 133 | `clazzId` int(11) NULL DEFAULT NULL, 134 | `courseId` int(11) NULL DEFAULT NULL, 135 | PRIMARY KEY (`id`) USING BTREE, 136 | INDEX `gid_exam_FK`(`gradeId`) USING BTREE, 137 | INDEX `clazzid_exam_FK`(`clazzId`) USING BTREE, 138 | CONSTRAINT `gradeid_exam_FK` FOREIGN KEY (`gradeId`) REFERENCES `grade` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT 139 | ) ENGINE = InnoDB AUTO_INCREMENT = 8 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Compact; 140 | 141 | -- ---------------------------- 142 | -- Records of exam 143 | -- ---------------------------- 144 | INSERT INTO `exam` VALUES (3, '2017级1班数学测试', '2019-11-18', '', 2, 4, 14, 11); 145 | INSERT INTO `exam` VALUES (4, 'hfut软件安全考试', '2019-11-17', '', 1, 4, 0, 20); 146 | INSERT INTO `exam` VALUES (5, '3班软件安全', '2019-11-17', '', 2, 4, 16, 20); 147 | INSERT INTO `exam` VALUES (6, '2017级2班数学', '2019-11-20', '', 2, 4, 15, 11); 148 | INSERT INTO `exam` VALUES (7, '2017级1班网络及其计算考试', '2019-11-28', '', 2, 4, 14, 17); 149 | 150 | -- ---------------------------- 151 | -- Table structure for grade 152 | -- ---------------------------- 153 | DROP TABLE IF EXISTS `grade`; 154 | CREATE TABLE `grade` ( 155 | `id` int(11) NOT NULL AUTO_INCREMENT, 156 | `name` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 157 | PRIMARY KEY (`id`) USING BTREE 158 | ) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Compact; 159 | 160 | -- ---------------------------- 161 | -- Records of grade 162 | -- ---------------------------- 163 | INSERT INTO `grade` VALUES (4, '2017级'); 164 | INSERT INTO `grade` VALUES (5, '2018级'); 165 | INSERT INTO `grade` VALUES (6, '2019级'); 166 | 167 | -- ---------------------------- 168 | -- Table structure for grade_course 169 | -- ---------------------------- 170 | DROP TABLE IF EXISTS `grade_course`; 171 | CREATE TABLE `grade_course` ( 172 | `id` int(11) NOT NULL AUTO_INCREMENT, 173 | `gradeId` int(11) NULL DEFAULT NULL, 174 | `courseId` int(11) NULL DEFAULT NULL, 175 | PRIMARY KEY (`id`) USING BTREE, 176 | INDEX `gid_gc_FK`(`gradeId`) USING BTREE, 177 | INDEX `cid_gc_FK`(`courseId`) USING BTREE, 178 | CONSTRAINT `courseid_gc_FK` FOREIGN KEY (`courseId`) REFERENCES `course` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT, 179 | CONSTRAINT `gradeid_gc_FK` FOREIGN KEY (`gradeId`) REFERENCES `grade` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT 180 | ) ENGINE = InnoDB AUTO_INCREMENT = 17 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Compact; 181 | 182 | -- ---------------------------- 183 | -- Records of grade_course 184 | -- ---------------------------- 185 | INSERT INTO `grade_course` VALUES (14, 4, 11); 186 | INSERT INTO `grade_course` VALUES (15, 4, 20); 187 | INSERT INTO `grade_course` VALUES (16, 4, 17); 188 | 189 | -- ---------------------------- 190 | -- Table structure for student 191 | -- ---------------------------- 192 | DROP TABLE IF EXISTS `student`; 193 | CREATE TABLE `student` ( 194 | `id` int(11) NOT NULL AUTO_INCREMENT, 195 | `number` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 196 | `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 197 | `sex` varchar(4) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 198 | `phone` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 199 | `qq` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 200 | `clazzId` int(11) NULL DEFAULT NULL, 201 | `gradeId` int(11) NULL DEFAULT NULL, 202 | PRIMARY KEY (`id`) USING BTREE, 203 | UNIQUE INDEX `number_student_FK`(`number`) USING BTREE, 204 | INDEX `cid_stu_FK`(`clazzId`) USING BTREE, 205 | INDEX `grade_student_FK`(`gradeId`) USING BTREE, 206 | CONSTRAINT `clazzid_student_FK` FOREIGN KEY (`clazzId`) REFERENCES `clazz` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT, 207 | CONSTRAINT `grade_student_FK` FOREIGN KEY (`gradeId`) REFERENCES `grade` (`id`) ON DELETE RESTRICT ON UPDATE RESTRICT 208 | ) ENGINE = InnoDB AUTO_INCREMENT = 96 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Compact; 209 | 210 | -- ---------------------------- 211 | -- Records of student 212 | -- ---------------------------- 213 | INSERT INTO `student` VALUES (83, '2017214919', '余永康', '男', '', '', 16, 4); 214 | INSERT INTO `student` VALUES (85, '2017214917', '李松昊', '女', '', '', 16, 4); 215 | INSERT INTO `student` VALUES (86, '2017214909', '李帮耀', '男', '', '', 16, 4); 216 | INSERT INTO `student` VALUES (87, '2017214906', '吴坤', '男', '', '', 16, 4); 217 | INSERT INTO `student` VALUES (88, '2017214921', '杨云朝', '男', '', '', 16, 4); 218 | INSERT INTO `student` VALUES (89, '2017214907', '王乐恒', '男', '', '', 16, 4); 219 | INSERT INTO `student` VALUES (90, '2017214908', '方明辉', '男', '', '', 16, 4); 220 | INSERT INTO `student` VALUES (91, '2017214814', 'wzx', '男', '', '', 17, 5); 221 | INSERT INTO `student` VALUES (92, '2014214801', '冉子硕', '男', '', '', 14, 4); 222 | INSERT INTO `student` VALUES (93, '2017214802', '侯圣明', '男', '', '', 14, 4); 223 | INSERT INTO `student` VALUES (94, '2017214866', '荣洪成', '男', '', '', 15, 4); 224 | INSERT INTO `student` VALUES (95, '2017214869', '李恒', '男', '', '', 15, 4); 225 | 226 | -- ---------------------------- 227 | -- Table structure for system 228 | -- ---------------------------- 229 | DROP TABLE IF EXISTS `system`; 230 | CREATE TABLE `system` ( 231 | `id` int(11) NOT NULL, 232 | `schoolName` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 233 | `forbidTeacher` tinyint(2) NULL DEFAULT NULL, 234 | `forbidStudent` tinyint(2) NULL DEFAULT NULL, 235 | `noticeTeacher` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 236 | `noticeStudent` varchar(500) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 237 | PRIMARY KEY (`id`) USING BTREE 238 | ) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Compact; 239 | 240 | -- ---------------------------- 241 | -- Table structure for teacher 242 | -- ---------------------------- 243 | DROP TABLE IF EXISTS `teacher`; 244 | CREATE TABLE `teacher` ( 245 | `id` int(11) NOT NULL AUTO_INCREMENT, 246 | `number` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 247 | `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 248 | `sex` varchar(4) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 249 | `phone` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 250 | `qq` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 251 | PRIMARY KEY (`id`) USING BTREE, 252 | UNIQUE INDEX `number_teacher_FK`(`number`) USING BTREE 253 | ) ENGINE = InnoDB AUTO_INCREMENT = 19 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Compact; 254 | 255 | -- ---------------------------- 256 | -- Records of teacher 257 | -- ---------------------------- 258 | INSERT INTO `teacher` VALUES (16, '001', '张慧', '女', '', ''); 259 | INSERT INTO `teacher` VALUES (17, '002', '杨志林', '男', '', ''); 260 | INSERT INTO `teacher` VALUES (18, '003', 'hfut', '男', '', ''); 261 | 262 | -- ---------------------------- 263 | -- Table structure for user 264 | -- ---------------------------- 265 | DROP TABLE IF EXISTS `user`; 266 | CREATE TABLE `user` ( 267 | `id` int(11) NOT NULL AUTO_INCREMENT, 268 | `account` varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 269 | `password` varchar(30) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT '111111', 270 | `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NULL DEFAULT NULL, 271 | `type` tinyint(1) NULL DEFAULT 2, 272 | PRIMARY KEY (`id`) USING BTREE, 273 | UNIQUE INDEX `account_user_FK`(`account`) USING BTREE 274 | ) ENGINE = InnoDB AUTO_INCREMENT = 108 CHARACTER SET = utf8 COLLATE = utf8_unicode_ci ROW_FORMAT = Compact; 275 | 276 | -- ---------------------------- 277 | -- Records of user 278 | -- ---------------------------- 279 | INSERT INTO `user` VALUES (1, 'admin', 'admin', 'admin', 1); 280 | INSERT INTO `user` VALUES (90, '001', '111111', '张慧', 3); 281 | INSERT INTO `user` VALUES (93, '2017214919', '111111', '余永康', 2); 282 | INSERT INTO `user` VALUES (95, '2017214917', '111111', '李松昊', 2); 283 | INSERT INTO `user` VALUES (96, '2017214909', '111111', '李帮耀', 2); 284 | INSERT INTO `user` VALUES (97, '2017214906', '111111', '吴坤', 2); 285 | INSERT INTO `user` VALUES (98, '2017214921', '111111', '杨云朝', 2); 286 | INSERT INTO `user` VALUES (99, '2017214907', '111111', '王乐恒', 2); 287 | INSERT INTO `user` VALUES (100, '2017214908', '111111', '方明辉', 2); 288 | INSERT INTO `user` VALUES (101, '002', '111111', '杨志林', 3); 289 | INSERT INTO `user` VALUES (102, '2017214814', '111111', 'wzx', 2); 290 | INSERT INTO `user` VALUES (103, '003', '111111', 'hfut', 3); 291 | INSERT INTO `user` VALUES (104, '2014214801', '111111', '冉子硕', 2); 292 | INSERT INTO `user` VALUES (105, '2017214802', '111111', '侯圣明', 2); 293 | INSERT INTO `user` VALUES (106, '2017214866', '111111', '荣洪成', 2); 294 | INSERT INTO `user` VALUES (107, '2017214869', '111111', '李恒', 2); 295 | 296 | SET FOREIGN_KEY_CHECKS = 1; 297 | -------------------------------------------------------------------------------- /src/test/java/com/hfut/studentmanager/StudentmanagerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class StudentmanagerApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/java/com/hfut/studentmanager/service/ClazzServiceTest.java: -------------------------------------------------------------------------------- 1 | package com.hfut.studentmanager.service; 2 | 3 | import org.junit.Test; 4 | import org.springframework.beans.factory.annotation.Autowired; 5 | 6 | public class ClazzServiceTest { 7 | 8 | @Autowired 9 | private ClazzService clazzService; 10 | 11 | @Test 12 | public void getClazzList() { 13 | if (clazzService == null){ 14 | System.out.println("空指针"); 15 | }else { 16 | System.out.println(clazzService.listAllClazz()); 17 | 18 | } 19 | } 20 | } --------------------------------------------------------------------------------