diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a2a3040 --- /dev/null +++ b/.gitignore @@ -0,0 +1,31 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/** +!**/src/test/** + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ + +### VS Code ### +.vscode/ diff --git a/mvnw b/mvnw new file mode 100644 index 0000000..a16b543 --- /dev/null +++ b/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..583cdbb --- /dev/null +++ b/pom.xml @@ -0,0 +1,95 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.2.5.RELEASE + + + com.pdxm + project_maagement-1 + 0.0.1-SNAPSHOT + war + project_maagement-1 + 我的第一个springboot程序 + + + 1.8 + + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-tomcat + provided + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 2.1.2 + + + org.springframework.boot + spring-boot-starter-log4j + 1.3.8.RELEASE + + + org.springframework.boot + spring-boot-devtools + runtime + + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.2.5 + + + mysql + mysql-connector-java + runtime + + + org.apache.commons + commons-lang3 + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + io.springfox + springfox-swagger-ui + 2.7.0 + + + io.springfox + springfox-swagger2 + 2.7.0 + + + + + Projectmanagement + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/src/main/java/com/yipin/liuwanr/ProjectMaagementApplication.java b/src/main/java/com/yipin/liuwanr/ProjectMaagementApplication.java new file mode 100644 index 0000000..654df11 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/ProjectMaagementApplication.java @@ -0,0 +1,15 @@ +package com.yipin.liuwanr; + +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +@MapperScan(basePackages = {"com.yipin.liuwanr.mapper"}) +public class ProjectMaagementApplication { + + public static void main(String[] args) { + SpringApplication.run(ProjectMaagementApplication.class, args); + } + +} diff --git a/src/main/java/com/yipin/liuwanr/ServletInitializer.java b/src/main/java/com/yipin/liuwanr/ServletInitializer.java new file mode 100644 index 0000000..4aebed4 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/ServletInitializer.java @@ -0,0 +1,13 @@ +package com.yipin.liuwanr; + +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +public class ServletInitializer extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { + return application.sources(ProjectMaagementApplication.class); + } + +} diff --git a/src/main/java/com/yipin/liuwanr/config/CORSConfig.java b/src/main/java/com/yipin/liuwanr/config/CORSConfig.java new file mode 100644 index 0000000..b5c78d8 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/config/CORSConfig.java @@ -0,0 +1,27 @@ +package com.yipin.liuwanr.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * @Description 跨域配置 + * @Date 2019/2/27 13:31 + **/ +@Configuration +public class CORSConfig { + + @Bean + public WebMvcConfigurer corsConfigurer(){ + return new WebMvcConfigurer() { + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedHeaders("*") + .allowedMethods("*") + .allowedOrigins("*"); + } + }; + } +} diff --git a/src/main/java/com/yipin/liuwanr/config/SwaggerConfig.java b/src/main/java/com/yipin/liuwanr/config/SwaggerConfig.java new file mode 100644 index 0000000..ecac271 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/config/SwaggerConfig.java @@ -0,0 +1,45 @@ +package com.yipin.liuwanr.config; + +import io.swagger.annotations.ApiOperation; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.service.Contact; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +@Configuration +@EnableSwagger2 +public class SwaggerConfig { + + @Bean + public Docket productApi() { + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select()//添加ApiOperiation注解的被扫描 + .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) + .paths(PathSelectors.any()) + .build(); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder().title("项目管理").description("项目管理模块") + .version("1.0").build(); + } + + /*public ApiInfo createApi(){ + return new ApiInfoBuilder().title("项目管理"). + description("项目管理"). + contact(new Contact("龚世杰","http://projestmgs.com","projestmgs@qq.com")).build(); + } + @Bean //等价于 标签 + public Docket createDoc(){ + return new Docket(DocumentationType.SWAGGER_2).apiInfo(createApi()).select(). + apis(RequestHandlerSelectors.basePackage("com.yipin.liuwanr.controller")).build(); + }*/ + +} \ No newline at end of file diff --git a/src/main/java/com/yipin/liuwanr/controller/Project_ManagementController.java b/src/main/java/com/yipin/liuwanr/controller/Project_ManagementController.java new file mode 100644 index 0000000..9cb31e1 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/controller/Project_ManagementController.java @@ -0,0 +1,344 @@ +package com.yipin.liuwanr.controller; + +import java.util.HashMap; +import java.util.List; + +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.CrossOrigin; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import com.yipin.liuwanr.entity.Judgment_Points; +import com.yipin.liuwanr.entity.ManagementAndPointVo; +import com.yipin.liuwanr.entity.Project_Management; +import com.yipin.liuwanr.entity.Response; +import com.yipin.liuwanr.entity.Role; +import com.yipin.liuwanr.service.Project_ManagementService; + +@Api(value = "项目管理", tags = "项目管理相关方法") +@RestController +@RequestMapping("/ProjectManagement") +@CrossOrigin +public class Project_ManagementController { + + @Autowired + private Project_ManagementService service; + + /** + * 查询用户角色 + * @param userId + * @return + */ + @ApiOperation(value = "查询角色", notes = "查询角色") + @GetMapping("/queryRole") + Response queryRole(Integer userId) { + Response resp = new Response(); + HashMap ret = service.queryRole(userId); + int status = (int) ret.get("retcode"); + if (status == 200) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + return resp; + } + + + /** + * 首页面查询 + * @param projectPermissions:权限 + * @param founder:创建人 + * @param state:状态 + * @param projectName:项目名称 + * @param systemId + * @return + */ + @GetMapping("/queryAllManagements") + Response queryAllManagements(@RequestParam Integer projectPermissions,@RequestParam Integer founder,@RequestParam Integer state,@RequestParam String projectName, + @RequestParam Integer systemId,@RequestParam Integer userId,@RequestParam Integer pageNo,@RequestParam Integer pageSize){ + Response resp = new Response(); + Project_Management vo=new Project_Management(); + if(null!=projectPermissions) { + vo.setProjectPermissions(projectPermissions); + }if(null!=founder) { + vo.setFounder(founder); + }if(null!=state) { + vo.setState(state); + }if(null!=systemId) { + vo.setSystemId(systemId); + }if(null!=projectName&&projectName!="") { + vo.setProjectName(projectName); + }if(null!=userId) { + vo.setUserId(userId); + } + HashMap ret = service.queryAllManagements(vo,pageNo,pageSize); + int status = (int) ret.get("retcode"); + if (status == 200) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + return resp; + } + + + /** + * 批量删除 + * @param point 项目id集合 + * @return + */ + @PostMapping("/removeProjectManagement") + Response removeProjectManagement(@RequestBody List point) { + Response resp = new Response(); + HashMap ret = service.deleteProjectManagement(point); + int status = (int) ret.get("retcode"); + if (status == 200) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + return resp; + } + + + /** + * 根据项目管理id查询对应信息 + * @param projectId + * @return + */ + @GetMapping("/getProjectId") + Response getProjectId(Integer projectId) { + Response resp = new Response(); + HashMap ret = service.getProjectId(projectId); + int status = (int) ret.get("retcode"); + if (status == 200) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + return resp; + } + + /** + * 添加点面板的数据展示+条件筛选 + * @param judgmentPointsName 判分点名称 + * @return + */ + @GetMapping("/queryAllJudgmentPoints") + Response queryAllJudgmentPoints(@RequestParam String judgmentPointsName,@RequestParam Integer systemId) { + Response resp = new Response(); + Judgment_Points points=new Judgment_Points(); + if(StringUtils.isEmpty(systemId)) { + resp.setStatus(300); + resp.setMessage("systemId cannot be empty"); + }else { + if(!StringUtils.isEmpty(judgmentPointsName)) { + points.setJudgmentPointsName(judgmentPointsName); + } + points.setSystemId(systemId); + + HashMap ret = service.queryAllJudgmentPoints(points); + int status = (int) ret.get("retcode"); + if (status == 200) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + } + return resp; + } + + + /** + * 实验任务表格信息的展示,根据判分点id和项目 + * @param judgmentPointsIds 判分点id + * @return + */ + @GetMapping("/getByjudgmentPointsId") + Response getByjudgmentPointsId(@RequestParam List judgmentPointsIds,Integer projectId,Integer userId) { + Response resp = new Response(); + HashMap ret = service.getByjudgmentPointsId(judgmentPointsIds,projectId,userId); + int status = (int) ret.get("retcode"); + if (status == 200) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + return resp; + } + + + /** + * 平均分配分值 + * @param number 判分点数量 + * @return + */ + @GetMapping("/avgValues") + Response avgValues(Integer number) { + Response resp = new Response(); + HashMap ret = service.avgValues(number); + int status = (int) ret.get("retcode"); + if (status == 200) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + return resp; + } + + + /** + * 添加角色 + * @param role 角色 + * @return + */ + @PostMapping("/addRole") + Response addRole(@RequestBody Role role) { + Response resp = new Response(); + HashMap ret = service.insertRole(role); + int status = (int) ret.get("retcode"); + if (status == 200) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + return resp; + } + + + /** + * 实验数据表格信息的展示,根据角色id + * @param roleId 角色Id + * @return + */ + @GetMapping("/getByRoleId") + Response getByRoleId(@RequestParam List roleId) { + Response resp = new Response(); + HashMap ret = service.getByRoleId(roleId); + int status = (int) ret.get("retcode"); + if (status == 200) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + return resp; + } + + + /** + * 开启/关闭实验数据 + */ + /*@ApiOperation(value = "开启/关闭实验数据", notes = "开启/关闭实验数据") + @PostMapping("/startexperimentalSwitch") + Response startexperimentalSwitch(@RequestParam Integer isStartexperimental) { + + }*/ + + /** + * 添加创建项目管理信息 + * @param vo 项目管理信息 + * @return + */ + @ApiOperation(value = "新增项目管理信息", notes = "新增项目管理信息") + @PostMapping("/addProjectManagement") + Response insertProjectManagement(@RequestBody ManagementAndPointVo vo) { + Response resp = new Response(); + Project_Management pro = vo.getManagement(); + List points=vo.getPooints(); + List roles = vo.getRoleId(); + if(StringUtils.isEmpty(pro)) { + resp.setStatus(300); + resp.setMessage("management cannot be empty"); + return resp; + } + if(points.isEmpty()||points.size()<=0) { + resp.setStatus(300); + resp.setMessage("pooints cannot be empty"); + return resp; + } + + if (pro.getIsstartexperimental()==0){//开启实验数据 + if(roles.isEmpty()||roles.size()<=0) { + resp.setStatus(300); + resp.setMessage("roleId cannot be empty"); + return resp; + } + } + + HashMap ret = service.insertProjectManagement(pro,points,roles); + int status = (int) ret.get("retcode"); + if (status == 200) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + return resp; + } + + + /** + * 修改项目管理信息 + * @param vo + * @return + */ + @PostMapping("/updateProjectManagement") + Response updateProjectManagement(@RequestBody ManagementAndPointVo vo) { + Response resp = new Response(); + Project_Management pro = vo.getManagement(); + List points=vo.getPooints(); + List roles = vo.getRoleId(); + if(StringUtils.isEmpty(pro)) { + resp.setStatus(300); + resp.setMessage("management cannot be empty"); + return resp; + } + if(points.isEmpty()||points.size()<=0) { + resp.setStatus(300); + resp.setMessage("pooints cannot be empty"); + return resp; + } + if(roles.isEmpty()||roles.size()<=0) { + resp.setStatus(300); + resp.setMessage("roleId cannot be empty"); + return resp; + } + HashMap ret = service.updateProjectManagement(pro,points,roles); + int status = (int) ret.get("retcode"); + if (status == 200) { + resp.setStatus(status); + resp.setMessage(ret.get("retvalue")); + } else { + resp.setStatus(status); + resp.setErrmessage(ret.get("retvalue").toString()); + } + return resp; + } + +} diff --git a/src/main/java/com/yipin/liuwanr/entity/Judgment_Points.java b/src/main/java/com/yipin/liuwanr/entity/Judgment_Points.java new file mode 100644 index 0000000..a870816 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/entity/Judgment_Points.java @@ -0,0 +1,93 @@ +package com.yipin.liuwanr.entity; + +/** + * 判分表 + */ +public class Judgment_Points { + + + private Integer judgmentPointsId;// 判分点主键Id + private String judgmentPointsName;// 判分点名称 + private String experimentalRequirements;//实验要求 + private String projectId;//绑定项目管理Id + private Integer judgmentPointsType;// 判分点类型(1、编程类 2、交易类 3、工具类 4、业务类) + private Integer isdel;// 是否删除(0、未删除 1、已删除) + private Integer systemId; + private Integer userId; + + private Integer score;//判分点指标的分数 + + public Integer getSystemId() { + return systemId; + } + + public void setSystemId(Integer systemId) { + this.systemId = systemId; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Integer getScore() { + return score; + } + + public void setScore(Integer score) { + this.score = score; + } + + public Integer getJudgmentPointsId() { + return judgmentPointsId; + } + + public void setJudgmentPointsId(Integer judgmentPointsId) { + this.judgmentPointsId = judgmentPointsId; + } + + public String getJudgmentPointsName() { + return judgmentPointsName; + } + + public void setJudgmentPointsName(String judgmentPointsName) { + this.judgmentPointsName = judgmentPointsName; + } + + public String getExperimentalRequirements() { + return experimentalRequirements; + } + + public void setExperimentalRequirements(String experimentalRequirements) { + this.experimentalRequirements = experimentalRequirements; + } + + public String getProjectId() { + return projectId; + } + + public void setProjectId(String projectId) { + this.projectId = projectId; + } + + public Integer getJudgmentPointsType() { + return judgmentPointsType; + } + + public void setJudgmentPointsType(Integer judgmentPointsType) { + this.judgmentPointsType = judgmentPointsType; + } + + public Integer getIsdel() { + return isdel; + } + + public void setIsdel(Integer isdel) { + this.isdel = isdel; + } + + +} diff --git a/src/main/java/com/yipin/liuwanr/entity/ManagementAndPointVo.java b/src/main/java/com/yipin/liuwanr/entity/ManagementAndPointVo.java new file mode 100644 index 0000000..fc22c04 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/entity/ManagementAndPointVo.java @@ -0,0 +1,35 @@ +package com.yipin.liuwanr.entity; + +import java.util.List; + +public class ManagementAndPointVo { + + private Project_Management management;//项目管理 + private List pooints;//判分点信息 + private List roleId;//存储角色id + + public Project_Management getManagement() { + return management; + } + + public void setManagement(Project_Management management) { + this.management = management; + } + + public List getPooints() { + return pooints; + } + + public void setPooints(List pooints) { + this.pooints = pooints; + } + + public List getRoleId() { + return roleId; + } + + public void setRoleId(List roleId) { + this.roleId = roleId; + } + +} diff --git a/src/main/java/com/yipin/liuwanr/entity/PageResult.java b/src/main/java/com/yipin/liuwanr/entity/PageResult.java new file mode 100644 index 0000000..eb8a10a --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/entity/PageResult.java @@ -0,0 +1,31 @@ +package com.yipin.liuwanr.entity; + +import java.io.Serializable; +import java.util.List; + +public class PageResult implements Serializable{ + + //总记录数 + private Long total; + //总记录 + private List rows; + + public PageResult(Long total, List rows) { + this.total = total; + this.rows = rows; + } + public Long getTotal() { + return total; + } + public void setTotal(Long total) { + this.total = total; + } + public List getRows() { + return rows; + } + public void setRows(List rows) { + this.rows = rows; + } + + +} diff --git a/src/main/java/com/yipin/liuwanr/entity/Project_Management.java b/src/main/java/com/yipin/liuwanr/entity/Project_Management.java new file mode 100644 index 0000000..fa1fb7d --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/entity/Project_Management.java @@ -0,0 +1,185 @@ +package com.yipin.liuwanr.entity; + +/** + * 项目管理 + * + * @author 86151 + * + */ +public class Project_Management { + + private Integer projectId;// 项目主键ID + private String projectName;// 项目名称 + private Integer projectPermissions;// 项目权限(0、练习 1、考核 2、竞赛) + private Integer founder;// 创建人(0、系统 1、老师) + private String creationTime;// 创建时间 + private Integer state;// 状态(0、草稿箱 1、已发布) + private String experimentalGoal;// 实验目标 + private String caseDescription; // 案例描述 + private String experimentTask;// 实验任务 + private String experimentalDataId;// 绑定实验数据ID + private String experimentSuggests; // 实验提示 + private Integer systemId;// 绑定服务配置ID + private Integer isdel; + private Integer isShow; + private Integer isstartexperimental;//是否启用实验数据(0启用 1不启用) + private Integer isstartexperimentSuggests; + private Integer isExperiment; + private Integer isAttendance; + private Integer userId; + + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public Integer getIsstartexperimental() { + return isstartexperimental; + } + + public void setIsstartexperimental(Integer isstartexperimental) { + this.isstartexperimental = isstartexperimental; + } + + public Integer getIsstartexperimentSuggests() { + return isstartexperimentSuggests; + } + + public void setIsstartexperimentSuggests(Integer isstartexperimentSuggests) { + this.isstartexperimentSuggests = isstartexperimentSuggests; + } + + public Integer getProjectId() { + return projectId; + } + + public void setProjectId(Integer projectId) { + this.projectId = projectId; + } + + public String getProjectName() { + return projectName; + } + + public void setProjectName(String projectName) { + this.projectName = projectName; + } + + public Integer getProjectPermissions() { + return projectPermissions; + } + + public void setProjectPermissions(Integer projectPermissions) { + this.projectPermissions = projectPermissions; + } + + public Integer getFounder() { + return founder; + } + + public void setFounder(Integer founder) { + this.founder = founder; + } + + public String getCreationTime() { + return creationTime; + } + + public void setCreationTime(String creationTime) { + this.creationTime = creationTime; + } + + public Integer getState() { + return state; + } + + public void setState(Integer state) { + this.state = state; + } + + public String getExperimentalGoal() { + return experimentalGoal; + } + + public void setExperimentalGoal(String experimentalGoal) { + this.experimentalGoal = experimentalGoal; + } + + public String getCaseDescription() { + return caseDescription; + } + + public void setCaseDescription(String caseDescription) { + this.caseDescription = caseDescription; + } + + public String getExperimentTask() { + return experimentTask; + } + + public void setExperimentTask(String experimentTask) { + this.experimentTask = experimentTask; + } + + public Integer getIsdel() { + return isdel; + } + + public void setIsdel(Integer isdel) { + this.isdel = isdel; + } + + public Integer getIsShow() { + return isShow; + } + + public void setIsShow(Integer isShow) { + this.isShow = isShow; + } + + public String getExperimentalDataId() { + return experimentalDataId; + } + + public void setExperimentalDataId(String experimentalDataId) { + this.experimentalDataId = experimentalDataId; + } + + public String getExperimentSuggests() { + return experimentSuggests; + } + + + public void setExperimentSuggests(String experimentSuggests) { + this.experimentSuggests = experimentSuggests; + } + + public Integer getSystemId() { + return systemId; + } + + public void setSystemId(Integer systemId) { + this.systemId = systemId; + } + + public Integer getIsExperiment() { + return isExperiment; + } + + public void setIsExperiment(Integer isExperiment) { + this.isExperiment = isExperiment; + } + + public Integer getIsAttendance() { + return isAttendance; + } + + public void setIsAttendance(Integer isAttendance) { + this.isAttendance = isAttendance; + } + +} diff --git a/src/main/java/com/yipin/liuwanr/entity/Response.java b/src/main/java/com/yipin/liuwanr/entity/Response.java new file mode 100644 index 0000000..59c7570 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/entity/Response.java @@ -0,0 +1,34 @@ +package com.yipin.liuwanr.entity; + +public class Response { + + private int status = 200; + + private Object message; + + private String errmessage; + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public Object getMessage() { + return message; + } + + public void setMessage(Object message) { + this.message = message; + } + + public String getErrmessage() { + return errmessage; + } + + public void setErrmessage(String errmessage) { + this.errmessage = errmessage; + } +} diff --git a/src/main/java/com/yipin/liuwanr/entity/Role.java b/src/main/java/com/yipin/liuwanr/entity/Role.java new file mode 100644 index 0000000..288a222 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/entity/Role.java @@ -0,0 +1,56 @@ +package com.yipin.liuwanr.entity; + +/** + * 角色表 + * @author 86151 + * + */ +public class Role { + + private Integer roleId;// 角色ID + private String roleName;// 角色名称 + private Integer roleNumber;// 角色数量 + private Integer roleType;// 角色类型 + private Integer roleAttribute;// 角色属性 + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + public Integer getRoleNumber() { + return roleNumber; + } + + public void setRoleNumber(Integer roleNumber) { + this.roleNumber = roleNumber; + } + + public Integer getRoleType() { + return roleType; + } + + public void setRoleType(Integer roleType) { + this.roleType = roleType; + } + + public Integer getRoleAttribute() { + return roleAttribute; + } + + public void setRoleAttribute(Integer roleAttribute) { + this.roleAttribute = roleAttribute; + } + +} diff --git a/src/main/java/com/yipin/liuwanr/entity/ScoreIndex.java b/src/main/java/com/yipin/liuwanr/entity/ScoreIndex.java new file mode 100644 index 0000000..d5c6eee --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/entity/ScoreIndex.java @@ -0,0 +1,79 @@ +package com.yipin.liuwanr.entity; + +/** + * 判分指标 + * + * @author 或然 + * + */ +public class ScoreIndex { + + private Integer scoreindexId;//判分点指标id + private Integer score;//分数 + private Integer judgmentPointsId;//判分点id + private Integer projectId;//项目id + private Integer isdel;//是否删除 + private Integer userId; + + public ScoreIndex( Integer score, Integer judgmentPointsId, Integer projectId,Integer userId) { + super(); + this.score = score; + this.judgmentPointsId = judgmentPointsId; + this.projectId = projectId; + this.userId = userId; + } + + public Integer getUserId() { + return userId; + } + + public void setUserId(Integer userId) { + this.userId = userId; + } + + public ScoreIndex() { + super(); + } + + public Integer getProjectId() { + return projectId; + } + + public void setProjectId(Integer projectId) { + this.projectId = projectId; + } + + public Integer getIsdel() { + return isdel; + } + + + public void setIsdel(Integer isdel) { + this.isdel = isdel; + } + + public Integer getScoreindexId() { + return scoreindexId; + } + + public void setScoreindexId(Integer scoreindexId) { + this.scoreindexId = scoreindexId; + } + + public Integer getScore() { + return score; + } + + public void setScore(Integer score) { + this.score = score; + } + + public Integer getJudgmentPointsId() { + return judgmentPointsId; + } + + public void setJudgmentPointsId(Integer judgmentPointsId) { + this.judgmentPointsId = judgmentPointsId; + } + +} diff --git a/src/main/java/com/yipin/liuwanr/helper/UserUtil.java b/src/main/java/com/yipin/liuwanr/helper/UserUtil.java new file mode 100644 index 0000000..8aeea8d --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/helper/UserUtil.java @@ -0,0 +1,38 @@ +package com.yipin.liuwanr.helper; + +import java.util.ArrayList; +import java.util.List; + +public class UserUtil { + + /** + * 平均分配分值 + * @param number 判分点数量 + * @return + */ + public static List averageValue(Integer number) { + Integer score=100/number; + Integer lastScore=score+100%number; + List list=new ArrayList(); + for (int i = 0; i < number-1; i++) { + list.add(score); + } + list.add(lastScore); + return list; + } + + /** + * 将string类型转成list集合 + * @param str + * @return + */ + public static List strToInteger(String str){ + String[] strs = str.split(","); + List list=new ArrayList(); + for (int i = 0; i < strs.length; i++) { + list.add(Integer.parseInt(strs[i])); + } + return list; + } + +} diff --git a/src/main/java/com/yipin/liuwanr/mapper/Project_ManagementMapper.java b/src/main/java/com/yipin/liuwanr/mapper/Project_ManagementMapper.java new file mode 100644 index 0000000..4116477 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/mapper/Project_ManagementMapper.java @@ -0,0 +1,240 @@ +package com.yipin.liuwanr.mapper; + +import java.util.List; + +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import com.yipin.liuwanr.entity.Judgment_Points; +import com.yipin.liuwanr.entity.Project_Management; +import com.yipin.liuwanr.entity.Role; + +/** + * 项目管理系统 项目管理表 + * + * @author 86151 + * + */ +public interface Project_ManagementMapper { + + /** + * 查询项目名称 + * @param projectName + * @return + */ + @Select("select count(*) from hr_project_management where projectName=#{projectName}") + Integer getByprojectName(String projectName); + + /** + * 分页查询+条件查询 + * + * @param management + * @return + */ + @Select({ "" }) + List queryManagements(Project_Management management); + + + /** + * 根据实验项目id查询信息 + * + * @param projectId + * @return + */ + @Select("select projectId,projectName,projectPermissions,experimentalGoal,caseDescription,experimentSuggests,state,isstartexperimental,isstartexperimentSuggests,userId from hr_project_management where isdel=0 and projectId=#{projectId}") + Project_Management getProjectId(Integer projectId); + + + /** + * 批量删除 + * @param projectId + */ + @Update("") + void deleteProjectManagement(@Param("point") List projectId); + + + /** + * 添加角色信息 + * + * @param role + * @return + */ + @Insert("insert into hr_role (roleNumber,roleType,roleAttribute) VALUES (#{roleNumber},#{roleType},#{roleAttribute})") + @Options(useGeneratedKeys = true, keyProperty = "roleId", keyColumn = "roleId") + void insertRole(Role role); + + /** + * 点击实验数据中单个角色后的编辑按钮,修改角色信息 + * + * @param role + */ + @Update("update hr_role set roleNumber=#{roleNumber},roleType=#{roleType},roleAttribute=#{roleAttribute} where roleId=#{roleId}") + void updateRole(Role role); + + + /** + * 点击编辑或者创建项目管理页面的保存按钮后, + * 修改角色表中的对应数据的项目id + * @param ids + * @param projectId + */ + @Update("") + void updateRoleProjectId(@Param("ids")List ids,@Param("projectId")Integer projectId); + + + @Delete("delete from hr_role where projectId=#{projectId}") + void deleteRole(Integer projectId); + + /** + * 添加角色信息后,在创建编辑页面的角色信息展示 + * + * @param role + * @return + */ + @Select({ "" }) + List getByRoleId(@Param("role") List role); + + + /** + * 点击具体某个项目信息的编辑按钮, + * 跳转到编辑项目管理页面的实验数据的信息展示 + * @param projectId + * @return + */ + @Select("select roleId,roleNumber,roleType,roleAttribute from hr_role where projectId=#{projectId}") + List queryProjectId(Integer projectId); + + + /** + * 添加判分点面板的判分信息展示 + * @return + */ + @Select({ "" }) + List queryAllJudgmentPoints(Judgment_Points points); + + + /** + * 从判分点添加面板,选择完数据后, + * 创建项目管理页面的实验任务信息展示 + * @param point + * @return + */ + @Select({ "" }) + List getByjudgmentPointsIds(@Param("point") List point); + + /** + * 点击具体某个项目信息的编辑按钮, + * 跳转到编辑项目管理页面的实验任务的信息展示 + * @param projectId + * @return + */ + @Select("select judgmentPointsId,judgmentPointsName,experimentalRequirements from hr_judgment_points where isdel=0 and FIND_IN_SET(#{projectId},projectId)>0") + List getByProjectId(Integer projectId); + + + @Select("select judgmentPointsId,projectId from hr_judgment_points where isdel=0 and FIND_IN_SET(#{projectId},projectId)>0") + List queryProjectIds(Integer projectId); + + /** + * 取出判分点中的项目管理的id + * @param judgmentPointsId + * @return + */ + @Select("select projectId,experimentalRequirements from hr_judgment_points where judgmentPointsId=#{judgmentPointsId}") + Judgment_Points getByjudgmentPointsId(Integer judgmentPointsId); + + /** + * 点击保存按按,需要修改判分点表中对应的项目id,实验要求 + * @param projectId + * @param judgmentPointsId + */ + @Update({""}) + void updateProject(String projectId,String experimentalRequirements,Integer judgmentPointsId); + + + /** + * 添加项目管理信息 + * + * @param management + */ + @Insert("INSERT INTO hr_project_management(projectName,projectPermissions,experimentalGoal,caseDescription,experimentSuggests,state,founder,systemId,creationTime,isstartexperimental,isstartexperimentSuggests,userId,isExperiment,isAttendance,isdel)" + + " VALUES (#{projectName},#{projectPermissions},#{experimentalGoal},#{caseDescription},#{experimentSuggests},#{state},1,#{systemId},now(),#{isstartexperimental},#{isstartexperimentSuggests},#{userId},0,0,0)") + @Options(useGeneratedKeys = true,keyProperty = "projectId",keyColumn = "projectId") + void insertProjectManagement(Project_Management management); + + /** + * 修改项目管理信息 + * + * @param management + */ + @Update("update hr_project_management set projectName=#{projectName},projectPermissions=#{projectPermissions},experimentalGoal=#{experimentalGoal},caseDescription=#{caseDescription},experimentSuggests=#{experimentSuggests},state=#{state}," + + "isstartexperimental=#{isstartexperimental},isstartexperimentSuggests=#{isstartexperimentSuggests} where projectId=#{projectId}") + void updateProjectManagement(Project_Management management); + + /** + * 根据项目id,查询出该项目所有的判分点id + * @param projectId + * @return + */ + @Select("select judgmentPointsId from hr_judgment_points where isdel=0 and FIND_IN_SET(#{projectId},projectId)>0") + List getByPointProjectId(Integer projectId); + + /** + * 根据项目id,查询出该项目所有的角色id + * @param projectId + * @return + */ + @Select("select roleId from hr_role where projectId=#{projectId}") + List getByRoleProjectId(Integer projectId); + + + /** + * 查询用户角色 + * @param userId + * @return + */ + @Select("SELECT ro.roleId FROM user us,role ro WHERE ro.roleId=us.accountRole AND us.userId=#{userId}") + Integer queryRole(Integer userId); + + + /** + * 查询用户角色 + * @param userId + * @return + */ + @Select("SELECT accountRole FROM user WHERE userId=#{userId}") + Integer queryRoleId(Integer userId); + + +} diff --git a/src/main/java/com/yipin/liuwanr/mapper/ScoreIndexMapper.java b/src/main/java/com/yipin/liuwanr/mapper/ScoreIndexMapper.java new file mode 100644 index 0000000..e61e8db --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/mapper/ScoreIndexMapper.java @@ -0,0 +1,63 @@ +package com.yipin.liuwanr.mapper; + +import java.util.List; + +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Insert; +import org.apache.ibatis.annotations.Options; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; +import org.apache.ibatis.annotations.Update; + +import com.yipin.liuwanr.entity.ScoreIndex; + +public interface ScoreIndexMapper { + + + /** + * 给判分指标添加分数 + * @param scoreIndex + */ + @Insert("insert into hr_score_index (score,judgmentPointsId,projectId,userId,isdel) " + + " values (#{score},#{judgmentPointsId},#{projectId},#{userId},0)") + @Options(useGeneratedKeys = true,keyProperty = "scoreindexId",keyColumn = "scoreindexId") + void addScoreIndex(ScoreIndex scoreIndex); + + + /** + * 修改分数 + * @param scoreIndex + */ + @Update("update hr_score_index set score=#{score} where judgmentPointsId=#{judgmentPointsId} and projectId=#{projectId} and userId=#{userId} ") + void updateScore(ScoreIndex scoreIndex); + + + /** + * 删除分数 + * @param scoreIndex + */ + @Delete("delete from hr_score_index where judgmentPointsId=#{judgmentPointsId} and projectId=#{projectId} and userId=#{userId}") + void removeScore(@Param("judgmentPointsId")Integer judgmentPointsId,@Param("projectId") Integer projectId,@Param("userId") Integer userId); + + @Delete("delete from hr_score_index where projectId=#{projectId} ") + void removeAllprojectId(@Param("projectId") Integer projectId); + + /** + * 根据判分点id和项目id查询具体分数 + * @return + */ + @Select("select score from hr_score_index where isdel=0 and judgmentPointsId=#{judgmentPointsId} and projectId=#{projectId} and userId=#{userId}") + Integer getbyJudgmentPointsIdScore(@Param("judgmentPointsId")Integer judgmentPointsId,@Param("projectId") Integer projectId,@Param("userId") Integer userId); + + /** + * 查询判分点id和分数 + * @param judgmentPointsId:判分点id + * @param projectId:项目id + * @return + */ + @Select({""}) + List queryScore(@Param("ids")List judgmentPointsId,@Param("projectId")Integer projectId,@Param("userId") Integer userId); +} diff --git a/src/main/java/com/yipin/liuwanr/service/Project_ManagementService.java b/src/main/java/com/yipin/liuwanr/service/Project_ManagementService.java new file mode 100644 index 0000000..2a28656 --- /dev/null +++ b/src/main/java/com/yipin/liuwanr/service/Project_ManagementService.java @@ -0,0 +1,612 @@ +package com.yipin.liuwanr.service; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.yipin.liuwanr.entity.*; +import org.apache.commons.lang3.StringUtils; +import org.jboss.logging.Logger; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import com.yipin.liuwanr.helper.UserUtil; +import com.yipin.liuwanr.mapper.Project_ManagementMapper; +import com.yipin.liuwanr.mapper.ScoreIndexMapper; + +@Service +public class Project_ManagementService { + + private static Logger logger = Logger.getLogger(Project_ManagementService.class); + + @Autowired + private Project_ManagementMapper mapper; + + @Autowired + private ScoreIndexMapper indexMapper; + + + /** + * 查询用户角色 + * + * @param userId + * @return + */ + public HashMap queryRole(Integer userId) { + HashMap resp = new HashMap(); + try { + Integer roleId = mapper.queryRoleId(userId); + if (null != roleId) { + //角色为教师 + if (roleId == 3) { + resp.put("retvalue", 1); + } + //角色为管理员 + else if (roleId == 1 || roleId == 2) { + resp.put("retvalue", 0); + } else if (roleId == 4) { + resp.put("retcode", 300); + resp.put("retvalue", "Role does not meet the requirements"); + return resp; + } + resp.put("retcode", 200); + } else { + resp.put("retcode", 300); + resp.put("retvalue", "user does not exist"); + } + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 分页查询+条件查询 + * + * @param vo + * @return + */ + public HashMap queryAllManagements(Project_Management vo, Integer pageNo, Integer pageSize) { + HashMap resp = new HashMap(); + try { + //获取用户的角色信息 + Integer roleId = mapper.queryRoleId(vo.getUserId()); + if (null != roleId) { + //角色不对(学生没有权限) + if (roleId == 4) { + resp.put("retcode", 300); + resp.put("retvalue", "Role does not meet the requirements"); + return resp; + } + //角色等于管理员或者超级管理员 + else if (roleId == 1 || roleId == 2) { + vo.setUserId(null); + } + } + PageHelper.startPage(pageNo, pageSize); + //条件查询 + List list = mapper.queryManagements(vo); + PageInfo info = new PageInfo(list); + resp.put("retvalue", new PageResult(info.getTotal(), list)); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 批量删除 + * + * @param point:项目管理id + * @return + */ + @Transactional + public HashMap deleteProjectManagement(List point) { + HashMap resp = new HashMap(); + try { + for (Integer po : point) { + //判分点 + List points = mapper.queryProjectIds(po); + for (int i = 0; i < points.size(); i++) { + //判分点 + Judgment_Points pos = points.get(i); + Integer pointId = pos.getJudgmentPointsId();//判分点id + String projectIds = pos.getProjectId();//项目id + + //判分点中删除项目 + if (!StringUtils.isEmpty(projectIds)) { + List lists = Arrays.asList(projectIds.split(",")); + List obj = new ArrayList(lists); + String prijectId = po.toString(); + if (lists.contains(prijectId)) { + obj.remove(prijectId); + projectIds = StringUtils.strip(obj.toString(), "[]").replace(" ", ""); + mapper.updateProject(projectIds, null, pointId); + } + } + } + //删除分数 + indexMapper.removeAllprojectId(po); + mapper.deleteRole(po); + } + mapper.deleteProjectManagement(point); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Delete Failed"); + throw new RuntimeException(); + } + return resp; + } + + + /** + * 根据项目管理id查询对应信息 + * + * @param projectId + * @return + */ + public HashMap getProjectId(Integer projectId) { + HashMap resp = new HashMap(); + List judgmentPointsId = new ArrayList(); + List obj = new ArrayList(); + List indexs = new ArrayList(); + + try { + // 项目信息 + Project_Management management = mapper.getProjectId(projectId); + + if (null != management) { + // 判分点信息 + List points = mapper.getByProjectId(projectId); + //判分点不为空 + if (null != points && !points.isEmpty()) { + //存储判分点id + for (int i = 0; i < points.size(); i++) { + judgmentPointsId.add(points.get(i).getJudgmentPointsId()); + } + //得到对应判分点的分数 + List scores = indexMapper.queryScore(judgmentPointsId, projectId, management.getUserId()); + if (scores.size() > 0 && !scores.isEmpty()) { + //为有分数的赋值 + for (int i = 0; i < points.size(); i++) { + Judgment_Points point = points.get(i); + for (int j = 0; j < scores.size(); j++) { + ScoreIndex score = scores.get(j); + if (point.getJudgmentPointsId().equals(score.getJudgmentPointsId())) { + point.setScore(score.getScore()); + points.set(i, point); + indexs.add(i); + break; + } + } + } + //为没值的赋值 + for (int i = 0; i < points.size(); i++) { + if (!indexs.contains(i)) { + Judgment_Points points3 = points.get(i); + points3.setScore(0); + points.set(i, points3); + } + } + } else { + for (int i = 0; i < points.size(); i++) { + Judgment_Points point = points.get(i); + //给分数赋值 + point.setScore(0); + //修改该判分点 + points.set(i, point); + } + } + } + // 角色信息 + List roles = mapper.queryProjectId(projectId); + // 存数据 + obj.add(management); + obj.add(points); + obj.add(roles); + } + resp.put("retvalue", obj); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 添加判分点页面的判分点信息展示 + * + * @return + */ + public HashMap queryAllJudgmentPoints(Judgment_Points points) { + HashMap resp = new HashMap(); + try { + resp.put("retvalue", mapper.queryAllJudgmentPoints(points)); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Add Failed"); + return resp; + } + return resp; + } + + + /** + * 创建项目管理页面的判分点信息展示 + * + * @param judgmentPointsId 判分点id + * @return + */ + public HashMap getByjudgmentPointsId(List judgmentPointsId, Integer projectId, Integer userId) { + HashMap resp = new HashMap(); + try { + List points = mapper.getByjudgmentPointsIds(judgmentPointsId); + List scores = indexMapper.queryScore(judgmentPointsId, projectId, userId); + List indexs = new ArrayList(); + //为新增项目时勾选判分点赋值 + if (scores.size() <= 0) { + for (int i = 0; i < points.size(); i++) { + Judgment_Points points2 = points.get(i); + points2.setScore(0); + points.set(i, points2); + } + } + //为修改项目时勾选判分点赋值 + else { + //为有分数的赋值 + for (int i = 0; i < points.size(); i++) { + Judgment_Points point = points.get(i); + for (int j = 0; j < scores.size(); j++) { + ScoreIndex score = scores.get(j); + if (point.getJudgmentPointsId().equals(score.getJudgmentPointsId())) { + point.setScore(score.getScore()); + points.set(i, point); + indexs.add(i); + break; + } + } + } + //为没值的赋值 + for (int i = 0; i < points.size(); i++) { + if (!indexs.contains(i)) { + Judgment_Points points3 = points.get(i); + points3.setScore(0); + points.set(i, points3); + } + } + } + + resp.put("retvalue", points); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 平均分配分值 + * + * @param number + * @return + */ + public HashMap avgValues(Integer number) { + HashMap resp = new HashMap(); + try { + resp.put("retvalue", UserUtil.averageValue(number)); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Calculation ERROR"); + return resp; + } + return resp; + } + + + /** + * 添加完角色信息 角色信息展示 + * + * @param roleId 角色ID + * @return + */ + public HashMap getByRoleId(List roleId) { + HashMap resp = new HashMap(); + try { + resp.put("retvalue", mapper.getByRoleId(roleId)); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Inquiry Failed"); + return resp; + } + return resp; + } + + + /** + * 修改角色信息 + * + * @param role 角色信息 + * @return + */ + public HashMap updateRole(Role role) { + HashMap resp = new HashMap(); + try { + mapper.updateRole(role); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "UPDATE ERROR"); + return resp; + } + return resp; + } + + + /** + * 添加角色信息 + * + * @param role 角色信息 + * @return + */ + public HashMap insertRole(Role role) { + HashMap resp = new HashMap(); + try { + mapper.insertRole(role); + Integer roleId = role.getRoleId(); + resp.put("retvalue", roleId); + resp.put("retcode", 200); + } catch (Exception e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Add Failed"); + return resp; + } + return resp; + } + + + /** + * 添加项目管理信息 + * + * @return + */ + @Transactional + public HashMap insertProjectManagement(Project_Management pro, List points, + List roles) { + HashMap resp = new HashMap(); + try { + String projectName = pro.getProjectName(); + Integer count = mapper.getByprojectName(projectName); + if (count != null) { + projectName += projectName + (count + 1); + pro.setProjectName(projectName); + } + // 添加项目信息 + mapper.insertProjectManagement(pro); + // 取出添加的项目信息的id + Integer projectId = pro.getProjectId(); + for (int i = 0; i < points.size(); i++) { + //拼接判分点中的项目id + StringBuffer buff = new StringBuffer(); + + //判分点id + Integer pointId = points.get(i).getJudgmentPointsId(); + //根据该判分点得到数据库存储的对应数据 + Judgment_Points point = mapper.getByjudgmentPointsId(pointId); + //取出绑定的项目id + String projectIds = point.getProjectId(); + //取出实验要求 + String experimentalRequirements = point.getExperimentalRequirements(); + + //数据库中该判分点已绑定过别的项目id,并且该判分点没有绑定过此时前端传来的项目id + if (!StringUtils.isEmpty(projectIds)) { + List lists = Arrays.asList(projectIds.split(",")); + if (!lists.contains(projectId.toString())) { + buff.append(projectIds); + buff.append(","); + buff.append(projectId); + } + } + //数据库中该判分点未绑定任何项目id + else if (projectIds == null) { + buff.append(projectId); + } + //数据中实验要求不为空,且数据库中的实验要求与前端传来的实验要求信息一致 + if (experimentalRequirements != null && !experimentalRequirements.equals("") + && experimentalRequirements.equals(points.get(i).getExperimentalRequirements())) { + mapper.updateProject(new String(buff), null, pointId); + } + //数据库中的实验要求与前端传来的实验要求信息不一致 + else if (!experimentalRequirements.equals(points.get(i).getExperimentalRequirements())) { + mapper.updateProject(new String(buff), points.get(i).getExperimentalRequirements(), pointId); + } + + // 得到判分指标信息 + ScoreIndex scoreIndex = new ScoreIndex(points.get(i).getScore(), pointId, projectId, pro.getUserId()); + // 在判分指标中添加对应信息 + indexMapper.addScoreIndex(scoreIndex); + } + // 修改角色信息中的项目管理id + if (roles != null && roles.size() > 0) { + mapper.updateRoleProjectId(roles, projectId); + } + + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Add Failed"); + throw new RuntimeException(); + } + return resp; + } + + + /** + * 修改项目管理信息 + * + * @return + */ + @Transactional + public HashMap updateProjectManagement(Project_Management pro, List points, + List roles) { + HashMap resp = new HashMap(); + + //项目id + Integer project = pro.getProjectId(); + //用户id + Integer userId = pro.getUserId(); + try { + // 取出该项目对应的判分点id + List judgments = mapper.getByPointProjectId(project); + // 取出该项目对应的角色id + List rolesIds = mapper.getByRoleProjectId(project); + + for (int i = 0; i < points.size(); i++) { + //拼接判分点中的项目id + StringBuffer buff = new StringBuffer(); + + //前端传来的判分点id + Integer pointId = points.get(i).getJudgmentPointsId(); + //前端传来的实验要求 + String experimentalRequirements1 = points.get(i).getExperimentalRequirements(); + //前端传来的分数 + Integer score1 = points.get(i).getScore(); + + //判分点信息 + Judgment_Points point = mapper.getByjudgmentPointsId(pointId); + String projectIds = point.getProjectId(); + String experimentalRequirements2 = point.getExperimentalRequirements(); + + // 如果数据库中有,则取出分数,进行比较 + if (judgments.contains(pointId)) { + //分数 + Integer score2 = indexMapper.getbyJudgmentPointsIdScore(pointId, project, userId); + // 如果分数不一致,则修改分数表中的分数 + if (score2 != null && score1 != score2) { + indexMapper.updateScore(new ScoreIndex(score1, pointId, project, userId)); + } + // 如果数据库中该判分点分数为空,则添加分数 + else if (score2 == null) { + indexMapper.addScoreIndex(new ScoreIndex(score1, pointId, project, pro.getUserId())); + } + //如果前端传来的实验要求与数据库中不一致,则修改数据库中的判分点信息 + if (!experimentalRequirements2.equals(experimentalRequirements1)) { + mapper.updateProject(point.getProjectId(), experimentalRequirements1, pointId); + } + } else { + //数据库中该判分点已绑定过别的项目id,并且该判分点没有绑定过此时前端传来的项目id + if (!StringUtils.isEmpty(projectIds)) { + List lists = Arrays.asList(projectIds.split(",")); + if (!lists.contains(project.toString())) { + buff.append(projectIds); + buff.append(","); + buff.append(project); + } + + } + //数据库中该判分点未绑定任何项目id + else if (projectIds == null) { + buff.append(project); + } + //数据中实验要求不为空,且数据库中的实验要求与前端传来的实验要求信息一致 + if (experimentalRequirements2 != null && !experimentalRequirements2.equals("") + && experimentalRequirements2.equals(experimentalRequirements1)) { + mapper.updateProject(new String(buff), null, pointId); + } + //数据库中的实验要求与前端传来的实验要求信息不一致 + else if (!experimentalRequirements2.equals(experimentalRequirements1)) { + mapper.updateProject(new String(buff), experimentalRequirements1, pointId); + } + // 添加分数 + indexMapper.addScoreIndex(new ScoreIndex(score1, pointId, project, pro.getUserId())); + } + judgments.remove(pointId); + } + + // 从判分点id中删除该项目的id + for (int i = 0; i < judgments.size(); i++) { + Integer judgmentPointsId = judgments.get(i); + + Judgment_Points point = mapper.getByjudgmentPointsId(judgmentPointsId); + String projectIds = point.getProjectId(); + // 删除分数表中对应的判分点id+项目id数据 + indexMapper.removeScore(judgmentPointsId, project, userId); + + // 对取出的数据,删除该项目的id + List str3 = Arrays.asList(projectIds.split(",")); + if (str3.contains(project.toString())) { + List arrayList = new ArrayList(str3); + arrayList.remove(project.toString()); + // 删除字符中项目id + projectIds = StringUtils.strip(arrayList.toString(), "[]").replace(" ", ""); + // 修改判分点中的项目id + mapper.updateProject(projectIds, null, judgments.get(i)); + } + } + + // 用来存储需要修改的角色id + List roleid = new ArrayList(); + + // 遍历前端传来的新的角色id + for (int i = 0; i < roles.size(); i++) { + // 如果前端传来的数据,在数据库中没有,则存起来 + if (!rolesIds.contains(roles.get(i))) { + roleid.add(roles.get(i)); + } + } + + if (roleid.size() > 0 && !roleid.isEmpty()) { + // 修改对应角色的项目id + mapper.updateRoleProjectId(roleid, project); + } + //项目名称去重 + String projectName = pro.getProjectName(); + Integer count = mapper.getByprojectName(projectName); + if (count != null) { + projectName += projectName + (count + 1); + pro.setProjectName(projectName); + } + //修改项目信息 + mapper.updateProjectManagement(pro); + resp.put("retcode", 200); + } catch (RuntimeException e) { + logger.error(e.getMessage()); + resp.put("retcode", 500); + resp.put("retvalue", "Update Failed"); + throw new RuntimeException(); + } + return resp; + } + +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..a6633d5 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,8 @@ +spring.datasource.url=jdbc:mysql://www.liuwanr.cn:3306/huoran?useUnicode=true&characterEncoding=utf8&useSSL=false&allowMultiQueries=true +spring.datasource.username=super +spring.datasource.password=huoran888 +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver + +spring.jackson.default-property-inclusion=non-null + +logging.level.com.yipin.liuwanr.mapper=debug diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml new file mode 100644 index 0000000..e69de29