diff --git a/.gitee/ISSUE_TEMPLATE.zh-CN.md b/.gitee/ISSUE_TEMPLATE.zh-CN.md deleted file mode 100644 index f09d98dde9597de75ffcdb237c2b580b8fffa3f9..0000000000000000000000000000000000000000 --- a/.gitee/ISSUE_TEMPLATE.zh-CN.md +++ /dev/null @@ -1,13 +0,0 @@ -### 该问题是怎么引起的? - - - -### 重现步骤 - - - -### 报错信息 - - - - diff --git a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md b/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md deleted file mode 100644 index 33948fdcb51264545ce5ae797f5310a1c06f871d..0000000000000000000000000000000000000000 --- a/.gitee/PULL_REQUEST_TEMPLATE.zh-CN.md +++ /dev/null @@ -1,15 +0,0 @@ -### 相关的Issue - - -### 原因(目的、解决的问题等) - - -### 描述(做了什么,变更了什么) - - -### 测试用例(新增、改动、可能影响的功能) - - - - - diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..3b78212958f73dd90a3cab970aeaff521893251c --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +# Created by .ignore support plugin (hsz.mobi) +.idea +target diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000000000000000000000000000000000000..e76d1f3241d38db9b28f05133823bbed1ad289ff --- /dev/null +++ b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed 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. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..2cc7d4a55c0cd0092912bf49ae38b3a9e3fd0054 Binary files /dev/null and b/.mvn/wrapper/maven-wrapper.jar differ diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties new file mode 100644 index 0000000000000000000000000000000000000000..642d572ce90e5085986bdd9c9204b9404f028084 --- /dev/null +++ b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/HELP.md b/HELP.md new file mode 100644 index 0000000000000000000000000000000000000000..1ee487dd97b5b3de7ab32991b5f3ce4fdec5f9c2 --- /dev/null +++ b/HELP.md @@ -0,0 +1,15 @@ +# Getting Started + +### Reference Documentation +For further reference, please consider the following sections: + +* [Official Apache Maven documentation](https://maven.apache.org/guides/index.html) +* [Spring Boot Maven Plugin Reference Guide](https://docs.spring.io/spring-boot/docs/2.2.7.RELEASE/maven-plugin/) +* [MyBatis Framework](https://mybatis.org/spring-boot-starter/mybatis-spring-boot-autoconfigure/) + +### Guides +The following guides illustrate how to use some features concretely: + +* [MyBatis Quick Start](https://github.com/mybatis/spring-boot-starter/wiki/Quick-Start) +* [Accessing data with MySQL](https://spring.io/guides/gs/accessing-data-mysql/) + diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 2affc0642a9b6eb45dfb0430efab2ab5b38d2049..0000000000000000000000000000000000000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# softline-files-manage - -#### Description -PC端 - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md index 8c2fe9a0667030bf79cd5b9c54bb9354a5653450..3b9aa012ee4b9aaa78eb14a26b05d5f9b9226b34 100644 --- a/README.md +++ b/README.md @@ -1,37 +1,40 @@ -# softline-files-manage - -#### 介绍 -PC端 - -#### 软件架构 -软件架构说明 - - -#### 安装教程 - -1. xxxx -2. xxxx -3. xxxx - -#### 使用说明 - -1. xxxx -2. xxxx -3. xxxx - -#### 参与贡献 - -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request - - -#### 码云特技 - -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 -5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +# softline-files-manage + + + + +#### 介绍 +PC端 + +#### 软件架构 +软件架构说明 + + +#### 安装教程 + +1. xxxx +2. xxxx +3. xxxx + +#### 使用说明 + +1. xxxx +2. xxxx +3. xxxx + +#### 参与贡献 + +1. Fork 本仓库 +2. 新建 Feat_xxx 分支 +3. 提交代码 +4. 新建 Pull Request + + +#### 码云特技 + +1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md +2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) +3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 +4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 +5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) +6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/mvnw b/mvnw new file mode 100644 index 0000000000000000000000000000000000000000..a16b5431b4c3cab50323a3f558003fd0abd87dad --- /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 0000000000000000000000000000000000000000..c8d43372c986d97911cdc21bd87e0cbe3d83bdda --- /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 0000000000000000000000000000000000000000..8306d3621521528fb5f14cfe7429ca15d17fc511 --- /dev/null +++ b/pom.xml @@ -0,0 +1,326 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.2.7.RELEASE + + + com.soft.line + softline-files-manage + 0.0.1-SNAPSHOT + softline-files-manage + Demo project for Spring Boot + + + 1.8 + 3.9 + 2.6 + 1.9.4 + 1.13 + 4.4 + 1.4 + 1.8 + + + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 2.1.2 + + + + org.springframework.boot + spring-boot-starter-web + + + mysql + mysql-connector-java + 5.1.6 + runtime + + + org.springframework.boot + spring-boot-starter-test + test + + + org.junit.vintage + junit-vintage-engine + + + + + + com.alibaba + fastjson + 1.2.4 + + + org.apache.commons + commons-lang3 + ${apache.commons-lang3.version} + + + commons-io + commons-io + ${apache.commons-io.version} + + + commons-fileupload + commons-fileupload + ${apache.commons-fileupload.version} + + + commons-beanutils + commons-beanutils + ${apache.commons-beanutils.version} + + + org.apache.commons + commons-collections4 + ${apache.commons-collections4.version} + + + org.apache.commons + commons-pool2 + + + org.apache.commons + commons-text + ${apache.commons-text.version} + + + org.projectlombok + lombok + 1.18.12 + + + + + org.springframework.boot + spring-boot-devtools + + + + io.springfox + springfox-swagger2 + 2.8.0 + + + io.springfox + springfox-swagger-ui + 2.8.0 + + + + + + + + + + + + + + org.pegdown + pegdown + 1.6.0 + test + + + + + + org.springframework.boot + spring-boot-starter-aop + + + + + com.alibaba + druid + 1.1.10 + + + log4j + log4j + 1.2.17 + + + + com.google.code.gson + gson + 2.8.0 + + + org.json + json + 20090211 + + + io.jsonwebtoken + jjwt + 0.6.0 + + + + redis.clients + jedis + 2.9.0 + + + + + + com.github.pagehelper + pagehelper-spring-boot-starter + 1.2.5 + + + + + org.apache.poi + poi-ooxml + 4.1.2 + + + + org.apache.httpcomponents + httpclient + 4.5.10 + + + + + + + + + + cn.hutool + hutool-all + 5.5.1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + + + src/main/java + + **/*.xml + + + + + + + diff --git a/src/main/java/com/soft/line/SoftlineFilesManageApplication.java b/src/main/java/com/soft/line/SoftlineFilesManageApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..d601c71c159a889a6b07853639f455c87ee17689 --- /dev/null +++ b/src/main/java/com/soft/line/SoftlineFilesManageApplication.java @@ -0,0 +1,27 @@ +package com.soft.line; + +import lombok.extern.slf4j.Slf4j; +import org.mybatis.spring.annotation.MapperScan; +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; + +@SpringBootApplication +@MapperScan(basePackages = "com.soft.line.mapper") +@Slf4j +@ServletComponentScan +public class SoftlineFilesManageApplication extends SpringBootServletInitializer { + + @Override + protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { + return builder.sources(SoftlineFilesManageApplication.class); + } + + public static void main(String[] args) { + SpringApplication.run(SoftlineFilesManageApplication.class, args); + log.info("--->SoftlineFilesManageApplication has already started<---"); + } + +} diff --git a/src/main/java/com/soft/line/aop/Permission.java b/src/main/java/com/soft/line/aop/Permission.java new file mode 100644 index 0000000000000000000000000000000000000000..10aae273722670c2fae1b4391b8a2207fce515ea --- /dev/null +++ b/src/main/java/com/soft/line/aop/Permission.java @@ -0,0 +1,16 @@ +package com.soft.line.aop; + +import lombok.extern.slf4j.Slf4j; + +import java.lang.annotation.*; + +/** + * @author wu.xueqiao on 2020/5/12. + * @version 0.1 + * @Description 定义用户访问权限 Permission + */ +@Target( ElementType.METHOD ) +@Retention( RetentionPolicy.RUNTIME ) +@Documented +public @interface Permission { +} diff --git a/src/main/java/com/soft/line/aop/PermissionAspect.java b/src/main/java/com/soft/line/aop/PermissionAspect.java new file mode 100644 index 0000000000000000000000000000000000000000..a98457be0505a82ebfa410c19a95cc0f23acc20c --- /dev/null +++ b/src/main/java/com/soft/line/aop/PermissionAspect.java @@ -0,0 +1,76 @@ +package com.soft.line.aop; + + +import com.fasterxml.jackson.databind.ObjectMapper; +import com.soft.line.entity.UserInfo; +import com.soft.line.filter.HttpRequestUtil; +import com.soft.line.filter.UserTokenDto; +import com.soft.line.mapper.UserInfoMapper; +import com.soft.line.util.exception.CommonResult; +import lombok.extern.slf4j.Slf4j; +import net.bytebuddy.implementation.bytecode.Throw; +import org.aspectj.lang.ProceedingJoinPoint; +import org.aspectj.lang.annotation.Around; +import org.aspectj.lang.annotation.Aspect; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletResponse; +import java.io.OutputStream; +import java.util.HashMap; +import java.util.Map; + +/** + * 注解@Permission 业务逻辑 + * @author wu.xueqiao on 2020/5/12. + * @version 0.1 + */ + +@Aspect +@Slf4j +@Component +@ResponseBody +public class PermissionAspect { + + + @Autowired + private UserInfoMapper userInfoMapper; + + //环绕通知 + @Around(value="@annotation(permission)") + public Object checkPermission(ProceedingJoinPoint joinPoint, Permission permission) throws Throwable{ + //获取请求token中的人员信息,判断人员所具有的权限,权限符合则继续,不符合则抛出相关提醒; + log.info("------开始校验用户操作权限------"); + //获取请求客户端的个人信息 + UserTokenDto userToken=HttpRequestUtil.getUserToken(); + RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes(); + HttpServletResponse response=((ServletRequestAttributes)requestAttributes).getResponse(); + Map map=new HashMap<>(); + String userName=userToken.getUserInfo().getUserName(); + String password=userToken.getUserInfo().getPassword(); + map.put("username",userName); + map.put("password",password); + // log.info(userToken.getUserName()); + //根据角色,编辑业务逻辑。。。。。 + UserInfo userInfo=userInfoMapper.userLogin(map); + Object o=null; + //判断该 用户 的角色id + if(userInfo.getRoleId()==1){ + //符合角色要求 继续执行 + o=joinPoint.proceed(); + }else { + //封装无操作权限 返回数据 + response.setHeader("Content-type","application/json; charset=UTF-8"); + OutputStream outputStream=response.getOutputStream(); + CommonResult commonResult=CommonResult.failed("err:您没有该权限"); + outputStream.write(new ObjectMapper().writeValueAsString(commonResult).getBytes("UTF-8")); + } + return o; + + } + +} diff --git a/src/main/java/com/soft/line/auth/AuthConstant.java b/src/main/java/com/soft/line/auth/AuthConstant.java new file mode 100644 index 0000000000000000000000000000000000000000..3a791885201da693fbc6e9df6c9e66ca9c05e9c9 --- /dev/null +++ b/src/main/java/com/soft/line/auth/AuthConstant.java @@ -0,0 +1,45 @@ +package com.soft.line.auth; + +/** + * 权限相关常量定义 + * + * @author 86185 + * @date 2020/5/9 15:51 + */ +public class AuthConstant { + + /** + * 用户默认密码 + */ + public static final String DEFAULT_PASSWORD = "111111"; + /** + * 密码加密拼接key值 + */ + public static final String PASSWORD_ENCRYPT_KEY = "$admin_key"; + + /** + * 请求header中token参数名 + */ + public static final String TOKEN_HEADER = "Authorization"; + /** + * token中加密的md5长度 + */ + public static final int TOKEN_MD5_LENGTH = 32; + /** + * 加密token拼接字符 + */ + public static final String SAFE_STRING = "$token$"; + /** + * 用户名密码登录生成token前缀 + */ + public static final String USER_TOKEN_PREFIX = "Basic "; + /** + * 微信授权登录生成token前缀 + */ + public static final String WE_CHAT_TOKEN_PREFIX = "Bearer "; + /** + * 微信授权登录服务器第三方session有效时间,单位秒,默认24小时 + */ + public static final long WE_CHAT_EXPIRES = 86400; + +} diff --git a/src/main/java/com/soft/line/auth/Md5Util.java b/src/main/java/com/soft/line/auth/Md5Util.java new file mode 100644 index 0000000000000000000000000000000000000000..19e0ee7140a216d80d58ab554bcdb5219dd86af5 --- /dev/null +++ b/src/main/java/com/soft/line/auth/Md5Util.java @@ -0,0 +1,18 @@ +package com.soft.line.auth; + +import org.apache.commons.codec.digest.DigestUtils; + +/** + * Md5加密工具 + * + * @author 86185 + * @date 2020/5/13 10:53 + */ +public class Md5Util { + + public static String encodeMd5(final String str) { + + return DigestUtils.md5Hex(str); + } + +} diff --git a/src/main/java/com/soft/line/auth/StrUtil.java b/src/main/java/com/soft/line/auth/StrUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..683a215527d03a3f94007157e1077d7a6aad3087 --- /dev/null +++ b/src/main/java/com/soft/line/auth/StrUtil.java @@ -0,0 +1,35 @@ +package com.soft.line.auth; + +/** + * @author 86185 + * @date 2020/5/13 10:57 + */ +public class StrUtil { + + /** + * 拼接字符串 + * + * @param str 需拼接字符串 + * @param params 替换str中的{}字符参数 + * @return str + */ + public static String spliceStr(String str, Object... params) { + StringBuilder builder = new StringBuilder(str.length() + 30); + int i = 0; + int j; + for (Object param : params) { + j = str.indexOf("{}", i); + if (j != -1) { + builder.append(str, i, j); + builder.append(param); + i = j + 2; + } else { + break; + } + } + builder.append(str, i, str.length()); + + return builder.toString(); + } + +} diff --git a/src/main/java/com/soft/line/common/AppletSystemConstant.java b/src/main/java/com/soft/line/common/AppletSystemConstant.java new file mode 100644 index 0000000000000000000000000000000000000000..94978de7f6455dffb56ae3778c19fc003e2feb5b --- /dev/null +++ b/src/main/java/com/soft/line/common/AppletSystemConstant.java @@ -0,0 +1,146 @@ +package com.soft.line.common; + +/** + * 小程序 常量 + * + * @author wpb + * @version 1.0 + * @date 2020/6/3 11:35 + */ +public class AppletSystemConstant { + + /* 基础数据 */ + + /** + * 部门对应 code_type + */ + public static final String CODE_TYPE_DEPT = "1"; + + /** + * 证书对应 code_type + */ + public static final String CODE_TYPE_CERT = "103"; + + /* 合同 部分通用 */ + + /** + * id + */ + public static final String ID = "id"; + + + /** + * 部门 + * depId + */ + public static final String DEP_ID = "depId"; + + /** + * 合同名称 + * contract_name + */ + public static final String CONTRACT_NAME = "contractName"; + + /** + * 项目id + * pro_id + */ + public static final String PRO_ID = "proId"; + + /** + * 总金额 + * total_amount + */ + public static final String TOTAL_AMOUNT = "totalAmount"; + + /** + * 第一签约方 + * part_a + */ + public static final String PART_A = "partA"; + + /** + * 第一签约方 + * part_b + */ + public static final String PART_B = "partB"; + + /** + * 签约时间 + * sign_time + */ + public static final String SIGN_TIME = "signTime"; + + /** + * 签约地点 + * sign_addr + */ + public static final String SIGN_ADDR = "signAddr"; + + /** + * 付款方式 + * payment + */ + public static final String PAYMENT = "payment"; + + /** + * 起始时间 + * begin_date + */ + public static final String BEGIN_DATE = "beginDate"; + + /** + * 终止时间 + * end_date + */ + public static final String END_DATE = "endDate"; + + /** + * 备注 + * note + */ + public static final String NOTE = "note"; + + /** + * 修改人 + * modify_person + */ + public static final String MODIFY_PERSON = "modifyPerson"; + + + /** + * 第几页 + * pageNum + */ + public static final String PAGE_NUM = "pageNum"; + + /** + * 每页数量 + * dataNum + */ + public static final String DATA_NUM = "dataNum"; + + /* 证书 部分通用 */ + + /** + * 证书比编号 + */ + public static final String CERT_ID = "certId"; + + /** + * 证书类型 + */ + public static final String CERT_TYPE = "certType"; + + /** + * 默认2004年 - 按照年份归档使用,显示最早年份 + * assignYear + */ + public static final int ASSIGN_YEAR = 2004; + + /** + * 初始值 + * num = 0 + */ + public static final int NUM = 0; +} diff --git a/src/main/java/com/soft/line/common/GlobalExceptionHandler.java b/src/main/java/com/soft/line/common/GlobalExceptionHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..9428f1a352fdd116b4bd0c4eeaea69f9bcce4553 --- /dev/null +++ b/src/main/java/com/soft/line/common/GlobalExceptionHandler.java @@ -0,0 +1,74 @@ +package com.soft.line.common; + +import com.soft.line.util.exception.CommonResult; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.BindException; +import org.springframework.validation.FieldError; +import org.springframework.web.HttpRequestMethodNotSupportedException; +import org.springframework.web.bind.MethodArgumentNotValidException; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.RestControllerAdvice; + +import java.util.stream.Collectors; + +/** + * @Description: 全局异常处理器 异常在此处拦截进行处理 不用再在dao service controller中处理 + * + * @version: v1.0.0 + * @author: wpb + * @date: 2020年3月6日 下午1:13:00 + */ +@Slf4j +@RestControllerAdvice +public class GlobalExceptionHandler { + + /** + * 请求方式不支持 + */ + @ExceptionHandler({ HttpRequestMethodNotSupportedException.class }) + public CommonResult handleException(HttpRequestMethodNotSupportedException e) { + log.error(e.getMessage(), e); + return CommonResult.failed("不支持' " + e.getMethod() + "'请求"); + } + + /** + * 拦截未知的运行时异常 + */ + @ExceptionHandler(RuntimeException.class) + public CommonResult notFount(RuntimeException e) { + log.error("运行时异常:", e); + return CommonResult.failed("服务器异常,请联系管理员"); + } + + /** + * 参数校验异常 + */ + @ExceptionHandler({ MethodArgumentNotValidException.class }) + public CommonResult handleParamsException(MethodArgumentNotValidException e) { + String errorMsg = e.getBindingResult().getAllErrors().stream() + .map(objectError -> ((FieldError) objectError).getDefaultMessage()).collect(Collectors.joining(",")); + log.error(errorMsg, e); + return CommonResult.failed(errorMsg); + } + + /** + * formdata参数校验异常 + */ + @ExceptionHandler({ BindException.class }) + public CommonResult handleFromParamsException(BindException e) { + String errorMsg = e.getBindingResult().getAllErrors().stream() + .map(objectError -> ((FieldError) objectError).getDefaultMessage()).collect(Collectors.joining(",")); + log.error(errorMsg, e); + return CommonResult.failed(errorMsg); + } + + /** + * 系统异常 + */ + @ExceptionHandler(Exception.class) + public CommonResult handleException(Exception e) { + log.error(e.getMessage(), e); + return CommonResult.failed("服务器错误,请联系管理员"); + } + +} diff --git a/src/main/java/com/soft/line/common/WebMvcConfig.java b/src/main/java/com/soft/line/common/WebMvcConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..65d4b90da09e64948f472889c0d4c44aed699c5b --- /dev/null +++ b/src/main/java/com/soft/line/common/WebMvcConfig.java @@ -0,0 +1,33 @@ +package com.soft.line.common; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; +import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * @Description: 自定义静态资源映射配置(访问上传的文件) + * @version: v1.0.0 + * @author: wpb + * @date: 2020年3月30日 下午5:09:03 + */ +@Configuration +@EnableWebMvc +public class WebMvcConfig implements WebMvcConfigurer { + + @Value("${uploadFileDir}") + private String uploadFileDir; + + @Value("${uploadFileMapping}") + private String uploadFileMappingUrl; + + @Override + public void addResourceHandlers(ResourceHandlerRegistry registry) { + registry.addResourceHandler("/" + uploadFileMappingUrl + "**").addResourceLocations("file:///" + uploadFileDir); + registry.addResourceHandler("swagger-ui.html") + .addResourceLocations("classpath:/META-INF/resources/"); + registry.addResourceHandler("/webjars/**") + .addResourceLocations("classpath:/META-INF/resources/webjars/"); + } +} diff --git a/src/main/java/com/soft/line/controller/AppletCertificateController.java b/src/main/java/com/soft/line/controller/AppletCertificateController.java new file mode 100644 index 0000000000000000000000000000000000000000..2d5bd3138b6d3c37abda3628f5c2486862481d54 --- /dev/null +++ b/src/main/java/com/soft/line/controller/AppletCertificateController.java @@ -0,0 +1,161 @@ +package com.soft.line.controller; + +import com.soft.line.common.AppletSystemConstant; +import com.soft.line.entity.AppletCertificate; +import com.soft.line.service.AppletCertificateService; +import com.soft.line.util.MP.AjaxResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.validation.annotation.Validated; +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.RestController; + +import java.util.Map; + +/** + * 小程序证书 + * + * @author wpb + * @version 1.0 + * @date 2020/6/3 15:13 + */ +@RestController +@RequestMapping("/applet") +public class AppletCertificateController { + + @Autowired + private AppletCertificateService appletCertificateService; + + /** + * 小程序接口使用 + * 获取每个部门的证书总数 + * + * @return + */ + @PostMapping("/getCertificateNum") + public AjaxResult getCertificateNum() { + return appletCertificateService.getCertificateNum(); + } + + /** + * 根据证书类型获取证书年列表数据 + * + * @param paramMap 参数 + * @return + */ + @PostMapping("/getCertificateYearList") + public AjaxResult getCertificateYearList(@RequestBody Map paramMap) { + if (!StringUtils.hasText(paramMap.get(AppletSystemConstant.CERT_TYPE).toString())) { + return AjaxResult.error("证书类型不为空"); + } + return appletCertificateService.getCertificateYearList(paramMap); + } + + /** + * 根据证书类型cert_type和起始日期年份以及当前页、每页显示条数分页查询证书年列表 + * + * @param paramMap 参数 + * @return + */ + @PostMapping("/getCertificateList") + public AjaxResult getCertificateList(@RequestBody Map paramMap) { + if (!StringUtils.hasText(paramMap.get(AppletSystemConstant.CERT_TYPE).toString())) { + return AjaxResult.error("证书类型不为空"); + } + if (!StringUtils.hasText(String.valueOf(paramMap.get(AppletSystemConstant.PAGE_NUM)))) { + return AjaxResult.error("第几页不能为空"); + } + if (!StringUtils.hasText(String.valueOf(paramMap.get(AppletSystemConstant.DATA_NUM)))) { + return AjaxResult.error("条数不能为空"); + } + return appletCertificateService.getCertificateList(paramMap); + } + + /** + * 小程序使用 + * 根据证书id查询证书信息 + * + * @param paramMap 参数 + * @return + */ + @PostMapping("/getCertificate") + public AjaxResult getCertificate(@RequestBody Map paramMap) { + if(paramMap.get(AppletSystemConstant.ID) == null){ + return AjaxResult.error("请选择证书"); + } + return appletCertificateService.getCertificate(paramMap); + } + + /** + * 小程序使用 + * 修改证书信息 + * + * @param appletCertificate 参数 + * @return + */ + @PostMapping("/updateCertificate") + public AjaxResult updateCertificate(@Validated @RequestBody AppletCertificate appletCertificate) { + + return appletCertificateService.updateCertificate(appletCertificate); + } + + /** + * 小程序使用 + * 删除证书 + * + * @param paramMap + * @return + */ + @PostMapping("/deleteCertificate") + public AjaxResult deleteCertificate(@RequestBody Map paramMap) { + if(!StringUtils.hasText(paramMap.get(AppletSystemConstant.ID).toString())){ + return AjaxResult.error("证书唯一码不存在"); + } + return appletCertificateService.deleteCertificate(paramMap); + } + + /** + * 小程序使用 + * 根据证书名称分页模糊查询证书列表 + * + * @param paramMap + * @return + */ + @PostMapping("/getCertificateSearchList") + public AjaxResult getCertificateSearchList(@RequestBody Map paramMap) { + if (!StringUtils.hasText(String.valueOf(paramMap.get(AppletSystemConstant.PAGE_NUM)))) { + return AjaxResult.error("第几页不能为空"); + } + if (!StringUtils.hasText(String.valueOf(paramMap.get(AppletSystemConstant.DATA_NUM)))) { + return AjaxResult.error("条数不能为空"); + } + return appletCertificateService.getCertificateSearchList(paramMap); + } + + /** + * 小程序使用 + * 新增证书 + * + * @param appletCertificate 参数 + * @return + */ + @PostMapping("/addCertificate") + public AjaxResult addCertificate(@Validated @RequestBody AppletCertificate appletCertificate) { + return appletCertificateService.addCertificate(appletCertificate); + } + + /** + * 小程序使用 + * 根据证书详情信息分页查询证书列表 + * + * @param paramMap 参数 + * @return + */ + @PostMapping("/getCertificateQueryList") + public AjaxResult getCertificateQueryList(@RequestBody Map paramMap) { + return appletCertificateService.getCertificateQueryList(paramMap); + } + +} diff --git a/src/main/java/com/soft/line/controller/AppletCommonController.java b/src/main/java/com/soft/line/controller/AppletCommonController.java new file mode 100644 index 0000000000000000000000000000000000000000..8de1687225f9d6c239b6f179e3becc6cc6e4f85c --- /dev/null +++ b/src/main/java/com/soft/line/controller/AppletCommonController.java @@ -0,0 +1,102 @@ +package com.soft.line.controller; + +import com.soft.line.service.AppletCommonService; +import com.soft.line.util.MP.AjaxResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + + +/** + * 小程序接口 + * 公用 —— 枚举数据,文件上传 + * + * @author wpb + * @version 1.0 + * @date 2020/6/1 9:06 + */ +@RestController +@RequestMapping("/applet") +public class AppletCommonController { + + + @Autowired + private AppletCommonService appletCommonService; + + /** + * 小程序使用 + * 获取到所有的枚举数据。 + * + * @return + */ + @PostMapping("/getBaseData") + public AjaxResult getBaseData() { + return appletCommonService.getBaseData(); + } + + /** + * 小程序使用 + * 合同file上传 + * + * @param file 文件 + * @param id id + * @param fileName 文件名 + * @param modifyPerson 修改人 + * @return + */ + @PostMapping("/uploadContractAttach") + public AjaxResult uploadContractAttach(@RequestParam("file") MultipartFile file, + @RequestParam("id") Integer id, @RequestParam("fileName") String fileName, @RequestParam("modifyPerson") String modifyPerson) { + + if (!StringUtils.hasText(fileName)) { + return AjaxResult.error("请填写合同名称"); + } + + if (id == null) { + return AjaxResult.error("请选择部门"); + } + + if (file.isEmpty()) { + return AjaxResult.error("请选择要上传的文件!!!"); + } + + return appletCommonService.uploadContractAttach(file, id, fileName, modifyPerson); + + } + + /** + * 小程序使用 + * 证书 file上传 + * + * @param file 文件 + * @param id id + * @param fileName 文件名 + * @param modifyPerson 修改人 + * @return + */ + @PostMapping("/uploadCertificateAttach") + public AjaxResult uploadCertificateAttach(@RequestParam("file") MultipartFile file, + @RequestParam("id") Integer id, @RequestParam("fileName") String fileName, @RequestParam("modifyPerson") String modifyPerson) { + + if (!StringUtils.hasText(fileName)) { + return AjaxResult.error("证书名称不存在"); + } + + if (id == null) { + return AjaxResult.error("请选择部门"); + } + + if (file.isEmpty()) { + return AjaxResult.error("请选择要上传的文件!!!"); + } + + return appletCommonService.uploadCertificateAttach(file, id, fileName, modifyPerson); + + } + + +} diff --git a/src/main/java/com/soft/line/controller/AppletContractController.java b/src/main/java/com/soft/line/controller/AppletContractController.java new file mode 100644 index 0000000000000000000000000000000000000000..38983725506acc637e79d68a6c0f04cd2299971d --- /dev/null +++ b/src/main/java/com/soft/line/controller/AppletContractController.java @@ -0,0 +1,184 @@ +package com.soft.line.controller; + +import com.soft.line.common.AppletSystemConstant; +import com.soft.line.entity.AppletContract; +import com.soft.line.service.AppletContractService; +import com.soft.line.util.MP.AjaxResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.util.StringUtils; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + + +import java.util.Map; + +/** + * 小程序合同控制 + * + * @author wpb + * @version 1.0 + * @date 2020/5/26 13:32 + */ +@RestController +@RequestMapping("/applet") +public class AppletContractController { + + @Autowired + private AppletContractService appletContractService; + + /** + * 小程序使用 + * 查询每个部门的合同总数 + * + * @return + */ + @PostMapping("/getContractNum") + public AjaxResult getContractNum() { + return appletContractService.getContractNum(); + } + + /** + * 小程序使用 + * 根据部门id获取合同年列表数据 + * + * @param paraMap 参数 + * @return + */ + @PostMapping("/getContractYearList") + public AjaxResult getContractYearList(@RequestBody Map paraMap) { + if (!StringUtils.hasText(String.valueOf(paraMap.get(AppletSystemConstant.DEP_ID)))) { + return AjaxResult.error("部门不能为空"); + } + return appletContractService.getContractYearList(paraMap); + } + + /** + * 小程序接口 + * 根据部门id和签订年份分页查询合同列表 + * + * @param paraMap 参数 + * @return + */ + @PostMapping("/getContractList") + public AjaxResult getContractList(@RequestBody Map paraMap) { + if (!StringUtils.hasText(String.valueOf(paraMap.get(AppletSystemConstant.DEP_ID)))) { + return AjaxResult.error("部门不能为空"); + } + if (!StringUtils.hasText(String.valueOf(paraMap.get(AppletSystemConstant.SIGN_TIME)))) { + return AjaxResult.error("年限不能为空"); + } + if (!StringUtils.hasText(String.valueOf(paraMap.get(AppletSystemConstant.PAGE_NUM)))) { + return AjaxResult.error("第几页不能为空"); + } + if (!StringUtils.hasText(String.valueOf(paraMap.get(AppletSystemConstant.DATA_NUM)))) { + return AjaxResult.error("条数不能为空"); + } + return appletContractService.getContractList(paraMap); + } + + /** + * 小程序使用接口 + * 根据合同名称分页模糊查询合同列表 + * + * @param paraMap 参数 + * @return + */ + @PostMapping("/getContractSearchList") + public AjaxResult getContractSearchList(@RequestBody Map paraMap) { + if (!StringUtils.hasText(String.valueOf(paraMap.get(AppletSystemConstant.CONTRACT_NAME)))) { + return AjaxResult.error("合同名称不能为空"); + } + if (!StringUtils.hasText(String.valueOf(paraMap.get(AppletSystemConstant.PAGE_NUM)))) { + return AjaxResult.error("第几页不能为空"); + } + if (!StringUtils.hasText(String.valueOf(paraMap.get(AppletSystemConstant.DATA_NUM)))) { + return AjaxResult.error("条数不能为空"); + } + return appletContractService.getContractSearchList(paraMap); + } + + /** + * 根据合同详情信息分页查询合同列表 + * + * @param paraMap 参数 + * @return + */ + @PostMapping("/getContractQueryList") + public AjaxResult getContractQueryList(@RequestBody Map paraMap) { + if (!StringUtils.hasText(String.valueOf(paraMap.get(AppletSystemConstant.PAGE_NUM)))) { + return AjaxResult.error("第几页不能为空"); + } + if (!StringUtils.hasText(String.valueOf(paraMap.get(AppletSystemConstant.DATA_NUM)))) { + return AjaxResult.error("条数不能为空"); + } + return appletContractService.getContractQueryList(paraMap); + } + + /** + * 小程序使用接口 + * 新增合同 + * + * @param appletContract 参数 + * @return + */ + @PostMapping("/addContract") + public AjaxResult addContract(@Validated @RequestBody AppletContract appletContract) { + return appletContractService.addContract(appletContract); + } + + /** + * 小程序使用 + * 修改合同信息 + * + * @param appletContract 参数 + * @return + */ + @PostMapping("/updateContract") + public AjaxResult updateContract(@Validated @RequestBody AppletContract appletContract) { + if(appletContract.getId() == null){ + return AjaxResult.error("请选择合同"); + } + + return appletContractService.updateContract(appletContract); + } + + /** + * 根据合同id查询合同详情信息 + * + * @param paraMap 参数 + * @return + */ + @PostMapping("/getContract") + public AjaxResult getContract(@RequestBody Map paraMap) { + return appletContractService.getContract(paraMap); + } + + /** + * 小程序使用 + * 根据id删除合同信息 + * + * @param paraMap 参数 + * @return + */ + @PostMapping("/deleteContract") + public AjaxResult deleteContract(@RequestBody Map paraMap) { + return appletContractService.deleteContract(paraMap); + } + + /** + * 小程序使用 + * 获取用户的合同部门 + * + * @param paraMap 参数 + * @return + */ + @PostMapping("/getUserContDep") + public AjaxResult getUserContDep(@RequestBody Map paraMap) { + if(paraMap.get("userId") == null){ + return AjaxResult.error("没有用户ID"); + } + + return appletContractService.getUserContDep(paraMap); + } + +} diff --git a/src/main/java/com/soft/line/controller/AttachmentController.java b/src/main/java/com/soft/line/controller/AttachmentController.java new file mode 100644 index 0000000000000000000000000000000000000000..f98e0d9263e68bf8e961e69f63d9c2433677ab5f --- /dev/null +++ b/src/main/java/com/soft/line/controller/AttachmentController.java @@ -0,0 +1,46 @@ +package com.soft.line.controller; + +import com.soft.line.entity.AttachmentInfo; +import com.soft.line.service.AttachMentInfoService; +import com.soft.line.util.exception.CommonResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.util.Map; + +@Api(description = "附件接口") +@Slf4j +@RestController +@RequestMapping("/attachment") +public class AttachmentController { + + @Autowired + private AttachMentInfoService attachMentInfoService; + + @ApiOperation(value = "获取附件列表", notes = "获取附件列表") + @GetMapping("/attachment/{attachmentType}/{id}") + public CommonResult getAll(@PathVariable("attachmentType") String attachmentType,@PathVariable("id") Integer id){ + System.out.println("attachmentType:"+attachmentType); + return CommonResult.success(attachMentInfoService.selectAll(attachmentType,id)); + } + + + @ApiOperation(value = "删除附件", notes = "删除附件") + @DeleteMapping("/attachment") + public CommonResult delete(@RequestBody Map map){ + attachMentInfoService.delete(map); + return CommonResult.success("删除成功"); + } + + @ApiOperation(value = "上传附件", notes = "上传附件") + @PostMapping("/upload") + public CommonResult upload(@RequestParam("file") MultipartFile uploadFile, + @RequestParam("type") String type,@RequestParam("cId")Integer cId){ + return CommonResult.success(attachMentInfoService.save(uploadFile,type,cId)); + } + +} diff --git a/src/main/java/com/soft/line/controller/CertificateInfoController.java b/src/main/java/com/soft/line/controller/CertificateInfoController.java new file mode 100644 index 0000000000000000000000000000000000000000..4fb56eb3b09f0c990e0767cbdf7b79a3b31425de --- /dev/null +++ b/src/main/java/com/soft/line/controller/CertificateInfoController.java @@ -0,0 +1,135 @@ +package com.soft.line.controller; + + +import com.soft.line.entity.CertificateInfo; +import com.soft.line.service.CertificateInfoService; +import com.soft.line.service.CodeDetailService; +import com.soft.line.util.exception.CommonResult; +import com.soft.line.util.exception.ResultData; +import com.soft.line.util.jackson.converter.StringToDateUtil; +import com.soft.line.util.poi.PoiUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author wu.xueqiao on 2020/5/8. + * @version 0.1 + */ + +@Api(description = "证书接口") +@Slf4j +@RestController +@RequestMapping("/dataManage") +public class CertificateInfoController { + + @Autowired + private CertificateInfoService certificateInfoService; + @Autowired + private CodeDetailService codeDetailService; + + + /** + * @param map 参数:pageSize,pageNum,查询条件:证书名称,人员姓名等 + * @return + * @Description 证书查询 模糊查询 个人证书查询 分页 + */ + @ApiOperation(value = "证书列表", notes = "查询证书列表") + //设置请求参数 + @ApiImplicitParams({ + // @ApiImplicitParam(paramType = "query", name = "userName", value = "名称", required = false, dataType = "String"), + // @ApiImplicitParam(paramType = "query", name = "dicCode", value = "编码", required = false, dataType = "String") + // ..... + }) + // @Permission + @PostMapping("/getCompanyAllCertificates") + public CommonResult getCompanyAllCertificates(@RequestBody Map map) { + return CommonResult.success(certificateInfoService.getAllCompanyCertificates(map)); + } + + @ApiOperation(value = "获取所有证书列表", notes = "获取所有证书列表") + @PostMapping("/certificates") + public CommonResult getAllCertificates(@RequestBody Map map) { + return CommonResult.success(certificateInfoService.getAllCertificates(map)); + } + + @ApiOperation(value = "删除证书", notes = "删除证书") + @DeleteMapping("/certificate") + public CommonResult deleteCertificate(@RequestBody Map map) { + certificateInfoService.delete(map); + return CommonResult.success("删除成功"); + } + + @ApiOperation(value = "保存证书", notes = "保存证书") + @PostMapping("/certificate") + public CommonResult saveCertificate(@RequestBody @Validated CertificateInfo certificateInfo) { + if (certificateInfoService.countByCId(certificateInfo.getId(), certificateInfo.getCertId()) > 0) { + return CommonResult.success("存在相同证书编号","存在相同证书编号"); + } + if (certificateInfo.getBeginDate() != null && certificateInfo.getEndDate() != null) { + if (certificateInfo.getBeginDate().after(certificateInfo.getEndDate())) { + return CommonResult.success("起始日期不能>终止日期", "起始日期不能>终止日期"); + } + } + if (certificateInfo.getId() == null) { + //添加 + certificateInfoService.add(certificateInfo); + return CommonResult.success("添加成功"); + } else { + //修改 + certificateInfoService.update(certificateInfo); + return CommonResult.success("修改成功"); + } + } + + @ApiOperation(value = "导入证书", notes = "导入证书") + @PostMapping("/certificate/import") + public CommonResult importCertificate(@RequestParam MultipartFile file, HttpServletRequest request) { + System.out.println("importCertificate"); + if (file == null){ + return CommonResult.success("上传文件不能为空","上传文件不能为空"); + } + String fileName = file.getOriginalFilename(); + if (!fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(xlsx)$")) { + return CommonResult.success("上传文件格式错误,请上传后缀为.xls或.xlsx的文件","上传文件格式错误,请上传后缀为.xls或.xlsx的文件"); + } + Map map = PoiUtils.excel2Certificate(file,codeDetailService,certificateInfoService); + String warningMsg = (String)map.get("warningMsg"); + if (warningMsg.length()>0){ + return CommonResult.failed(warningMsg); + }else{ + List certificateInfoList = (List)map.get("certificateInfoList"); + certificateInfoService.insertRecord(certificateInfoList); + return CommonResult.success("导入成功"); + } + + } + + @ApiOperation(value = "导出证书", notes = "导出证书") + @PostMapping("/certificate/export") + public void exportCertificate(@RequestBody Map map,HttpServletResponse response) { + List certificateInfoList = certificateInfoService.getAllByIDList(map); + PoiUtils.certificate2Excel(certificateInfoList,response); + } + +} diff --git a/src/main/java/com/soft/line/controller/CodeDetailController.java b/src/main/java/com/soft/line/controller/CodeDetailController.java new file mode 100644 index 0000000000000000000000000000000000000000..fda43216719fc190d7ecda682a28fb02a11116e5 --- /dev/null +++ b/src/main/java/com/soft/line/controller/CodeDetailController.java @@ -0,0 +1,34 @@ +package com.soft.line.controller; + +import com.soft.line.entity.LasCodeItem; +import com.soft.line.service.CodeDetailService; +import com.soft.line.util.exception.CommonResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@Api(description = "内部代码") +@Slf4j +@RestController +public class CodeDetailController { + + @Autowired + private CodeDetailService codeDetailService; + + @ApiOperation(value = "菜单按钮列表") + @ApiImplicitParams({ + @ApiImplicitParam(name = "codeType", value = "codeType", required = true, dataType = "String", paramType = "path") + }) + @GetMapping("codeDetail/{codeType}") + public CommonResult> getCodeDetailByCodeType(@PathVariable("codeType") String codeType) { + return CommonResult.success(codeDetailService.selectByCodeType(codeType)); + } +} diff --git a/src/main/java/com/soft/line/controller/CommonController.java b/src/main/java/com/soft/line/controller/CommonController.java new file mode 100644 index 0000000000000000000000000000000000000000..4f603e19b4caf75abb7b8ee704341b6d23554923 --- /dev/null +++ b/src/main/java/com/soft/line/controller/CommonController.java @@ -0,0 +1,83 @@ +package com.soft.line.controller; + +import com.soft.line.entity.*; +import com.soft.line.service.ButtonInfoService; +import com.soft.line.service.CodeDetailService; +import com.soft.line.service.MenuInfoService; +import com.soft.line.service.RoleInfoService; +import com.soft.line.util.exception.CommonResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +@Api( description = "通用接口") +@Slf4j +@RestController +@RequestMapping("/common") +public class CommonController { + + @Autowired + private CodeDetailService codeDetailService; + @Autowired + private ButtonInfoService buttonInfoService; + @Autowired + private MenuInfoService menuInfoService; + @Autowired + private RoleInfoService roleInfoService; + + @ApiOperation(value = "获取枚举值lasCodeItem") + @ApiImplicitParams({ + @ApiImplicitParam(name = "itemTypeId", value = "itemTypeId", required = true, dataType = "String", paramType = "path") + }) + @GetMapping("lasCodeItem/{itemTypeId}") + public CommonResult> getCodeDetailByCodeType(@PathVariable("itemTypeId") String itemTypeId) { + return CommonResult.success(codeDetailService.selectByCodeType(itemTypeId)); + } + + @GetMapping("/buttons") + @ApiOperation(value = "获取所有按钮列表") + public CommonResult> getAllButtons() { + return CommonResult.success(buttonInfoService.selectAll()); + } + + @GetMapping("/topMenu") + @ApiOperation(value = "获取所有顶级菜单") + public CommonResult> getTopMenu() { + return CommonResult.success(menuInfoService.selectTopMenu()); + } + + @GetMapping("/pageMenu") + @ApiOperation(value = "获取所有有操作按钮的页面") + public CommonResult> getAllButtonMenu() { + return CommonResult.success(menuInfoService.selectSonMenus()); + } + + @GetMapping("/roleNames") + @ApiOperation(value = "获取所有角色名") + public CommonResult> getAllRoleInfo() { + return CommonResult.success(roleInfoService.selectAll()); + } + + + @GetMapping("getDepByRole") + @ApiOperation(value = "根据角色获取部门") + public CommonResult> getDepByRole() { + return CommonResult.success(codeDetailService.getDepByRole()); + } + + @GetMapping("/deparments") + @ApiOperation(value = "获取所有部门列表") + public CommonResult> getAllDep() { + return CommonResult.success(codeDetailService.selectAllDep()); + } + +} diff --git a/src/main/java/com/soft/line/controller/ContractInfoController.java b/src/main/java/com/soft/line/controller/ContractInfoController.java new file mode 100644 index 0000000000000000000000000000000000000000..58e5d020be8389474c3c7ca1f4956e754d883e9b --- /dev/null +++ b/src/main/java/com/soft/line/controller/ContractInfoController.java @@ -0,0 +1,109 @@ +package com.soft.line.controller; + +import com.soft.line.entity.ContractInfo; +import com.soft.line.service.CodeDetailService; +import com.soft.line.service.ContractInfoService; +import com.soft.line.util.exception.CommonResult; +import com.soft.line.util.jackson.converter.StringToDateUtil; +import com.soft.line.util.poi.PoiUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @Description 合同相关 + * @author wu.xueqiao on 2020/5/21. + * @version 0.1 + */ +@Api(description = "合同接口") +@Slf4j +@RequestMapping("/dataManage") +@RestController +public class ContractInfoController { + + @Autowired + private ContractInfoService contractInfoService; + @Autowired + private CodeDetailService codeDetailService; + + @PostMapping("/getAllAboutContracts") + public CommonResult getAllAboutContracts(@RequestBody Map map){ + return CommonResult.success(contractInfoService.getAllAboutContracts(map)); + } + + @ApiOperation(value = "获取所有合同", notes = "获取所有合同") + @PostMapping("/contracts") + public CommonResult getAllContracts(@RequestBody Map map){ + return CommonResult.success(contractInfoService.getAllContracts(map)); + } + + @ApiOperation(value = "删除合同", notes = "删除合同") + @DeleteMapping("/contract") + public CommonResult deleteContract(@RequestBody Map map){ + contractInfoService.delete(map); + return CommonResult.success("删除成功"); + } + + @ApiOperation(value = "保存合同", notes = "保存合同") + @PostMapping("/contract") + public CommonResult saveContract(@RequestBody @Validated ContractInfo contractInfo){ + if (contractInfoService.countContractByIdAndName(contractInfo.getId(),contractInfo.getContractName())>0){ + return CommonResult.success("存在相同合同名称","存在相同合同名称"); + } + if (contractInfo.getBeginDate() != null && contractInfo.getEndDate() != null) { + if (contractInfo.getBeginDate().after(contractInfo.getEndDate())) { + return CommonResult.success("起始日期不能>终止日期", "起始日期不能>终止日期"); + } + } + if (contractInfo.getId()==null){ + //添加 + contractInfoService.add(contractInfo); + return CommonResult.success("添加成功"); + }else{ + //修改 + contractInfoService.update(contractInfo); + return CommonResult.success("修改成功"); + } + } + + @ApiOperation(value = "导入合同", notes = "导入合同") + @PostMapping("/contract/import") + public CommonResult importContract(@RequestParam MultipartFile file, HttpServletRequest request) { + if (file == null){ + return CommonResult.success("上传文件不能为空","上传文件不能为空"); + } + String fileName = file.getOriginalFilename(); + if (!fileName.matches("^.+\\.(?i)(xls)$") && !fileName.matches("^.+\\.(?i)(xlsx)$")) { + return CommonResult.success("上传文件格式错误,请上传后缀为.xls或.xlsx的文件","上传文件格式错误,请上传后缀为.xls或.xlsx的文件"); + } + List contractInfoList = null; + Map map = PoiUtils.excel2ContractInfo(file,codeDetailService,contractInfoService); + String warningMsg = (String)map.get("warningMsg"); + if (warningMsg.length()>0){ + //System.out.println("warningMsg:"+warningMsg); + return CommonResult.failed(warningMsg); + }else{ + contractInfoList = (List)map.get("contractInfoList"); + contractInfoService.insertList(contractInfoList); + return CommonResult.success("导入成功"); + } + } + + @ApiOperation(value = "导出合同", notes = "导出合同") + @PostMapping("/contract/export") + public void exportContract(@RequestBody Map map, HttpServletResponse response) { + List contractInfoList = contractInfoService.getAllCNByIDList(map); + PoiUtils.contract2Excel(contractInfoList,response); + } + +} diff --git a/src/main/java/com/soft/line/controller/LasUserInfoController.java b/src/main/java/com/soft/line/controller/LasUserInfoController.java new file mode 100644 index 0000000000000000000000000000000000000000..955efe7f9e2625b90c4f7995fe92e47e3475132a --- /dev/null +++ b/src/main/java/com/soft/line/controller/LasUserInfoController.java @@ -0,0 +1,35 @@ +package com.soft.line.controller; + +import com.soft.line.service.LasUserInfoService; +import com.soft.line.util.exception.CommonResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +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.RestController; + +import java.util.Map; + +@Api(description = "用户相关接口") +@RestController +@RequestMapping("/systemAdmin") +public class LasUserInfoController { + + @Autowired + public LasUserInfoService lasUserInfoService; + + /** + * 获取符合添加用户合同部门关系的用户 + * @return + */ + @ApiOperation(value = "获取符合添加用户合同部门关系的用户", notes = "获取符合添加用户合同部门关系的用户") + @PostMapping("/selectUserInfoForConDep") + public CommonResult selectUserInfoForConDep(){ + return CommonResult.success(lasUserInfoService.selectUserInfoForConDep()); + } +} diff --git a/src/main/java/com/soft/line/controller/LoginController.java b/src/main/java/com/soft/line/controller/LoginController.java new file mode 100644 index 0000000000000000000000000000000000000000..0ced770d7cd8d62574f2a092aa7f469c8797b4d6 --- /dev/null +++ b/src/main/java/com/soft/line/controller/LoginController.java @@ -0,0 +1,66 @@ +package com.soft.line.controller; + + +import com.soft.line.service.LoginService; +import com.soft.line.util.exception.CommonResult; +import com.soft.line.util.exception.ResultData; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.HashMap; +import java.util.Map; + +/** + * @author wu.xueqiao on 2020/5/8. + * @version 0.1 + */ +@Api(description = "登录相关接口") +@Slf4j +@RestController +@RequestMapping("/auth") +public class LoginController { + + @Autowired + private LoginService loginService; + + + @ApiOperation(value = "登录", notes = "登录系统") + @ApiImplicitParams({ + @ApiImplicitParam(paramType = "query", name = "userame", value = "账号", required = false, dataType = "String"), + @ApiImplicitParam(paramType = "query", name = "password", value = "密码", required = false, dataType = "String") + }) + @PostMapping("/login") + public CommonResult loginUserInfo(@RequestBody Map map){ + return loginService.userLogin(map); + } + @ApiOperation(value = "登出", notes = "登出系统") + @ApiImplicitParams({ + }) + @PostMapping("/logout") + public CommonResult exitUser(){ + return loginService.loginOut(); + } + + @PostMapping("/userInfo") + public CommonResult getUserInfo(){ + return CommonResult.success(loginService.getUserPermission()); + } + + @GetMapping("/test") + public CommonResult getStr(){ + return CommonResult.success("abc"); + } + + @PostMapping("/getSupDep") + public CommonResult getSupDep(@RequestBody Map map){ + String depId= (String)map.get("depId"); + return CommonResult.success(loginService.getSupDep(depId)); + } +} + + diff --git a/src/main/java/com/soft/line/controller/MenuInfoController.java b/src/main/java/com/soft/line/controller/MenuInfoController.java new file mode 100644 index 0000000000000000000000000000000000000000..61e2874b1652cfd9ffa0fa7da9da76156a2eb46b --- /dev/null +++ b/src/main/java/com/soft/line/controller/MenuInfoController.java @@ -0,0 +1,117 @@ +package com.soft.line.controller; + +import com.github.pagehelper.PageInfo; +import com.soft.line.entity.ButtonInfo; +import com.soft.line.entity.MenuButtonInfo; +import com.soft.line.entity.MenuInfo; +import com.soft.line.service.ButtonInfoService; +import com.soft.line.service.CodeDetailService; +import com.soft.line.service.MenuInfoService; +import com.soft.line.util.exception.CommonResult; +import com.soft.line.util.exception.ResultData; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.*; + +@Api(description = "菜单接口") +@Slf4j +@RestController +@RequestMapping("/systemAdmin") +public class MenuInfoController { + + @Autowired + private MenuInfoService menuInfoService; + @Autowired + private ButtonInfoService buttonInfoService; + + @PostMapping("/menus") + @ApiOperation(value = "查询所有菜单列表") + public CommonResult getAllMenus(@RequestBody Map map) { + return CommonResult.success(menuInfoService.selectAll(map)); + } + + @GetMapping("/selectALlMenuName") + @ApiOperation(value = "查询所有菜单名称") + public CommonResult> getAllMenuNames() { + return CommonResult.success(menuInfoService.selectALlMenuName()); + } + + @ApiOperation(value = "获取菜单") + @ApiImplicitParams({ + @ApiImplicitParam(name = "menuId", value = "菜单ID", required = true, dataType = "Integer", paramType = "path") + }) + @GetMapping("/getMenu") + public CommonResult getMenuInfoByID(@RequestBody Map map) { + Integer id = (Integer) map.get("id"); + return CommonResult.success(menuInfoService.selectByPrimaryKey(id)); + } + + @ApiOperation(value = "删除菜单") + @DeleteMapping("/menu") + public CommonResult deleteMenu(@RequestBody Map map){ + menuInfoService.delete((Integer) map.get("id")); + return CommonResult.success("删除成功"); + } + + @ApiOperation(value = "保存菜单") + @PostMapping("/menu") + public CommonResult saveMenu(@RequestBody Map map) { + MenuInfo menuInfo = new MenuInfo(); + menuInfo.setId((Integer) map.get("id")); + if (map.get("menuName")==null||"".equals((String)map.get("menuName"))){ + return CommonResult.failed("菜单名称不能为空"); + }else{ + //新增时判断menuName是否重复 + menuInfo.setMenuName(map.get("menuName").toString()); + if (menuInfoService.countMenuName(menuInfo.getId(),menuInfo.getMenuName())>0){ + return CommonResult.failed("菜单名称已存在"); + } + } + + menuInfo.setMenuIcon(map.get("menuIcon")==null?"":map.get("menuIcon").toString()); + menuInfo.setMenuUrl(map.get("menuUrl")==null?"":map.get("menuUrl").toString()); + if (map.get("orderBy")==null){ + return CommonResult.failed("菜单排序不能为空"); + }else{ + menuInfo.setOrderBy((map.get("orderBy")==null?"":map.get("orderBy").toString())); + if (menuInfoService.countOrderBy(menuInfo.getId(),menuInfo.getOrderBy())>0){ + return CommonResult.failed("菜单排序已存在"); + } + } + + //判断父级菜单是否存在 + menuInfo.setpId((Integer) map.get("pId")); + if (menuInfo.getpId()==-1){ + menuInfo.setState(1); + }else { + MenuInfo pMenu = menuInfoService.selectParentMenu(menuInfo.getpId()); + if (pMenu==null){ + return CommonResult.failed("父级菜单不存在"); + } + menuInfo.setState(pMenu.getState()+1); + } + + menuInfo.setModifyTime(new Date()); + menuInfo.setModifyPerson("admin"); + List buttonInfos =new ArrayList(); + for (String buttonId : (List)map.get("buttonList")){ + ButtonInfo buttonInfo = buttonInfoService.selectByButtonId(buttonId); + buttonInfos.add(buttonInfo); + } + menuInfo.setButtonInfoList(buttonInfos); + if(menuInfo.getId()!=null){ + menuInfoService.updateMenInfo(menuInfo); + }else{ + menuInfoService.addMenuInfo(menuInfo); + } + return CommonResult.success("保存菜单成功"); + + } + +} diff --git a/src/main/java/com/soft/line/controller/MpLoginController.java b/src/main/java/com/soft/line/controller/MpLoginController.java new file mode 100644 index 0000000000000000000000000000000000000000..9b5ac210807b113f324af67a9eaa50b324bf5138 --- /dev/null +++ b/src/main/java/com/soft/line/controller/MpLoginController.java @@ -0,0 +1,67 @@ +package com.soft.line.controller; + +import com.soft.line.filter.HttpRequestUtil; +import com.soft.line.filter.UserTokenDto; +import com.soft.line.service.LoginService; +import com.soft.line.util.MP.AjaxResult; +import com.soft.line.util.exception.ResultData; +import io.swagger.models.auth.In; +import org.springframework.beans.factory.annotation.Autowired; +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.RestController; + +import javax.servlet.http.HttpServletRequest; +import java.util.Map; + +/** + * @Description 小程序登录相关 + * @author wu.xueqiao on 2020/6/1. + * @version 0.1 + */ +@RestController +@RequestMapping("/applet") +public class MpLoginController { + + @Autowired + private LoginService loginService; + @Autowired + HttpServletRequest request; + + + @PostMapping("/autoLogin") + public AjaxResult autoLogin(@RequestBody Map map){ + return loginService.autoLogin(map.get("code")); + } + + @PostMapping("/bindUserInfo") + public AjaxResult bindUserInfo(@RequestBody Map paraMap) { + return loginService.bindUserInfo(paraMap); + } + + @PostMapping("/getUserInfo") + public AjaxResult getUserInfo(@RequestBody Map paraMap) { + return loginService.getUserInfo(paraMap); + } + + /** + * 修改密码 + * @param paraMap + * @return + */ + @PostMapping("/updatePassword") + public AjaxResult updatePassword(@RequestBody Map paraMap){ + return loginService.updatePassword(paraMap); + } + + /** + * 解除绑定 + * + * @return + */ + @PostMapping("/untie") + public AjaxResult untie(){ + return loginService.untie(); + } +} diff --git a/src/main/java/com/soft/line/controller/RoleInfoController.java b/src/main/java/com/soft/line/controller/RoleInfoController.java new file mode 100644 index 0000000000000000000000000000000000000000..1a420dd8a53d60bc56b091961160aa15ffe4f002 --- /dev/null +++ b/src/main/java/com/soft/line/controller/RoleInfoController.java @@ -0,0 +1,62 @@ +package com.soft.line.controller; + + +import com.soft.line.service.RoleInfoService; +import com.soft.line.service.UserInfoService; +import com.soft.line.util.exception.CommonResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +@Api(description = "角色接口") +@Slf4j +@RestController +@RequestMapping("/systemAdmin") +public class RoleInfoController { + + @Autowired + private RoleInfoService roleInfoService; + @Autowired + private UserInfoService userInfoService; + + @PostMapping("/roles") + @ApiOperation(value = "获取所有角色列表") + public CommonResult getAllMenus(@RequestBody Map map) { + return CommonResult.success(roleInfoService.selectAllRoleMenuInfo(map)); + } + + @DeleteMapping("/role") + @ApiOperation(value = "删除角色") + public CommonResult deleteRole(@RequestBody Map map) { + roleInfoService.delete(map); + return CommonResult.success("删除成功"); + } + + @PostMapping("/role") + @ApiOperation(value = "保存角色") + public CommonResult saveRole(@RequestBody Map map) { + if (map.get("roleName")==null||"".equals(map.get("roleName"))){ + return CommonResult.success("角色名称不能为空","角色名称不能为空"); + }else if(roleInfoService.countRoleName((Integer)map.get("id"),(String)map.get("roleName")) > 0){ + return CommonResult.success("角色名称已存在","角色名称不能为空"); + } + if (map.get("id")==null){ + //添加 + roleInfoService.add(map); + return CommonResult.success("添加成功"); + }else{ + //修改 + if (userInfoService.countByRoleId((Integer) map.get("id"))>0 && !map.get("state").equals("1")){ + return CommonResult.success("该角色已有用户使用,无法被禁用","该角色已有用户使用,无法被禁用"); + }else{ + roleInfoService.update(map); + return CommonResult.success("修改成功"); + } + } + } +} diff --git a/src/main/java/com/soft/line/controller/StatisticsController.java b/src/main/java/com/soft/line/controller/StatisticsController.java new file mode 100644 index 0000000000000000000000000000000000000000..d21db1d4c5116ebcaf8d213fc3960a645262711a --- /dev/null +++ b/src/main/java/com/soft/line/controller/StatisticsController.java @@ -0,0 +1,92 @@ +package com.soft.line.controller; + +import com.soft.line.service.StatisticsService; +import com.soft.line.util.exception.CommonResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +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.RestController; + +import java.util.Map; + +@Api(description = "统计接口") +@Slf4j +@RequestMapping("/statistics") +@RestController +public class StatisticsController { + + @Autowired + private StatisticsService statisticsService; + + @ApiOperation(value = "统计证书", notes = "统计证书") + @PostMapping("/certificates") + public CommonResult statisticsForCertificate(@RequestBody Map map){ + return CommonResult.success(statisticsService.statisticsForCertificate(map)); + } + + @ApiOperation(value = "年部门合同统计", notes = "年部门合同统计") + @PostMapping("/contracts/countNumGroupByDepThisYear") + public CommonResult countNumGroupByDepThisYear(@RequestBody Map map){ + return CommonResult.success(statisticsService.countNumGroupByDepThisYear(map)); + } + + @ApiOperation(value = "根据部门分组查询历年数量", notes = "根据部门分组查询历年数量") + @PostMapping("/contracts/countDepGroupByYear") + public CommonResult countDepGroupByYear(@RequestBody Map map){ + return CommonResult.success(statisticsService.countDepGroupByYear(map)); + } + + @ApiOperation(value = "合同类型统计", notes = "合同类型统计") + @PostMapping("/contracts/countNumByTypeYear") + public CommonResult countNumByTypeYear(){ + return CommonResult.success(statisticsService.countNumByTypeYear()); + } + + @ApiOperation(value = "合同总金额排行榜", notes = "合同总金额排行榜") + @PostMapping("/contracts/amountRanking") + public CommonResult amountRankingForContract(){ + return CommonResult.success(statisticsService.amountRankingForContract()); + } + + + @ApiOperation(value = "部门合同排行榜", notes = "部门合同排行榜") + @PostMapping("/contracts/depRanking") + public CommonResult depRankingForContract(){ + return CommonResult.success(statisticsService.depRankingForContract()); + } + + + @ApiOperation(value = "今年证书类型排行", notes = "今年证书类型排行") + @PostMapping("/certificates/certTypeRankThisYear") + public CommonResult certTypeRankThisYear(){ + return CommonResult.success(statisticsService.certTypeRankThisYear()); + } + + @ApiOperation(value = "根据年份来统计合同数量", notes = "根据年份来统计合同数量") + @PostMapping("/contracts/sumContractByYear") + public CommonResult sumContractByYear(@RequestBody Map map){ + return CommonResult.success(statisticsService.sumContractByYear(map)); + } + + @ApiOperation(value = "根据年份来统计合同性质", notes = "根据年份来统计合同性质") + @PostMapping("/contracts/sumContractNatureByYear") + public CommonResult sumContractNatureByYear(@RequestBody Map map){ + return CommonResult.success(statisticsService.sumContractNatureByYear(map)); + } + + @ApiOperation(value = "根据部门年份来统计合同性质", notes = "根据部门年份来统计合同性质") + @PostMapping("/contracts/sumContractNatureByYearAndDep") + public CommonResult sumContractNatureByYearAndDep(@RequestBody Map map){ + return CommonResult.success(statisticsService.sumContractNatureByYearAndDep(map)); + } + + @ApiOperation(value = "根据部门统计合同个数", notes = "根据部门统计合同个数") + @PostMapping("/contracts/countNumGroupByDep") + public CommonResult countNumGroupByDep(){ + return CommonResult.success(statisticsService.countNumGroupByDep()); + } +} diff --git a/src/main/java/com/soft/line/controller/UserConDepController.java b/src/main/java/com/soft/line/controller/UserConDepController.java new file mode 100644 index 0000000000000000000000000000000000000000..b3a7955a602bfcb730256a6df83bb82dff4fb88f --- /dev/null +++ b/src/main/java/com/soft/line/controller/UserConDepController.java @@ -0,0 +1,65 @@ +package com.soft.line.controller; + +import com.soft.line.service.CodeDetailService; +import com.soft.line.service.LasUserInfoService; +import com.soft.line.service.UserConDepService; +import com.soft.line.util.exception.CommonResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +@Api(description = "用户合同部门相关接口") +@RestController +@RequestMapping("/systemAdmin") +public class UserConDepController { + + @Autowired + private UserConDepService userConDepService; + + @Autowired + private LasUserInfoService lasUserInfoService; + + @Autowired + private CodeDetailService codeDetailService; + + @PostMapping("/userConDeps") + @ApiOperation(value = "获取所有用户合同部门") + public CommonResult getAllMenus(@RequestBody Map map) { + return CommonResult.success(userConDepService.selectUserConDep(map)); + } + + @DeleteMapping("/userConDep") + @ApiOperation(value = "删除用户合同部门") + public CommonResult deleteRole(@RequestBody Map map) { + userConDepService.delete(map); + return CommonResult.success("删除成功"); + } + + @PostMapping("/userConDep") + @ApiOperation(value = "保存用户合同部门") + public CommonResult saveRole(@RequestBody Map map) { + if (map.get("userId")==null||"".equals(map.get("userId"))) { + return CommonResult.failed("用户名称不能为空!"); + } + // id为空,新增 + if (map.get("id")==null||"".equals(map.get("id"))){ + //新增时判断是否有数据,有则提示并不能新增 + if (userConDepService.exitsUserConDep(map)){ + return CommonResult.failed("该用户已存在配置记录,不能新增!"); + } + } + userConDepService.save(map); + return CommonResult.success("保存成功"); + + } + + @PostMapping("/getConDepByUserId") + @ApiOperation(value = "获取所有用户合同部门") + public CommonResult getConDepByUserId(@RequestBody Map map) { + return CommonResult.success(userConDepService.getConDepByUserId(map)); + } +} diff --git a/src/main/java/com/soft/line/controller/UserInfoController.java b/src/main/java/com/soft/line/controller/UserInfoController.java new file mode 100644 index 0000000000000000000000000000000000000000..895fbcd04be46a199874cffcaf79448a85f4cd44 --- /dev/null +++ b/src/main/java/com/soft/line/controller/UserInfoController.java @@ -0,0 +1,105 @@ +package com.soft.line.controller; + +import com.soft.line.aop.Permission; +import com.soft.line.entity.UserInfo; +import com.soft.line.service.UserInfoService; +import com.soft.line.util.exception.CommonResult; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.Map; + +/** + * @author wu.xueqiao on 2020/5/22. + * @version 0.1 + */ +@Api(description = "用户管理相关接口") +@RestController +@RequestMapping("/systemAdmin") +public class UserInfoController { + + + @Autowired + private UserInfoService userInfoService; + + /** + * 添加&&修改用户 + * @param userInfo + * @return + */ + @ApiOperation(value = "添加&&修改用户", notes = "添加&&修改用户") + @ApiImplicitParams({ + @ApiImplicitParam(paramType = "query", name = "userInfo", value = "账号", required = false, dataType = "com.soft.line.entity.UserInfo"), + }) + @PostMapping("/account") + public CommonResult addUser(@RequestBody @Validated UserInfo userInfo){ + int result=userInfoService.addUser(userInfo); + if(result==1){ + return CommonResult.success("保存成功"); + }else { + return CommonResult.failed(); + } + } + + @ApiOperation(value = "获取用户列表&&模糊查询", notes = "获取用户列表") + @ApiImplicitParams({ + @ApiImplicitParam(paramType = "query", name = "pageSize", value = "页量", required = false, dataType = "java.lang.Integer"), + @ApiImplicitParam(paramType = "query", name = "pageNum", value = "页码", required = false, dataType = "java.lang.Integer"), + @ApiImplicitParam(paramType = "query", name = "map", value = "模糊匹配条件", required = false, dataType = "java.util.Map") + }) + @PostMapping("/accounts") + public CommonResult getAllUsers(@RequestBody Map map){ + return CommonResult.success(userInfoService.getAllUsers(map)); + } + + /** + * @Permission + * @Des 权限判定该 删除操作者 是否具有该权限 + * @param map + * @return + */ + @ApiOperation(value = "删除用户", notes = "删除用户") + @ApiImplicitParams({ + @ApiImplicitParam(paramType = "query", name = "id", value = "userId", required = true, dataType = "java.lang.Integer"), + }) + //@Permission + @DeleteMapping("/account") + public CommonResult delUser(@RequestBody Map map){ + int result=userInfoService.delUser(Integer.valueOf(map.get("id").toString())); + if(result==1){ + return CommonResult.success("删除成功"); + }else { + return CommonResult.failed(); + } + } + @ApiOperation(value = "获取单个用户信息", notes = "获取用户信息") + @ApiImplicitParams({ + @ApiImplicitParam(paramType = "query", name = "id", value = "userId", required = false, dataType = "java.lang.Integer"), + }) + @GetMapping("/accounts") + public CommonResult getUserInfo(@RequestParam("id") int id){ + return CommonResult.success(userInfoService.getUserInfo(id)); + } + + @ApiOperation(value = "修改用户密码", notes = "修改用户密码") + @ApiImplicitParams({ + @ApiImplicitParam(paramType = "query", name = "id", value = "userId", required = true, dataType = "java.lang.Integer"), + @ApiImplicitParam(paramType = "query", name = "oldPassword", value = "oldPassword", required = true, dataType = "java.lang.String"), + @ApiImplicitParam(paramType = "query", name = "newPassword", value = "newPassword", required = true, dataType = "java.lang.String"), + @ApiImplicitParam(paramType = "query", name = "confirmPassword", value = "confirmPassword", required = true, dataType = "java.lang.String") + }) + @PostMapping("/changePassword") + public CommonResult changePassword(@RequestBody Map map){ + Boolean result=userInfoService.changePassword(map); + if(result){ + return CommonResult.success("修改成功"); + }else { + return CommonResult.failed(); + } + } +} diff --git a/src/main/java/com/soft/line/druid/DruidConfig.java b/src/main/java/com/soft/line/druid/DruidConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..21384f22ddd6aef14447a7581311b3199c33a3a3 --- /dev/null +++ b/src/main/java/com/soft/line/druid/DruidConfig.java @@ -0,0 +1,31 @@ +package com.soft.line.druid; + +import com.alibaba.druid.pool.DruidDataSource; +import com.alibaba.druid.support.http.StatViewServlet; +import com.alibaba.druid.support.http.WebStatFilter; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.boot.web.servlet.ServletRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import javax.servlet.FilterRegistration; +import javax.sql.DataSource; +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +/** + * @author wu.xueqiao on 2020/5/11. + * @version 0.1 + */ +@Configuration +public class DruidConfig { + + @ConfigurationProperties(prefix = "spring.datasource") + @Bean + public DataSource druid() { + return new DruidDataSource(); + } +} + diff --git a/src/main/java/com/soft/line/druid/DruidFilter.java b/src/main/java/com/soft/line/druid/DruidFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..84fdeb81e4cd2422bdf20c9776b7a4847c6e17dd --- /dev/null +++ b/src/main/java/com/soft/line/druid/DruidFilter.java @@ -0,0 +1,18 @@ +package com.soft.line.druid; + +import com.alibaba.druid.support.http.WebStatFilter; + +import javax.servlet.annotation.WebFilter; +import javax.servlet.annotation.WebInitParam; + +/** + * @author wu.xueqiao on 2020/5/11. + * @version 0.1 + */ +@WebFilter(filterName="druidWebStatFilter",urlPatterns="/*", + initParams={ + @WebInitParam(name="exclusions",value="*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*")// 忽略资源 + }) +public class DruidFilter extends WebStatFilter { + +} diff --git a/src/main/java/com/soft/line/druid/DruidServlet.java b/src/main/java/com/soft/line/druid/DruidServlet.java new file mode 100644 index 0000000000000000000000000000000000000000..aff64902fbb0fd8f8e4e38a25babcd778f251a8c --- /dev/null +++ b/src/main/java/com/soft/line/druid/DruidServlet.java @@ -0,0 +1,23 @@ +package com.soft.line.druid; + +import com.alibaba.druid.support.http.StatViewServlet; +import org.springframework.context.annotation.Configuration; + +import javax.servlet.annotation.WebInitParam; +import javax.servlet.annotation.WebServlet; + +/** + * @author wu.xueqiao on 2020/5/11. + * @version 0.1 + */ +@WebServlet(urlPatterns = "/druid/*", + initParams={ + @WebInitParam(name="allow",value="127.0.0.1"),// IP白名单 (没有配置或者为空,则允许所有访问) + // @WebInitParam(name="deny",value="192.168.16.111"),// IP黑名单 (存在共同时,deny优先于allow) + @WebInitParam(name="loginUsername",value="admin"),// 用户名 + @WebInitParam(name="loginPassword",value="druid"),// 密码 + @WebInitParam(name="resetEnable",value="false")// 禁用HTML页面上的“Reset All”功能 + }) +public class DruidServlet extends StatViewServlet{ + //页面访问 http://localhost:9100/softline/druid/index.html +} diff --git a/src/main/java/com/soft/line/entity/AppletCertificate.java b/src/main/java/com/soft/line/entity/AppletCertificate.java new file mode 100644 index 0000000000000000000000000000000000000000..e31989e25d10edf41ac8574cf12b741540e0304a --- /dev/null +++ b/src/main/java/com/soft/line/entity/AppletCertificate.java @@ -0,0 +1,62 @@ +package com.soft.line.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.util.Date; +import java.util.List; + +/** + * 小程序校验证书 + * @author wpb + * @version 1.0 + * @date 2020/6/15 16:41 + */ +@Data +public class AppletCertificate { + + private Integer id; + + private String certId; + + @NotBlank + @Size(max = 200) + private String certType; + + @NotBlank + @Size(max = 100) + private String certName; + + /*@NotBlank + @Size(max = 200) + private String projectName;*/ + + @NotBlank + @Size(max = 200) + private String certUnit; + + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date beginDate; + + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date endDate; + + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date issueDate; + + @Size(max = 200) + private String note; + + @NotBlank + private String modifyPerson; + + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date modifyTime; + + private String delFlg; + + private List deleteAttachmentList; +} diff --git a/src/main/java/com/soft/line/entity/AppletContract.java b/src/main/java/com/soft/line/entity/AppletContract.java new file mode 100644 index 0000000000000000000000000000000000000000..3d3074e8bcab6208705245b42dfd6efeff8ce018 --- /dev/null +++ b/src/main/java/com/soft/line/entity/AppletContract.java @@ -0,0 +1,88 @@ +package com.soft.line.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 小程序校验合同 + * @author wpb + * @version 1.0 + * @date 2020/6/15 16:09 + */ +@Data +public class AppletContract { + + private Integer id; + + @NotBlank + private String depId; + + @NotBlank + @Size(max = 200) + private String contractName; + + @NotBlank + private String contractType; + + @Size(max = 50) + private String proId; + + @NotNull + private BigDecimal totalAmount; + + @NotBlank + @Size(max = 100) + private String partA; + + @NotBlank + @Size(max = 100) + private String partB; + + @Size(max = 100) + private String partC; + + @NotNull + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date signTime; + + @NotBlank + @Size(max = 100) + private String signAddr; + + @NotNull + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date beginDate; + + @NotNull + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date endDate; + + @Size(max = 200) + private String payment; + + @Size(max = 1000) + private String note; + + @NotBlank + private String modifyPerson; + + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date modifyTime; + + private String delFlg; + + @NotBlank + private String contractNature; + + @Size(max = 1000) + private String contractContent; + + private List deleteAttachmentList; +} diff --git a/src/main/java/com/soft/line/entity/AttachmentInfo.java b/src/main/java/com/soft/line/entity/AttachmentInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..385bf8ec21e30cb1663dd39923fb6299cbcde213 --- /dev/null +++ b/src/main/java/com/soft/line/entity/AttachmentInfo.java @@ -0,0 +1,79 @@ +package com.soft.line.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; + +public class AttachmentInfo { + + private Integer id; + + private String attachmentName; + + private String attachmentUrl; + + private String modifyPerson; + + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date modifyTime; + + private String type; + + private Integer cId; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getAttachmentName() { + return attachmentName; + } + + public void setAttachmentName(String attachmentName) { + this.attachmentName = attachmentName == null ? null : attachmentName.trim(); + } + + public String getAttachmentUrl() { + return attachmentUrl; + } + + public void setAttachmentUrl(String attachmentUrl) { + this.attachmentUrl = attachmentUrl == null ? null : attachmentUrl.trim();; + } + + public String getModifyPerson() { + return modifyPerson; + } + + public void setModifyPerson(String modifyPerson) { + this.modifyPerson = modifyPerson == null ? null : modifyPerson.trim(); + } + + public Date getModifyTime() { + return modifyTime; + } + + public void setModifyTime(Date modifyTime) { + this.modifyTime = modifyTime; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public Integer getcId() { + return cId; + } + + public void setcId(Integer cId) { + this.cId = cId; + } +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/entity/ButtonInfo.java b/src/main/java/com/soft/line/entity/ButtonInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..f1d81eeeb63d9c7ac715a79f87fdd7912890d45a --- /dev/null +++ b/src/main/java/com/soft/line/entity/ButtonInfo.java @@ -0,0 +1,32 @@ +package com.soft.line.entity; + +public class ButtonInfo { + + private String buttonId; + private String buttonName; + private String buttonType; + + public String getButtonId() { + return buttonId; + } + + public void setButtonId(String buttonId) { + this.buttonId = buttonId; + } + + public String getButtonName() { + return buttonName; + } + + public void setButtonName(String buttonName) { + this.buttonName = buttonName; + } + + public String getButtonType() { + return buttonType; + } + + public void setButtonType(String buttonType) { + this.buttonType = buttonType; + } +} diff --git a/src/main/java/com/soft/line/entity/CertificateInfo.java b/src/main/java/com/soft/line/entity/CertificateInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..fac992215bbcb68038e7ea07a373028dbf7b8b91 --- /dev/null +++ b/src/main/java/com/soft/line/entity/CertificateInfo.java @@ -0,0 +1,61 @@ +package com.soft.line.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.fasterxml.jackson.annotation.JsonInclude; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class CertificateInfo { + + private Integer id; + + @ApiModelProperty(value = "证书ID") + @Length(max = 200,message="证书ID不能大于200位") + private String certId; + + @ApiModelProperty(value = "证书类型") + @NotNull(message = "证书类型不能为空") + private String certType; + + @ApiModelProperty(value = "证书名称") + @NotNull(message = "证书名称不能为空") + @Length(max = 100,message="证书名称不能大于100字") + private String certName; + + @ApiModelProperty(value = "颁发单位") + @NotNull(message = "颁发单位不能为空") + @Length(max = 200,message="颁发单位不能大于200字") + private String certUnit; + + @ApiModelProperty(value = "发证日期") + @JsonFormat(pattern = "yyyyMMdd",timezone = "Asia/Shanghai") + private Date beginDate; + + @ApiModelProperty(value = "到期日期") + @JsonFormat(pattern = "yyyyMMdd",timezone = "Asia/Shanghai") + private Date endDate; + + @Length(max = 200,message="备注不能大于200字") + private String note; + + private String modifyPerson; + + @JsonFormat(pattern = "yyyyMMdd",timezone = "Asia/Shanghai") + private Date modifyTime; + + private String delFlg; + + @ApiModelProperty(value = "颁发日期") + @JsonFormat(pattern = "yyyyMMdd",timezone = "Asia/Shanghai") + private Date issueDate; + +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/entity/CodeDetail.java b/src/main/java/com/soft/line/entity/CodeDetail.java new file mode 100644 index 0000000000000000000000000000000000000000..7d43f46001c860e2c5ac2f560738c91383354109 --- /dev/null +++ b/src/main/java/com/soft/line/entity/CodeDetail.java @@ -0,0 +1,259 @@ +package com.soft.line.entity; + +public class CodeDetail { + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column code_detail.code_type + * + * @mbggenerated + */ + private String codeType; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column code_detail.code_detail + * + * @mbggenerated + */ + private String codeDetail; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column code_detail.code_content1 + * + * @mbggenerated + */ + private String codeContent1; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column code_detail.code_content2 + * + * @mbggenerated + */ + private String codeContent2; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column code_detail.code_content3 + * + * @mbggenerated + */ + private String codeContent3; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column code_detail.code_content4 + * + * @mbggenerated + */ + private String codeContent4; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column code_detail.orderby + * + * @mbggenerated + */ + private Integer orderby; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column code_detail.note + * + * @mbggenerated + */ + private String note; + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column code_detail.code_type + * + * @return the value of code_detail.code_type + * + * @mbggenerated + */ + public String getCodeType() { + return codeType; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column code_detail.code_type + * + * @param codeType the value for code_detail.code_type + * + * @mbggenerated + */ + public void setCodeType(String codeType) { + this.codeType = codeType == null ? null : codeType.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column code_detail.code_detail + * + * @return the value of code_detail.code_detail + * + * @mbggenerated + */ + public String getCodeDetail() { + return codeDetail; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column code_detail.code_detail + * + * @param codeDetail the value for code_detail.code_detail + * + * @mbggenerated + */ + public void setCodeDetail(String codeDetail) { + this.codeDetail = codeDetail == null ? null : codeDetail.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column code_detail.code_content1 + * + * @return the value of code_detail.code_content1 + * + * @mbggenerated + */ + public String getCodeContent1() { + return codeContent1; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column code_detail.code_content1 + * + * @param codeContent1 the value for code_detail.code_content1 + * + * @mbggenerated + */ + public void setCodeContent1(String codeContent1) { + this.codeContent1 = codeContent1 == null ? null : codeContent1.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column code_detail.code_content2 + * + * @return the value of code_detail.code_content2 + * + * @mbggenerated + */ + public String getCodeContent2() { + return codeContent2; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column code_detail.code_content2 + * + * @param codeContent2 the value for code_detail.code_content2 + * + * @mbggenerated + */ + public void setCodeContent2(String codeContent2) { + this.codeContent2 = codeContent2 == null ? null : codeContent2.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column code_detail.code_content3 + * + * @return the value of code_detail.code_content3 + * + * @mbggenerated + */ + public String getCodeContent3() { + return codeContent3; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column code_detail.code_content3 + * + * @param codeContent3 the value for code_detail.code_content3 + * + * @mbggenerated + */ + public void setCodeContent3(String codeContent3) { + this.codeContent3 = codeContent3 == null ? null : codeContent3.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column code_detail.code_content4 + * + * @return the value of code_detail.code_content4 + * + * @mbggenerated + */ + public String getCodeContent4() { + return codeContent4; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column code_detail.code_content4 + * + * @param codeContent4 the value for code_detail.code_content4 + * + * @mbggenerated + */ + public void setCodeContent4(String codeContent4) { + this.codeContent4 = codeContent4 == null ? null : codeContent4.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column code_detail.orderby + * + * @return the value of code_detail.orderby + * + * @mbggenerated + */ + public Integer getOrderby() { + return orderby; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column code_detail.orderby + * + * @param orderby the value for code_detail.orderby + * + * @mbggenerated + */ + public void setOrderby(Integer orderby) { + this.orderby = orderby; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column code_detail.note + * + * @return the value of code_detail.note + * + * @mbggenerated + */ + public String getNote() { + return note; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column code_detail.note + * + * @param note the value for code_detail.note + * + * @mbggenerated + */ + public void setNote(String note) { + this.note = note == null ? null : note.trim(); + } +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/entity/ContractInfo.java b/src/main/java/com/soft/line/entity/ContractInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..00185917a9554ad24d064fab91f4862871fab6d7 --- /dev/null +++ b/src/main/java/com/soft/line/entity/ContractInfo.java @@ -0,0 +1,99 @@ +package com.soft.line.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.DecimalMin; +import javax.validation.constraints.NotNull; +import java.math.BigDecimal; +import java.util.Date; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class ContractInfo { + + private Integer id; + + @ApiModelProperty(value = "部门ID") + @NotNull(message = "部门不能为空") + private String depId; + + @ApiModelProperty(value = "合同名称") + @NotNull(message = "合同名称不能为空") + @Length(max = 100,message="合同名称不能大于100位") + private String contractName; + + @ApiModelProperty(value = "合同类别") + @NotNull(message = "合同类别") + private String contractType; + + @ApiModelProperty(value = "总金额") + @NotNull(message = "总金额不能为空") + private BigDecimal totalAmount; + + @ApiModelProperty(value = "甲方") + @NotNull(message = "甲方不能为空") + @Length(max = 100,message="甲方不能大于100字") + private String partA; + + @ApiModelProperty(value = "乙方") + @NotNull(message = "乙方不能为空") + @Length(max = 100,message="乙方不能大于100字") + private String partB; + + @ApiModelProperty(value = "其他签约方") + @Length(max = 100,message="其他签约方不能大于100字") + private String partC; + + @ApiModelProperty(value = "合同有效日期") + @NotNull(message = "合同有效日期不能为空") + @JsonFormat(pattern = "yyyyMMdd",timezone = "Asia/Shanghai") + private Date signTime; + + @ApiModelProperty(value = "签约地点") + @NotNull(message = "签约地点不能为空") + @Length(max = 100,message="签约地点不能大于100位") + private String signAddr; + + @ApiModelProperty(value = "开始时间") + @NotNull(message = "开始时间不能为空") + @JsonFormat(pattern = "yyyyMMdd",timezone = "Asia/Shanghai") + private Date beginDate; + + @ApiModelProperty(value = "结束时间") + @NotNull(message = "结束时间不能为空") + @JsonFormat(pattern = "yyyyMMdd",timezone = "Asia/Shanghai") + private Date endDate; + + @ApiModelProperty(value = "支付方式") + @NotNull(message = "支付方式不能为空") + private String payment; + + @ApiModelProperty(value = "备注") + @Length(max = 200,message="备注不能大于200字") + private String note; + + private String modifyPerson; + + @JsonFormat(pattern = "yyyyMMdd",timezone = "Asia/Shanghai") + private Date modifyTime; + + private String delFlg; + + @ApiModelProperty(value = "合同性质") + @NotNull(message = "合同性质不能为空") + private String contractNature; + + @ApiModelProperty(value = "项目编号") + @Length(max = 50,message="项目编号不能大于50字") + private String proId; + + @ApiModelProperty(value = "合同内容") + @Length(max = 1000,message="合同内容不能大于1000字") + private String contractContent; +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/entity/LasCodeItem.java b/src/main/java/com/soft/line/entity/LasCodeItem.java new file mode 100644 index 0000000000000000000000000000000000000000..43acf6bebba1db8daba87142ffb1735f46efe4e9 --- /dev/null +++ b/src/main/java/com/soft/line/entity/LasCodeItem.java @@ -0,0 +1,33 @@ +package com.soft.line.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class LasCodeItem { + + @ApiModelProperty(value = "类别ID") + private Long itemTypeId; + + @ApiModelProperty(value = "类别描述") + private String itemTypeDesc; + + @ApiModelProperty(value = "代码项值") + private String itemVal; + + @ApiModelProperty(value = "代码项描述") + private String itemDesc; + + @JsonFormat(pattern = "yyyyMMdd",timezone = "Asia/Shanghai") + private Date createTime; + + @JsonFormat(pattern = "yyyyMMdd",timezone = "Asia/Shanghai") + private Date updateTime; +} diff --git a/src/main/java/com/soft/line/entity/LasDepartmentInfo.java b/src/main/java/com/soft/line/entity/LasDepartmentInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..3cf5c73d75e09fc312442735efaae763d56e5f55 --- /dev/null +++ b/src/main/java/com/soft/line/entity/LasDepartmentInfo.java @@ -0,0 +1,36 @@ +package com.soft.line.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class LasDepartmentInfo { + + private String id; + + // 部门名词 + private String depName; + + // 上级部门ID + private String superiorDepId; + + //公司ID + private String companyId; + + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date createTime; + + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date updateTime; + + //公司ID + private String contractDepId; +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/entity/LasUserInfo.java b/src/main/java/com/soft/line/entity/LasUserInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..92b1ff713aa2b0ff1f1f76b6c2fc1268d5641e64 --- /dev/null +++ b/src/main/java/com/soft/line/entity/LasUserInfo.java @@ -0,0 +1,42 @@ +package com.soft.line.entity; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import java.util.Date; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class LasUserInfo { + + private Integer id; + + @ApiModelProperty(value = "用户名") + private String userName; + + @ApiModelProperty(value = "密码") + private String password; + + @ApiModelProperty(value = "电话") + private String telephone; + + private String lastUpdateUser; + + private Date lastUpdateTime; + + @ApiModelProperty(value = "状态") + private String userStatus; + + @ApiModelProperty(value = "角色") + private Integer roleId; + + @ApiModelProperty(value = "部门ID") + private String depId; + +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/entity/MenuButtonInfo.java b/src/main/java/com/soft/line/entity/MenuButtonInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..b8e1a2f1c3ba570becbb7b1011eda40ee092584f --- /dev/null +++ b/src/main/java/com/soft/line/entity/MenuButtonInfo.java @@ -0,0 +1,168 @@ +package com.soft.line.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; + +public class MenuButtonInfo { + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column menu_button_info.id + * + * @mbggenerated + */ + private Integer id; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column menu_button_info.menu_id + * + * @mbggenerated + */ + private Integer menuId; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column menu_button_info.button_id + * + * @mbggenerated + */ + private String buttonId; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column menu_button_info.modify_person + * + * @mbggenerated + */ + private String modifyPerson; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column menu_button_info.modify_time + * + * @mbggenerated + */ + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date modifyTime; + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column menu_button_info.id + * + * @return the value of menu_button_info.id + * + * @mbggenerated + */ + public Integer getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column menu_button_info.id + * + * @param id the value for menu_button_info.id + * + * @mbggenerated + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column menu_button_info.menu_id + * + * @return the value of menu_button_info.menu_id + * + * @mbggenerated + */ + public Integer getMenuId() { + return menuId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column menu_button_info.menu_id + * + * @param menuId the value for menu_button_info.menu_id + * + * @mbggenerated + */ + public void setMenuId(Integer menuId) { + this.menuId = menuId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column menu_button_info.button_id + * + * @return the value of menu_button_info.button_id + * + * @mbggenerated + */ + public String getButtonId() { + return buttonId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column menu_button_info.button_id + * + * @param buttonId the value for menu_button_info.button_id + * + * @mbggenerated + */ + public void setButtonId(String buttonId) { + this.buttonId = buttonId == null ? null : buttonId.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column menu_button_info.modify_person + * + * @return the value of menu_button_info.modify_person + * + * @mbggenerated + */ + public String getModifyPerson() { + return modifyPerson; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column menu_button_info.modify_person + * + * @param modifyPerson the value for menu_button_info.modify_person + * + * @mbggenerated + */ + public void setModifyPerson(String modifyPerson) { + this.modifyPerson = modifyPerson == null ? null : modifyPerson.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column menu_button_info.modify_time + * + * @return the value of menu_button_info.modify_time + * + * @mbggenerated + */ + public Date getModifyTime() { + return modifyTime; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column menu_button_info.modify_time + * + * @param modifyTime the value for menu_button_info.modify_time + * + * @mbggenerated + */ + public void setModifyTime(Date modifyTime) { + this.modifyTime = modifyTime; + } +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/entity/MenuInfo.java b/src/main/java/com/soft/line/entity/MenuInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..ddd7cf816bbfe0fc11818921ec6cd9b24cdf076a --- /dev/null +++ b/src/main/java/com/soft/line/entity/MenuInfo.java @@ -0,0 +1,55 @@ +package com.soft.line.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotNull; +import java.util.Date; +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class MenuInfo { + + private Integer id; + + private String menuIcon; + + @ApiModelProperty(value = "菜单名") + @NotNull(message = "菜单名不能为空") + @Length(min=4,max = 20,message="菜单名称长度不能小于4位,且不能大于20位") + private String menuName; + + private Integer state; + + @ApiModelProperty(value = "菜单路径") + @NotNull(message = "菜单路径不能为空") + @Length(max =255,message="菜单路径长度不能小于4位,且不能大于20位") + private String menuUrl; + + @ApiModelProperty(value = "菜单排序") + @NotNull(message = "菜单排序不能为空") + private String orderBy; + + private Integer pId; + + private String modifyPerson; + + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date modifyTime; + + private List buttonInfoList; + + public Integer getpId() { + return pId; + } + + public void setpId(Integer pId) { + this.pId = pId; + } +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/entity/RoleInfo.java b/src/main/java/com/soft/line/entity/RoleInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..2d6bff255196d57a9ac9e2c0b5db6be52575ec3a --- /dev/null +++ b/src/main/java/com/soft/line/entity/RoleInfo.java @@ -0,0 +1,31 @@ +package com.soft.line.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotNull; +import java.util.Date; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class RoleInfo { + + private Integer id; + + @NotNull(message = "角色名称不能为空") + @Length(min=2,max=20,message="角色名称不能小于2位,且不能大于20位") + private String name; + + @NotNull(message = "角色状态不能为空") + private String state; + + private String modifyPerson; + + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date modifyTime; + +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/entity/RoleMenu.java b/src/main/java/com/soft/line/entity/RoleMenu.java new file mode 100644 index 0000000000000000000000000000000000000000..37bbf15955e7f0c8998cbcd7a685e8c180bd5226 --- /dev/null +++ b/src/main/java/com/soft/line/entity/RoleMenu.java @@ -0,0 +1,168 @@ +package com.soft.line.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; + +public class RoleMenu { + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column role_menu.id + * + * @mbggenerated + */ + private Integer id; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column role_menu.role_id + * + * @mbggenerated + */ + private Integer roleId; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column role_menu.menu_button_id + * + * @mbggenerated + */ + private Integer menuButtonId; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column role_menu.modify_person + * + * @mbggenerated + */ + private String modifyPerson; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column role_menu.modify_time + * + * @mbggenerated + */ + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date modifyTime; + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column role_menu.id + * + * @return the value of role_menu.id + * + * @mbggenerated + */ + public Integer getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column role_menu.id + * + * @param id the value for role_menu.id + * + * @mbggenerated + */ + public void setId(Integer id) { + this.id = id; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column role_menu.role_id + * + * @return the value of role_menu.role_id + * + * @mbggenerated + */ + public Integer getRoleId() { + return roleId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column role_menu.role_id + * + * @param roleId the value for role_menu.role_id + * + * @mbggenerated + */ + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column role_menu.menu_button_id + * + * @return the value of role_menu.menu_button_id + * + * @mbggenerated + */ + public Integer getMenuButtonId() { + return menuButtonId; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column role_menu.menu_button_id + * + * @param menuButtonId the value for role_menu.menu_button_id + * + * @mbggenerated + */ + public void setMenuButtonId(Integer menuButtonId) { + this.menuButtonId = menuButtonId; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column role_menu.modify_person + * + * @return the value of role_menu.modify_person + * + * @mbggenerated + */ + public String getModifyPerson() { + return modifyPerson; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column role_menu.modify_person + * + * @param modifyPerson the value for role_menu.modify_person + * + * @mbggenerated + */ + public void setModifyPerson(String modifyPerson) { + this.modifyPerson = modifyPerson == null ? null : modifyPerson.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column role_menu.modify_time + * + * @return the value of role_menu.modify_time + * + * @mbggenerated + */ + public Date getModifyTime() { + return modifyTime; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column role_menu.modify_time + * + * @param modifyTime the value for role_menu.modify_time + * + * @mbggenerated + */ + public void setModifyTime(Date modifyTime) { + this.modifyTime = modifyTime; + } +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/entity/UserConDep.java b/src/main/java/com/soft/line/entity/UserConDep.java new file mode 100644 index 0000000000000000000000000000000000000000..4de8ff9e68142dc204786ae3d9e3cfae7a565d9b --- /dev/null +++ b/src/main/java/com/soft/line/entity/UserConDep.java @@ -0,0 +1,39 @@ +package com.soft.line.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotNull; +import java.util.Date; +import java.util.List; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UserConDep { + + private Integer id; + + @ApiModelProperty(value = "用户ID") + private Integer userId; + + @ApiModelProperty(value = "用户ID") + private String userName; + + @ApiModelProperty(value = "合同部门id(item_type_id=101)") + private String contractDepartmentId; + + @ApiModelProperty(value = "修改人") + private String modifyPerson; + + @ApiModelProperty(value = "修改时间") + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date modifyTime; + + @ApiModelProperty(value = "合同部门") + private List depList; +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/entity/UserInfo.java b/src/main/java/com/soft/line/entity/UserInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..8b58b5feee49e3f5adfbe638066879bfea1feba6 --- /dev/null +++ b/src/main/java/com/soft/line/entity/UserInfo.java @@ -0,0 +1,57 @@ +package com.soft.line.entity; + +import io.swagger.annotations.ApiModelProperty; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import java.util.Date; + +@Data +@NoArgsConstructor +@AllArgsConstructor +public class UserInfo { + + private Integer id; + + @ApiModelProperty(value = "用户名") + @NotNull(message = "用户名不能为空") + @Length(min=4,max = 20,message="用户名长度不能小于4位,且不能大于20位") + private String userName; + + @ApiModelProperty(value = "密码") + //@NotNull(message = "密码不能为空") + @Length(min=6,max=32,message="密码长度不能小于6位,且不能大于32位") + private String password; + + @ApiModelProperty(value = "电话") + @NotNull(message = "电话不能为空") + @Pattern(regexp = "1[3|4|5|7|8][0-9]\\d{8}") + private String phone; + + private String modifyPerson; + + private Date modifyTime; + + private String headImgUrl; + + @ApiModelProperty(value = "状态") + @NotNull(message = "状态不能为空") + private String userStatus; + + @ApiModelProperty(value = "角色") + @NotNull(message = "角色不能为空") + private Integer roleId; + + private String salt; + + private String openId; + + @ApiModelProperty(value = "部门ID") + @NotNull(message = "部门ID为空") + private String depId; + +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/entity/UserInfoToken.java b/src/main/java/com/soft/line/entity/UserInfoToken.java new file mode 100644 index 0000000000000000000000000000000000000000..a9482cdb871c9f6be8c1466b8d5c82d7d1c23351 --- /dev/null +++ b/src/main/java/com/soft/line/entity/UserInfoToken.java @@ -0,0 +1,20 @@ +package com.soft.line.entity; + +import lombok.Data; + +/** + * @author wu.xueqiao on 2020/5/12. + * @version 0.1 + */ +@Data +public class UserInfoToken { + + private Integer id; + private String userName; + private String phone; + private int roleId; + private String roleName; + private String password; + + +} diff --git a/src/main/java/com/soft/line/entity/UserPermission.java b/src/main/java/com/soft/line/entity/UserPermission.java new file mode 100644 index 0000000000000000000000000000000000000000..b145312faa5948509016c16d4e8a4f975c7d87fa --- /dev/null +++ b/src/main/java/com/soft/line/entity/UserPermission.java @@ -0,0 +1,37 @@ +package com.soft.line.entity; + +import lombok.Data; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author wu.xueqiao on 2020/6/3. + * @version 0.1 + */ +@Data +public class UserPermission { + + private int id; + + private String userName; + + private String status; + + private String phone; + + private Date modifyTime; + + private String avatar; + + private int roleId; + + private RoleInfo role; + + private LasDepartmentInfo depInfo; + + private List> menuList; + + private List conDepList; +} diff --git a/src/main/java/com/soft/line/entity/WorkJournal.java b/src/main/java/com/soft/line/entity/WorkJournal.java new file mode 100644 index 0000000000000000000000000000000000000000..2932bbae458ac51e53c1b139fc4bdc79884161f3 --- /dev/null +++ b/src/main/java/com/soft/line/entity/WorkJournal.java @@ -0,0 +1,297 @@ +package com.soft.line.entity; + +import com.fasterxml.jackson.annotation.JsonFormat; + +import java.util.Date; + +public class WorkJournal { + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column work_journal.id + * + * @mbggenerated + */ + private Long id; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column work_journal.work_type + * + * @mbggenerated + */ + private String workType; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column work_journal.work_table + * + * @mbggenerated + */ + private String workTable; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column work_journal.work_table_seq + * + * @mbggenerated + */ + private Long workTableSeq; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column work_journal.work_date + * + * @mbggenerated + */ + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date workDate; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column work_journal.note + * + * @mbggenerated + */ + private String note; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column work_journal.modify_person + * + * @mbggenerated + */ + private String modifyPerson; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column work_journal.modify_time + * + * @mbggenerated + */ + @JsonFormat(pattern = "yyyy-MM-dd",timezone = "Asia/Shanghai") + private Date modifyTime; + + /** + * This field was generated by MyBatis Generator. + * This field corresponds to the database column work_journal.db_op_type + * + * @mbggenerated + */ + private String dbOpType; + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column work_journal.id + * + * @return the value of work_journal.id + * + * @mbggenerated + */ + public Long getId() { + return id; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column work_journal.id + * + * @param id the value for work_journal.id + * + * @mbggenerated + */ + public void setId(Long id) { + this.id = id; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column work_journal.work_type + * + * @return the value of work_journal.work_type + * + * @mbggenerated + */ + public String getWorkType() { + return workType; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column work_journal.work_type + * + * @param workType the value for work_journal.work_type + * + * @mbggenerated + */ + public void setWorkType(String workType) { + this.workType = workType == null ? null : workType.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column work_journal.work_table + * + * @return the value of work_journal.work_table + * + * @mbggenerated + */ + public String getWorkTable() { + return workTable; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column work_journal.work_table + * + * @param workTable the value for work_journal.work_table + * + * @mbggenerated + */ + public void setWorkTable(String workTable) { + this.workTable = workTable == null ? null : workTable.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column work_journal.work_table_seq + * + * @return the value of work_journal.work_table_seq + * + * @mbggenerated + */ + public Long getWorkTableSeq() { + return workTableSeq; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column work_journal.work_table_seq + * + * @param workTableSeq the value for work_journal.work_table_seq + * + * @mbggenerated + */ + public void setWorkTableSeq(Long workTableSeq) { + this.workTableSeq = workTableSeq; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column work_journal.work_date + * + * @return the value of work_journal.work_date + * + * @mbggenerated + */ + public Date getWorkDate() { + return workDate; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column work_journal.work_date + * + * @param workDate the value for work_journal.work_date + * + * @mbggenerated + */ + public void setWorkDate(Date workDate) { + this.workDate = workDate; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column work_journal.note + * + * @return the value of work_journal.note + * + * @mbggenerated + */ + public String getNote() { + return note; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column work_journal.note + * + * @param note the value for work_journal.note + * + * @mbggenerated + */ + public void setNote(String note) { + this.note = note == null ? null : note.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column work_journal.modify_person + * + * @return the value of work_journal.modify_person + * + * @mbggenerated + */ + public String getModifyPerson() { + return modifyPerson; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column work_journal.modify_person + * + * @param modifyPerson the value for work_journal.modify_person + * + * @mbggenerated + */ + public void setModifyPerson(String modifyPerson) { + this.modifyPerson = modifyPerson == null ? null : modifyPerson.trim(); + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column work_journal.modify_time + * + * @return the value of work_journal.modify_time + * + * @mbggenerated + */ + public Date getModifyTime() { + return modifyTime; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column work_journal.modify_time + * + * @param modifyTime the value for work_journal.modify_time + * + * @mbggenerated + */ + public void setModifyTime(Date modifyTime) { + this.modifyTime = modifyTime; + } + + /** + * This method was generated by MyBatis Generator. + * This method returns the value of the database column work_journal.db_op_type + * + * @return the value of work_journal.db_op_type + * + * @mbggenerated + */ + public String getDbOpType() { + return dbOpType; + } + + /** + * This method was generated by MyBatis Generator. + * This method sets the value of the database column work_journal.db_op_type + * + * @param dbOpType the value for work_journal.db_op_type + * + * @mbggenerated + */ + public void setDbOpType(String dbOpType) { + this.dbOpType = dbOpType == null ? null : dbOpType.trim(); + } +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/filter/ConfigurationFilter.java b/src/main/java/com/soft/line/filter/ConfigurationFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..02d06abf4051c672d0a6f515773908e78a3fd34b --- /dev/null +++ b/src/main/java/com/soft/line/filter/ConfigurationFilter.java @@ -0,0 +1,149 @@ +package com.soft.line.filter; + +import com.google.gson.Gson; +import org.apache.catalina.filters.RemoteIpFilter; +import org.springframework.boot.web.servlet.FilterRegistrationBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.converter.HttpMessageConverter; +import org.springframework.http.converter.StringHttpMessageConverter; + +import javax.servlet.*; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.nio.charset.Charset; + + +/** + * @author wu.xueqiao on 2020/5/12. + * @version 0.1 + */ +@Configuration +public class ConfigurationFilter { + @Bean + public HttpMessageConverter responseBodyConverter() { + StringHttpMessageConverter converter = new StringHttpMessageConverter( + Charset.forName("UTF-8")); + return converter; + } + + @Bean + public RemoteIpFilter remoteIpFilter() { + return new RemoteIpFilter(); + } + + @Bean + public FilterRegistrationBean testFilterRegistration() { + FilterRegistrationBean registration = new FilterRegistrationBean(); + registration.setFilter(new MyFilter()); + registration.addUrlPatterns("/*"); + registration.addInitParameter("name", "value"); + registration.setName("MyFilter"); + registration.setOrder(1); + return registration; + } + + public class MyFilter implements Filter { + @Override + public void destroy() { + } + + @Override + public void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, + final FilterChain chain) + throws IOException, ServletException { + + final Gson gson = new Gson(); + //final ResultData rd = new ResultData(); + final ResponseWrapper responseWrapper=new ResponseWrapper(); + final HttpServletRequest request = (HttpServletRequest) servletRequest; + final HttpServletResponse response = (HttpServletResponse) servletResponse; + response.setHeader("Access-Control-Allow-Origin", "*"); + response.setHeader("Access-Control-Allow-Methods", "POST,GET,PUT,OPTIONS,DELETE"); + response.setHeader("Access-Control-Max-Age", "3600"); + response.setHeader("Access-Control-Allow-Headers", "Origin,X-Requested-With,Content-Type,Accept,Access-Token,token"); + final String uri = request.getRequestURI(); + String auth = request.getHeader("Access-Token"); + Token token = null; + if (!uri.contains("/")) { + //if (!uri.contains("/login")&&!uri.contains("/autoLogin") && !uri.contains("/bindUserInfo") && !uri.contains("/uploadContractAttach") && !uri.contains("/uploadCertificateAttach") && !uri.contains("/uploadFiles") ) { + if (auth == null || "".equals(auth)) { + if (uri.contains("/file/download/")) { + auth = request.getParameter("token"); + if (auth == null || "".equals(auth)) { + response.setContentType("application/json"); + response.setCharacterEncoding("UTF-8"); + //rd.setMsg("Authentication Failed: Require Authorization"); + responseWrapper.failure(StatusCode.SC_10000.val(),"Authentication Failed: Require Authorization"); + //rd.setStatus("10000"); + final String write = gson.toJson(responseWrapper); + response.getWriter().write(write); + return; + } + } else { + response.setContentType("application/json"); + response.setCharacterEncoding("UTF-8"); + //rd.setMsg("Authentication Failed: Require Authorization"); + responseWrapper.failure(StatusCode.SC_10000.val(),"Authentication Failed: Require Authorization"); + //rd.setStatus("10000"); + final String write = gson.toJson(responseWrapper); + response.getWriter().write(write); + return; + } + } + token = new Token(auth); + if (token.getErr() == Token.ExpiredJwtError) { + response.setContentType("application/json"); + response.setCharacterEncoding("UTF-8"); + //rd.setMsg("Authentication Failed: 认证过期"); + responseWrapper.failure(StatusCode.SC_10001.val(),"Authentication Failed: 认证过期"); + // rd.setStatus("10000"); + final String write = gson.toJson(responseWrapper); + response.getWriter().write(write); + return; + } + if (token.getErr() == Token.SignatureError) { + response.setContentType("application/json"); + response.setCharacterEncoding("UTF-8"); + //rd.setMsg("Authentication Failed: 非法认证"); + responseWrapper.failure(StatusCode.SC_10002.val(),"Authentication Failed: 非法认证"); + + //rd.setStatus("10000"); + final String write = gson.toJson(responseWrapper); + response.getWriter().write(write); + return; + } + if (HttpRequestUtil.REDIS_SERVICE.getKeyValue(token.getUsername()) == null + || "".equals(HttpRequestUtil.REDIS_SERVICE.getKeyValue(token.getUsername()))) { + response.setContentType("application/json"); + response.setCharacterEncoding("UTF-8"); + //rd.setMsg("会话过期,请重新登录"); + responseWrapper.failure(StatusCode.SC_10003.val(),"会话过期,请重新登录"); + //rd.setStatus("10000"); + final String write = gson.toJson(responseWrapper); + response.getWriter().write(write); + return; + } + HttpRequestUtil.REDIS_SERVICE.setKeyTimeout(token.getUsername(), HttpRequestUtil.expire); + } + try { + chain.doFilter(request, response); + } catch (final Exception e) { + System.out.println(e.toString()); + response.setContentType("application/json"); + response.setCharacterEncoding("UTF-8"); + //rd.setMsg("服务器异常"); + responseWrapper.failure(StatusCode.SC_500.val(),"请求失败"); + //rd.setStatus("10001"); + final String write = gson.toJson(responseWrapper); + response.getWriter().write(write); + return; + } + } + + @Override + public void init(FilterConfig arg0) throws ServletException { + } + } +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/filter/GlobalApplicationContextHolder.java b/src/main/java/com/soft/line/filter/GlobalApplicationContextHolder.java new file mode 100644 index 0000000000000000000000000000000000000000..b855667afe61f1768782f4395f8858d314b44d9c --- /dev/null +++ b/src/main/java/com/soft/line/filter/GlobalApplicationContextHolder.java @@ -0,0 +1,71 @@ +package com.soft.line.filter; + +import org.springframework.context.ApplicationContext; +import org.springframework.context.ApplicationContextAware; +import org.springframework.stereotype.Component; + +import java.util.Map; + +@Component +public class GlobalApplicationContextHolder implements ApplicationContextAware { + + private static ApplicationContext context; + + /** + *

because the ApplicationContextAware interface is implemented,

+ *

when it is configured as bean, it will automatically injecting ApplicationContext.

+ */ + @Override + public void setApplicationContext(final ApplicationContext applicationContext) { + setAppContext(applicationContext); + } + + /** + * provide a static method for setting up ApplicationContext. + * + * @param applicationContext + */ + public static void setAppContext(final ApplicationContext applicationContext) { + context = applicationContext; + } + + /** + * static method to obtain ApplicationContext + * + * @return + */ + public static ApplicationContext getApplicationContext() { + return context; + } + + /** + * get bean based on the bean name. + * + * @param name + * + * @return + */ + public static Object getBean(final String name) { + return getApplicationContext().getBean(name); + } + + /** + * get bean (generic) according to Class. + * + * @param clazz + * @return + */ + public static T getBean(final Class clazz) { + return getApplicationContext().getBean(clazz); + } + + /** + * get all the bean to implement an interface based on Class. + * + * @param clazz + * @return + */ + public static Map getBeansOfType(final Class clazz) { + return getApplicationContext().getBeansOfType(clazz); + } +} diff --git a/src/main/java/com/soft/line/filter/GsonUtil.java b/src/main/java/com/soft/line/filter/GsonUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..901b3051743af975baffd2f6e54608f906e6f464 --- /dev/null +++ b/src/main/java/com/soft/line/filter/GsonUtil.java @@ -0,0 +1,19 @@ +package com.soft.line.filter; + + +import com.google.gson.Gson; + +public class GsonUtil { + public static String javabeanToJson(final UserTokenDto user) { + final Gson gson = new Gson(); + final String json = gson.toJson(user); + return json; + } + + public static UserTokenDto jsonToJavaBean(final String json) { + final Gson gson = new Gson(); + final UserTokenDto user = gson.fromJson(json, UserTokenDto.class); + return user; + } + +} diff --git a/src/main/java/com/soft/line/filter/HttpRequestUtil.java b/src/main/java/com/soft/line/filter/HttpRequestUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..e2a57f269412bce8a15bc99d3be1cc5a5a7a6cb4 --- /dev/null +++ b/src/main/java/com/soft/line/filter/HttpRequestUtil.java @@ -0,0 +1,53 @@ +package com.soft.line.filter; + + +import com.soft.line.util.redis.RedisClient; +import org.springframework.web.context.request.RequestAttributes; +import org.springframework.web.context.request.RequestContextHolder; +import org.springframework.web.context.request.ServletRequestAttributes; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpSession; +import java.util.Enumeration; +import java.util.HashMap; +import java.util.Map; + + +public class HttpRequestUtil { + public static final RedisClient REDIS_SERVICE = (RedisClient) GlobalApplicationContextHolder.getApplicationContext() + .getBean("redisClient"); + + public static final String key = "SOFTLINE-BUILD"; + // 过期时间设置为 15 min + public static final Integer expire = 60*15; + + public static UserTokenDto getUserToken() { + + final RequestAttributes ra = RequestContextHolder.getRequestAttributes(); + final ServletRequestAttributes sra = (ServletRequestAttributes) ra; + final HttpServletRequest request = sra.getRequest(); + //HttpSession session=request.getSession(); + final Map map = getHeadersInfo(request); + String token = map.get("access-token"); + if (token == null || "".equals(token)) { + token = request.getParameter("token"); + } + final Token tokenInfo = new Token(token); + String json = null; + + json = REDIS_SERVICE.getKeyValue(tokenInfo.getUsername()); + + return GsonUtil.jsonToJavaBean(json); + } + + private static Map getHeadersInfo(final HttpServletRequest request) { + final Map map = new HashMap(); + final Enumeration headerNames = request.getHeaderNames(); + while (headerNames.hasMoreElements()) { + final String key = headerNames.nextElement(); + final String value = request.getHeader(key); + map.put(key, value); + } + return map; + } +} diff --git a/src/main/java/com/soft/line/filter/ResponseWrapper.java b/src/main/java/com/soft/line/filter/ResponseWrapper.java new file mode 100644 index 0000000000000000000000000000000000000000..e3ca08d0fefe728d551329694e8be0675a2ad741 --- /dev/null +++ b/src/main/java/com/soft/line/filter/ResponseWrapper.java @@ -0,0 +1,84 @@ +package com.soft.line.filter; + + + +import java.io.Serializable; +import java.util.HashMap; +import java.util.Map; + + +public class ResponseWrapper implements Serializable { + + private static final String OK = "OK"; + private static final String ERROR = "Error"; + private static final String BOOL_RES_KEY = "result"; + private ResponseWrapper.Meta meta; + private Object data; + + public ResponseWrapper() { + } + + public ResponseWrapper success(String code) { + return this.success(code, new HashMap(0)); + } + + public ResponseWrapper success(String code, Object data) { + this.meta = new ResponseWrapper.Meta(code, "OK"); + this.data = data != null ? data : new HashMap(0); + return this; + } + + public static ResponseWrapper successRespForBool(boolean result) { + ResponseWrapper dr = new ResponseWrapper(); + Map res = new HashMap(); + res.put("result", result); + dr.success(StatusCode.SC_200.val(), res); + return dr; + } + + public static ResponseWrapper successRespForVoid() { + ResponseWrapper dr = new ResponseWrapper(); + dr.success(StatusCode.SC_200.val()); + return dr; + } + + public ResponseWrapper failure(String code) { + return this.failure(code, "Error"); + } + + public ResponseWrapper failure(String code, String message) { + this.meta = new ResponseWrapper.Meta(code, message); + this.data = new HashMap(0); + return this; + } + + public ResponseWrapper.Meta getMeta() { + return this.meta; + } + + public Object getData() { + return this.data; + } + + public static class Meta implements Serializable { + private String code; + private String message; + + public Meta(String code) { + this(code, ""); + } + + public Meta(String code, String message) { + this.code = code; + this.message = message; + } + + public String getCode() { + return this.code; + } + + public String getMessage() { + return this.message; + } + } +} diff --git a/src/main/java/com/soft/line/filter/StatusCode.java b/src/main/java/com/soft/line/filter/StatusCode.java new file mode 100644 index 0000000000000000000000000000000000000000..afad865709fd224b0aaa4bda711d35f98a7670fd --- /dev/null +++ b/src/main/java/com/soft/line/filter/StatusCode.java @@ -0,0 +1,63 @@ +package com.soft.line.filter; + +public enum StatusCode { + + SC_200("SC_200"), + SC_201("SC_201"), + SC_400("SC_400"), + SC_401("SC_401"), + SC_404("SC_404"), + SC_405("SC_405"), + SC_422("SC_422"), + SC_500("SC_500"), + SC_10000("SC_10000"), + SC_10001("SC_10001"), + SC_10002("SC_10002"), + SC_10004("SC_10004"), + SC_10003("SC_10003"); + + + + private String code; + + private StatusCode(String code) { + this.code = code; + } + + public String val() { + return this.code; + } + + public static StatusCode valueOf(int code) { + switch (code) { + case 200: + return SC_200; + case 201: + return SC_201; + case 400: + return SC_400; + case 401: + return SC_401; + case 404: + return SC_404; + case 405: + return SC_405; + case 422: + return SC_422; + case 500: + return SC_500; + case 10000: + return SC_10000; + case 10001: + return SC_10001; + case 10002: + return SC_10002; + case 10003: + return SC_10003; + case 10004: + return SC_10004; + default: + return SC_500; + } + } +} diff --git a/src/main/java/com/soft/line/filter/Token.java b/src/main/java/com/soft/line/filter/Token.java new file mode 100644 index 0000000000000000000000000000000000000000..1dfdc5e87611ee97b38ab5c8fcde5fc0b7d6f92e --- /dev/null +++ b/src/main/java/com/soft/line/filter/Token.java @@ -0,0 +1,74 @@ +package com.soft.line.filter; + +import com.soft.line.auth.AuthConstant; +import com.soft.line.auth.Md5Util; +import com.soft.line.entity.UserInfo; +import io.jsonwebtoken.*; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.StringUtils; + +/** + * @author wu.xueqiao on 2020/5/12. + * @version 0.1 + */ +public class Token { + + private String account; + + private String username; + + + + private int err = 0; + + public static final int ExpiredJwtError = 1; + + public static final int SignatureError = 2; + + public Token(final String token) { + try { +// if (StringUtils.isEmpty(token) || token.length() < AuthConstant.TOKEN_MD5_LENGTH) { +// return null; +// } + String base64Token = token.substring(0, token.length() - AuthConstant.TOKEN_MD5_LENGTH); +// if (!token.toUpperCase().endsWith(Md5Util.encodeMd5(base64Token + AuthConstant.SAFE_STRING).toUpperCase())) { +// return null; +// } + String tokenPlainText = new String(Base64.decodeBase64(base64Token)); + tokenPlainText = tokenPlainText.substring(AuthConstant.USER_TOKEN_PREFIX.length()); + String[] arr = tokenPlainText.split("-"); +// if (arr.length < 4 - 1) { +// return null; +// } + +// UserToken userToken = new UserToken(); + UserInfo user = new UserInfo(); + user.setId(Integer.valueOf(arr[0])); + user.setUserName(arr[1]); + + this.username = arr[1]; + } catch (final ExpiredJwtException e) { + this.err = ExpiredJwtError; + } catch (final SignatureException e) { + this.err = SignatureError; + } + } + + public String getAccount() { + + return account; + } + + + public String getUsername() { + + return username; + } + + + public int getErr() { + + return err; + } + +} diff --git a/src/main/java/com/soft/line/filter/UserTokenDto.java b/src/main/java/com/soft/line/filter/UserTokenDto.java new file mode 100644 index 0000000000000000000000000000000000000000..bf738bad560e60a3428c108c781443d6115ae2d9 --- /dev/null +++ b/src/main/java/com/soft/line/filter/UserTokenDto.java @@ -0,0 +1,19 @@ +package com.soft.line.filter; + +import com.soft.line.entity.UserInfoToken; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; +import java.util.Map; + + +@Data +public class UserTokenDto implements Serializable { + + private UserInfoToken userInfo; + + private String token; + + +} diff --git a/src/main/java/com/soft/line/mapper/AppletCertificateMapper.java b/src/main/java/com/soft/line/mapper/AppletCertificateMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..904027fb983e0bece70864acd6b76d0cec2059da --- /dev/null +++ b/src/main/java/com/soft/line/mapper/AppletCertificateMapper.java @@ -0,0 +1,130 @@ +package com.soft.line.mapper; + +import com.soft.line.entity.AppletCertificate; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * 小程序 证书 + * + * @author wpb + * @version 1.0 + * @date 2020/6/3 15:46 + */ +public interface AppletCertificateMapper { + + /** + * 获取每个部门的证书总数 + * + * @return + */ + List> getCertificateNum(); + + /** + * 根据证书类型获取证书年列表数据 + * + * @param certType 参数 + * @return + */ + List> getCertificateYearList(@Param(value = "certType") String certType); + + /** + * 根据证书类型cert_type和起始日期年份以及当前页、每页显示条数分页查询证书年列表 + * + * @param paramMap 参数 + * @return + */ + List> getCertificateList(Map paramMap); + + /** + * 根据证书类型cert_type和起始日期年份以及当前页、每页显示条数分页查询证书年列表 + * 符合条件的 总数 + * + * @param paramMap 参数 + * @return + */ + int countCertificateList(Map paramMap); + + /** + * 根据id查询详情 + * + * @param paramMap 参数 + * @return + */ + Map getCertificate(Map paramMap); + + /** + * 修改证书 + * + * @param appletCertificate 参数 + * @return + */ + int updateCertificate(AppletCertificate appletCertificate); + + /** + * 根据证书编号和!id,校验证书编号是否重复 + * + * @param certId 证书编号 + * @param id id + * @return + */ + int checkCertificateByCertIdAndId(String certId, int id); + + /** + * 删除证书 + * + * @param paramMap 参数 + * @return + */ + int deleteCertificate(Map paramMap); + + /** + * 根据证书名称分页模糊查询证书列表 + * + * @param paramMap 参数 + * @return + */ + List> getCertificateSearchList(Map paramMap); + + /** + * 根据证书名称模糊查询证书列表总数 + * + * @param paramMap 参数 + * @return + */ + int countGetCertificateSearchList(Map paramMap); + + /** + * 新增证书 + * + * @param appletCertificate 参数 + * @return + */ + int addCertificate(AppletCertificate appletCertificate); + + /** + * 校验 证书编号是否存在 + * + * @param certId 证书编号 + * @return + */ + int checkCertificateByCertId(@Param(value = "certId") String certId); + + /** + * 根据证书详情信息分页查询证书列表 + * + * @param paramMap 参数 + * @return + */ + List> getContractQueryList(Map paramMap); + + /** + * 根据证书详情信息查询证书列表 求和 + * + * @param paramMap 参数 + * @return + */ + int countGetContractQueryList(Map paramMap); +} diff --git a/src/main/java/com/soft/line/mapper/AppletCertificateMapper.xml b/src/main/java/com/soft/line/mapper/AppletCertificateMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..af5773328a5627c65948ca07fa6e8376d0ae7d12 --- /dev/null +++ b/src/main/java/com/soft/line/mapper/AppletCertificateMapper.xml @@ -0,0 +1,253 @@ + + + + + + + + + + + + + + + + UPDATE certificate_info + SET cert_id = #{certId}, + cert_type = #{certType}, + cert_name = #{certName}, + issue_date = #{issueDate}, + cert_unit = #{certUnit}, + begin_date = #{beginDate}, + end_date = #{endDate}, + + note = #{note}, + + modify_person = #{modifyPerson}, + modify_time = NOW() + WHERE + id = #{id} + + + + + + update certificate_info + set modify_person = #{modifyPerson}, + modify_time = #{modifyTime}, + del_flg = '1' + where id = #{id} + + + + + + + + INSERT INTO certificate_info ( + cert_id, + cert_type, + cert_name, + issue_date, + cert_unit, + begin_date, + end_date, + + note, + + modify_person, + modify_time, + del_flg + ) + VALUES + ( + #{certId}, + #{certType}, + #{certName}, + #{issueDate}, + #{certUnit}, + #{beginDate}, + #{endDate}, + + #{note}, + + #{modifyPerson}, + NOW(), + '0' + ) + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/AppletCommonMapper.java b/src/main/java/com/soft/line/mapper/AppletCommonMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..54eea38e5b3c4f5cb14f1986d9e481c031bfb56f --- /dev/null +++ b/src/main/java/com/soft/line/mapper/AppletCommonMapper.java @@ -0,0 +1,71 @@ +package com.soft.line.mapper; + +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * 小程序公用 + * + * @author wpb + * @version 1.0 + * @date 2020/6/1 9:16 + */ +public interface AppletCommonMapper { + /** + * 枚举数据 + * + * @return + */ + List> codeDetailMap(); + + /** + * 根据 (类型)code_type 查询 (代码序号)code_detail + * @param codeType 部门类型 + * @return + */ + List codeDetailList(String codeType); + + /** + * 添加附件 + * + * @param attachmentName 名称 + * @param attachmentUrl 地址 + * @param modifyPerson 添加人 + * @param modifyTime 时间 + * @param type 类型 + * @param cId 对应的id + * @return + */ + int addAnnex(@Param(value = "attachmentName") String attachmentName, @Param(value = "attachmentUrl") String attachmentUrl, + @Param(value = "modifyPerson") String modifyPerson, @Param(value = "modifyTime") Date modifyTime, + @Param(value = "type") String type, @Param(value = "cId") int cId); + + /** + * 根据 cid 和 类型 查询 附件 + * + * @param cId + * @param type + * @return + */ + List> getAnnexes(@Param(value = "cId") int cId, @Param(value = "type") String type); + + /** + * 根据id删除附件 + * + * @param id + * @return + */ + int delAnnex(int id); + + /** + * 批量删除 + * + * @param ids + */ + void delAnnexList(List ids); + + +} diff --git a/src/main/java/com/soft/line/mapper/AppletCommonMapper.xml b/src/main/java/com/soft/line/mapper/AppletCommonMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..0cc8c0337f7d187dc1f44e41f004e468f363f40a --- /dev/null +++ b/src/main/java/com/soft/line/mapper/AppletCommonMapper.xml @@ -0,0 +1,43 @@ + + + + + + + + + + insert into attachment_info( + attachment_name,attachment_url,modify_person,modify_time,type,c_id + )value ( + #{attachmentName},#{attachmentUrl},#{modifyPerson},#{modifyTime},#{type},#{cId} + ) + + + + + + delete from attachment_info where id = #{id} + + + + delete from attachment_info where id in + + #{id} + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/AppletContractMapper.java b/src/main/java/com/soft/line/mapper/AppletContractMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..d67a3449c6aff6fe737f21194d7cd74b6427ec38 --- /dev/null +++ b/src/main/java/com/soft/line/mapper/AppletContractMapper.java @@ -0,0 +1,156 @@ +package com.soft.line.mapper; + +import com.soft.line.entity.AppletContract; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +/** + * 小程序合同mapper + * + * @author wpb + * @version 1.0 + * @date 2020/5/26 15:49 + */ +public interface AppletContractMapper { + + /** + * 查询每个部门的合同总数 + * + * @return + */ + List> contractNum(); + + + /** + * 根据部门id获取合同年列表数据 + * + * @param paraMap + * @return + */ + List> getContractYearList(Map paraMap); + + /** + * 根据部门id和签订年份分页查询合同列表 + * + * @param paraMap + * @return + */ + List> getContractList(Map paraMap); + + /** + * 合同根据id和所在年计数 + * @param depId + * @param signTime + * @return + */ + int countContractList(@Param(value = "depId") String depId,@Param(value = "signTime") String signTime); + + + /** + * 根据合同名称分页模糊查询合同列表 + * + * @param paraMap + * @return + */ + List> getContractSearchList(Map paraMap); + + /** + * 根据 合同名称模糊查询 个数 + * @param contractName + * @return + */ + int countContractSearchList(String contractName); + + + /** + * 根据合同详情信息分页查询合同列表 + * + * @param paraMap + * @return + */ + List> getContractQueryList(Map paraMap); + + /** + * 根据 合同信息 模糊查询 + * @param paraMap + * @return + */ + int countContractQueryList(Map paraMap); + + /** + * 添加合同 + * + * @param appletContract + * @return + */ + int addContract(AppletContract appletContract); + + /** + * 修改合同 + * + * @param appletContract 参数 + * @return + */ + int updateContract(AppletContract appletContract); + + /** + * 通过id,查询部门详情 + * + * @param paraMap + * @return + */ + Map getContract(Map paraMap); + + /** + * 根据id删除合同 + * + * @param paraMap + * @return + */ + int deleteContract(Map paraMap); + + /** + * 根据合同名称,校验合同是否存在 + * + * @param contractName + * @return + */ + int checkContractByName(String contractName); + + /** + * 根据合同名称 and id 判断合同 是否 存在 + * + * @param contractName + * @param id + * @return + */ + int checkContractByNameAndId(@Param(value = "contractName") String contractName, @Param(value = "id") int id); + + /** + * 通过proId 查询相关的支出合同 + */ + List> getAboutAllZCContracts(Map paraMap); + /** + * 查询相关的协议 + */ + List> getAboutAllXYContracts(Map paraMap); + + /** + * 通过id查询相关合同性质 + */ + List> getAboutContractNatureByIdList(Map paraMap,@Param("idList")List idList); + + /** + * 通过ID查询相关合同 + */ + List> getAboutAllContractsByIdList(Map paraMap); + + /** + * 获取用户的合同部门 + * + * @return + */ + List> getUserContDep(@Param("userId") int userId); +} diff --git a/src/main/java/com/soft/line/mapper/AppletContractMapper.xml b/src/main/java/com/soft/line/mapper/AppletContractMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..53cbc27f22e4aaa217bd3d6d1d4def4537a74d83 --- /dev/null +++ b/src/main/java/com/soft/line/mapper/AppletContractMapper.xml @@ -0,0 +1,342 @@ + + + + + + + + + + + + + + + + + + + + + + insert into `contract_info` (`dep_id`, `contract_name`, `contract_type`, `pro_id`, + `total_amount`, `part_a`, `part_b`, `part_c`, + `sign_time`, `sign_addr`, `begin_date`, + `end_date`, `payment`, + + `note`, + + `modify_person`, `modify_time`, `del_flg`, + `contract_nature`,`contract_content` + ) + values (#{depId,jdbcType=DECIMAL}, #{contractName,jdbcType=VARCHAR}, #{contractType,jdbcType=VARCHAR}, #{proId,jdbcType=VARCHAR}, + #{totalAmount,jdbcType=DECIMAL}, #{partA,jdbcType=VARCHAR}, #{partB,jdbcType=VARCHAR},#{partC,jdbcType=VARCHAR}, + #{signTime,jdbcType=TIMESTAMP}, #{signAddr,jdbcType=VARCHAR}, #{beginDate,jdbcType=TIMESTAMP}, + #{endDate,jdbcType=TIMESTAMP}, #{payment,jdbcType=VARCHAR}, + + #{note,jdbcType=VARCHAR}, + + #{modifyPerson,jdbcType=VARCHAR}, NOW(), '0', + #{contractNature,jdbcType=VARCHAR}, #{contractContent,jdbcType=VARCHAR} + ) + + + + + UPDATE contract_info set + dep_id = #{depId} , + contract_name = #{contractName} , + contract_type = #{contractType} , + pro_id = #{proId} , + total_amount = #{totalAmount} , + part_a = #{partA} , + part_b = #{partB} , + part_c = #{partC} , + sign_time = #{signTime} , + sign_addr = #{signAddr} , + begin_date = #{beginDate} , + end_date = #{endDate} , + payment = #{payment} , + + note = #{note} , + + contract_nature = #{contractNature}, + contract_content = #{contractContent}, + modify_person = #{modifyPerson} , + modify_time = NOW() + where id = #{id} + + + + + + update contract_info set modify_person = #{modifyPerson} , del_flg = '1' , modify_time = NOW() where id = #{id} + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/AttachmentInfoMapper.java b/src/main/java/com/soft/line/mapper/AttachmentInfoMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..473a0e8281c33e35bde64cf77e380d306cec8b4c --- /dev/null +++ b/src/main/java/com/soft/line/mapper/AttachmentInfoMapper.java @@ -0,0 +1,32 @@ +package com.soft.line.mapper; + + +import com.soft.line.entity.AttachmentInfo; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +public interface AttachmentInfoMapper { + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table attachment_info + * + * @mbggenerated + */ + int insert(AttachmentInfo record); + + int delete(@Param("attachmentType") String attachmentType,@Param("cId") Integer cId); + + int deleteFileRecord(AttachmentInfo record); + + int deleteFileMap(Map map); + + AttachmentInfo selectByPrimaryKey(Integer id); + + List selectAll(@Param("attachmentType") String attachmentType,@Param("cId") Integer cId); + + List selectAllByTypeAndName(@Param("attachmentType") String attachmentType,@Param("attachmentName") String attachmentName); + +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/AttachmentInfoMapper.xml b/src/main/java/com/soft/line/mapper/AttachmentInfoMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..7830d8d09b6854fb8dc7c8d772dd286de9760876 --- /dev/null +++ b/src/main/java/com/soft/line/mapper/AttachmentInfoMapper.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + insert into `attachment_info` (`attachment_name`, `attachment_url`, `modify_person`, + `modify_time`,`type`,`c_id`) + values (#{attachmentName,jdbcType=VARCHAR}, #{attachmentUrl,jdbcType=VARCHAR}, #{modifyPerson,jdbcType=VARCHAR}, + #{modifyTime,jdbcType=TIMESTAMP},#{type,jdbcType=VARCHAR},#{cId,jdbcType=INTEGER}) + + + + delete from `attachment_info` where `type` = #{attachmentType} and `c_id` = #{cId} + + + + delete from `attachment_info` where `type` = #{type} and `c_id` = #{cId} and `attachment_name` = #{attachmentName} + + + + delete from `attachment_info` where `type` = #{type} and `c_id` = #{cId} and `id` = #{id} + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/ButtonInfoMapper.java b/src/main/java/com/soft/line/mapper/ButtonInfoMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..660308998795e542377cefd1aa3ec0fee7d0f81f --- /dev/null +++ b/src/main/java/com/soft/line/mapper/ButtonInfoMapper.java @@ -0,0 +1,20 @@ +package com.soft.line.mapper; + +import com.soft.line.entity.ButtonInfo; +import com.soft.line.entity.CodeDetail; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +public interface ButtonInfoMapper { + + List selectAll(); + + List selectButtonsByMenuId(Integer menuId); + + ButtonInfo selectByButtonId(String buttonId); + + List selectButtonsByRoleIdAndMenuId(@Param("roleId") Integer roleId,@Param("menuId") Integer menuId); +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/ButtonInfoMapper.xml b/src/main/java/com/soft/line/mapper/ButtonInfoMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..3094b8c20e2caf6b7f804ea41532ca2972b226b0 --- /dev/null +++ b/src/main/java/com/soft/line/mapper/ButtonInfoMapper.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/CertificateInfoMapper.java b/src/main/java/com/soft/line/mapper/CertificateInfoMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..1cfdb7a1848fe2964f3c94bf0cd3c2618dcb258c --- /dev/null +++ b/src/main/java/com/soft/line/mapper/CertificateInfoMapper.java @@ -0,0 +1,43 @@ +package com.soft.line.mapper; + +import com.soft.line.entity.CertificateInfo; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +@Mapper +public interface CertificateInfoMapper { + + int insert(CertificateInfo certificateInfo); + + int insertRecord(CertificateInfo record); + + int delete(Map map); + + int update(CertificateInfo certificateInfo); + + CertificateInfo selectByPrimaryKey(Long id); + + List selectAll(Map map); + + + List getPersonalAll(String userName); + + List getAllCompanyCertificates(Map map); + + int countCertificateByIdAndCId(@Param("id")Integer id,@Param("certId")String certId); + + List getAllByIdList(@Param("idList")List idList); + + //根据年份分组查询数量 + List> countNumGroupByYear(); + + //根据部门分组查询数量 + List> countNumGroupByCertType(); + + //今年证书类型排行 + List> certTypeRankThisYear(); + +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/CertificateInfoMapper.xml b/src/main/java/com/soft/line/mapper/CertificateInfoMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..6cfbf25016a57d65d5a72131c6b6058e171f3ce9 --- /dev/null +++ b/src/main/java/com/soft/line/mapper/CertificateInfoMapper.xml @@ -0,0 +1,171 @@ + + + + + + + + + + + + + + + + + + + + insert into `certificate_info` (`cert_id`, `cert_type`, `cert_name`, + `issue_date`,`cert_unit`, `begin_date`, `end_date`, + `note`, `modify_person`) + values (#{certId,jdbcType=VARCHAR}, #{certType,jdbcType=VARCHAR}, #{certName,jdbcType=VARCHAR}, + #{issueDate,jdbcType=TIMESTAMP},#{certUnit,jdbcType=VARCHAR}, #{beginDate,jdbcType=TIMESTAMP}, #{endDate,jdbcType=TIMESTAMP}, + #{note,jdbcType=VARCHAR}, #{modifyPerson,jdbcType=VARCHAR}) + + + + insert into `certificate_info` (`cert_id`, `cert_type`, `cert_name`, + `issue_date`,`cert_unit`, `begin_date`, `end_date`, + `note`, `modify_person`) + values (#{certId,jdbcType=VARCHAR}, #{certType,jdbcType=VARCHAR}, #{certName,jdbcType=VARCHAR}, + #{issueDate,jdbcType=TIMESTAMP},#{certUnit,jdbcType=VARCHAR}, #{beginDate,jdbcType=TIMESTAMP}, #{endDate,jdbcType=TIMESTAMP}, + #{note,jdbcType=VARCHAR}, #{modifyPerson,jdbcType=VARCHAR}) + + + + update `certificate_info` set `del_flg` = '1' where `id` = #{id,jdbcType=INTEGER} + + + + update `certificate_info` set `cert_id` = #{certId,jdbcType=VARCHAR}, + `cert_type` = #{certType,jdbcType=VARCHAR}, + `cert_name` = #{certName,jdbcType=VARCHAR}, + `issue_date` = #{issueDate,jdbcType=TIMESTAMP}, + `cert_unit` = #{certUnit,jdbcType=VARCHAR}, + `begin_date` = #{beginDate,jdbcType=TIMESTAMP}, + `end_Date` = #{endDate,jdbcType=TIMESTAMP}, + `note` = #{note,jdbcType=VARCHAR}, + `modify_person` = #{modifyPerson,jdbcType=VARCHAR}, + `modify_time` = #{modifyTime,jdbcType=VARCHAR} + where `id` = #{id,jdbcType=INTEGER} + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/CodeDetailMapper.java b/src/main/java/com/soft/line/mapper/CodeDetailMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..b34984bce72a174c2db3b52a4f9e62d2bd3348be --- /dev/null +++ b/src/main/java/com/soft/line/mapper/CodeDetailMapper.java @@ -0,0 +1,40 @@ +package com.soft.line.mapper; + +import com.soft.line.entity.CodeDetail; +import java.util.List; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +public interface CodeDetailMapper { + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table code_detail + * + * @mbggenerated + */ + int insert(CodeDetail record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table code_detail + * + * @mbggenerated + */ + CodeDetail selectByPrimaryKey(@Param("codeType") String codeType, @Param("codeDetail") String codeDetail); + + String selectContent1ByPrimaryKey(@Param("codeType") String codeType, @Param("codeDetail") String codeDetail); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table code_detail + * + * @mbggenerated + */ + List selectAll(); + + List selectByCodeType(@Param("codeType") String codeType); + + CodeDetail selectByCodeContent1(@Param("codeType") String codeType,@Param("codeContent1") String codeContent1); + + List getDepByRole(@Param("userId") int userId); +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/CodeDetailMapper.xml b/src/main/java/com/soft/line/mapper/CodeDetailMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..8da2022ce453288e9c81cf018831ec2dd27712d5 --- /dev/null +++ b/src/main/java/com/soft/line/mapper/CodeDetailMapper.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + insert into `code_detail` (`code_type`, `code_detail`, `code_content1`, + `code_content2`, `code_content3`, `code_content4`, + `orderby`, `note`) + values (#{codeType,jdbcType=VARCHAR}, #{codeDetail,jdbcType=VARCHAR}, #{codeContent1,jdbcType=VARCHAR}, + #{codeContent2,jdbcType=VARCHAR}, #{codeContent3,jdbcType=VARCHAR}, #{codeContent4,jdbcType=VARCHAR}, + #{orderby,jdbcType=INTEGER}, #{note,jdbcType=VARCHAR}) + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/ContractInfoMapper.java b/src/main/java/com/soft/line/mapper/ContractInfoMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..794146e643de78d6795b4b3b27b3e5f7c50b14bd --- /dev/null +++ b/src/main/java/com/soft/line/mapper/ContractInfoMapper.java @@ -0,0 +1,63 @@ +package com.soft.line.mapper; + +import com.soft.line.entity.ContractInfo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +public interface ContractInfoMapper { + + int insert(ContractInfo contractInfo); + + int insertRecord(ContractInfo record); + + int delete(Map map); + + int update(ContractInfo contractInfo); + + ContractInfo selectByPrimaryKey(Integer id); + + List selectAll(Map map); + + List selectAllNaturesByIdList(@Param("idList")List idList); + + List getAllAboutContracts(Map map); + + int countContractByIdAndName(@Param("id")Integer id,@Param("contractName")String contractName); + + List getAllByIdList(Map map); + + List getAllCNByIdList(@Param("idList")List idList); + + //根据部门分组查询数量(今年) + List> countNumGroupByDepThisYear(); + + //根据部门分组查询历年数量 + List> countDepGroupByYear(@Param("dep")String dep); + + //合同类型统计 + List> countNumByTypeYear(); + + //今年合同总数 + int countThisYearContract(); + + //合同总金额排行榜 + List> amountRanking(); + + //部门合同排行榜 + List> depRanking(); + + //某年合同总数 + List> sumContractByYear(@Param("year") String year); + + //某年合同性质(收入,支出,净收益(收入-支出)) + List> sumContractNatureByYear(@Param("year") String year); + + //某年合同性质(收入,支出,净收益(收入-支出)) + List> sumContractNatureByYearAndDep(@Param("year") String year,@Param("depIdList")List depIdList); + + //根据部门分组查询数量 + List> countNumGroupByDep(@Param("depIdList")List depIdList); + +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/ContractInfoMapper.xml b/src/main/java/com/soft/line/mapper/ContractInfoMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..9f3eebf2e8da4b9b3b2c8fc02965c9e941ea903f --- /dev/null +++ b/src/main/java/com/soft/line/mapper/ContractInfoMapper.xml @@ -0,0 +1,375 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into `contract_info` (`dep_id`, `contract_name`,`contract_type`, `pro_id`, + `total_amount`, `part_a`, `part_b`, `part_c`, + `sign_time`, `sign_addr`, `begin_date`, `end_date`, + `payment`, `note`,`modify_person`, + `contract_nature`,`contract_content` + ) + values (#{depId,jdbcType=DECIMAL}, #{contractName,jdbcType=VARCHAR},#{contractType,jdbcType=VARCHAR}, #{proId,jdbcType=VARCHAR}, + #{totalAmount,jdbcType=DECIMAL}, #{partA,jdbcType=VARCHAR}, #{partB,jdbcType=VARCHAR}, #{partC,jdbcType=VARCHAR}, + #{signTime,jdbcType=TIMESTAMP}, #{signAddr,jdbcType=VARCHAR}, #{beginDate,jdbcType=TIMESTAMP}, #{endDate,jdbcType=TIMESTAMP}, + #{payment,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}, #{modifyPerson,jdbcType=VARCHAR}, + #{contractNature,jdbcType=VARCHAR},#{contractContent,jdbcType=VARCHAR} + ) + + + + insert into `contract_info` (`dep_id`, `contract_name`,`contract_type`, `pro_id`, + `total_amount`, `part_a`, `part_b`, `part_c`, + `sign_time`, `sign_addr`, `begin_date`, `end_date`, + `payment`, `note`,`modify_person`, + `contract_nature`,`contract_content` + ) + values (#{depId,jdbcType=DECIMAL}, #{contractName,jdbcType=VARCHAR},#{contractType,jdbcType=VARCHAR}, #{proId,jdbcType=VARCHAR}, + #{totalAmount,jdbcType=DECIMAL}, #{partA,jdbcType=VARCHAR}, #{partB,jdbcType=VARCHAR}, #{partC,jdbcType=VARCHAR}, + #{signTime,jdbcType=TIMESTAMP}, #{signAddr,jdbcType=VARCHAR}, #{beginDate,jdbcType=TIMESTAMP}, #{endDate,jdbcType=TIMESTAMP}, + #{payment,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}, #{modifyPerson,jdbcType=VARCHAR}, + #{contractNature,jdbcType=VARCHAR},#{contractContent,jdbcType=VARCHAR} + ) + + + + update `contract_info` set `del_flg` = '1' where `id` = #{id,jdbcType=INTEGER} + + + + update `contract_info` set `dep_id` = #{depId,jdbcType=DECIMAL}, + `contract_name` = #{contractName,jdbcType=VARCHAR}, + `contract_type` = #{contractType,jdbcType=VARCHAR}, + `pro_id` = #{proId,jdbcType=VARCHAR}, + `total_amount` = #{totalAmount,jdbcType=DECIMAL}, + `part_a` = #{partA,jdbcType=VARCHAR}, + `part_b` = #{partB,jdbcType=VARCHAR}, + `part_c` = #{partC,jdbcType=VARCHAR}, + `sign_time` = #{signTime,jdbcType=TIMESTAMP}, + `sign_addr` = #{signAddr,jdbcType=VARCHAR}, + `begin_date` = #{beginDate,jdbcType=TIMESTAMP}, + `end_date` = #{endDate,jdbcType=TIMESTAMP}, + `payment` = #{payment,jdbcType=VARCHAR}, + `note` = #{note,jdbcType=VARCHAR}, + `modify_person` = #{modifyPerson,jdbcType=VARCHAR}, + `modify_time` = #{modifyTime,jdbcType=TIMESTAMP}, + `contract_nature` = #{contractNature,jdbcType=VARCHAR}, + `contract_content` = #{contractContent,jdbcType=VARCHAR} + where `id` = #{id,jdbcType=INTEGER} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/LasCodeItemMapper.java b/src/main/java/com/soft/line/mapper/LasCodeItemMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..56ea70967f307e18399494beb125b908192cf58f --- /dev/null +++ b/src/main/java/com/soft/line/mapper/LasCodeItemMapper.java @@ -0,0 +1,32 @@ +package com.soft.line.mapper; + +import com.soft.line.entity.LasCodeItem; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface LasCodeItemMapper { + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table code_detail + * + * @mbggenerated + */ + LasCodeItem selectByPrimaryKey(@Param("itemTypeId") String itemTypeId, @Param("itemVal") String itemVal); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table code_detail + * + * @mbggenerated + */ + List selectAll(); + + List selectAllConDep(@Param("userId")Integer userId); + + List selectByCodeType(@Param("itemTypeId") String itemTypeId); + + LasCodeItem selectByItemDesc(@Param("itemTypeId") String itemTypeId, @Param("itemDesc") String itemDesc); + +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/LasCodeItemMapper.xml b/src/main/java/com/soft/line/mapper/LasCodeItemMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..64645c3bf6090c1f105fd578e89963480fca7108 --- /dev/null +++ b/src/main/java/com/soft/line/mapper/LasCodeItemMapper.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/LasDepartmentInfoMapper.java b/src/main/java/com/soft/line/mapper/LasDepartmentInfoMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..823ec64d0edea5354f598dfdb0b8cc545026be5c --- /dev/null +++ b/src/main/java/com/soft/line/mapper/LasDepartmentInfoMapper.java @@ -0,0 +1,20 @@ +package com.soft.line.mapper; + +import com.soft.line.entity.LasDepartmentInfo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface LasDepartmentInfoMapper { + + LasDepartmentInfo getDepByRole(@Param("userId") int userId); + + List selectAllSuperior(); + + LasDepartmentInfo selectSuperiorDepByDepId(@Param("depId") String depId); + + LasDepartmentInfo selectSuperiorDepByDepName(@Param("depName") String depName); + + //获取上一级部门 + LasDepartmentInfo selectSupDepByDepId(@Param("depId") String depId); +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/LasDepartmentInfoMapper.xml b/src/main/java/com/soft/line/mapper/LasDepartmentInfoMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..adc7fe4791b444ba595b6bbeb3ba776dc5f2108a --- /dev/null +++ b/src/main/java/com/soft/line/mapper/LasDepartmentInfoMapper.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/LasUserInfoMapper.java b/src/main/java/com/soft/line/mapper/LasUserInfoMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..b7c9ac3e3986198fa45839e43ba170f1b64fdd3c --- /dev/null +++ b/src/main/java/com/soft/line/mapper/LasUserInfoMapper.java @@ -0,0 +1,35 @@ +package com.soft.line.mapper; + +import com.soft.line.entity.LasUserInfo; + +import java.util.List; +import java.util.Map; + +public interface LasUserInfoMapper { + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_info + * + * @mbggenerated + */ + LasUserInfo selectByPrimaryKey(Integer id); + + /** + * 根据登录信息,获取用户 + * @param map + * @return + */ + LasUserInfo userLogin(Map map); + + List selectUserForConDep(); + + List selectAllUsers(); + + int countRegister(Integer userId); + + int countDepManager(Integer userId); + + int countAssistantManager(Integer userId); + +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/LasUserInfoMapper.xml b/src/main/java/com/soft/line/mapper/LasUserInfoMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..514e00f20ccbd351761f5a9b9f85f12baea7ff8f --- /dev/null +++ b/src/main/java/com/soft/line/mapper/LasUserInfoMapper.xml @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/MenuButtonInfoMapper.java b/src/main/java/com/soft/line/mapper/MenuButtonInfoMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..84035bd69139eb91b146225b74866a0b61bb9004 --- /dev/null +++ b/src/main/java/com/soft/line/mapper/MenuButtonInfoMapper.java @@ -0,0 +1,25 @@ +package com.soft.line.mapper; + +import com.soft.line.entity.MenuButtonInfo; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +@Mapper +public interface MenuButtonInfoMapper { + + int insert(MenuButtonInfo record); + + int deleteByMenuIdAndButtonId(@Param("menuId") int menuId,@Param("buttonId") String buttonId); + + int deleteByMenuId(@Param("menuId") int menuId); + + MenuButtonInfo selectByPrimaryKey(Integer id); + + List selectAll(); + + List selectButtonIdByMenuId(Integer menuId); +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/MenuButtonInfoMapper.xml b/src/main/java/com/soft/line/mapper/MenuButtonInfoMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..7f9b5ac98a1bf57f4782ca9955dfffd4430fca7a --- /dev/null +++ b/src/main/java/com/soft/line/mapper/MenuButtonInfoMapper.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + + insert into `menu_button_info` (`menu_id`, `button_id`, `modify_person`, + `modify_time`) + values (#{menuId,jdbcType=INTEGER}, #{buttonId,jdbcType=VARCHAR}, #{modifyPerson,jdbcType=VARCHAR}, + #{modifyTime,jdbcType=TIMESTAMP}) + + + + + + + + + + delete from menu_button_info where menu_id=#{menuId} and button_id=#{buttonId} + + + + delete from menu_button_info where menu_id in (select mi.id from menu_info mi where mi.id=#{menuId}) + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/MenuInfoMapper.java b/src/main/java/com/soft/line/mapper/MenuInfoMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..006eec4a84b1eced0457c83fc82fd3048d13e4bc --- /dev/null +++ b/src/main/java/com/soft/line/mapper/MenuInfoMapper.java @@ -0,0 +1,51 @@ +package com.soft.line.mapper; + +import com.soft.line.entity.MenuInfo; +import org.apache.ibatis.annotations.Delete; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; +import java.util.Map; + +public interface MenuInfoMapper { + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table menu_info + * + * @mbggenerated + */ + int insert(MenuInfo record); + + int update(MenuInfo record); + + int delete(Integer id); + + MenuInfo selectByPrimaryKey(Integer id); + + //获取该菜单的父级菜单 + MenuInfo selectParentMenu(Integer pid); + + List selectAll(@Param("menuName") String menuName,@Param("menuUrl") String menuUrl); + + int countMenuName(@Param("id") Integer id,@Param("menuName") String menuName); + + int countOrderBy(@Param("id") Integer id,@Param("ory") String orderBy); + + //获取所有菜单名 + List selectALlMenuName(); + + //获取顶级菜单 + List selectTopMenu(); + + //查询menu_button_info中的menu + List selectMenusInMenuButton(); + + //查询role_menu中的menu_info + List selectByRoleId(@Param("roleId") Integer roleId); + + Map getParentMenu(int id); + + +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/MenuInfoMapper.xml b/src/main/java/com/soft/line/mapper/MenuInfoMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..fbb5ef148b81ff30f48171accf8ea957142e7847 --- /dev/null +++ b/src/main/java/com/soft/line/mapper/MenuInfoMapper.xml @@ -0,0 +1,119 @@ + + + + + + + + + + + + + + + + + insert into `menu_info` (`menu_icon`, `menu_name`, `state`, + `menu_url`, `orderby`, `p_id`, + `modify_person`, `modify_time`) + values (#{menuIcon,jdbcType=VARCHAR}, #{menuName,jdbcType=VARCHAR}, #{state,jdbcType=INTEGER}, + #{menuUrl,jdbcType=VARCHAR}, #{orderBy,jdbcType=VARCHAR}, #{pId,jdbcType=INTEGER}, + #{modifyPerson,jdbcType=VARCHAR}, #{modifyTime,jdbcType=TIMESTAMP}) + + + + update `menu_info` set `menu_icon` = #{menuIcon,jdbcType=VARCHAR} , + `menu_name` = #{menuName,jdbcType=VARCHAR}, + `state` = #{state,jdbcType=INTEGER}, + `menu_url` = #{menuUrl,jdbcType=VARCHAR}, + `orderby` = #{orderBy,jdbcType=VARCHAR}, + `p_id` = #{pId,jdbcType=INTEGER}, + `modify_person` = #{modifyPerson,jdbcType=VARCHAR}, + `modify_time` = #{modifyTime,jdbcType=TIMESTAMP} + where `id` = #{id,jdbcType=INTEGER} + + + + delete from menu_info where id = #{id} + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/RoleInfoMapper.java b/src/main/java/com/soft/line/mapper/RoleInfoMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..27a3813475e7901b3ceef967c9bda4b768596c3e --- /dev/null +++ b/src/main/java/com/soft/line/mapper/RoleInfoMapper.java @@ -0,0 +1,26 @@ +package com.soft.line.mapper; + +import com.soft.line.entity.RoleInfo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +public interface RoleInfoMapper { + + int insert(Map map); + + int update(Map map); + + RoleInfo selectByPrimaryKey(Integer id); + + List selectAll(String roleName); + + int delete(@Param("roleId") Integer roleId); + + int countRoleName(@Param("id") Integer id,@Param("roleName") String roleName); + + RoleInfo selectByRoleName(String roleName); + + String selectRoleName(@Param("roleId") int roleId); +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/RoleInfoMapper.xml b/src/main/java/com/soft/line/mapper/RoleInfoMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..ebe97462b60eb8e21a87e92e9528f3bab2e8df17 --- /dev/null +++ b/src/main/java/com/soft/line/mapper/RoleInfoMapper.xml @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + insert into `role_info` (`name`,`state`,`modify_person`,`modify_time`) + values (#{roleName},#{state},#{modifyPerson},#{modifyTime}) + + + + update `role_info` set `name` = #{roleName},`state` = #{state},`modify_person`=#{modifyPerson},`modify_time`=#{modifyTime} + where `id` = #{id} + + + + + + + + delete from role_info where id = #{roleId} + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/RoleMenuMapper.java b/src/main/java/com/soft/line/mapper/RoleMenuMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..89326e90234b4bbe97e9065eccc25040e457e31c --- /dev/null +++ b/src/main/java/com/soft/line/mapper/RoleMenuMapper.java @@ -0,0 +1,21 @@ +package com.soft.line.mapper; + +import com.soft.line.entity.RoleMenu; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface RoleMenuMapper { + + int insert(@Param("roleId")Integer roleId,@Param("menuId") Integer menuId,@Param("buttonId") String buttonId,@Param("modifyPerson") String modifyPerson); + + RoleMenu selectByPrimaryKey(Integer id); + + List selectAll(); + + int deleteByRoleId(Integer roleId); + + int deleteByMenuId(Integer menuId); + + int deleteByMenuIdAndButtonId(@Param("menuId") int menuId, @Param("buttonId") String buttonId); +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/RoleMenuMapper.xml b/src/main/java/com/soft/line/mapper/RoleMenuMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..8d7cce340a50a6daad2cfdb3ab2e1ca131ae5657 --- /dev/null +++ b/src/main/java/com/soft/line/mapper/RoleMenuMapper.xml @@ -0,0 +1,37 @@ + + + + + + + + + + + + insert into `role_menu` (`role_id`, `menu_button_id`, `modify_person`) + select #{roleId}, mbi.id ,#{modifyPerson} from menu_button_info mbi + where mbi.menu_id = #{menuId} and mbi.button_id = #{buttonId} + + + + + + delete from role_menu where role_id = #{roleId} + + + + delete from role_menu where menu_button_id in (select mbi.id from menu_button_info mbi where mbi.menu_id =(select mi.id from menu_info mi where mi.id=#{menuId})) + + + + delete from role_menu where menu_button_id in (select mbi.id from menu_button_info mbi where mbi.menu_id=#{menuId} and mbi.button_id=#{buttonId}) + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/UserConDepMapper.java b/src/main/java/com/soft/line/mapper/UserConDepMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..e5bb3dd14a7affde5cf0eecaaf7851ff91d8dd3d --- /dev/null +++ b/src/main/java/com/soft/line/mapper/UserConDepMapper.java @@ -0,0 +1,20 @@ +package com.soft.line.mapper; + + +import com.soft.line.entity.UserConDep; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface UserConDepMapper { + + List selectAllUser(@Param("userId")Integer userId); + + List selectAllConDep(@Param("userId")Integer userId); + + int countUserConDepByUserId(@Param("userId")Integer userId); + + int insert(@Param("userId")Integer userId, @Param("contractDepartmentId") String contractDepartmentId,@Param("modifyPerson") String modifyPerson); + + int deleteByUserId(Integer userId); +} diff --git a/src/main/java/com/soft/line/mapper/UserConDepMapper.xml b/src/main/java/com/soft/line/mapper/UserConDepMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..d2883193447293f4dfdbebebb42ffc7be95fdebd --- /dev/null +++ b/src/main/java/com/soft/line/mapper/UserConDepMapper.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + insert into `user_contractdepartment` (`user_id`, `contract_department_id`, `modify_person`) + values (#{userId,jdbcType=INTEGER}, #{contractDepartmentId,jdbcType=VARCHAR}, #{modifyPerson,jdbcType=VARCHAR}) + + + + delete from user_contractdepartment where user_id = #{userId} + + + + + + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/UserInfoMapper.java b/src/main/java/com/soft/line/mapper/UserInfoMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..833ea938dd3d2274e3d30af430a43327ffb7e7e5 --- /dev/null +++ b/src/main/java/com/soft/line/mapper/UserInfoMapper.java @@ -0,0 +1,93 @@ +package com.soft.line.mapper; + +import com.soft.line.entity.UserInfo; +import org.apache.ibatis.annotations.Param; + +import java.util.List; +import java.util.Map; + +public interface UserInfoMapper { + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_info + * + * @mbggenerated + */ + int insert(UserInfo record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_info + * + * @mbggenerated + */ + UserInfo selectByPrimaryKey(Integer id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table user_info + * + * @mbggenerated + */ + List selectAll(); + + /** + * 根据登录信息,获取用户 + * @param map + * @return + */ + UserInfo userLogin(Map map); + + /** + * 模糊查询 + * @param map + * @return + */ + List getAllUsers(Map map); + + /** + * 根据id删除用户 + * @param id + * @return + */ + int delUser(int id); + + /** + * 修改人员信息 + * @param userInfo + * @return + */ + int updateUserInfo(UserInfo userInfo); + + /** + * 根据openId 获取人员信息 + * @param openId + * @return + */ + UserInfo getUserInfoByOpenId(String openId); + + /** + * 获取人员信息 + * @param phone + * @param userName + * @param password + * @return + */ + UserInfo getUserInfoByPhoneAndUserNameAndPassword(String phone, String userName, String password); + + /** + * 根据id 修改人员的openId + * @param openId + * @param id + * @return + */ + int updateOpenIdById(String openId, int id); + + int updatePassword(int id,String password); + + int deleteOpenId(int id); + + int countByRoleId(int roleId); + + // String selectRoleName(@Param("roleId") int roleId); +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/UserInfoMapper.xml b/src/main/java/com/soft/line/mapper/UserInfoMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..513d3ca4aa23eb931dc4ca423181a2086c906aff --- /dev/null +++ b/src/main/java/com/soft/line/mapper/UserInfoMapper.xml @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + insert into `user_info` (`user_name`, `password`, `phone`, + `modify_person`, `modify_time`, `head_img_url`, + `user_status`, `role_id`, `salt`, + `open_id`,`dep_id`) + values (#{userName,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, #{phone,jdbcType=VARCHAR}, + 'admin', now(), #{headImgUrl,jdbcType=VARCHAR}, + #{userStatus,jdbcType=VARCHAR}, #{roleId,jdbcType=INTEGER}, #{salt,jdbcType=VARCHAR}, + #{openId,jdbcType=VARCHAR},#{depId,jdbcType=VARCHAR}) + + + + + + + + DELETE FROM `user_info` + WHERE `id`=#{id,jdbcType=INTEGER} + + + + UPDATE `user_info` + + `user_name`=#{userName,jdbcType=VARCHAR}, + `password`=#{password,jdbcType=VARCHAR}, + `phone`=#{phone,jdbcType=VARCHAR}, + `modify_person`=#{modifyPerson,jdbcType=VARCHAR}, + `head_img_url`=#{headImgUrl,jdbcType=VARCHAR}, + `user_status`=#{userStatus,jdbcType=VARCHAR}, + `dep_id`=#{depId,jdbcType=INTEGER}, + `role_id`=#{roleId,jdbcType=INTEGER} + + WHERE `id`=#{id,jdbcType=INTEGER} + + + + + + UPDATE `user_info` + SET `open_id`=#{openId} + WHERE `id`=#{id} + + + + UPDATE `user_info` + SET `password`=#{password} + WHERE `id`=#{id} + + + + UPDATE `user_info` + SET `open_id`=null + WHERE `id`=#{id} + + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/WorkJournalMapper.java b/src/main/java/com/soft/line/mapper/WorkJournalMapper.java new file mode 100644 index 0000000000000000000000000000000000000000..09283ebfd3a42b88cd71879f459dec8a0f300efb --- /dev/null +++ b/src/main/java/com/soft/line/mapper/WorkJournalMapper.java @@ -0,0 +1,30 @@ +package com.soft.line.mapper; + +import com.soft.line.entity.WorkJournal; +import java.util.List; + +public interface WorkJournalMapper { + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table work_journal + * + * @mbggenerated + */ + int insert(WorkJournal record); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table work_journal + * + * @mbggenerated + */ + WorkJournal selectByPrimaryKey(Long id); + + /** + * This method was generated by MyBatis Generator. + * This method corresponds to the database table work_journal + * + * @mbggenerated + */ + List selectAll(); +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/mapper/WorkJournalMapper.xml b/src/main/java/com/soft/line/mapper/WorkJournalMapper.xml new file mode 100644 index 0000000000000000000000000000000000000000..1f244c88451e5441790fdd8a456d9b331e082303 --- /dev/null +++ b/src/main/java/com/soft/line/mapper/WorkJournalMapper.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + + + + + + + + insert into `work_journal` (`work_type`, `work_table`, `work_table_seq`, + `work_date`, `note`, `modify_person`, + `modify_time`, `db_op_type`) + values (#{workType,jdbcType=VARCHAR}, #{workTable,jdbcType=VARCHAR}, #{workTableSeq,jdbcType=BIGINT}, + #{workDate,jdbcType=TIMESTAMP}, #{note,jdbcType=VARCHAR}, #{modifyPerson,jdbcType=VARCHAR}, + #{modifyTime,jdbcType=TIMESTAMP}, #{dbOpType,jdbcType=VARCHAR}) + + + + \ No newline at end of file diff --git a/src/main/java/com/soft/line/service/AppletCertificateService.java b/src/main/java/com/soft/line/service/AppletCertificateService.java new file mode 100644 index 0000000000000000000000000000000000000000..a825f7ae1c4ec5d049b1c432b5c7374aeb10a060 --- /dev/null +++ b/src/main/java/com/soft/line/service/AppletCertificateService.java @@ -0,0 +1,87 @@ +package com.soft.line.service; + +import com.soft.line.entity.AppletCertificate; +import com.soft.line.util.MP.AjaxResult; + +import java.util.Map; + +/** + * 小程序 证书 + * + * @author wpb + * @version 1.0 + * @date 2020/6/3 15:44 + */ +public interface AppletCertificateService { + + /** + * 获取每个部门的证书总数 + * + * @return + */ + AjaxResult getCertificateNum(); + + /** + * 根据证书类型获取证书年列表数据 + * + * @param paramMap 参数 + * @return + */ + AjaxResult getCertificateYearList(Map paramMap); + + /** + * 根据证书类型cert_type和起始日期年份以及当前页、每页显示条数分页查询证书年列表 + * + * @param paramMap 参数 + * @return + */ + AjaxResult getCertificateList(Map paramMap); + + /** + * 根据证书id查询证书信息 + * + * @param paramMap 参数 + * @return + */ + AjaxResult getCertificate(Map paramMap); + + /** + * 修改证书 + * + * @param appletCertificate + * @return + */ + AjaxResult updateCertificate(AppletCertificate appletCertificate); + + /** + * 删除证书 + * + * @param paramMap 参数 + * @return + */ + AjaxResult deleteCertificate(Map paramMap); + + /** + * 根据证书名称分页模糊查询证书列表 + * + * @param paramMap 参数 + * @return + */ + AjaxResult getCertificateSearchList(Map paramMap); + + /** + * 添加证书 + * + * @param appletCertificate 参数 + * @return + */ + AjaxResult addCertificate(AppletCertificate appletCertificate); + + /** + * 根据证书详情信息分页查询证书列表 + * + * @param paramMap 参数 + * @return + */ + AjaxResult getCertificateQueryList(Map paramMap); +} diff --git a/src/main/java/com/soft/line/service/AppletCommonService.java b/src/main/java/com/soft/line/service/AppletCommonService.java new file mode 100644 index 0000000000000000000000000000000000000000..b00bb2301020faba20bdd75c6125f70dca810717 --- /dev/null +++ b/src/main/java/com/soft/line/service/AppletCommonService.java @@ -0,0 +1,45 @@ +package com.soft.line.service; + +import com.soft.line.util.MP.AjaxResult; +import org.springframework.web.multipart.MultipartFile; + + +/** + * 小程序 公用 + * + * @author wpb + * @version 1.0 + * @date 2020/6/1 9:07 + */ +public interface AppletCommonService { + /** + * 获取到所有的枚举数据 + * + * @return + */ + AjaxResult getBaseData(); + + /** + * 合同上传 + * + * @param file 文件 + * @param id id + * @param fileName 文件名称 + * @param modifyPerson 修改人 + * @return + */ + AjaxResult uploadContractAttach(MultipartFile file, int id, String fileName, String modifyPerson); + + /** + * 证书 file上传 + * + * @param file 文件 + * @param id id + * @param fileName 文件名称 + * @param modifyPerson 修改人 + * @return + */ + AjaxResult uploadCertificateAttach(MultipartFile file, int id, String fileName, String modifyPerson); + + +} diff --git a/src/main/java/com/soft/line/service/AppletContractService.java b/src/main/java/com/soft/line/service/AppletContractService.java new file mode 100644 index 0000000000000000000000000000000000000000..f4eed9c556a031a73328e0dfaaf2d5b192778216 --- /dev/null +++ b/src/main/java/com/soft/line/service/AppletContractService.java @@ -0,0 +1,97 @@ +package com.soft.line.service; + +import com.soft.line.entity.AppletContract; +import com.soft.line.util.MP.AjaxResult; + +import java.util.Map; + +/** + * 小程序合同service + * + * @author wpb + * @version 1.0 + * @date 2020/5/26 15:46 + */ +public interface AppletContractService { + + /** + * 获取每个部门的合同总数, + * 注意:若某个部门下合同数为空,也需要返回此部门id的key, + * + * @return + */ + AjaxResult getContractNum(); + + /** + * 根据部门id获取合同年列表数据 + * + * @param paraMap 部门编号 + * @return + */ + AjaxResult getContractYearList(Map paraMap); + + /** + * 根据部门id和签订年份分页查询合同列表 + * + * @param paraMap 参数 + * @return + */ + AjaxResult getContractList(Map paraMap); + + /** + * 根据合同名称分页模糊查询合同列表 + * + * @param paraMap 参数 + * @return + */ + AjaxResult getContractSearchList(Map paraMap); + + /** + * 根据合同详情信息分页查询合同列表 + * + * @param paraMap 参数 + * @return + */ + AjaxResult getContractQueryList(Map paraMap); + + /** + * 添加合同 + * + * @param appletContract 参数 + * @return + */ + AjaxResult addContract(AppletContract appletContract); + + /** + * 修改合同信息 + * + * @param appletContract 入参 + * @return + */ + AjaxResult updateContract(AppletContract appletContract); + + /** + * 根据合同id查询合同信息 + * + * @param paraMap 参数 + * @return + */ + AjaxResult getContract(Map paraMap); + + /** + * 删除合同信息 + * + * @param paraMap 参数 + * @return + */ + AjaxResult deleteContract(Map paraMap); + + + /** + * 获取用户的合同部门 + * + * @param paraMap 参数 + * @return + */ + AjaxResult getUserContDep(Map paraMap); +} diff --git a/src/main/java/com/soft/line/service/AttachMentInfoService.java b/src/main/java/com/soft/line/service/AttachMentInfoService.java new file mode 100644 index 0000000000000000000000000000000000000000..deacd885c9c422ff8ea978f16dc5d6f67efca2eb --- /dev/null +++ b/src/main/java/com/soft/line/service/AttachMentInfoService.java @@ -0,0 +1,17 @@ +package com.soft.line.service; + +import com.soft.line.entity.AttachmentInfo; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.Map; + +public interface AttachMentInfoService { + + public List selectAll(String attachmentType,Integer cId); + + public void delete(Map map); + + public String save(MultipartFile file,String type,Integer cId); +} diff --git a/src/main/java/com/soft/line/service/ButtonInfoService.java b/src/main/java/com/soft/line/service/ButtonInfoService.java new file mode 100644 index 0000000000000000000000000000000000000000..542b26100cee729d56d0e46a7d4fc44412114c04 --- /dev/null +++ b/src/main/java/com/soft/line/service/ButtonInfoService.java @@ -0,0 +1,16 @@ +package com.soft.line.service; + +import com.github.pagehelper.PageInfo; +import com.soft.line.entity.ButtonInfo; +import com.soft.line.entity.MenuButtonInfo; +import com.soft.line.entity.MenuInfo; + +import java.util.List; +import java.util.Map; + +public interface ButtonInfoService { + + public List selectAll(); + + public ButtonInfo selectByButtonId(String buttonId); +} diff --git a/src/main/java/com/soft/line/service/CertificateInfoService.java b/src/main/java/com/soft/line/service/CertificateInfoService.java new file mode 100644 index 0000000000000000000000000000000000000000..3101e978fcf581379384ed35a01e8094e29c7aa5 --- /dev/null +++ b/src/main/java/com/soft/line/service/CertificateInfoService.java @@ -0,0 +1,33 @@ +package com.soft.line.service; + +import com.github.pagehelper.PageInfo; +import com.soft.line.entity.CertificateInfo; + +import java.util.List; +import java.util.Map; + +/** + * @author wu.xueqiao on 2020/5/8. + * @version 0.1 + */ + +public interface CertificateInfoService { + + public List getPersonalAll(String userName); + + public PageInfo getAllCompanyCertificates(final Map map); + + public PageInfo getAllCertificates(final Map map); + + public void delete(final Map map); + + public void add(final CertificateInfo certificateInfo); + + public void insertRecord(List list); + + public void update(final CertificateInfo certificateInfo); + + public int countByCId(Integer id,String cId); + + public List getAllByIDList(Map map); +} diff --git a/src/main/java/com/soft/line/service/CodeDetailService.java b/src/main/java/com/soft/line/service/CodeDetailService.java new file mode 100644 index 0000000000000000000000000000000000000000..e5716e3a66b1e4e7c3a4b5bfe2ed58adcd611e88 --- /dev/null +++ b/src/main/java/com/soft/line/service/CodeDetailService.java @@ -0,0 +1,23 @@ +package com.soft.line.service; + +import com.soft.line.entity.CodeDetail; +import com.soft.line.entity.LasCodeItem; +import com.soft.line.entity.LasDepartmentInfo; + +import java.util.List; + +public interface CodeDetailService { + + public LasCodeItem selectByPrimaryKey(String itemTypeId, String itemVal); + + public LasCodeItem selectByItemDesc(String itemTypeId, String itemDesc); + + public List selectByCodeType(String codeType); + + public List getDepByRole(); + + public List selectAllDep(); + + public LasDepartmentInfo selectSuperiorDepByDepName(String depName); + +} diff --git a/src/main/java/com/soft/line/service/ContractInfoService.java b/src/main/java/com/soft/line/service/ContractInfoService.java new file mode 100644 index 0000000000000000000000000000000000000000..a2783e180c8f2c16fb3e4f01c898c58234ba9707 --- /dev/null +++ b/src/main/java/com/soft/line/service/ContractInfoService.java @@ -0,0 +1,32 @@ +package com.soft.line.service; + +import com.github.pagehelper.PageInfo; +import com.soft.line.entity.ContractInfo; +import com.soft.line.entity.MenuInfo; + +import java.util.List; +import java.util.Map; + +/** + * @author wu.xueqiao on 2020/5/21. + * @version 0.1 + */ +public interface ContractInfoService { + + + public PageInfo getAllAboutContracts(Map map); + + public PageInfo getAllContracts(Map map); + + public void delete(Map map); + + public void add(ContractInfo contractInfo); + + public void insertList(List list); + + public void update(ContractInfo contractInfo); + + public int countContractByIdAndName(Integer id,String contractName); + + public List getAllCNByIDList(Map map) ; +} diff --git a/src/main/java/com/soft/line/service/LasUserInfoService.java b/src/main/java/com/soft/line/service/LasUserInfoService.java new file mode 100644 index 0000000000000000000000000000000000000000..af2200416c03d04290bd0cf5d46862080156bbf5 --- /dev/null +++ b/src/main/java/com/soft/line/service/LasUserInfoService.java @@ -0,0 +1,19 @@ +package com.soft.line.service; + +import com.soft.line.entity.LasUserInfo; + +import java.util.List; + +public interface LasUserInfoService { + + public List selectUserInfoForConDep(); + + //判断是否为归档登记员 + public boolean isRegister(Integer userId); + + //判断是否为部门经理 + public boolean isDepManager(Integer userId); + + //判断是否为总经理室的副总经理 + public boolean isAssistantManager(Integer userId); +} diff --git a/src/main/java/com/soft/line/service/LoginService.java b/src/main/java/com/soft/line/service/LoginService.java new file mode 100644 index 0000000000000000000000000000000000000000..2d8fc84187237530d53b5a71a837046039a2453f --- /dev/null +++ b/src/main/java/com/soft/line/service/LoginService.java @@ -0,0 +1,35 @@ +package com.soft.line.service; + +import com.soft.line.entity.LasDepartmentInfo; +import com.soft.line.entity.UserInfo; +import com.soft.line.entity.UserPermission; +import com.soft.line.util.MP.AjaxResult; +import com.soft.line.util.exception.CommonResult; +import com.soft.line.util.exception.ResultData; + +import java.util.Map; + +/** + * @author wu.xueqiao on 2020/5/12. + * @version 0.1 + */ +public interface LoginService { + + CommonResult userLogin(Map map); + + CommonResult loginOut(); + + AjaxResult autoLogin(String code); + + AjaxResult bindUserInfo(Map map); + + AjaxResult getUserInfo(Map map); + + AjaxResult updatePassword(Map map); + + AjaxResult untie(); + + UserPermission getUserPermission(); + + LasDepartmentInfo getSupDep(String depId); +} diff --git a/src/main/java/com/soft/line/service/MenuInfoService.java b/src/main/java/com/soft/line/service/MenuInfoService.java new file mode 100644 index 0000000000000000000000000000000000000000..d2647b91dc4f6ec37f1922216842bc3700656cce --- /dev/null +++ b/src/main/java/com/soft/line/service/MenuInfoService.java @@ -0,0 +1,37 @@ +package com.soft.line.service; + +import com.github.pagehelper.PageInfo; +import com.soft.line.entity.ButtonInfo; +import com.soft.line.entity.MenuButtonInfo; +import com.soft.line.entity.MenuInfo; + +import java.util.List; +import java.util.Map; + +public interface MenuInfoService { + + public PageInfo selectAll(final Map map); + + public List selectButtonsByMenuId(Integer menuId); + + public MenuInfo selectByPrimaryKey(Integer id); + + public MenuInfo selectParentMenu(Integer pid); + + public int countMenuName(Integer id,String menuName); + + public int countOrderBy(Integer id,String orderBy); + + public List selectALlMenuName(); + + public void addMenuInfo(MenuInfo menuInfo); + + public void updateMenInfo(MenuInfo menuInfo); + + public void delete(Integer id); + + public List selectTopMenu(); + + //获取所有有操作按钮的菜单 + public List selectSonMenus(); +} diff --git a/src/main/java/com/soft/line/service/RoleInfoService.java b/src/main/java/com/soft/line/service/RoleInfoService.java new file mode 100644 index 0000000000000000000000000000000000000000..8bf11c777624e456a88fc6f0dec01c0a6a05bd71 --- /dev/null +++ b/src/main/java/com/soft/line/service/RoleInfoService.java @@ -0,0 +1,21 @@ +package com.soft.line.service; + +import com.github.pagehelper.PageInfo; +import com.soft.line.entity.RoleInfo; + +import java.util.List; +import java.util.Map; + +public interface RoleInfoService { + List selectAll(); + + PageInfo>> selectAllRoleMenuInfo(final Map map); + + void delete(final Map map); + + void add(final Map map); + + void update(final Map map); + + int countRoleName(Integer roleId,String roleName); +} diff --git a/src/main/java/com/soft/line/service/StatisticsService.java b/src/main/java/com/soft/line/service/StatisticsService.java new file mode 100644 index 0000000000000000000000000000000000000000..a6ab173687efcfeb1088788d871a65f2ab92b141 --- /dev/null +++ b/src/main/java/com/soft/line/service/StatisticsService.java @@ -0,0 +1,29 @@ +package com.soft.line.service; + +import java.util.List; +import java.util.Map; + +public interface StatisticsService { + + public List> statisticsForCertificate(Map map); + + public List> countNumGroupByDepThisYear(Map map); + + public List> countDepGroupByYear(Map map); + + public List> countNumByTypeYear(); + + public List> amountRankingForContract(); + + public List> depRankingForContract(); + + public List> certTypeRankThisYear(); + + public List> sumContractByYear(Map map) ; + + public List> sumContractNatureByYear(Map map) ; + + public List> sumContractNatureByYearAndDep(Map map) ; + + public List> countNumGroupByDep() ; +} diff --git a/src/main/java/com/soft/line/service/UserConDepService.java b/src/main/java/com/soft/line/service/UserConDepService.java new file mode 100644 index 0000000000000000000000000000000000000000..243c838c80b8f574e4b8e2e28559db9ac566d27c --- /dev/null +++ b/src/main/java/com/soft/line/service/UserConDepService.java @@ -0,0 +1,23 @@ +package com.soft.line.service; + +import com.github.pagehelper.PageInfo; +import com.soft.line.entity.LasCodeItem; +import com.soft.line.entity.LasUserInfo; +import com.soft.line.entity.UserConDep; + +import java.util.List; +import java.util.Map; + +public interface UserConDepService { + + PageInfo selectUserConDep(Map map); + + List getConDepByUserId(Map map); + + public boolean exitsUserConDep(Map map); + + public void delete(Map map); + + public void save(Map map); + +} diff --git a/src/main/java/com/soft/line/service/UserInfoService.java b/src/main/java/com/soft/line/service/UserInfoService.java new file mode 100644 index 0000000000000000000000000000000000000000..a40bf7921d6a996b47a9bd5281ee819566e7fb3a --- /dev/null +++ b/src/main/java/com/soft/line/service/UserInfoService.java @@ -0,0 +1,27 @@ +package com.soft.line.service; + +import com.github.pagehelper.PageInfo; +import com.soft.line.entity.UserInfo; + +import java.util.List; +import java.util.Map; + +/** + * @author wu.xueqiao on 2020/5/12. + * @version 0.1 + */ +public interface UserInfoService { + + UserInfo getUserInfo(int userId); + + PageInfo getAllUsers(Map map); + + int delUser(int id); + + int addUser(UserInfo userInfo); + + Boolean changePassword(Map map); + + int countByRoleId(Integer roleId); + +} diff --git a/src/main/java/com/soft/line/service/impl/AppletCertificateServiceImpl.java b/src/main/java/com/soft/line/service/impl/AppletCertificateServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..3cc91e99e74a395c3721fdc30b513c44733a07c2 --- /dev/null +++ b/src/main/java/com/soft/line/service/impl/AppletCertificateServiceImpl.java @@ -0,0 +1,306 @@ +package com.soft.line.service.impl; + +import com.soft.line.common.AppletSystemConstant; +import com.soft.line.entity.AppletCertificate; +import com.soft.line.entity.AttachmentInfo; +import com.soft.line.mapper.AppletCertificateMapper; +import com.soft.line.mapper.AppletCommonMapper; +import com.soft.line.service.AppletCertificateService; +import com.soft.line.util.MP.AjaxResult; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.io.File; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * 小程序 证书 + * + * @author wpb + * @version 1.0 + * @date 2020/6/3 15:45 + */ +@Service +public class AppletCertificateServiceImpl implements AppletCertificateService { + + /** + * 虚拟 + */ + @Value("${uploadFileMapping}") + private String uploadFileMappingUrl; + + /** + * 文件上传路径 例如:D盘下的路径 + */ + @Value(value = "${uploadFileDir}") + private String uploadFileDir; + + @Autowired + private AppletCertificateMapper appletCertificateMapper; + + @Autowired + private AppletCommonMapper appletCommonMapper; + + @Override + public AjaxResult getCertificateNum() { + Map map = new HashMap<>(0); + List> mapList = appletCertificateMapper.getCertificateNum(); + //查询证书类型 + List certTypes = appletCommonMapper.codeDetailList(AppletSystemConstant.CODE_TYPE_CERT); + + if (certTypes.size() > 0) { + for (String certType : certTypes) { + map.put(certType, 0); + } + + for (Map mapData : mapList) { + for (String certType : certTypes) { + if (certType.equals(mapData.get("certType"))) { + map.put(certType, mapData.get("num")); + } + } + } + + } else { + return AjaxResult.error("查询证书类型出错"); + } + return AjaxResult.success(map); + } + + @Override + public AjaxResult getCertificateYearList(Map paramMap) { + List> list = new ArrayList<>(); + + //获取今年字符串 例:2020 + String year = getDate("yyyy", new Date()); + + for (int i = Integer.parseInt(year); i > AppletSystemConstant.ASSIGN_YEAR; i--) { + Map map = new HashMap<>(0); + map.put("beginDate", String.valueOf(i)); + map.put("num", AppletSystemConstant.NUM); + list.add(map); + } + + // beginDate = 0 ; 2005年以前 + Map map = new HashMap<>(0); + map.put("beginDate", AppletSystemConstant.NUM); + map.put("num", AppletSystemConstant.NUM); + list.add(map); + + List> mapList = appletCertificateMapper.getCertificateYearList(paramMap.get("certType").toString()); + + if (mapList.size() > 0) { + //2005 年之前的,不包含2005 + int num = 0; + int time = 2005; + for (Map mapYear : mapList) { + if (Integer.parseInt(mapYear.get("beginDate").toString()) < time) { + num += Integer.parseInt(mapYear.get("num").toString()); + } + + //数据处理 2005年 以后的 + for (Map mapLists : list) { + for (Map mapData : mapList) { + if (Integer.parseInt(mapLists.get("beginDate").toString()) != 0) { + if (mapLists.get("beginDate").equals(mapData.get("beginDate"))) { + mapLists.put("num", mapData.get("num")); + } + } else { + mapLists.put("num", num); + } + } + } + + } + } + + return AjaxResult.success(list); + } + + @Override + public AjaxResult getCertificateList(Map paramMap) { + Map map = new HashMap<>(0); + + //从第几条开始 + int num = ((Integer.parseInt(paramMap.get("pageNum").toString())) - 1) * (Integer.parseInt(paramMap.get("dataNum").toString())); + paramMap.put("pageNum", num); + + List> mapList = appletCertificateMapper.getCertificateList(paramMap); + + //条件下的总个数 + //int i = appletCertificateMapper.countCertificateList(paramMap); + int i = mapList.size(); + + //总个数大于 + map.put("hasMore", i > (num + ((int) paramMap.get("dataNum")))); + map.put("certificateList", mapList); + + return AjaxResult.success(map); + } + + @Override + public AjaxResult getCertificate(Map paramMap) { + //证书详情 + Map certificate = appletCertificateMapper.getCertificate(paramMap); + + if (certificate == null || certificate.isEmpty()) { + return AjaxResult.error("未查询出结果"); + } + + //如果值为null 转化为"" + for (String key: certificate.keySet()) { + if (certificate.get(key)==null){ + certificate.put(key,""); + } + } + + //附件详情 + List> attachmentList = appletCommonMapper.getAnnexes(Integer.parseInt(paramMap.get("id").toString()), "2"); + //拼接路径 + List> annexesList = new ArrayList<>(); + // 拼 路径 uploadFileMappingUrl + for (Map mapAnnex : attachmentList) { + mapAnnex.put("attachmentUrl", uploadFileMappingUrl + mapAnnex.get("attachmentUrl")); + annexesList.add(mapAnnex); + } + + certificate.put("attachmentList", annexesList); + + return AjaxResult.success(certificate); + } + + @Override + public AjaxResult updateCertificate(AppletCertificate appletCertificate) { + if (appletCertificateMapper.checkCertificateByCertIdAndId(appletCertificate.getCertId(),appletCertificate.getId ()) != 0) { + return AjaxResult.error("证书编号已存在"); + } + + if (appletCertificateMapper.updateCertificate(appletCertificate) != 1) { + return AjaxResult.error("修改证书失败"); + } + + List deleteAttachmentList = appletCertificate.getDeleteAttachmentList(); + + StringBuilder deleteErrorMsg = new StringBuilder(); + + if (deleteAttachmentList.size() > 0) { + + //执行删除 + for (AttachmentInfo attachmentInfo : deleteAttachmentList) { + //附件表 url + String attachmentUrl = attachmentInfo.getAttachmentUrl(); + String fileUrl = attachmentUrl.substring(attachmentUrl.indexOf(uploadFileMappingUrl) + 12); + + //删除附件文件 + File fileDir = new File(uploadFileDir + fileUrl); + boolean deleteResult = fileDir.delete(); + + if (!deleteResult) { + //deleteErrorMsg += ",删除文件:" + attachmentUrl.substring(attachmentUrl.lastIndexOf("/")) + "失败"; + deleteErrorMsg.append(",删除文件:").append(attachmentUrl.substring(attachmentUrl.lastIndexOf("/")+1)).append("失败"); + } else { + appletCommonMapper.delAnnex(attachmentInfo.getId()); + } + + } + } + + return AjaxResult.success("修改证书成功" + deleteErrorMsg); + } + + @Override + public AjaxResult deleteCertificate(Map paramMap) { + //删除时间 + paramMap.put("modifyTime", new Date()); + //删除状态 + paramMap.put("delFlg", "1"); + if (appletCertificateMapper.deleteCertificate(paramMap) != 1) { + return AjaxResult.error("删除合同失败"); + } else { + //附件信息 + List> oldAttachments = appletCommonMapper.getAnnexes((int) paramMap.get("id"), "2"); + + //删除附件 + for (Map map : oldAttachments) { + //附件表 url + String attachmentUrl = (String) map.get("attachmentUrl"); + + //删除附件文件 + File fileDir = new File(uploadFileDir + attachmentUrl); + + boolean deleteResult = fileDir.delete(); + + //删除附件基本信息 + if (deleteResult) { + appletCommonMapper.delAnnex((int) map.get("id")); + } + } + + return AjaxResult.success(); + } + } + + @Override + public AjaxResult getCertificateSearchList(Map paramMap) { + Map map = new HashMap<>(0); + + //从第几条开始 + int num = ((int) paramMap.get("pageNum") - 1) * ((int) paramMap.get("dataNum")); + paramMap.put("pageNum", num); + + List> mapList = appletCertificateMapper.getCertificateSearchList(paramMap); + + map.put("certificateList",mapList); + //条件下的总个数 + map.put("hasMore",appletCertificateMapper.countGetCertificateSearchList(paramMap) > (num+(int) paramMap.get(AppletSystemConstant.DATA_NUM)) ); + + return AjaxResult.success(map); + } + + @Override + public AjaxResult addCertificate(AppletCertificate appletCertificate) { + + if (appletCertificateMapper.checkCertificateByCertId(appletCertificate.getCertId()) != 0) { + return AjaxResult.error("证书编号已存在"); + } + + if(appletCertificateMapper.addCertificate(appletCertificate) == 1){ + Map map = new HashMap<>(0); + map.put("id",appletCertificate.getId()); + return AjaxResult.success(map); + } + return AjaxResult.error(); + } + + @Override + public AjaxResult getCertificateQueryList(Map paramMap) { + Map map = new HashMap<>(0); + + //从第几条开始 + int num = ((int) paramMap.get("pageNum") - 1) * ((int) paramMap.get("dataNum")); + paramMap.put("pageNum", num); + + List> mapList = appletCertificateMapper.getContractQueryList(paramMap); + + map.put("certificateList",mapList); + map.put("hasMore",appletCertificateMapper.countGetContractQueryList(paramMap) > (num+(int) paramMap.get(AppletSystemConstant.DATA_NUM)) ); + + return AjaxResult.success(map); + } + + /** + * 自定义时间格式 + * + * @param timeFormat 格式化 + * @param date 日期 + * @return + */ + public static String getDate(String timeFormat, Date date) { + DateFormat dateFormat = new SimpleDateFormat(timeFormat); + return dateFormat.format(date); + } + +} diff --git a/src/main/java/com/soft/line/service/impl/AppletCommonServiceImpl.java b/src/main/java/com/soft/line/service/impl/AppletCommonServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..f7549665cf0ef94d00f811d9d875e9943c6b1b0c --- /dev/null +++ b/src/main/java/com/soft/line/service/impl/AppletCommonServiceImpl.java @@ -0,0 +1,177 @@ +package com.soft.line.service.impl; + +import com.soft.line.mapper.AppletCommonMapper; +import com.soft.line.service.AppletCommonService; +import com.soft.line.util.MP.AjaxResult; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.util.*; + +/** + * 小程序 公用 + * + * @author wpb + * @version 1.0 + * @date 2020/6/1 9:10 + */ +@Slf4j +@Service +public class AppletCommonServiceImpl implements AppletCommonService { + + /** + * 文件上传路径 例如:D盘下的路径 + */ + @Value(value = "${uploadFileDir}") + private String uploadFileDir; + + + @Autowired + private AppletCommonMapper appletCommonMapper; + + @Override + public AjaxResult getBaseData() { + //返回数据 + Map>> map = new HashMap<>(0); + + //数据库数据 + List> mapList = appletCommonMapper.codeDetailMap(); + + if (mapList.size() > 0) { + + Set codeTypeSet = new HashSet<>(); + + for (Map mapData : mapList) { + codeTypeSet.add(mapData.get("codeType")); + } + + for (String codeType : codeTypeSet) { + //枚举数据集合 + List> listData = new ArrayList<>(); + for (Map mapInitial : mapList) { + //枚举数据 + Map mapData = new HashMap<>(0); + + if (codeType.equals(mapInitial.get("codeType"))) { + mapData.put("codeDetail", mapInitial.get("codeDetail")); + mapData.put("codeContent1", mapInitial.get("codeContent1")); + listData.add(mapData); + } + + } + map.put(codeType, listData); + } + } else { + return AjaxResult.error(); + } + return AjaxResult.success(map); + } + + + @Override + public AjaxResult uploadContractAttach(MultipartFile file, int id, String fileName, String modifyPerson) { + File uploadRootFileDir = new File(uploadFileDir); + File fileDir = new File(uploadRootFileDir.getAbsolutePath(), "contract/" + id); + + if (!fileDir.exists()) { + fileDir.mkdirs(); + } + + //校验文件重名,不入附件表 但会删除老的,上传新的 + boolean checkName = false; + + //文件夹中已存在的文件 + File[] existingFiles = fileDir.listFiles(); + + for (File existingFile : existingFiles) { + //文件名一样就先删除 + if (existingFile.getName().equals(fileName)) { + checkName = true; + existingFile.delete(); + } + } + + File newFile = new File(fileDir.getAbsolutePath(), fileName); + + try { + file.transferTo(newFile); + } catch (Exception e) { + e.printStackTrace(); + log.error(e.getMessage(), e); + return AjaxResult.error("上传文件失败"); + } + + if (!checkName) { + //url地址 attachmentUrl + String attachmentUrl = "contract/" + id + "/" + fileName; + //标记时间 + Date modifyTime = new Date(); + + //附件类型(1:合同,2:证书) + String type = "1"; + //添加到附件表中 + int i = appletCommonMapper.addAnnex(fileName, attachmentUrl, modifyPerson, modifyTime, type, id); + //入库是否成功 + if (i != 1) { + return AjaxResult.error("文件入库失败,请再次上传"); + } + } + return AjaxResult.success(); + } + + @Override + public AjaxResult uploadCertificateAttach(MultipartFile file, int id, String fileName, String modifyPerson) { + + File uploadRootFileDir = new File(uploadFileDir); + File fileDir = new File(uploadRootFileDir.getAbsolutePath(), "certificate/" + id); + + if (!fileDir.exists()) { + fileDir.mkdirs(); + } + + //校验文件重名,不入附件表 但会删除老的,上传新的 + boolean checkName = false; + + //文件夹中已存在的文件 + File[] existingFiles = fileDir.listFiles(); + + for (File existingFile : existingFiles) { + //文件名一样就先删除 + if (existingFile.getName().equals(fileName)) { + checkName = true; + existingFile.delete(); + } + } + + File newFile = new File(fileDir.getAbsolutePath(), fileName); + + try { + file.transferTo(newFile); + } catch (Exception e) { + e.printStackTrace(); + log.error(e.getMessage(), e); + return AjaxResult.error("上传文件失败"); + } + + if (!checkName) { + //url地址 attachmentUrl + String attachmentUrl = "certificate/" + id + "/" + fileName; + //标记时间 + Date modifyTime = new Date(); + + //附件类型(1:合同,2:证书) + String type = "2"; + //添加到附件表中 + int i = appletCommonMapper.addAnnex(fileName, attachmentUrl, modifyPerson, modifyTime, type, id); + //入库是否成功 + if (i != 1) { + return AjaxResult.error("文件入库失败,请再次上传"); + } + } + return AjaxResult.success(); + } +} diff --git a/src/main/java/com/soft/line/service/impl/AppletContractServiceImpl.java b/src/main/java/com/soft/line/service/impl/AppletContractServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..3c8b0fbd6dd3852af6456d3dca4173004663abf5 --- /dev/null +++ b/src/main/java/com/soft/line/service/impl/AppletContractServiceImpl.java @@ -0,0 +1,349 @@ +package com.soft.line.service.impl; + +import com.soft.line.common.AppletSystemConstant; +import com.soft.line.entity.AppletContract; +import com.soft.line.entity.AttachmentInfo; +import com.soft.line.mapper.AppletCommonMapper; +import com.soft.line.mapper.AppletContractMapper; +import com.soft.line.service.AppletContractService; +import com.soft.line.util.MP.AjaxResult; +import com.soft.line.util.exception.CommonResult; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.io.File; +import java.math.BigDecimal; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.stream.Collectors; + +/** + * 小程序合同serviceImpl + * + * @author wpb + * @version 1.0 + * @date 2020/5/26 15:47 + */ +@Service +@Slf4j +public class AppletContractServiceImpl implements AppletContractService { + + /** + * 虚拟 + */ + @Value("${uploadFileMapping}") + private String uploadFileMappingUrl; + + /** + * 文件上传路径 例如:D盘下的路径 + */ + @Value(value = "${uploadFileDir}") + private String uploadFileDir; + + @Autowired + private AppletContractMapper appletContractMapper; + + @Autowired + private AppletCommonMapper appletCommonMapper; + + @Override + public AjaxResult getContractNum() { + Map map = new HashMap<>(0); + List> mapList = appletContractMapper.contractNum(); + //查询所有部门 code_detail + List deptIds = appletCommonMapper.codeDetailList(AppletSystemConstant.CODE_TYPE_DEPT); + if (deptIds.size() > 0) { + for (String deptId : deptIds) { + map.put(deptId, 0L); + } + for (Map mapData : mapList) { + for (String deptId : deptIds) { + if (deptId.equals(String.valueOf(mapData.get("depId")))) { + map.put(deptId, mapData.get("value")); + } + } + } + } else { + return AjaxResult.error("查询部门出错"); + } + return AjaxResult.success(map); + } + + @Override + public AjaxResult getContractYearList(Map paraMap) { + + //获取今年字符串 例:2020 + String year = getDate("yyyy", new Date()); + //设置 部门合同年列表初始值 + + List> list = new ArrayList<>(); + + for (int i = Integer.parseInt(year); i > AppletSystemConstant.ASSIGN_YEAR; i--) { + Map map = new HashMap<>(0); + map.put("signTime", String.valueOf(i)); + map.put("num", AppletSystemConstant.NUM); + list.add(map); + } + + Map map = new HashMap<>(0); + map.put("signTime", AppletSystemConstant.NUM); + map.put("num", AppletSystemConstant.NUM); + list.add(map); + + //根据部门id获取合同年列表数据 + List> mapLists = appletContractMapper.getContractYearList(paraMap); + + if (mapLists.size() > 0) { + //2005 年之前的,不包含2005 + int num = 0; + int time = 2005; + for (Map mapYear : mapLists) { + if (Integer.parseInt(mapYear.get("signTime").toString()) < time) { + num += Integer.parseInt(mapYear.get("num").toString()); + } + } + + //数据处理 + + for (Map mapList : list) { + for (Map mapData : mapLists) { + if (Integer.parseInt(mapList.get("signTime").toString()) != 0) { + if (mapList.get("signTime").equals(mapData.get("signTime"))) { + mapList.put("num", mapData.get("num")); + } + } else { + mapList.put("num", num); + } + } + } + } + + return AjaxResult.success(list); + } + + @Override + public AjaxResult getContractList(Map paraMap) { + Map map = new HashMap<>(0); + //从第几条开始 + int num = ((int) paraMap.get("pageNum") - 1) * ((int) paraMap.get("dataNum")); + paraMap.put("pageNum", num); + + List> mapList = appletContractMapper.getContractList(paraMap); + + //条件下的总个数 + int i = appletContractMapper.countContractList(paraMap.get("depId").toString(), paraMap.get("signTime").toString()); + + //总个数大于 当前数据+10 + map.put("hasMore", i > (num + ((int) paraMap.get(AppletSystemConstant.DATA_NUM)))); + map.put("contractList", mapList); + + return AjaxResult.success(map); + } + + + @Override + public AjaxResult getContractSearchList(Map paraMap) { + Map map = new HashMap<>(0); + //从第几条开始 + int num = ((int) paraMap.get("pageNum") - 1) * ((int) paraMap.get("dataNum")); + paraMap.put("pageNum", num); + + List> mapList = appletContractMapper.getContractSearchList(paraMap); + + //条件下的总个数 + int i = appletContractMapper.countContractSearchList(paraMap.get("contractName").toString()); + + //总个数大于 当前数据+10 + map.put("hasMore", i > (num + ((int) paraMap.get(AppletSystemConstant.DATA_NUM)))); + map.put("contractList", mapList); + + return AjaxResult.success(map); + } + + @Override + public AjaxResult getContractQueryList(Map paraMap) { + Map map = new HashMap<>(0); + //从第几条开始 + int pageNum = ((int) paraMap.get("pageNum") - 1) * ((int) paraMap.get("dataNum")); + paraMap.put("pageNum", pageNum); + List idList = new ArrayList(); + List> lists = new ArrayList<>(); + List> mapList = appletContractMapper.getContractQueryList(paraMap); + if (mapList.size() > 0) { + for (Map mp : mapList) { + idList.add(mp.get("id").toString()); + } + mapList = appletContractMapper.getAboutContractNatureByIdList(paraMap, idList); + for (Map mp : mapList) { + idList.add(mp.get("id").toString()); + } + paraMap.put("idList", idList); + mapList = appletContractMapper.getAboutAllContractsByIdList(paraMap); + } + lists = mapList; + //条件下的总个数 + int i = lists.size(); + + //总个数大于 当前数据+10 + map.put("hasMore", i > (pageNum + ((int) paraMap.get(AppletSystemConstant.DATA_NUM)))); + map.put("contractList", lists); + + return AjaxResult.success(map); + } + + @Override + public AjaxResult addContract(AppletContract appletContract) { + if (appletContractMapper.checkContractByName(appletContract.getContractName()) != 0) { + return AjaxResult.error("合同已存在"); + } + + //默认不删除 + appletContract.setDelFlg("0"); + //日期 + appletContract.setModifyTime(new Date()); + + int i = appletContractMapper.addContract(appletContract); + Map map = new HashMap<>(0); + if (i == 1) { + map.put("id", appletContract.getId()); + } else { + CommonResult.failed("添加合同失败"); + } + return AjaxResult.success(map); + } + + @Override + public AjaxResult updateContract(AppletContract appletContract) { + if (appletContractMapper.checkContractByNameAndId(appletContract.getContractName(), appletContract.getId()) != 0) { + return AjaxResult.error("合同已存在"); + } + + appletContract.setModifyTime(new Date()); + int count = appletContractMapper.updateContract(appletContract); + + if (count != 1) { + return AjaxResult.error("修改合同失败"); + } + + List deleteAttachmentList = appletContract.getDeleteAttachmentList(); + + StringBuilder deleteErrorMsg = new StringBuilder(); + + if (deleteAttachmentList.size() > 0) { + + //执行删除 + for (AttachmentInfo attachmentInfo : deleteAttachmentList) { + //附件表 url + String attachmentUrl = attachmentInfo.getAttachmentUrl(); + String fileUrl = attachmentUrl.substring(attachmentUrl.indexOf(uploadFileMappingUrl) + 12); + + //删除附件文件 + File fileDir = new File(uploadFileDir + fileUrl); + boolean deleteResult = fileDir.delete(); + + if (!deleteResult) { + //deleteErrorMsg += ",删除文件:" + attachmentUrl.substring(attachmentUrl.lastIndexOf("/")) + "失败"; + deleteErrorMsg.append(",删除文件:").append(attachmentUrl.substring(attachmentUrl.lastIndexOf("/") + 1)).append("失败"); + } else { + appletCommonMapper.delAnnex(attachmentInfo.getId()); + } + + } + } + + return AjaxResult.success("修改合同成功" + deleteErrorMsg); + } + + @Override + public AjaxResult getContract(Map paraMap) { + //合同详情 + Map map = appletContractMapper.getContract(paraMap); + if (map == null || map.isEmpty()) { + return AjaxResult.error("未查询出结果"); + } + + //如果值为null 转化为"" + for (String key : map.keySet()) { + if (map.get(key) == null) { + map.put(key, ""); + } + } + map.put("totalAmount", ((BigDecimal) map.get("totalAmount")).stripTrailingZeros().toPlainString()); + + //附件详情 + int cId = (int) paraMap.get("id"); + String type = "1"; + List> getAnnexesList = appletCommonMapper.getAnnexes(cId, type); + + List> annexesList = new ArrayList<>(); + // 拼 路径 uploadFileMappingUrl + for (Map mapAnnex : getAnnexesList) { + mapAnnex.put("attachmentUrl", uploadFileMappingUrl + mapAnnex.get("attachmentUrl")); + annexesList.add(mapAnnex); + } + + map.put("attachmentList", annexesList); + return AjaxResult.success(map); + } + + /** + * 删除合同 + * + * @param paraMap 参数 + */ + @Override + public AjaxResult deleteContract(Map paraMap) { + //删除时间 + paraMap.put("modifyTime", new Date()); + //删除状态 + paraMap.put("delFlg", "1"); + int i = appletContractMapper.deleteContract(paraMap); + if (i != 1) { + return AjaxResult.error("删除合同失败"); + } else { + //附件信息 + List> oldAttachments = appletCommonMapper.getAnnexes((int) paraMap.get("id"), "1"); + + //删除附件 + for (Map map : oldAttachments) { + //附件表 url + String attachmentUrl = (String) map.get("attachmentUrl"); + + //删除附件文件 + File fileDir = new File(uploadFileDir + attachmentUrl); + + boolean deleteResult = fileDir.delete(); + + //删除附件基本信息 + if (deleteResult) { + appletCommonMapper.delAnnex((int) map.get("id")); + } + } + + return AjaxResult.success(); + } + } + + @Override + public AjaxResult getUserContDep(Map paraMap) { + List> list = appletContractMapper.getUserContDep((Integer) paraMap.get("userId")); + return AjaxResult.success(list); + } + + /** + * 自定义时间格式 + * + * @param timeFormat 格式化 + * @param date 日期 + * @return + */ + public static String getDate(String timeFormat, Date date) { + DateFormat dateFormat = new SimpleDateFormat(timeFormat); + return dateFormat.format(date); + } + + +} diff --git a/src/main/java/com/soft/line/service/impl/AttachmentInfoServiceImpl.java b/src/main/java/com/soft/line/service/impl/AttachmentInfoServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..5836312165a86c1b509e020660d8d45a4df14266 --- /dev/null +++ b/src/main/java/com/soft/line/service/impl/AttachmentInfoServiceImpl.java @@ -0,0 +1,140 @@ +package com.soft.line.service.impl; + +import com.soft.line.entity.AttachmentInfo; +import com.soft.line.filter.HttpRequestUtil; +import com.soft.line.filter.UserTokenDto; +import com.soft.line.mapper.AttachmentInfoMapper; +import com.soft.line.service.AttachMentInfoService; +import com.soft.line.util.WebToolUtils; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.boot.web.server.LocalServerPort; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.net.Inet4Address; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.*; + +@Service +@Slf4j +public class AttachmentInfoServiceImpl implements AttachMentInfoService { + + private String[] docTypes = new String[]{ + "DOC", "DOCX", "XLS", "XLSX", "PPT", "PPTX", "PDF" + }; + + private String[] imgTypes = new String[]{ + "JPG", "JPEG", "PNG", "BMP" + }; + + /** + * 文件上传路径 例如:D盘下的路径 + */ + @Value(value = "${uploadFileDir}") + private String uploadFileDir; + + @Value("${uploadFileMapping}") + private String uploadFileMappingUrl; + + @Value("${server.port}") + private String port ; + + @Value( "${server.servlet.context-path}") + private String context_path; + + + @Autowired + private AttachmentInfoMapper attachmentInfoMapper; + + @Override + public List selectAll(String attachmentType, Integer cId) { + List list = attachmentInfoMapper.selectAll(attachmentType, cId); + List result = new ArrayList(); + try { + for (AttachmentInfo ainfo : list) { + String pathUrl = ainfo.getAttachmentUrl(); + pathUrl = WebToolUtils.getLocalIP() + ":" + port + context_path + "/" + uploadFileMappingUrl + pathUrl; + ainfo.setAttachmentUrl(pathUrl); + result.add(ainfo); + } + } catch (UnknownHostException | SocketException e) { + log.error(e.getMessage(), e); + } + return result; + } + + @Override + public void delete(Map map) { + attachmentInfoMapper.deleteFileMap(map); + } + + @Override + public String save(MultipartFile file, String type, Integer cId) { + String fileName = file.getOriginalFilename(); + String contentType = fileName.substring(fileName.lastIndexOf(".")+1).toUpperCase(); + String childPath = ""; + if (type.equals("1")) { + childPath = "contract"; + } else if (type.equals("2")) { + childPath = "certificate"; + } + if (!Arrays.asList(docTypes).contains(contentType) && !Arrays.asList(imgTypes).contains(contentType)) { + return "上传文件格式不正确"; + } + + //上传 + File uploadRootFileDir = new File(uploadFileDir); + File fileDir = new File(uploadRootFileDir.getAbsolutePath(), childPath + File.separator + cId); + if (!fileDir.exists()) { + fileDir.mkdirs(); + } + //文件夹中已存在的文件 + File[] existingFiles = fileDir.listFiles(); + + for (File existingFile : existingFiles) { + //文件名一样就先删除 + if (existingFile.getName().equals(fileName)) { + existingFile.delete(); + } + } + + File newFile = new File(fileDir.getAbsolutePath(), fileName); + try { + file.transferTo(newFile); + } catch (Exception e) { + e.printStackTrace(); + log.error(e.getMessage(), e); + return "上传文件失败"; + } + String userName="admin"; + UserTokenDto userToken= HttpRequestUtil.getUserToken(); + if(userToken!=null){ + userName=userToken.getUserInfo().getUserName(); + } + AttachmentInfo attachmentInfo = new AttachmentInfo(); + attachmentInfo.setAttachmentName(fileName); + attachmentInfo.setAttachmentUrl(childPath+"/" + cId + "/" + fileName); + attachmentInfo.setModifyPerson(userName); + attachmentInfo.setModifyTime(new Date()); + attachmentInfo.setType(type); + attachmentInfo.setcId(cId); + attachmentInfoMapper.deleteFileRecord(attachmentInfo); + if (attachmentInfoMapper.insert(attachmentInfo)!=1){ + return "文件入库失败,请再次上传"; + }else{ + try { + return WebToolUtils.getLocalIP() + ":" + port + context_path + "/" + uploadFileMappingUrl + attachmentInfo.getAttachmentUrl(); + }catch (UnknownHostException | SocketException e){ + log.error(e.getMessage(), e); + return "上传失败"; + } + } + + //return "上传成功"; + + } +} diff --git a/src/main/java/com/soft/line/service/impl/ButtonInfoServiceImpl.java b/src/main/java/com/soft/line/service/impl/ButtonInfoServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..eea7c5a45b920ba981328c2b871a8681d88eceb4 --- /dev/null +++ b/src/main/java/com/soft/line/service/impl/ButtonInfoServiceImpl.java @@ -0,0 +1,28 @@ +package com.soft.line.service.impl; + +import com.soft.line.entity.ButtonInfo; +import com.soft.line.mapper.ButtonInfoMapper; +import com.soft.line.service.ButtonInfoService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@Slf4j +public class ButtonInfoServiceImpl implements ButtonInfoService { + + @Autowired + private ButtonInfoMapper buttonInfoMapper; + + @Override + public List selectAll() { + return buttonInfoMapper.selectAll(); + } + + @Override + public ButtonInfo selectByButtonId(String buttonId) { + return buttonInfoMapper.selectByButtonId(buttonId); + } +} diff --git a/src/main/java/com/soft/line/service/impl/CertificateInfoServiceImpl.java b/src/main/java/com/soft/line/service/impl/CertificateInfoServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..026ebb7262ff9159ccf6f57e8573236dd846244b --- /dev/null +++ b/src/main/java/com/soft/line/service/impl/CertificateInfoServiceImpl.java @@ -0,0 +1,109 @@ +package com.soft.line.service.impl; + +import com.github.pagehelper.PageInfo; +import com.soft.line.entity.CertificateInfo; +import com.soft.line.filter.HttpRequestUtil; +import com.soft.line.filter.UserTokenDto; +import com.soft.line.mapper.AttachmentInfoMapper; +import com.soft.line.mapper.CertificateInfoMapper; +import com.soft.line.service.CertificateInfoService; +import com.soft.line.util.pagehelper.PageUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author wu.xueqiao on 2020/5/8. + * @version 0.1 + */ +@Service +@Slf4j +public class CertificateInfoServiceImpl implements CertificateInfoService { + + @Autowired + private CertificateInfoMapper certificateInfoMapper; + @Autowired + private AttachmentInfoMapper attachmentInfoMapper; + + @Override + public List getPersonalAll(String userName) { + return certificateInfoMapper.getPersonalAll(userName); + } + + @Override + public PageInfo getAllCompanyCertificates(final Map map) { + PageUtil.setPageParam(map); + List certificateInfos=certificateInfoMapper.getAllCompanyCertificates(map); + PageInfo beans = new PageInfo(certificateInfos); + beans.setList(certificateInfos); + return beans; + } + + @Override + public PageInfo getAllCertificates(Map map) { + PageUtil.setPageParam(map); + List certificateInfos=certificateInfoMapper.selectAll(map); + PageInfo beans = new PageInfo(certificateInfos); + beans.setList(certificateInfos); + return beans; + } + + @Override + public void delete(Map map) { + certificateInfoMapper.delete(map); + attachmentInfoMapper.delete("2",(Integer)map.get("id")); + } + + @Override + public int countByCId(Integer id, String cId) { + return certificateInfoMapper.countCertificateByIdAndCId(id,cId); + } + + @Override + public void add(CertificateInfo certificateInfo) { + String userName="admin"; + UserTokenDto userToken=HttpRequestUtil.getUserToken(); + if(userToken!=null){ + userName=userToken.getUserInfo().getUserName(); + } + certificateInfo.setModifyPerson(userName); + certificateInfoMapper.insert(certificateInfo); + } + + @Override + public void update(CertificateInfo certificateInfo) { + String userName="admin"; + UserTokenDto userToken=HttpRequestUtil.getUserToken(); + if(userToken!=null){ + userName=userToken.getUserInfo().getUserName(); + } + certificateInfo.setModifyPerson(userName); + certificateInfo.setModifyTime(new Date()); + certificateInfoMapper.update(certificateInfo); + } + + @Override + public void insertRecord(List list) { + String userName="admin"; + UserTokenDto userToken=HttpRequestUtil.getUserToken(); + if(userToken!=null){ + userName=userToken.getUserInfo().getUserName(); + } + for(CertificateInfo record:list){ + record.setModifyPerson(userName); + record.setModifyTime(new Date()); + certificateInfoMapper.insertRecord(record); + } + } + + @Override + public List getAllByIDList(Map map) { + List list = certificateInfoMapper.getAllByIdList((List) map.get("ids")); + return list; + } +} diff --git a/src/main/java/com/soft/line/service/impl/CodeDetailServiceImpl.java b/src/main/java/com/soft/line/service/impl/CodeDetailServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..ed394428f2684e2433130f45457481010d51a1b0 --- /dev/null +++ b/src/main/java/com/soft/line/service/impl/CodeDetailServiceImpl.java @@ -0,0 +1,98 @@ +package com.soft.line.service.impl; + +import com.soft.line.entity.CodeDetail; +import com.soft.line.entity.LasCodeItem; +import com.soft.line.entity.LasDepartmentInfo; +import com.soft.line.filter.HttpRequestUtil; +import com.soft.line.filter.UserTokenDto; +import com.soft.line.mapper.CodeDetailMapper; +import com.soft.line.mapper.LasCodeItemMapper; +import com.soft.line.mapper.LasDepartmentInfoMapper; +import com.soft.line.mapper.RoleInfoMapper; +import com.soft.line.service.CodeDetailService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; + +@Service +@Slf4j +public class CodeDetailServiceImpl implements CodeDetailService { + @Autowired + private CodeDetailMapper codeDetailMapper; + @Autowired + private LasCodeItemMapper lasCodeItemMapper; + @Autowired + private RoleInfoMapper roleInfoMapper; + @Autowired + private LasDepartmentInfoMapper lasDepartmentInfoMapper; + + @Override + public LasCodeItem selectByPrimaryKey(String itemTypeId, String itemVal) { + return lasCodeItemMapper.selectByPrimaryKey(itemTypeId,itemVal); + } + + @Override + public LasCodeItem selectByItemDesc(String itemTypeId, String itemDesc) { + return lasCodeItemMapper.selectByItemDesc(itemTypeId,itemDesc); + } + + @Override + public List selectByCodeType(String itemTypeId) { + return lasCodeItemMapper.selectByCodeType(itemTypeId); + } + + /*@Override + public List getDepByRole() { + List depList = new ArrayList(); + UserTokenDto userToken= HttpRequestUtil.getUserToken(); + if(userToken!=null){ + String roleName = roleInfoMapper.selectByPrimaryKey(userToken.getUserInfo().getRoleId()).getName(); + if (roleName.contains("管理员")){ + depList = codeDetailMapper.selectByCodeType("1"); + }else { + depList = codeDetailMapper.getDepByRole(userToken.getUserInfo().getId()); + } + } + return depList; + }*/ + + @Override + public List getDepByRole() { + List depList = new ArrayList(); + UserTokenDto userToken= HttpRequestUtil.getUserToken(); + if(userToken!=null){ + String roleName = userToken.getUserInfo().getRoleName(); + if (roleName.contains("管理员")||roleName.contains("归档登记员")){ + depList = lasDepartmentInfoMapper.selectAllSuperior(); + }else { + LasDepartmentInfo departmentInfo = lasDepartmentInfoMapper.getDepByRole(userToken.getUserInfo().getId()); + departmentInfo = getSupDep(departmentInfo.getId()); + depList.add(departmentInfo); + } + } + return depList; + } + + @Override + public List selectAllDep() { + return lasDepartmentInfoMapper.selectAllSuperior(); + } + + @Override + public LasDepartmentInfo selectSuperiorDepByDepName(String depName) { + return lasDepartmentInfoMapper.selectSuperiorDepByDepName(depName); + } + + public LasDepartmentInfo getSupDep(String depId) { + LasDepartmentInfo lasDepartmentInfo = lasDepartmentInfoMapper.selectSupDepByDepId(depId); + while (lasDepartmentInfo!=null && !lasDepartmentInfo.getSuperiorDepId().equals("0")){ + lasDepartmentInfo = getSupDep(lasDepartmentInfo.getId()); + } + lasDepartmentInfo = lasDepartmentInfoMapper.selectSuperiorDepByDepId(depId); + return lasDepartmentInfo; + } + +} diff --git a/src/main/java/com/soft/line/service/impl/ContractInfoServiceImpl.java b/src/main/java/com/soft/line/service/impl/ContractInfoServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..e4b12cac361c5a22b74a70cb28dbb9d2ca0bc35f --- /dev/null +++ b/src/main/java/com/soft/line/service/impl/ContractInfoServiceImpl.java @@ -0,0 +1,144 @@ +package com.soft.line.service.impl; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageInfo; +import com.soft.line.entity.ContractInfo; +import com.soft.line.filter.HttpRequestUtil; +import com.soft.line.filter.UserTokenDto; +import com.soft.line.mapper.AttachmentInfoMapper; +import com.soft.line.mapper.ContractInfoMapper; +import com.soft.line.mapper.UserConDepMapper; +import com.soft.line.service.ContractInfoService; +import com.soft.line.util.pagehelper.PageUtil; +import io.swagger.models.auth.In; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @author wu.xueqiao on 2020/5/21. + * @version 0.1 + */ +@Service +@Slf4j +public class ContractInfoServiceImpl implements ContractInfoService { + @Autowired + private ContractInfoMapper contractInfoMapper; + @Autowired + private AttachmentInfoMapper attachmentInfoMapper; + @Autowired + private UserConDepMapper userConDepMapper; + + + @Override + public PageInfo getAllAboutContracts(Map map) { + PageUtil.setPageParam(map); + List contractInfos = contractInfoMapper.getAllAboutContracts(map); + PageInfo beans = new PageInfo(contractInfos); + beans.setList(contractInfos); + return beans; + } + + @Override + public PageInfo getAllContracts(Map map) { + //PageUtil.setPageParam(map); + List conResults = new ArrayList(); + List depList = new ArrayList(); + if (map.get("depId")!=null && map.get("depId").toString().length() > 0) { + depList.add(map.get("depId").toString()); + } else { + Integer userId = null; + UserTokenDto userToken = HttpRequestUtil.getUserToken(); + if (userToken != null) { + userId = userToken.getUserInfo().getId(); + } + depList = userConDepMapper.selectAllConDep(userId); + if (depList.size() == 0) { + PageInfo beans = new PageInfo(conResults); + beans.setList(conResults); + return beans; + } + } + map.put("depList",depList); + //根据查询条件查询数据 + List constracts1 = contractInfoMapper.selectAll(map); + if (constracts1.size() == 0) { + conResults = constracts1; + } else { + List idList = new ArrayList(); + for (ContractInfo con : constracts1) { + idList.add(con.getId()); + } + //查到的id在关联pro_id查询对应的收入支出合同 + List constracts2 = contractInfoMapper.selectAllNaturesByIdList(idList); + for (ContractInfo con : constracts2) { + idList.add(con.getId()); + } + map.put("idList", idList); + PageUtil.setPageParam(map); + conResults = contractInfoMapper.getAllByIdList(map); + } + + PageInfo beans = new PageInfo(conResults); + beans.setList(conResults); + return beans; + } + + @Override + public void delete(Map map) { + contractInfoMapper.delete(map); + attachmentInfoMapper.delete("1", (Integer) map.get("id")); + } + + @Override + public void add(ContractInfo contractInfo) { + String userName = "admin"; + UserTokenDto userToken = HttpRequestUtil.getUserToken(); + if (userToken != null) { + userName = userToken.getUserInfo().getUserName(); + } + contractInfo.setModifyPerson(userName); + contractInfoMapper.insert(contractInfo); + } + + @Override + public void update(ContractInfo contractInfo) { + String userName = "admin"; + UserTokenDto userToken = HttpRequestUtil.getUserToken(); + if (userToken != null) { + userName = userToken.getUserInfo().getUserName(); + } + contractInfo.setModifyPerson(userName); + contractInfo.setModifyTime(new Date()); + contractInfoMapper.update(contractInfo); + } + + @Override + public void insertList(List list) { + String userName = "admin"; + UserTokenDto userToken = HttpRequestUtil.getUserToken(); + if (userToken != null) { + userName = userToken.getUserInfo().getUserName(); + } + for (ContractInfo record : list) { + record.setModifyPerson(userName); + record.setModifyTime(new Date()); + contractInfoMapper.insertRecord(record); + } + } + + @Override + public int countContractByIdAndName(Integer id, String contractName) { + return contractInfoMapper.countContractByIdAndName(id, contractName); + } + + @Override + public List getAllCNByIDList(Map map) { + return contractInfoMapper.getAllCNByIdList((List) map.get("ids")); + } +} diff --git a/src/main/java/com/soft/line/service/impl/LasUserInfoServiceImpl.java b/src/main/java/com/soft/line/service/impl/LasUserInfoServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..d895c454e957724c1ca089723e82a238c247949d --- /dev/null +++ b/src/main/java/com/soft/line/service/impl/LasUserInfoServiceImpl.java @@ -0,0 +1,50 @@ +package com.soft.line.service.impl; + +import com.soft.line.entity.LasUserInfo; +import com.soft.line.mapper.LasUserInfoMapper; +import com.soft.line.service.LasUserInfoService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; + +@Service +@Slf4j +public class LasUserInfoServiceImpl implements LasUserInfoService { + + @Autowired + private LasUserInfoMapper lasUserInfoMapper; + + @Override + public List selectUserInfoForConDep() { + return lasUserInfoMapper.selectAllUsers(); + } + + @Override + public boolean isRegister(Integer userId) { + boolean flg = false; + if (lasUserInfoMapper.countRegister(userId) > 0) { + flg = true; + } + return flg; + } + + @Override + public boolean isDepManager(Integer userId) { + boolean flg = false; + if (lasUserInfoMapper.countDepManager(userId) > 0) { + flg = true; + } + return flg; + } + + @Override + public boolean isAssistantManager(Integer userId) { + boolean flg = false; + if (lasUserInfoMapper.countAssistantManager(userId) > 0) { + flg = true; + } + return flg; + } +} diff --git a/src/main/java/com/soft/line/service/impl/LoginServiceImpl.java b/src/main/java/com/soft/line/service/impl/LoginServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..45ff56ade002885102d311f65d13b4919ba13276 --- /dev/null +++ b/src/main/java/com/soft/line/service/impl/LoginServiceImpl.java @@ -0,0 +1,329 @@ +package com.soft.line.service.impl; + +import com.soft.line.auth.AuthConstant; +import com.soft.line.auth.Md5Util; +import com.soft.line.auth.StrUtil; +import com.soft.line.entity.*; +import com.soft.line.filter.GsonUtil; +import com.soft.line.filter.HttpRequestUtil; +import com.soft.line.filter.UserTokenDto; +import com.soft.line.mapper.*; +import com.soft.line.service.LoginService; +import com.soft.line.util.MP.AjaxResult; +import com.soft.line.util.MP.OpenIdUtil; +import com.soft.line.util.MP.SystemConstant; +import com.soft.line.util.encrypt.AesEncryptUtil; +import com.soft.line.util.exception.CommonResult; +import com.soft.line.util.exception.ResultData; +import com.soft.line.util.redis.RedisClient; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.SignatureAlgorithm; +import io.swagger.models.auth.In; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.binary.Base64; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.nio.charset.StandardCharsets; +import java.util.*; +import java.util.stream.Collectors; + +import static com.soft.line.filter.HttpRequestUtil.REDIS_SERVICE; + +/** + * @author wu.xueqiao on 2020/5/12. + * @version 0.1 + */ +@Slf4j +@Service +public class LoginServiceImpl implements LoginService { + + @Autowired + private UserInfoMapper userInfoMapper; + @Autowired + private LasUserInfoMapper lasUserInfoMapper; + @Autowired + private LasDepartmentInfoMapper lasDepartmentInfoMapper; + @Resource + private RedisClient redisClient; + @Autowired + private RoleInfoMapper roleInfoMapper; + @Autowired + private MenuInfoMapper menuInfoMapper; + @Autowired + private ButtonInfoMapper buttonInfoMapper; + @Autowired + private UserConDepMapper userConDepMapper; + @Autowired + private LasCodeItemMapper lasCodeItemMapper; + + @Override + public CommonResult userLogin(Map map) { + + String password = (String) map.get("password"); + password = AesEncryptUtil.encrypt(password, AuthConstant.PASSWORD_ENCRYPT_KEY); + map.replace("password", password); + System.out.println("password:" + (String) map.get("password")); + // UserInfo userInfo= userInfoMapper.userLogin(map); + LasUserInfo userInfo = lasUserInfoMapper.userLogin(map); + if (userInfo != null) { + UserInfoToken userInfoToken = new UserInfoToken(); + userInfoToken.setUserName(userInfo.getUserName()); + userInfoToken.setRoleId(userInfo.getRoleId()); + String roleName = roleInfoMapper.selectRoleName(userInfo.getRoleId()); + userInfoToken.setRoleName(roleName); + //userInfoToken.setPhone(userInfo.getPhone()); + userInfoToken.setPhone(userInfo.getTelephone()); + userInfoToken.setId(userInfo.getId()); + userInfoToken.setPassword(userInfo.getPassword()); + UserTokenDto user = new UserTokenDto(); + user.setUserInfo(userInfoToken); + String token = returnToken(user); + user.setToken(token); + if (token == null || "".equals(token)) { + return CommonResult.failed("redis插入失败"); + } + return CommonResult.success(user); + } else { + return CommonResult.failed("登录失败!"); + } + } + + @Override + public CommonResult loginOut() { + UserTokenDto userTokenDto = HttpRequestUtil.getUserToken(); + String key = userTokenDto.getUserInfo().getUserName(); + boolean out = REDIS_SERVICE.del(key); + if (out) { + return CommonResult.success("退出登录成功!"); + } else { + return CommonResult.failed("退出登录失败!"); + } + + } + + + private String returnToken(final UserTokenDto user) { + if (redisClient.getKeyValue(user.getUserInfo().getUserName()) == null || "".equals(redisClient.getKeyValue(user.getUserInfo().getUserName()))) { +// final Map claims = new HashMap<>(); +// claims.put("password", user.getUserInfo().getPassword()); +// claims.put("username", user.getUserInfo().getUserName()); +// claims.put("uuid", UUID.randomUUID().toString()); + //final String token = Jwts.builder().setClaims(claims) + // .signWith(SignatureAlgorithm.HS512, HttpRequestUtil.key).compact(); + + String spliceStr; + Long lifeTime = null; + if (lifeTime == null) { + spliceStr = "{}-{}-{}"; + } else { + spliceStr = "{}-{}-{}-{}"; + lifeTime = System.currentTimeMillis() + lifeTime; + } + String tokenPlainText = AuthConstant.USER_TOKEN_PREFIX + StrUtil.spliceStr(spliceStr, user.getUserInfo().getId(), + user.getUserInfo().getUserName(), user.getUserInfo().getRoleName(), lifeTime); + String base64Token = Base64.encodeBase64String(tokenPlainText.getBytes(StandardCharsets.UTF_8)); + String md5PlainText = base64Token + AuthConstant.SAFE_STRING; + String token = base64Token + Md5Util.encodeMd5(md5PlainText).toUpperCase(); + user.setToken(token); + System.out.println(token); + if (!redisClient.setKeyValue(user.getUserInfo().getUserName(), GsonUtil.javabeanToJson(user), HttpRequestUtil.expire)) { + return null; + } + return token; + } else { + redisClient.setKeyTimeout(user.getUserInfo().getUserName(), HttpRequestUtil.expire); + return GsonUtil.jsonToJavaBean(redisClient.getKeyValue(user.getUserInfo().getUserName())).getToken(); + } + } + + @Override + public AjaxResult autoLogin(String code) { + Map data = new HashMap<>(); + + //获取openId + String openId = OpenIdUtil.getOpenId(code); + + if (openId == null) { + System.out.println("获取openId失败!"); + return AjaxResult.error("获取微信信息失败,请稍后再试!"); + } + UserInfo userInfo = userInfoMapper.getUserInfoByOpenId(openId); + //用户已经绑定过openId 则签发token 以及返回userInfo + if (userInfo != null) { + try { + UserInfoToken userInfoToken = new UserInfoToken(); + userInfoToken.setUserName(userInfo.getUserName()); + userInfoToken.setRoleId(userInfo.getRoleId()); + userInfoToken.setPhone(userInfo.getPhone()); + userInfoToken.setId(userInfo.getId()); + userInfoToken.setPassword(userInfo.getPassword()); + UserTokenDto user = new UserTokenDto(); + user.setUserInfo(userInfoToken); + String token = returnToken(user); + userInfo.setPassword(""); + data.put("userInfo", userInfo); + data.put("token", token); + } catch (Exception e) { + e.printStackTrace(); + log.error("签发token失败!", e); + return AjaxResult.error("登录失败,请稍后再试!"); + } + + return AjaxResult.success(data); + + } + //用户未绑定过openId + else { + //返回未绑定 + return AjaxResult.noBand(); + } + } + + @Override + public AjaxResult bindUserInfo(Map map) { + String code = map.get("code"); + String phone = map.get("phone"); + String userName = map.get("userName"); + String password = map.get("password"); + Map data = new HashMap<>(); + UserInfo userInfo = userInfoMapper.getUserInfoByPhoneAndUserNameAndPassword(phone, userName, password); + if (userInfo == null) { + return AjaxResult.error("手机或账号密码错误!"); + } + //获取openId + String openId = OpenIdUtil.getOpenId(code); + + if (openId == null) { + System.out.println("获取openId失败!"); + return AjaxResult.error("获取微信信息失败,请稍后再试!"); + } + //绑定openId + userInfoMapper.updateOpenIdById(openId, userInfo.getId()); + try { + UserInfoToken userInfoToken = new UserInfoToken(); + userInfoToken.setUserName(userInfo.getUserName()); + userInfoToken.setRoleId(userInfo.getRoleId()); + userInfoToken.setPhone(userInfo.getPhone()); + userInfoToken.setId(userInfo.getId()); + userInfoToken.setPassword(userInfo.getPassword()); + UserTokenDto user = new UserTokenDto(); + user.setUserInfo(userInfoToken); + String token = returnToken(user); + userInfo.setPassword(""); + data.put("userInfo", userInfo); + data.put("token", token); + } catch (Exception e) { + e.printStackTrace(); + log.error("签发token失败!", e); + return AjaxResult.error("登录失败,请稍后再试!"); + } + return AjaxResult.success(data); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public AjaxResult getUserInfo(Map map) { + UserTokenDto userTokenDto = HttpRequestUtil.getUserToken(); + int id = userTokenDto.getUserInfo().getId(); + String code = map.get("code"); + //获取openId + String openId = OpenIdUtil.getOpenId(code); + if (openId == null) { + System.out.println("获取openId失败!"); + return AjaxResult.error("获取微信信息失败,请稍后再试!"); + } + UserInfo userInfo = userInfoMapper.getUserInfoByOpenId(openId); + //有token又没有根据此openId查出用户 说明openId变了 此时根据用户id查询绑定用户openId + if (userInfo == null) { + userInfoMapper.updateOpenIdById(openId, id); + userInfo = userInfoMapper.getUserInfoByOpenId(openId); + return AjaxResult.success(userInfo); + } + return AjaxResult.success(userInfo); + } + + @Override + public AjaxResult updatePassword(Map map) { + UserTokenDto userTokenDto = HttpRequestUtil.getUserToken(); + int id = userTokenDto.getUserInfo().getId(); + + int result = userInfoMapper.updatePassword(id, (String) map.get("password")); + if (result > 0) { + return AjaxResult.success(); + } + return AjaxResult.error(); + } + + @Override + public AjaxResult untie() { + UserTokenDto userTokenDto = HttpRequestUtil.getUserToken(); + int id = userTokenDto.getUserInfo().getId(); + int result = userInfoMapper.deleteOpenId(id); + if (result > 0) { + return AjaxResult.success(); + } + return AjaxResult.error(); + } + + @Override + public UserPermission getUserPermission() { + UserTokenDto userTokenDto = HttpRequestUtil.getUserToken(); + Integer userId = userTokenDto.getUserInfo().getId(); + LasUserInfo userInfo = lasUserInfoMapper.selectByPrimaryKey(userId); + UserPermission userPermission = new UserPermission(); + userPermission.setId(userId); + userPermission.setPhone(userInfo.getTelephone()); + userPermission.setModifyTime(userInfo.getLastUpdateTime()); + userPermission.setRoleId(userInfo.getRoleId()); + userPermission.setUserName(userInfo.getUserName()); + userPermission.setStatus(userInfo.getUserStatus()); + //对应部门 + /*LasDepartmentInfo lasDepartmentInfo = getSupDep(userInfo.getDepId()); + LasDepartmentInfo supDep = lasDepartmentInfoMapper.selectSuperiorDepByDepId(lasDepartmentInfo.getId()); + userPermission.setDepInfo(supDep);*/ + userPermission.setDepInfo(lasDepartmentInfoMapper.getDepByRole(userId)); + //对应合同部门 + userPermission.setConDepList(lasCodeItemMapper.selectAllConDep(userId)); + //获取对应角色 + RoleInfo role = roleInfoMapper.selectByPrimaryKey(userInfo.getRoleId()); + userPermission.setRole(role); + List> menuList = new ArrayList<>(); + List list = new ArrayList<>(); + for (RoleInfo roleInfo : roleInfoMapper.selectAll(role.getName())) { + for (MenuInfo menuInfo : menuInfoMapper.selectByRoleId(roleInfo.getId())) { + Map menuMap = new HashMap<>(); + menuMap.put("menuId", menuInfo.getId()); + menuMap.put("menuName", menuInfo.getMenuName()); + menuMap.put("menuUrl", menuInfo.getMenuUrl()); + menuMap.put("menuIcon", menuInfo.getMenuIcon()); + if (menuInfo.getpId() != -1) { + list.add(menuInfo.getpId()); + } + List buttonList = buttonInfoMapper.selectButtonsByRoleIdAndMenuId(roleInfo.getId(), menuInfo.getId()); + menuMap.put("buttonList", buttonList); + menuList.add(menuMap); + } + } + List pList = list.stream().distinct().collect(Collectors.toList()); + for (Integer id : pList) { + menuList.add(menuInfoMapper.getParentMenu(id)); + } + userPermission.setMenuList(menuList); + return userPermission; + } + + @Override + public LasDepartmentInfo getSupDep(String depId) { + LasDepartmentInfo lasDepartmentInfo = lasDepartmentInfoMapper.selectSupDepByDepId(depId); + while (lasDepartmentInfo != null && !lasDepartmentInfo.getSuperiorDepId().equals("0")) { + lasDepartmentInfo = getSupDep(lasDepartmentInfo.getId()); + } + lasDepartmentInfo = lasDepartmentInfoMapper.selectSuperiorDepByDepId(depId); + return lasDepartmentInfo; + } + + +} diff --git a/src/main/java/com/soft/line/service/impl/MenuInfoServiceImpl.java b/src/main/java/com/soft/line/service/impl/MenuInfoServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..fc1495306742dc6bbfa30119a29473e16d4f7224 --- /dev/null +++ b/src/main/java/com/soft/line/service/impl/MenuInfoServiceImpl.java @@ -0,0 +1,150 @@ +package com.soft.line.service.impl; + +import com.github.pagehelper.PageInfo; +import com.soft.line.entity.ButtonInfo; +import com.soft.line.entity.MenuButtonInfo; +import com.soft.line.entity.MenuInfo; +import com.soft.line.mapper.ButtonInfoMapper; +import com.soft.line.mapper.MenuButtonInfoMapper; +import com.soft.line.mapper.MenuInfoMapper; +import com.soft.line.mapper.RoleMenuMapper; +import com.soft.line.service.MenuInfoService; +import com.soft.line.util.pagehelper.PageUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; + +@Service +@Slf4j +public class MenuInfoServiceImpl implements MenuInfoService { + + @Autowired + private MenuInfoMapper menuInfoMapper; + @Autowired + private ButtonInfoMapper buttonInfoMapper; + @Autowired + private MenuButtonInfoMapper menuButtonInfoMapper; + @Autowired + private RoleMenuMapper roleMenuMapper; + + @Override + public PageInfo selectAll(final Map map) { + PageUtil.setPageParam(map); + //String menuName = (String)map.get("menuName"); + List menuInfoList = menuInfoMapper.selectAll((String)map.get("menuName"),(String)map.get("menuUrl")); + for (MenuInfo menuInfo:menuInfoList) { + menuInfo.setButtonInfoList(selectButtonsByMenuId(menuInfo.getId())); + } + PageInfo menuInfoPage =new PageInfo(menuInfoList); + return menuInfoPage; + } + + @Override + public List selectButtonsByMenuId(Integer menuId) { + return buttonInfoMapper.selectButtonsByMenuId(menuId); + } + + @Override + public MenuInfo selectByPrimaryKey(Integer id) { + MenuInfo menuInfo = menuInfoMapper.selectByPrimaryKey(id); + menuInfo.setButtonInfoList(buttonInfoMapper.selectButtonsByMenuId((id))); + return menuInfo; + } + + @Override + public MenuInfo selectParentMenu(Integer pid) { + return menuInfoMapper.selectParentMenu(pid); + } + + @Override + public int countMenuName(Integer id,String menuName) { + return menuInfoMapper.countMenuName(id,menuName); + } + + @Override + public int countOrderBy(Integer id,String orderBy) { + return menuInfoMapper.countOrderBy(id,orderBy); + } + + @Override + public List selectALlMenuName() { + return menuInfoMapper.selectALlMenuName(); + } + + @Override + public void addMenuInfo(MenuInfo menuInfo) { + menuInfoMapper.insert(menuInfo); + for (ButtonInfo buttonInfo : menuInfo.getButtonInfoList()) { + MenuButtonInfo menuButtonInfo = new MenuButtonInfo(); + menuButtonInfo.setMenuId(menuInfo.getId()); + menuButtonInfo.setButtonId(buttonInfo.getButtonId()); + menuButtonInfo.setModifyPerson(menuInfo.getModifyPerson()); + menuButtonInfo.setModifyTime(new Date()); + menuButtonInfoMapper.insert(menuButtonInfo); + } + } + + @Override + public void updateMenInfo(MenuInfo menuInfo) { + menuInfoMapper.update(menuInfo); + List oldButtonList = menuButtonInfoMapper.selectButtonIdByMenuId(menuInfo.getId()); + List newButtonList = new ArrayList(); + for (ButtonInfo bi:menuInfo.getButtonInfoList()){ + newButtonList.add(bi.getButtonId()); + } + //旧的比新的多,删除旧的 + List dealOldButtonList = getDiffrent(oldButtonList,newButtonList); + for (String buttonId : dealOldButtonList) { + roleMenuMapper.deleteByMenuIdAndButtonId(menuInfo.getId(),buttonId); + menuButtonInfoMapper.deleteByMenuIdAndButtonId(menuInfo.getId(),buttonId); + } + //新的比旧的多,新增新的 + List dealNewButtonList = getDiffrent(newButtonList,oldButtonList); + for (String buttonId : dealNewButtonList) { + MenuButtonInfo menuButtonInfo = new MenuButtonInfo(); + menuButtonInfo.setMenuId(menuInfo.getId()); + menuButtonInfo.setButtonId(buttonId); + menuButtonInfo.setModifyPerson(menuInfo.getModifyPerson()); + menuButtonInfo.setModifyTime(new Date()); + menuButtonInfoMapper.insert(menuButtonInfo); + } + } + + @Override + @Transactional + public void delete(Integer id) { + roleMenuMapper.deleteByMenuId(id); + menuButtonInfoMapper.deleteByMenuId(id); + menuInfoMapper.delete(id); + } + + @Override + public List selectTopMenu() { + return menuInfoMapper.selectTopMenu(); + } + + @Override + public List selectSonMenus() { + List menuInfoList= menuInfoMapper.selectMenusInMenuButton(); + List resultList = new ArrayList(); + for (MenuInfo menuInfo : menuInfoList){ + menuInfo.setButtonInfoList(buttonInfoMapper.selectButtonsByMenuId(menuInfo.getId())); + resultList.add(menuInfo); + } + return resultList; + } + + //取两个list的差集 + private static List getDiffrent(List list1, List list2) { + List list3 = new ArrayList(); + list3.addAll(list1); + list3.removeAll(list2); + return list3; + } +} diff --git a/src/main/java/com/soft/line/service/impl/RoleInfoServiceImpl.java b/src/main/java/com/soft/line/service/impl/RoleInfoServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..43d8dacd68f7c3ef71a59c8725faa1d42e0a383f --- /dev/null +++ b/src/main/java/com/soft/line/service/impl/RoleInfoServiceImpl.java @@ -0,0 +1,118 @@ +package com.soft.line.service.impl; + +import com.github.pagehelper.PageInfo; +import com.soft.line.entity.ButtonInfo; +import com.soft.line.entity.MenuInfo; +import com.soft.line.entity.RoleInfo; +import com.soft.line.filter.HttpRequestUtil; +import com.soft.line.filter.UserTokenDto; +import com.soft.line.mapper.ButtonInfoMapper; +import com.soft.line.mapper.MenuInfoMapper; +import com.soft.line.mapper.RoleInfoMapper; +import com.soft.line.mapper.RoleMenuMapper; +import com.soft.line.service.RoleInfoService; +import com.soft.line.util.pagehelper.PageUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; +import java.util.stream.Collectors; + +@Slf4j +@Service +public class RoleInfoServiceImpl implements RoleInfoService { + + @Autowired + private RoleInfoMapper roleInfoMapper; + @Autowired + private MenuInfoMapper menuInfoMapper; + @Autowired + private ButtonInfoMapper buttonInfoMapper; + @Autowired + private RoleMenuMapper roleMenuMapper; + + @Override + public List selectAll() { + return roleInfoMapper.selectAll(null); + } + + @Override + public PageInfo>> selectAllRoleMenuInfo(Map map) { + PageUtil.setPageParam(map); + List> reultList = new ArrayList>(); + for (RoleInfo roleInfo:roleInfoMapper.selectAll((String)map.get("roleName"))){ + Map roleMap = new HashMap(); + roleMap.put("id",roleInfo.getId()); + roleMap.put("roleName",roleInfo.getName()); + roleMap.put("state",roleInfo.getState()); + List> menuList = new ArrayList>(); + for (MenuInfo menuInfo:menuInfoMapper.selectByRoleId(roleInfo.getId())){ + Map menuMap = new HashMap(); + menuMap.put("menuId",menuInfo.getId()); + menuMap.put("menuName",menuInfo.getMenuName()); + List buttonInfos=buttonInfoMapper.selectButtonsByRoleIdAndMenuId(roleInfo.getId(),menuInfo.getId()); + menuMap.put("buttonList",buttonInfos); + menuList.add(menuMap); + } + roleMap.put("menuList",menuList); + reultList.add(roleMap); + } + PageInfo>> resultPage = new PageInfo(reultList); + return resultPage; + } + + @Override + public void delete(Map map) { + Integer roleId =(Integer)map.get("id"); + roleMenuMapper.deleteByRoleId(roleId); + roleInfoMapper.delete(roleId); + } + + @Override + public int countRoleName(Integer roleId, String roleName) { + return roleInfoMapper.countRoleName(roleId,roleName); + } + + @Override + public void add(Map map) { + String roleName = (String)map.get("roleName"); + String modifyPerson = "admin"; + UserTokenDto userToken= HttpRequestUtil.getUserToken(); + if(userToken!=null){ + modifyPerson=userToken.getUserInfo().getUserName(); + } + map.put("modifyPerson",modifyPerson); + map.put("modifyTime",new Date()); + roleInfoMapper.insert(map); + RoleInfo roleInfo = roleInfoMapper.selectByRoleName(roleName); + List> menuList=(List)map.get("menu"); + for (Map mp:menuList){ + Integer menuId=(Integer)mp.get("menuId"); + for (String buttonId:(List)mp.get("buttonList")){ + roleMenuMapper.insert(roleInfo.getId(),menuId,buttonId,modifyPerson); + } + } + } + + @Override + public void update(Map map) { + Integer roleId =(Integer)map.get("id"); + String modifyPerson = "admin"; + UserTokenDto userToken= HttpRequestUtil.getUserToken(); + if(userToken!=null){ + modifyPerson=userToken.getUserInfo().getUserName(); + } + map.put("modifyPerson",modifyPerson); + map.put("modifyTime",new Date()); + roleInfoMapper.update(map); + roleMenuMapper.deleteByRoleId(roleId); + List> menuList=(List)map.get("menu"); + for (Map mp:menuList){ + Integer menuId=(Integer)mp.get("menuId"); + for (String buttonId:(List)mp.get("buttonList")){ + roleMenuMapper.insert(roleId,menuId,buttonId,modifyPerson); + } + } + } +} diff --git a/src/main/java/com/soft/line/service/impl/StatisticsServiceImpl.java b/src/main/java/com/soft/line/service/impl/StatisticsServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..0536e4b7b88a28d2e2a6c9f78b72bd3c94d9da43 --- /dev/null +++ b/src/main/java/com/soft/line/service/impl/StatisticsServiceImpl.java @@ -0,0 +1,117 @@ +package com.soft.line.service.impl; + +import com.soft.line.entity.LasDepartmentInfo; +import com.soft.line.filter.HttpRequestUtil; +import com.soft.line.filter.UserTokenDto; +import com.soft.line.mapper.CertificateInfoMapper; +import com.soft.line.mapper.ContractInfoMapper; +import com.soft.line.mapper.LasDepartmentInfoMapper; +import com.soft.line.mapper.UserConDepMapper; +import com.soft.line.service.StatisticsService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +@Service +@Slf4j +public class StatisticsServiceImpl implements StatisticsService { + + @Autowired + private ContractInfoMapper contractInfoMapper; + @Autowired + private CertificateInfoMapper certificateInfoMapper; + @Autowired + private LasDepartmentInfoMapper lasDepartmentInfoMapper; + @Autowired + private UserConDepMapper userConDepMapper; + + @Override + public List> statisticsForCertificate(Map map) { + String x = (String)map.get("x"); + String y = (String)map.get("y"); + List> resultList = new ArrayList>(); + if (y.equals("数量")){ + if(x.equals("年份")){ + resultList = certificateInfoMapper.countNumGroupByYear(); + }else if (x.equals("类型")){ + resultList = certificateInfoMapper.countNumGroupByCertType(); + } + } + return resultList; + } + + @Override + public List> countNumGroupByDepThisYear(Map map) { + return contractInfoMapper.countNumGroupByDepThisYear(); + } + + @Override + public List> countDepGroupByYear(Map map) { + String dep = map.get("dep").toString(); + System.out.println("dep:"+dep); + return contractInfoMapper.countDepGroupByYear(dep); + } + + @Override + public List> countNumByTypeYear() { + return contractInfoMapper.countNumByTypeYear(); + } + + @Override + public List> amountRankingForContract() { + return contractInfoMapper.amountRanking(); + } + + @Override + public List> depRankingForContract() { + return contractInfoMapper.depRanking(); + } + + @Override + public List> certTypeRankThisYear() { + return certificateInfoMapper.certTypeRankThisYear(); + } + + @Override + public List> sumContractByYear(Map map) { + return contractInfoMapper.sumContractByYear(map.get("year").toString()); + } + + @Override + public List> sumContractNatureByYear(Map map) { + return contractInfoMapper.sumContractNatureByYear(map.get("year").toString()); + } + + @Override + public List> sumContractNatureByYearAndDep(Map map) { + List depIdList = new ArrayList(); + UserTokenDto userToken= HttpRequestUtil.getUserToken(); + if (userToken!=null){ + int userId = userToken.getUserInfo().getId(); + depIdList = userConDepMapper.selectAllConDep(userId); + return contractInfoMapper.sumContractNatureByYearAndDep(map.get("year").toString(),depIdList); + }else{ + return null; + } + + } + + @Override + public List> countNumGroupByDep() { + List depIdList = new ArrayList(); + UserTokenDto userToken= HttpRequestUtil.getUserToken(); + if (userToken!=null){ + int userId = userToken.getUserInfo().getId(); + depIdList = userConDepMapper.selectAllConDep(userId); + return contractInfoMapper.countNumGroupByDep(depIdList); + }else{ + return null; + } + } + + +} diff --git a/src/main/java/com/soft/line/service/impl/UserConDepServiceImpl.java b/src/main/java/com/soft/line/service/impl/UserConDepServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..b214a32b756d1e51b9409a742536b7d3f90e4a9e --- /dev/null +++ b/src/main/java/com/soft/line/service/impl/UserConDepServiceImpl.java @@ -0,0 +1,72 @@ +package com.soft.line.service.impl; + +import com.github.pagehelper.PageInfo; +import com.soft.line.entity.LasCodeItem; +import com.soft.line.entity.LasUserInfo; +import com.soft.line.entity.UserConDep; +import com.soft.line.filter.HttpRequestUtil; +import com.soft.line.filter.UserTokenDto; +import com.soft.line.mapper.LasCodeItemMapper; +import com.soft.line.mapper.UserConDepMapper; +import com.soft.line.service.UserConDepService; +import com.soft.line.util.pagehelper.PageUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +@Slf4j +@Service +public class UserConDepServiceImpl implements UserConDepService { + + @Autowired + public UserConDepMapper userConDepMapper; + @Autowired + public LasCodeItemMapper lasCodeItemMapper; + + @Override + public PageInfo selectUserConDep(Map map) { + PageUtil.setPageParam(map); + List ucpList =userConDepMapper.selectAllUser((Integer) map.get("userId")); + for (UserConDep ucp:ucpList){ + List userConDeps=lasCodeItemMapper.selectAllConDep(ucp.getUserId()); + ucp.setDepList(userConDeps); + } + PageInfo resultPage = new PageInfo(ucpList); + resultPage.setList(ucpList); + return resultPage; + } + + @Override + public List getConDepByUserId(Map map) { + return lasCodeItemMapper.selectAllConDep((Integer) map.get("userId")); + } + + @Override + public boolean exitsUserConDep(Map map) { + int count = userConDepMapper.countUserConDepByUserId((Integer) map.get("userId")); + return count>0; + } + + @Override + public void delete(Map map) { + userConDepMapper.deleteByUserId((Integer)map.get("userId")); + } + + @Override + public void save (Map map) { + String modifyPerson = "admin"; + UserTokenDto userToken= HttpRequestUtil.getUserToken(); + if(userToken!=null){ + modifyPerson=userToken.getUserInfo().getUserName(); + } + userConDepMapper.deleteByUserId((Integer)map.get("userId")); + for (String contractDepartmentId:(List)map.get("depList")){ + userConDepMapper.insert((Integer) map.get("userId"),contractDepartmentId,modifyPerson); + } + } +} diff --git a/src/main/java/com/soft/line/service/impl/UserInfoServiceImpl.java b/src/main/java/com/soft/line/service/impl/UserInfoServiceImpl.java new file mode 100644 index 0000000000000000000000000000000000000000..8e1d7b0e712261fa9b62c3525a5387c0b228cf51 --- /dev/null +++ b/src/main/java/com/soft/line/service/impl/UserInfoServiceImpl.java @@ -0,0 +1,86 @@ +package com.soft.line.service.impl; + + +import com.github.pagehelper.PageInfo; +import com.soft.line.entity.UserInfo; +import com.soft.line.filter.HttpRequestUtil; +import com.soft.line.filter.UserTokenDto; +import com.soft.line.mapper.UserInfoMapper; +import com.soft.line.service.UserInfoService; +import com.soft.line.util.pagehelper.PageUtil; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.List; +import java.util.Map; + +/** + * @author wu.xueqiao on 2020/5/12. + * @version 0.1 + */ +@Service +public class UserInfoServiceImpl implements UserInfoService { + + @Autowired + private UserInfoMapper userInfoMapper; + + + @Override + public UserInfo getUserInfo(int userId) { + return userInfoMapper.selectByPrimaryKey(userId); + } + + @Override + public PageInfo getAllUsers(Map map) { + PageUtil.setPageParam(map); + List userInfos=userInfoMapper.getAllUsers(map); + PageInfo beans = new PageInfo(userInfos); + beans.setList(userInfos); + return beans; + } + + @Override + public int delUser(int id) { + int result=userInfoMapper.delUser(id); + if(result==1){ + return 1; + }else { + return 0; + } + } + + @Override + public int addUser(UserInfo userInfo) { + UserTokenDto userTokenDto= HttpRequestUtil.getUserToken(); + userInfo.setModifyPerson(userTokenDto.getUserInfo().getUserName()); + if (userInfo.getId()==null){ + return userInfoMapper.insert(userInfo); + }else { + return userInfoMapper.updateUserInfo(userInfo); + } + + } + + @Override + public Boolean changePassword(Map map) { + int id=Integer.valueOf(map.get("id").toString()); + UserInfo userInfo=userInfoMapper.selectByPrimaryKey(id); + String password=userInfo.getPassword(); + String oldPassword=map.get("oldPassword").toString(); + String newPassword=map.get("newPassword").toString(); + String confirmPassword=map.get("confirmPassword").toString(); + if(password.equals(oldPassword) && newPassword.equals(confirmPassword)){ + userInfo.setPassword(newPassword); + int update=userInfoMapper.updateUserInfo(userInfo); + if(update==1){ + return true; + } + } + return false; + } + + @Override + public int countByRoleId(Integer roleId) { + return userInfoMapper.countByRoleId(roleId); + } +} diff --git a/src/main/java/com/soft/line/util/MP/AjaxResult.java b/src/main/java/com/soft/line/util/MP/AjaxResult.java new file mode 100644 index 0000000000000000000000000000000000000000..97c983250e123d24adccf39b73f318e46232372b --- /dev/null +++ b/src/main/java/com/soft/line/util/MP/AjaxResult.java @@ -0,0 +1,236 @@ +package com.soft.line.util.MP; + + +import java.util.HashMap; + +/** + * @Description: 封装的controller返回值类 + * + * @version: v1.0.0 + * @author: zlx + * @date: 2020年3月6日 下午1:10:49 + */ +public class AjaxResult extends HashMap { + private static final long serialVersionUID = 1L; + + /** 状态码 */ + public static final String CODE_TAG = "code"; + + /** 返回内容 */ + public static final String MSG_TAG = "msg"; + + /** 数据对象 */ + public static final String DATA_TAG = "data"; + + /** + * 状态类型 + */ + public enum Type { + + /** 成功 */ + SUCCESS(200), + /** 警告 */ + WARN(301), + /** 未绑定 */ + NOBAND(501), + /** 错误 */ + ERROR(500); + + private final int value; + + Type(int value) { + this.value = value; + } + + public int value() { + return this.value; + } + } + + /** + * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。 + */ + public AjaxResult() { + } + + /** + * 初始化一个新创建的 AjaxResult 对象 + * + * @param type 状态类型 + * @param msg 返回内容 + */ + public AjaxResult(Type type, String msg) { + super.put(CODE_TAG, type.value); + super.put(MSG_TAG, msg); + } + + /** + * 初始化一个新创建的 AjaxResult 对象 + * + * @param type 状态类型 + * @param msg 返回内容 + * @param data 数据对象 + */ + public AjaxResult(Type type, String msg, Object data) { + super.put(CODE_TAG, type.value); + super.put(MSG_TAG, msg); + if (data != null) { + super.put(DATA_TAG, data); + } + } + + /** + * 返回成功消息 + * + * @return 成功消息 + */ + public static AjaxResult success() { + return AjaxResult.success("成功"); + } + + /** + * 返回成功数据 + * + * @return 成功消息 + */ + public static AjaxResult success(Object data) { + return AjaxResult.success("成功", data); + } + + /** + * 返回成功消息 + * + * @param msg 返回内容 + * @return 成功消息 + */ + public static AjaxResult success(String msg) { + return AjaxResult.success(msg, null); + } + + /** + * 返回成功消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 成功消息 + */ + public static AjaxResult success(String msg, Object data) { + return new AjaxResult(Type.SUCCESS, msg, data); + } + + /** + * 返回成功消息带有服务器时间秒值 + * + * @param data + * @return + */ + public static AjaxResult successWithServerTime() { + AjaxResult ajaxResult = AjaxResult.success(); + ajaxResult.put("ServerTime", DateUtil.getNowTimeSecond()); + return ajaxResult; + } + + /** + * 返回成功消息带有服务器时间秒值 + * + * @param data + * @return + */ + public static AjaxResult successWithServerTime(Object data) { + AjaxResult ajaxResult = AjaxResult.success(data); + ajaxResult.put("ServerTime", DateUtil.getNowTimeSecond()); + return ajaxResult; + } + + /** + * 返回警告消息 + * + * @param msg 返回内容 + * @return 警告消息 + */ + public static AjaxResult warn(String msg) { + return AjaxResult.warn(msg, null); + } + + /** + * 返回警告消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 警告消息 + */ + public static AjaxResult warn(String msg, Object data) { + return new AjaxResult(Type.WARN, msg, data); + } + + /** + * 返回错误消息 + * + * @return + */ + public static AjaxResult error() { + return AjaxResult.error("失败"); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @return 警告消息 + */ + public static AjaxResult error(String msg) { + return AjaxResult.error(msg, null); + } + + /** + * 返回错误消息 + * + * @param msg 返回内容 + * @param data 数据对象 + * @return 警告消息 + */ + public static AjaxResult error(String msg, Object data) { + return new AjaxResult(Type.ERROR, msg, data); + } + + /** + * 返回错误消息带有服务器时间秒值 + * + * @return + */ + public static AjaxResult errorWithServerTime() { + AjaxResult ajaxResult = AjaxResult.error("失败"); + ajaxResult.put("ServerTime", DateUtil.getNowTimeSecond()); + return ajaxResult; + } + + /** + * 返回错误消息带有服务器时间秒值 + * + * @return + */ + public static AjaxResult errorWithServerTime(String msg) { + AjaxResult ajaxResult = AjaxResult.error(msg); + ajaxResult.put("ServerTime", DateUtil.getNowTimeSecond()); + return ajaxResult; + } + + /** + * 返回未绑定 + * + * @return + */ + public static AjaxResult noBand() { + return AjaxResult.noBand("未绑定"); + + } + + /** + * 返回未绑定 + * + * @return + */ + private static AjaxResult noBand(String string) { + return new AjaxResult(Type.NOBAND, string); + } +} diff --git a/src/main/java/com/soft/line/util/MP/DateUtil.java b/src/main/java/com/soft/line/util/MP/DateUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..add112c56ebc3fe125ab1a441e6a739a7dd1c2d8 --- /dev/null +++ b/src/main/java/com/soft/line/util/MP/DateUtil.java @@ -0,0 +1,103 @@ +package com.soft.line.util.MP; + +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.Date; + +/** + * @Description: 日期工具类 + * + * @version: v1.0.0 + * @author: zlx + * @date: 2020年3月17日 上午10:41:08 + */ +public class DateUtil { + + /** + * 获取yyyy-MM-dd格式今日日期字符串 + * + * @return 例:"2020-01-01" + */ + public static String getSimpleNowDateStr() { + DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); + Date date = new Date(); + String dateStr = dateFormat.format(date); + return dateStr; + } + + /** + * 获取某格式今日日期字符串 + * + * @return + */ + public static String getNowDateStr(String formatStr) { + DateFormat dateFormat = new SimpleDateFormat(formatStr); + Date date = new Date(); + String dateStr = dateFormat.format(date); + return dateStr; + } + + /** + * 获取某格式某日期字符串 + * + * @return + */ + public static String getDateStr(Date date,String formatStr) { + DateFormat dateFormat = new SimpleDateFormat(formatStr); + String dateStr = dateFormat.format(date); + return dateStr; + } + + /** + * 判断当前时间是否在[startTime, endTime]区间,注意时间格式要一致 + * + * @param nowTime + * @param startTime + * @param endTime + * @return + */ + public static boolean isEffectiveDate(Date nowTime, Date startTime, Date endTime) { + if (nowTime.getTime() == startTime.getTime() || nowTime.getTime() == endTime.getTime()) { + return true; + } + + Calendar date = Calendar.getInstance(); + date.setTime(nowTime); + + Calendar begin = Calendar.getInstance(); + begin.setTime(startTime); + + Calendar end = Calendar.getInstance(); + end.setTime(endTime); + + if (date.after(begin) && date.before(end)) { + return true; + } else { + return false; + } + } + + /** + * 获取当前时间秒值 + * + * @return + */ + public static long getNowTimeSecond() { + return new Date().getTime() / 1000; + } + + + /** + * 获取yyyyMMddHHmmssSSS格式今日日期字符串 + * + * @return 例:"20200326190038998" + */ + public static String getSimpleDayTimeStr() { + DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmssSSS"); + Date date = new Date(); + String dateStr = dateFormat.format(date); + return dateStr; + } + +} diff --git a/src/main/java/com/soft/line/util/MP/HttpClientUtil.java b/src/main/java/com/soft/line/util/MP/HttpClientUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..dafb52802aa8e39bc7969859d33470cb2222000a --- /dev/null +++ b/src/main/java/com/soft/line/util/MP/HttpClientUtil.java @@ -0,0 +1,113 @@ +package com.soft.line.util.MP; + +import lombok.extern.slf4j.Slf4j; +import org.apache.http.HttpResponse; +import org.apache.http.client.CookieStore; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.impl.client.BasicCookieStore; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.cookie.BasicClientCookie; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; + +import java.io.IOException; +import java.util.List; + +/** + * @Description: HttpClient工具类 发送post和get请求 + * + * @version: v1.0.0 + * @author: zlx + * @date: 2020年3月17日 下午3:12:43 + */ +@Slf4j +public class HttpClientUtil { + + public static CookieStore cookieStore = new BasicCookieStore(); + public static CloseableHttpClient httpCilent = HttpClients.custom().setDefaultCookieStore(cookieStore).build(); + + public static String httpPost(String url, List list) { + + // 配置超时时间 + RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(5000).setConnectionRequestTimeout(5000) + .setSocketTimeout(5000).setRedirectsEnabled(true).build(); + + HttpPost httpPost = new HttpPost(url); + // 设置超时时间 + httpPost.setConfig(requestConfig); + + String strResult = ""; + int StatusCode = 404; + try { + if (list != null) { + UrlEncodedFormEntity entity = new UrlEncodedFormEntity(list, "UTF-8"); + // 设置post求情参数 + httpPost.setEntity(entity); + } + HttpResponse httpResponse = httpCilent.execute(httpPost); + + if (httpResponse != null) { + StatusCode = httpResponse.getStatusLine().getStatusCode(); + if (httpResponse.getStatusLine().getStatusCode() == 200) { + strResult = EntityUtils.toString(httpResponse.getEntity()); + log.info("post/" + StatusCode + ":" + strResult); + return strResult; + } else { + strResult = "Error Response: " + httpResponse.getStatusLine().toString(); + log.info("post/" + StatusCode + ":" + strResult); + strResult = null; + } + } + + } catch (Exception e) { + log.error(e.getMessage()); + } + + return strResult; + } + + public static String HttpGet(String url) { + + RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(5000) // 设置连接超时时间 + .setConnectionRequestTimeout(5000) // 设置请求超时时间 + .setSocketTimeout(5000).setRedirectsEnabled(true)// 默认允许自动重定向 + .build(); + HttpGet httpGet2 = new HttpGet(url); + httpGet2.setConfig(requestConfig); + String srtResult = null; + int StatusCode = 404; + try { + HttpResponse httpResponse = httpCilent.execute(httpGet2); + StatusCode = httpResponse.getStatusLine().getStatusCode(); + if (httpResponse.getStatusLine().getStatusCode() == 200) { + srtResult = EntityUtils.toString(httpResponse.getEntity());// 获得返回的结果 + log.info("get/" + StatusCode + ":" + srtResult); + return srtResult; + } else { + srtResult = EntityUtils.toString(httpResponse.getEntity());// 获得返回的结果 + log.info("get/" + StatusCode + ":" + srtResult); + return null; + } + } catch (IOException e) { + log.error(e.getMessage()); + } + return null; + } + + public static void setCookieStore(List cookielist) { + for (BasicClientCookie cookie : cookielist) { + HttpClientUtil.cookieStore.addCookie(cookie); + } + } + + public static void createCookie(List cookielist) { + for (BasicClientCookie cookie : cookielist) { + HttpClientUtil.cookieStore.addCookie(cookie); + } + } + +} diff --git a/src/main/java/com/soft/line/util/MP/OpenIdUtil.java b/src/main/java/com/soft/line/util/MP/OpenIdUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..1b3dc0e5ede0da5c02042b502aaf43a62ead6084 --- /dev/null +++ b/src/main/java/com/soft/line/util/MP/OpenIdUtil.java @@ -0,0 +1,22 @@ +package com.soft.line.util.MP; + + +import com.alibaba.fastjson.JSONObject; + +public class OpenIdUtil { + + public static String getOpenId (String code) { + + + String url = "https://api.weixin.qq.com/sns/jscode2session?appid=" + + SystemConstant.APP_ID + "&secret=" + SystemConstant.APP_SECRET + "&js_code=" + + code + "&grant_type=authorization_code"; + + String reString= HttpClientUtil.httpPost(url, null); + + JSONObject jsonObject = JSONObject.parseObject(reString); + + String openId=jsonObject.getString("openid"); + return openId; + } +} diff --git a/src/main/java/com/soft/line/util/MP/SystemConstant.java b/src/main/java/com/soft/line/util/MP/SystemConstant.java new file mode 100644 index 0000000000000000000000000000000000000000..359faba9102de5ccf32d23bb5bf8083a896b2211 --- /dev/null +++ b/src/main/java/com/soft/line/util/MP/SystemConstant.java @@ -0,0 +1,34 @@ +package com.soft.line.util.MP; + +/** + * @Description: 系统常量 + * + * @version: v1.0.0 + * @author: zlx + * @date: 2020年3月6日 下午1:16:12 + */ +public class SystemConstant { + + // 刷新token(有返回值) + public static final int RESCODE_REFTOKEN_MSG = 1006; + // 刷新token + public static final int RESCODE_REFTOKEN = 1007; + + // token不存在 + public static final int JWT_ERRCODE_NULL = 4000; + // token 过期 + public static final int JWT_ERRCODE_EXPIRE = 4001; + // 验证不通过 + public static final int JWT_ERRCODE_FAIL = 4002; + + public static final String JWT_SECERT = "8677df7fc3a34e26a61c034d5ec8245d"; + + public static final long JWT_TTL = 10 * 1000;// M/d/h/m/s/ms + + //小程序appId + public static final String APP_ID="wx670dad59ddddc338"; + + //小程序appSecret + public static final String APP_SECRET ="a4d7f702c8f36d9f8a7f10f87b851711"; + +} diff --git a/src/main/java/com/soft/line/util/WebToolUtils.java b/src/main/java/com/soft/line/util/WebToolUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..a6a36e82f42374a24caa29d742d8ab965cd83378 --- /dev/null +++ b/src/main/java/com/soft/line/util/WebToolUtils.java @@ -0,0 +1,74 @@ +package com.soft.line.util; + +import java.net.InetAddress; +import java.net.NetworkInterface; +import java.net.SocketException; +import java.net.UnknownHostException; +import java.util.Enumeration; + +public class WebToolUtils { + + public static String getLocalIP() throws UnknownHostException, SocketException { + if (isWindowsOS()) { + return InetAddress.getLocalHost().getHostAddress(); + } else { + return getLinuxLocalIp(); + } + } + + /** + * 判断操作系统是否是Windows + * + * @return + */ + public static boolean isWindowsOS() { + boolean isWindowsOS = false; + String osName = System.getProperty("os.name"); + if (osName.toLowerCase().indexOf("windows") > -1) { + isWindowsOS = true; + } + return isWindowsOS; + } + + /** + * 获取本地Host名称 + */ + public static String getLocalHostName() throws UnknownHostException { + return InetAddress.getLocalHost().getHostName(); + } + + /** + * 获取Linux下的IP地址 + * + * @return IP地址 + * @throws SocketException + */ + private static String getLinuxLocalIp() throws SocketException { + String ip = ""; + try { + for (Enumeration en = NetworkInterface.getNetworkInterfaces(); en.hasMoreElements();) { + NetworkInterface intf = en.nextElement(); + String name = intf.getName(); + if (!name.contains("docker") && !name.contains("lo")) { + for (Enumeration enumIpAddr = intf.getInetAddresses(); enumIpAddr.hasMoreElements();) { + InetAddress inetAddress = enumIpAddr.nextElement(); + if (!inetAddress.isLoopbackAddress()) { + String ipaddress = inetAddress.getHostAddress().toString(); + if (!ipaddress.contains("::") && !ipaddress.contains("0:0:") && !ipaddress.contains("fe80")) { + ip = ipaddress; + System.out.println(ipaddress); + } + } + } + } + } + } catch (SocketException ex) { + System.out.println("获取ip地址异常"); + ip = "127.0.0.1"; + ex.printStackTrace(); + } + System.out.println("IP:"+ip); + return ip; + } + +} diff --git a/src/main/java/com/soft/line/util/config/Swagger2Config.java b/src/main/java/com/soft/line/util/config/Swagger2Config.java new file mode 100644 index 0000000000000000000000000000000000000000..afc7e736e68a6f20a16c1870ac59284c8fb68a09 --- /dev/null +++ b/src/main/java/com/soft/line/util/config/Swagger2Config.java @@ -0,0 +1,42 @@ +package com.soft.line.util.config; + +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; + +/** + * @author wu.xueqiao on 2020/5/8. + * @version 0.1 + */ + +@Configuration +@EnableSwagger2 +public class Swagger2Config { + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2) + .apiInfo(apiInfo()) + .select() + .apis(RequestHandlerSelectors.basePackage("com.soft.line.controller")) + .paths(PathSelectors.any()) + .build(); + } + + private ApiInfo apiInfo() { + return new ApiInfoBuilder() + .title("Swagger接口列表") + .description("接口") + .termsOfServiceUrl("http://localhost:9100/swagger-ui.html") + .contact(new Contact("ljc", "http://www.softline.sh.cn", "154040976@qq.com")) + .version("1.1.0") + .build(); + } + +} diff --git a/src/main/java/com/soft/line/util/encrypt/AesEncryptUtil.java b/src/main/java/com/soft/line/util/encrypt/AesEncryptUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..8823eb8a638001d5c9a6864f41872ee5a0b4c444 --- /dev/null +++ b/src/main/java/com/soft/line/util/encrypt/AesEncryptUtil.java @@ -0,0 +1,34 @@ +package com.soft.line.util.encrypt; + +import cn.hutool.crypto.SecureUtil; +import cn.hutool.crypto.symmetric.AES; + +/** + * AES方式加密解密数据工具类 + * + * @author 86185 + * @date 2020/5/9 16:55 + */ +public final class AesEncryptUtil extends BaseEncrypt { + + public static String encrypt(String content, String key) { + return encrypt(content, key.getBytes(DEFAULT_CHARSET)); + } + + public static String encrypt(String content, byte[] key) { + key = concat(key); + AES aes = SecureUtil.aes(key); + return encrypt(aes, content); + } + + public static String decrypt(String encrypt, String key) { + return decrypt(encrypt, key.getBytes(DEFAULT_CHARSET)); + } + + public static String decrypt(String encrypt, byte[] key) { + key = concat(key); + AES aes = SecureUtil.aes(key); + return decrypt(aes, encrypt); + } + +} diff --git a/src/main/java/com/soft/line/util/encrypt/BaseEncrypt.java b/src/main/java/com/soft/line/util/encrypt/BaseEncrypt.java new file mode 100644 index 0000000000000000000000000000000000000000..a09058d8cfc042a013386676697cd5d122519170 --- /dev/null +++ b/src/main/java/com/soft/line/util/encrypt/BaseEncrypt.java @@ -0,0 +1,73 @@ +package com.soft.line.util.encrypt; + +import cn.hutool.crypto.symmetric.SymmetricCrypto; +import lombok.extern.slf4j.Slf4j; +import org.apache.tomcat.util.codec.binary.Base64; + +import java.nio.charset.Charset; +import java.nio.charset.StandardCharsets; + +/** + * @author 86185 + * @date 2020/5/9 16:49 + */ +@Slf4j +public class BaseEncrypt { + + private static final int DEFAULT_KEY_LENGTH = 16; + protected static final Charset DEFAULT_CHARSET = StandardCharsets.UTF_8; + + protected static String encrypt(SymmetricCrypto crypto, String content) { + try { + byte[] encrypt = crypto.encrypt(content); + return Base64.encodeBase64String(encrypt); + } catch (Exception e) { + log.warn("encrypt error", e); + throw new RuntimeException("encrypt content error."); + } + } + + protected static String decrypt(SymmetricCrypto crypto, String encrypt) { + try { + byte[] contentByte = Base64.decodeBase64(encrypt); + byte[] decrypt = crypto.decrypt(contentByte); + return new String(decrypt); + } catch (Exception e) { + log.warn("decrypt error", e); + throw new RuntimeException("decrypt error."); + } + } + + protected static byte[] concat(byte[] key) { + return concat(key, DEFAULT_KEY_LENGTH); + } + + protected static byte[] concat(byte[] key, int keyLength) { + if (key == null || key.length == keyLength) { + return key; + } + byte[] bytes = new byte[keyLength]; + if (key.length > keyLength) { + System.arraycopy(key, 0, bytes, 0, keyLength); + } else { + int len = keyLength - key.length; + for (int i = 0; i < len; i++) { + byte[] b = {(byte) len}; + key = concat(key, b); + } + bytes = key; + } + return bytes; + } + + private static byte[] concat(byte[] firstArray, byte[] secondArray) { + if (firstArray == null || secondArray == null) { + return null; + } + byte[] bytes = new byte[firstArray.length + secondArray.length]; + System.arraycopy(firstArray, 0, bytes, 0, firstArray.length); + System.arraycopy(secondArray, 0, bytes, firstArray.length, secondArray.length); + return bytes; + } + +} diff --git a/src/main/java/com/soft/line/util/encrypt/Md5Util.java b/src/main/java/com/soft/line/util/encrypt/Md5Util.java new file mode 100644 index 0000000000000000000000000000000000000000..7787d87b88f179707021f70aa0dbbecc7f3dbd7c --- /dev/null +++ b/src/main/java/com/soft/line/util/encrypt/Md5Util.java @@ -0,0 +1,18 @@ +package com.soft.line.util.encrypt; + +import org.apache.commons.codec.digest.DigestUtils; + +/** + * Md5加密工具 + * + * @author 86185 + * @date 2020/5/13 10:53 + */ +public class Md5Util { + + public static String encodeMd5(final String str) { + + return DigestUtils.md5Hex(str); + } + +} diff --git a/src/main/java/com/soft/line/util/exception/Asserts.java b/src/main/java/com/soft/line/util/exception/Asserts.java new file mode 100644 index 0000000000000000000000000000000000000000..7760abd51fc6a6168b2a9aff80ceb7c76b9f21f3 --- /dev/null +++ b/src/main/java/com/soft/line/util/exception/Asserts.java @@ -0,0 +1,18 @@ +package com.soft.line.util.exception; + + + +/** + * @Description 断言处理类,用于抛出各种API异常 + * @Author wu.xueqiao + * @Date 2020/05/08 12:47 + */ +public class Asserts { + public static void fail(String message) { + throw new GlobalException(message); + } + + public static void fail(IErrorCode errorCode) { + throw new GlobalException(errorCode); + } +} diff --git a/src/main/java/com/soft/line/util/exception/CommonResult.java b/src/main/java/com/soft/line/util/exception/CommonResult.java new file mode 100644 index 0000000000000000000000000000000000000000..42e92152d2831fcba8116f1f852097a78583aeeb --- /dev/null +++ b/src/main/java/com/soft/line/util/exception/CommonResult.java @@ -0,0 +1,135 @@ +package com.soft.line.util.exception; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Description 返回详细信息 + * @Author wu.xueqiao + * @Date 2020/05/08 12:47 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class CommonResult { + private Integer code; + private String msg; + private T result; + + public CommonResult(Integer code, String msg) { + this.code = code; + this.msg = msg; + } + + /** + * 成功返回结果 + * + * @param result 获取的数据 + * @param + * @return + */ + public static CommonResult success(T result) { + return new CommonResult(ResultCode.SUCCESS.getCode(), ResultCode.SUCCESS.getMessage(), result); + } + + /** + * 成功返回结果 + * + * @param result 获取的数据 + * @param message 提示信息 + * @param + * @return + */ + public static CommonResult success(T result, String message) { + return new CommonResult(ResultCode.SUCCESS.getCode(), message, result); + } + + /** + * 失败返回结果 + * + * @param errorCode 错误码 + * @param + * @return + */ + public static CommonResult failed(IErrorCode errorCode) { + return new CommonResult(errorCode.getCode(), errorCode.getMessage(), null); + } + + /** + * 失败返回结果 + * + * @param errorCode 错误码 + * @param message 提示信息 + * @param + * @return + */ + public static CommonResult failed(IErrorCode errorCode, String message) { + return new CommonResult(errorCode.getCode(), message, null); + } + + /** + * 失败返回结果 + * + * @param message 提示信息 + * @param + * @return + */ + public static CommonResult failed(String message) { + return new CommonResult(ResultCode.FAILED.getCode(), message, null); + } + + + /** + * 失败返回结果 + * + * @param + * @return + */ + public static CommonResult failed() { + return failed(ResultCode.FAILED); + } + + /** + * 参数验证失败返回结果 + * + * @param + * @return + */ + public static CommonResult validateFailed() { + return failed(ResultCode.VALIDATE_FAILED); + } + + /** + * 提示信息 + * + * @param message 提示信息 + * @param + * @return + */ + public static CommonResult validateFailed(String message) { + return new CommonResult(ResultCode.VALIDATE_FAILED.getCode(), message, null); + } + + /** + * 未登录返回结果 + * + * @param result 获取的数据 + * @param + * @return + */ + public static CommonResult unauthorized(T result) { + return new CommonResult(ResultCode.UNAUTHORIZED.getCode(), ResultCode.UNAUTHORIZED.getMessage(), result); + } + + /** + * 未授权返回结果 + * + * @param result 获取的数据 + * @param + * @return + */ + public static CommonResult forbidden(T result) { + return new CommonResult(ResultCode.FORBIDDEN.getCode(), ResultCode.FORBIDDEN.getMessage(), result); + } +} diff --git a/src/main/java/com/soft/line/util/exception/GlobalException.java b/src/main/java/com/soft/line/util/exception/GlobalException.java new file mode 100644 index 0000000000000000000000000000000000000000..debf63bf0f3c7c4b05927c0d2a5f4e3862ee86f7 --- /dev/null +++ b/src/main/java/com/soft/line/util/exception/GlobalException.java @@ -0,0 +1,35 @@ +package com.soft.line.util.exception; + + + +/** + * @Description 自定义异常 + * @Author wu.xueqiao + * @Date 2020/05/08 12:47 + */ + +public class GlobalException extends RuntimeException { + private IErrorCode errorCode; + + public IErrorCode getErrorCode() { + return errorCode; + } + + public GlobalException(IErrorCode errorCode) { + super(errorCode.getMessage()); + this.errorCode = errorCode; + } + + public GlobalException(String message) { + super(message); + } + + public GlobalException(Throwable cause) { + super(cause); + } + + public GlobalException(String message, Throwable cause) { + super(message, cause); + } + +} diff --git a/src/main/java/com/soft/line/util/exception/IErrorCode.java b/src/main/java/com/soft/line/util/exception/IErrorCode.java new file mode 100644 index 0000000000000000000000000000000000000000..e22940ba1c7344246fdd9a343705089c8ed17dd0 --- /dev/null +++ b/src/main/java/com/soft/line/util/exception/IErrorCode.java @@ -0,0 +1,12 @@ +package com.soft.line.util.exception; + +/** + * @Description 封装API的错误码 + * @Author wu.xueqiao + * @Date 2020/05/08 12:47 + */ +public interface IErrorCode { + Integer getCode(); + + String getMessage(); +} diff --git a/src/main/java/com/soft/line/util/exception/ResultCode.java b/src/main/java/com/soft/line/util/exception/ResultCode.java new file mode 100644 index 0000000000000000000000000000000000000000..838676ac290d06c690a104a358d9ca4bd7b55cb7 --- /dev/null +++ b/src/main/java/com/soft/line/util/exception/ResultCode.java @@ -0,0 +1,34 @@ +package com.soft.line.util.exception; + +/** + * @Description 枚举一些常用API操作码 + * @Author wu.xueqiao + * @Date 2020/05/08 12:47 + */ +public enum ResultCode implements IErrorCode { + + SUCCESS(200, "操作成功"), + FAILED(500, "操作失败"), + VALIDATE_FAILED(404, "参数检验失败"), + UNAUTHORIZED(401, "暂未登录或token已经过期"), + FORBIDDEN(403, "没有相关权限"); + + + private Integer code; + private String message; + + private ResultCode(Integer code, String message) { + this.code = code; + this.message = message; + } + + public Integer getCode() { + return code; + } + + public String getMessage() { + return message; + } + + +} diff --git a/src/main/java/com/soft/line/util/exception/ResultData.java b/src/main/java/com/soft/line/util/exception/ResultData.java new file mode 100644 index 0000000000000000000000000000000000000000..04cd2739879e61fe80d0671b91de2ee46010dd25 --- /dev/null +++ b/src/main/java/com/soft/line/util/exception/ResultData.java @@ -0,0 +1,53 @@ +package com.soft.line.util.exception; + +import java.io.Serializable; + +public class ResultData implements Serializable { + + private static final long serialVersionUID = 6342989717148610893L; + private int status; + + private String msg; + + private Object data; + + public int getStatus() { + + return status; + } + + public void setStatus(final int status) { + + this.status = status; + } + + public String getMsg() { + + return msg; + } + + public void setMsg(final String msg) { + + this.msg = msg; + } + + public Object getData() { + + return data; + } + + public void setData(final Object data) { + + this.data = data; + } + + public ResultData(final int status, final String msg, final Object data) { + super(); + this.data = data; + this.status = status; + this.msg = msg; + } + + public ResultData() { + } +} diff --git a/src/main/java/com/soft/line/util/generator/mybatis-generator.xml b/src/main/java/com/soft/line/util/generator/mybatis-generator.xml new file mode 100644 index 0000000000000000000000000000000000000000..529a97487df806baab8c2527916a150af5911ba0 --- /dev/null +++ b/src/main/java/com/soft/line/util/generator/mybatis-generator.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
\ No newline at end of file diff --git a/src/main/java/com/soft/line/util/jackson/converter/ConverterConfig.java b/src/main/java/com/soft/line/util/jackson/converter/ConverterConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..ec27878ffa42b67c596feee91bac2a14cadd77bc --- /dev/null +++ b/src/main/java/com/soft/line/util/jackson/converter/ConverterConfig.java @@ -0,0 +1,33 @@ +package com.soft.line.util.jackson.converter; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.core.convert.converter.Converter; + +import java.util.Date; + +/** + * 转换器配置 + * + * @author + * @date + */ +@Configuration +public class ConverterConfig { + + @Bean + public Converter stringToDateConverter() { + return new StringToDateConverter(); + } + + @Bean + public Converter stringToIntegerConverter() { + return new StringToIntegerConverter(); + } + + @Bean + public Converter stringToDoubleConverter() { + return new StringToDoubleConverter(); + } + +} diff --git a/src/main/java/com/soft/line/util/jackson/converter/StringToDateConverter.java b/src/main/java/com/soft/line/util/jackson/converter/StringToDateConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..929e769562edc901ba4798e92100bbccf2bf5181 --- /dev/null +++ b/src/main/java/com/soft/line/util/jackson/converter/StringToDateConverter.java @@ -0,0 +1,21 @@ +package com.soft.line.util.jackson.converter; + +import org.springframework.core.convert.converter.Converter; + +import java.util.Date; + +/** + * + * 日期转换器,将请求参数的日期字符串转换成java.util.Date类型 + * + * + * @author + * @date + */ +public class StringToDateConverter implements Converter { + + @Override + public Date convert(String source) { + return StringToDateUtil.convert(source); + } +} diff --git a/src/main/java/com/soft/line/util/jackson/converter/StringToDateUtil.java b/src/main/java/com/soft/line/util/jackson/converter/StringToDateUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..82116107d63a59c3901bb0465c333a2dfa0376b7 --- /dev/null +++ b/src/main/java/com/soft/line/util/jackson/converter/StringToDateUtil.java @@ -0,0 +1,88 @@ +package com.soft.line.util.jackson.converter; + +import org.apache.commons.lang3.StringUtils; + +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.Date; + +/** + * + *
+ * 日期转换器,将请求参数的日期字符串转换成java.util.Date类型
+ * 日期格式顺序:
+ * 	1.yyyy-MM-dd HH:mm:ss:S
+ * 	2.yyyy-MM-dd HH:mm:ss
+ * 	3.yyyy-MM-dd HH:mm
+ * 	4.yyyy-MM-dd HH
+ * 	5.yyyy-MM-dd
+ * 
+ *
+ * + * @author + * @date + */ +public class StringToDateUtil { + /** + * 日期格式化数组 + */ + private static DateFormat[] dateFormats = { + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss:S"), + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"), + new SimpleDateFormat("yyyy-MM-dd HH:mm"), + new SimpleDateFormat("yyyy-MM-dd HH"), + new SimpleDateFormat("yyyy-MM-dd"), + new SimpleDateFormat("yyyy-MM") + }; + + /** + * + *
+     * 1.如果日期字符串为空,则直接返回空
+     * 2.使用格式化组进行格式化,如果解析成功,则直接返回
+     * 4.否则,抛出非法参数异常
+     * @param source 请求的日期参数
+     * @return 解析后的日期类型:java.util.Date
+     * @exception IllegalArgumentException 非法参数异常
+     * 
+ *
+ */ + public static Date convert(String source) { + if (StringUtils.isBlank(source)) { + return null; + } + source = source.trim(); + + try { + int timeLength = source.length(); + Long time = Long.parseLong(source); + if (timeLength == 10) { + time = time * 1000; + } + Date date = new Date(time); + return date; + } catch (Exception e) { + + } + + Date date = null; + boolean flag = false; + for (DateFormat dateFormat : dateFormats) { + try { + date = dateFormat.parse(source); + flag = true; + break; + } catch (ParseException e) { + // e.printStackTrace(); + } + } + + if (flag) { + return date; + } else { + throw new IllegalArgumentException("不能解析日期:" + source); + } + + } +} diff --git a/src/main/java/com/soft/line/util/jackson/converter/StringToDoubleConverter.java b/src/main/java/com/soft/line/util/jackson/converter/StringToDoubleConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..f12a3235c3fa3512767fdcc0d298a52cf9506cd0 --- /dev/null +++ b/src/main/java/com/soft/line/util/jackson/converter/StringToDoubleConverter.java @@ -0,0 +1,19 @@ +package com.soft.line.util.jackson.converter; + +import org.springframework.core.convert.converter.Converter; + +/** + * + * + * + * + * @author + * @date + */ +public class StringToDoubleConverter implements Converter { + + @Override + public Double convert(String source) { + return StringToDoubleUtil.convert(source); + } +} diff --git a/src/main/java/com/soft/line/util/jackson/converter/StringToDoubleUtil.java b/src/main/java/com/soft/line/util/jackson/converter/StringToDoubleUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..583941c3f487a1e2b65f0cfc2d897fd547f99130 --- /dev/null +++ b/src/main/java/com/soft/line/util/jackson/converter/StringToDoubleUtil.java @@ -0,0 +1,26 @@ +package com.soft.line.util.jackson.converter; + + +import org.apache.commons.lang3.StringUtils; + +/** + * + *
+ * 空字符串("")转换成Double的null
+ *
+ * 
+ *
+ * + * @author + * @date + */ +public class StringToDoubleUtil { + + public static Double convert(String source) { + if (StringUtils.isBlank(source)) { + return null; + } + Double d = Double.parseDouble(source); + return d; + } +} diff --git a/src/main/java/com/soft/line/util/jackson/converter/StringToIntegerConverter.java b/src/main/java/com/soft/line/util/jackson/converter/StringToIntegerConverter.java new file mode 100644 index 0000000000000000000000000000000000000000..4dd0c7e2bed1d88c58328491fd2f79474770aafa --- /dev/null +++ b/src/main/java/com/soft/line/util/jackson/converter/StringToIntegerConverter.java @@ -0,0 +1,19 @@ +package com.soft.line.util.jackson.converter; + +import org.springframework.core.convert.converter.Converter; + +/** + * + * + * + * + * @author + * @date + */ +public class StringToIntegerConverter implements Converter { + + @Override + public Integer convert(String source) { + return StringToIntegerUtil.convert(source); + } +} diff --git a/src/main/java/com/soft/line/util/jackson/converter/StringToIntegerUtil.java b/src/main/java/com/soft/line/util/jackson/converter/StringToIntegerUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..f264f3aace6e19b1a5b9db774bbd2c45ca9558e3 --- /dev/null +++ b/src/main/java/com/soft/line/util/jackson/converter/StringToIntegerUtil.java @@ -0,0 +1,41 @@ +/* + * Copyright 2019-2029 TuMingLong(https://github.com/TuMingLong) + * + * Licensed 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 + * + * http://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. + */ + +package com.soft.line.util.jackson.converter; + +import org.apache.commons.lang3.StringUtils; + +/** + * + *
+ * 空字符串("")转换成Integer的null
+ *
+ * 
+ *
+ * + * @author + * @date + */ +public class StringToIntegerUtil { + + public static Integer convert(String source) { + if (StringUtils.isBlank(source)) { + return null; + } + Integer i = Integer.parseInt(source); + return i; + } +} diff --git a/src/main/java/com/soft/line/util/pagehelper/PageBeans.java b/src/main/java/com/soft/line/util/pagehelper/PageBeans.java new file mode 100644 index 0000000000000000000000000000000000000000..4f4b510e9cb78056b994c318db5b03edf66d5f80 --- /dev/null +++ b/src/main/java/com/soft/line/util/pagehelper/PageBeans.java @@ -0,0 +1,81 @@ +package com.soft.line.util.pagehelper; + +import com.github.pagehelper.Page; + +import java.io.Serializable; +import java.util.List; + +public class PageBeans implements Serializable { + private static final long serialVersionUID = 6545455108462881123L; + private long total; //总记录数 + private List list; //结果集 + private int pageNum; // 第几页 + private int pageSize; // 每页记录数 + private int pages; // 总页数 + private int size; // 当前页的数量 <= pageSize,该属性来自ArrayList的size属性 + + /** + * 包装Page对象,因为直接返回Page对象. + * @param list page结果 + */ + public PageBeans(List list) { + if (list instanceof Page) { + Page page = (Page) list; + this.pageNum = page.getPageNum(); + this.pageSize = page.getPageSize(); + this.total = page.getTotal(); + this.pages = page.getPages(); + this.list = page; + this.size = page.size(); + } + } + + public long getTotal() { + return total; + } + + public void setTotal(long total) { + this.total = total; + } + + public List getList() { + return list; + } + + public void setList(List list) { + this.list = list; + } + + public int getPageNum() { + return pageNum; + } + + public void setPageNum(int pageNum) { + this.pageNum = pageNum; + } + + public int getPageSize() { + return pageSize; + } + + public void setPageSize(int pageSize) { + this.pageSize = pageSize; + } + + public int getPages() { + return pages; + } + + public void setPages(int pages) { + this.pages = pages; + } + + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size = size; + } + +} diff --git a/src/main/java/com/soft/line/util/pagehelper/PageUtil.java b/src/main/java/com/soft/line/util/pagehelper/PageUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..de4a3da9433ef4559be2a36354cc6f0ae1af83a3 --- /dev/null +++ b/src/main/java/com/soft/line/util/pagehelper/PageUtil.java @@ -0,0 +1,43 @@ +package com.soft.line.util.pagehelper; + +import com.github.pagehelper.Page; +import com.github.pagehelper.PageHelper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Map; + + +public class PageUtil { + private static final transient Logger LOG = LoggerFactory.getLogger(PageUtil.class); + /** + * set page. + * + * @param paramMap + * + * @return page info. + */ + public static Page> setPageParam(final Map paramMap) { + int pageNum = 1; + int pageSize = 10; + final Object pageNumO = paramMap.get("pageNum"); + final Object pageSizeO = paramMap.get("pageSize"); + if (null != pageNumO) { + pageNum = Integer.parseInt(pageNumO.toString()); + } + + if (null != pageSizeO) { + pageSize = Integer.parseInt(pageSizeO.toString()); + } + + if (paramMap.containsKey("pageNum")) { + pageNum = Integer.parseInt(paramMap.get("pageNum").toString()); + } + + if (paramMap.containsKey("pageSize")) { + pageSize = Integer.parseInt(paramMap.get("pageSize").toString()); + } + final Page> page = PageHelper.startPage(pageNum, pageSize); + return page; + } +} diff --git a/src/main/java/com/soft/line/util/poi/PoiUtils.java b/src/main/java/com/soft/line/util/poi/PoiUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..24f7c38f51da35cb5c9f7b7f3643e3aeb14ce022 --- /dev/null +++ b/src/main/java/com/soft/line/util/poi/PoiUtils.java @@ -0,0 +1,663 @@ +package com.soft.line.util.poi; + +import com.soft.line.entity.*; +import com.soft.line.service.CertificateInfoService; +import com.soft.line.service.CodeDetailService; +import com.soft.line.service.ContractInfoService; +import com.soft.line.util.jackson.converter.StringToDoubleUtil; +import org.apache.poi.hssf.usermodel.*; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.PostConstruct; +import javax.servlet.http.HttpServletResponse; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.math.BigDecimal; +import java.text.DateFormat; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class PoiUtils { + + public static void certificate2Excel(List list, HttpServletResponse response) { + String title = "证书信息表"; + //创建一个 Excel 文档 + HSSFWorkbook workbook = new HSSFWorkbook(); + //5. 创建样式 + //创建标题行的样式 + HSSFCellStyle headerStyle = workbook.createCellStyle(); + headerStyle.setFillForegroundColor(IndexedColors.YELLOW.index); + headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + HSSFSheet sheet = workbook.createSheet(title); + //创建标题行 + HSSFRow r0 = sheet.createRow(0); + HSSFCell c0 = r0.createCell(0); + c0.setCellValue("证书名称"); + c0.setCellStyle(headerStyle); + HSSFCell c1 = r0.createCell(1); + c1.setCellStyle(headerStyle); + c1.setCellValue("证书编号"); + HSSFCell c2 = r0.createCell(2); + c2.setCellStyle(headerStyle); + c2.setCellValue("证书类型"); + HSSFCell c3 = r0.createCell(3); + c3.setCellStyle(headerStyle); + c3.setCellValue("颁发单位"); + HSSFCell c4 = r0.createCell(4); + c4.setCellStyle(headerStyle); + c4.setCellValue("颁发日期"); + HSSFCell c5 = r0.createCell(5); + c5.setCellStyle(headerStyle); + c5.setCellValue("起始日期"); + HSSFCell c6 = r0.createCell(6); + c6.setCellStyle(headerStyle); + c6.setCellValue("终止日期"); + HSSFCell c7 = r0.createCell(7); + c7.setCellStyle(headerStyle); + c7.setCellValue("备注"); + for (int i = 0; i < list.size(); i++) { + CertificateInfo cert = list.get(i); + HSSFRow row = sheet.createRow(i + 1); + row.createCell(0).setCellValue(cert.getCertName()); + row.createCell(1).setCellValue(cert.getCertId() == null ? "" : cert.getCertId()); + row.createCell(2).setCellValue(cert.getCertType()); + row.createCell(3).setCellValue(cert.getCertUnit()); + row.createCell(4).setCellValue(dateToString(cert.getIssueDate())); + row.createCell(5).setCellValue(dateToString(cert.getBeginDate())); + row.createCell(6).setCellValue(dateToString(cert.getEndDate())); + row.createCell(7).setCellValue(cert.getNote() == null ? "" : cert.getNote()); + } + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + workbook.write(baos); + response.setContentType("application/octet-stream;charset=utf-8"); + OutputStream outputStream = response.getOutputStream(); + outputStream.write(baos.toByteArray()); + outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (baos != null) { + baos.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + + try { + workbook.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public static void contract2Excel(List list, HttpServletResponse response) { + String title = "合同信息表"; + //创建一个 Excel 文档 + HSSFWorkbook workbook = new HSSFWorkbook(); + //5. 创建样式 + //创建标题行的样式 + HSSFCellStyle headerStyle = workbook.createCellStyle(); + headerStyle.setFillForegroundColor(IndexedColors.YELLOW.index); + headerStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND); + HSSFSheet sheet = workbook.createSheet(title); + //创建标题行 + HSSFRow r0 = sheet.createRow(0); + HSSFCell c0 = r0.createCell(0); + c0.setCellValue("部门"); + c0.setCellStyle(headerStyle); + HSSFCell c1 = r0.createCell(1); + c1.setCellStyle(headerStyle); + c1.setCellValue("合同名称"); + HSSFCell c2 = r0.createCell(2); + c2.setCellStyle(headerStyle); + c2.setCellValue("合同类别"); + HSSFCell c3 = r0.createCell(3); + c3.setCellStyle(headerStyle); + c3.setCellValue("项目编号"); + HSSFCell c4 = r0.createCell(4); + c4.setCellStyle(headerStyle); + c4.setCellValue("总金额"); + HSSFCell c5 = r0.createCell(5); + c5.setCellStyle(headerStyle); + c5.setCellValue("甲方"); + HSSFCell c6 = r0.createCell(6); + c6.setCellStyle(headerStyle); + c6.setCellValue("乙方"); + HSSFCell c7 = r0.createCell(7); + c7.setCellStyle(headerStyle); + c7.setCellValue("其他签约方"); + HSSFCell c8 = r0.createCell(8); + c8.setCellStyle(headerStyle); + c8.setCellValue("签约日期"); + HSSFCell c9 = r0.createCell(9); + c9.setCellStyle(headerStyle); + c9.setCellValue("签约地点"); + HSSFCell c10 = r0.createCell(10); + c10.setCellStyle(headerStyle); + c10.setCellValue("起始日期"); + HSSFCell c11 = r0.createCell(11); + c11.setCellStyle(headerStyle); + c11.setCellValue("终止日期"); + HSSFCell c12 = r0.createCell(12); + c12.setCellStyle(headerStyle); + c12.setCellValue("付款方式"); + HSSFCell c13 = r0.createCell(13); + c13.setCellStyle(headerStyle); + c13.setCellValue("备注"); + HSSFCell c14 = r0.createCell(14); + c14.setCellStyle(headerStyle); + c14.setCellValue("合同性质"); + HSSFCell c15 = r0.createCell(15); + c15.setCellStyle(headerStyle); + c15.setCellValue("合同内容"); + for (int i = 0; i < list.size(); i++) { + ContractInfo cont = list.get(i); + HSSFRow row = sheet.createRow(i + 1); + row.createCell(0).setCellValue(cont.getDepId()); + row.createCell(1).setCellValue(cont.getContractName()); + row.createCell(2).setCellValue(cont.getContractType()); + row.createCell(3).setCellValue(cont.getProId() == null ? "" : cont.getProId()); + row.createCell(4).setCellValue(cont.getTotalAmount().toString()); + row.createCell(5).setCellValue(cont.getPartA()); + row.createCell(6).setCellValue(cont.getPartB()); + row.createCell(7).setCellValue(cont.getPartC() == null ? "" : cont.getPartC()); + row.createCell(8).setCellValue(dateToString(cont.getSignTime())); + row.createCell(9).setCellValue(cont.getSignAddr()); + row.createCell(10).setCellValue(dateToString(cont.getBeginDate())); + row.createCell(11).setCellValue(dateToString(cont.getEndDate())); + row.createCell(12).setCellValue(cont.getPayment()); + row.createCell(13).setCellValue(cont.getNote() == null ? "" : cont.getNote()); + row.createCell(14).setCellValue(cont.getContractNature() == null ? "" : cont.getContractNature()); + row.createCell(15).setCellValue(cont.getContractContent() == null ? "" : cont.getContractContent()); + } + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try { + workbook.write(baos); + response.setContentType("application/octet-stream;charset=utf-8"); + OutputStream outputStream = response.getOutputStream(); + outputStream.write(baos.toByteArray()); + outputStream.close(); + } catch (IOException e) { + e.printStackTrace(); + } finally { + try { + if (baos != null) { + baos.close(); + } + } catch (IOException e) { + e.printStackTrace(); + } + + try { + workbook.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + } + + public static Map excel2Certificate(MultipartFile file, CodeDetailService codeDetailService, CertificateInfoService certificateInfoService) { + List certificateInfoList = new ArrayList(); + CertificateInfo cert = null; + Map map = new HashMap(); + String warningMsg = ""; + String chgrow = "\r\n"; + try { + String fileName = file.getOriginalFilename(); + boolean isExcel2003 = true; + if (fileName.matches("^.+\\.(?i)(xlsx)$")) { + isExcel2003 = false; + } + InputStream is = file.getInputStream(); + //1. 创建一个 workbook 对象 + Workbook workbook = null; + if (isExcel2003) { + workbook = new HSSFWorkbook(is); + } else { + workbook = new XSSFWorkbook(is); + } + //2. 获取 workbook 中表单的数量 + int numberOfSheets = workbook.getNumberOfSheets(); + for (int i = 0; i < numberOfSheets; i++) { + //3. 获取表单 + Sheet sheet = workbook.getSheetAt(i); + //4. 获取表单中的行数 + int physicalNumberOfRows = sheet.getPhysicalNumberOfRows(); + + for (int j = 0; j < physicalNumberOfRows; j++) { + //5. 跳过标题行 + if (j == 0) { + if (sheet.getRow(j).getLastCellNum() != 8) { + warningMsg += "证书导入模板格式不对!" + chgrow; + break; + } else { + continue;//跳过标题行 + } + } + int rowCount = j + 1; + //6. 获取行 + Row row = sheet.getRow(j); + if (row == null) { + continue;//防止数据中间有空行 + } + //7. 获取列数 + //int physicalNumberOfCells = row.getPhysicalNumberOfCells(); + int physicalNumberOfCells = row.getLastCellNum(); + cert = new CertificateInfo(); + for (int k = 0; k < physicalNumberOfCells; k++) { + Cell cell = row.getCell(k); + String cellValue = null; + if (cell != null) { + cell.setCellType(CellType.STRING); + cellValue = cell.getStringCellValue(); + } + LasCodeItem lasCodeItem = null; + switch (k) { + case 0: + //证书名称 + if (cellValue == null || "".equals(cellValue)) { + warningMsg += "第" + rowCount + "行证书名称不存在 " + chgrow; + } else if (cellValue.length() > 100) { + warningMsg += "第" + rowCount + "行证书名称应不大于100字 " + chgrow; + } else { + cert.setCertName(cellValue); + } + break; + case 1: + //证书编号 + if (cellValue != null && !"".equals(cellValue) && certificateInfoService.countByCId(null, cellValue) > 0) { + warningMsg += "第" + rowCount + "行存在相同的证书编号 " + chgrow; + } else { + cert.setCertId(cellValue); + } + break; + case 2: + //证书类型 + lasCodeItem = codeDetailService.selectByItemDesc("103", cellValue); + if (lasCodeItem == null) { + warningMsg += "第" + rowCount + "行证书类型不存在 " + chgrow; + } else { + cert.setCertType(lasCodeItem.getItemVal()); + } + break; + case 3: + //颁发单位 + if (cellValue == null || "".equals(cellValue)) { + warningMsg += "第" + rowCount + "行发奖单位为空 " + chgrow; + } else { + cert.setCertUnit(cellValue); + } + break; + case 4: + //颁发日期 + if (cellValue != null && !"".equals(cellValue) && !isDate(cellValue)) { + warningMsg += "第" + rowCount + "行颁发日期格式错误!日期样式:【20100101】" + chgrow; + } else { + cert.setIssueDate(StringToDate(cellValue)); + } + break; + case 5: + //发证日期 + if (cellValue != null && !"".equals(cellValue) && !isDate(cellValue)) { + warningMsg += "第" + rowCount + "行发证日期格式错误!日期样式:【20100101】" + chgrow; + } else { + cert.setBeginDate(StringToDate(cellValue)); + } + break; + case 6: + //到期日期 + if (cellValue != null && !"".equals(cellValue) && !isDate(cellValue)) { + warningMsg += "第" + rowCount + "行到期日期格式错误!日期样式:【20100101】" + chgrow; + } else if (cert.getBeginDate() != null && cert.getEndDate() != null) { + if (cert.getBeginDate().after(cert.getEndDate())) { + warningMsg += "第" + rowCount + "行发证日期大于到期日期 " + chgrow; + } + } else { + cert.setEndDate(StringToDate(cellValue)); + } + break; + case 7: + //备注 + cert.setNote(cellValue); + break; + + } + } + certificateInfoList.add(cert); + } + } + map.put("warningMsg", warningMsg); + map.put("certificateInfoList", certificateInfoList); + } catch (IOException e) { + e.printStackTrace(); + } finally { + return map; + } + } + + public static Map excel2ContractInfo(MultipartFile file, CodeDetailService codeDetailService, ContractInfoService contractInfoService) { + Map map = new HashMap(); + String warningMsg = ""; + String chgrow = "\r\n"; + List contractInfoList = new ArrayList(); + ContractInfo cont = null; + try { + String fileName = file.getOriginalFilename(); + boolean isExcel2003 = true; + if (fileName.matches("^.+\\.(?i)(xlsx)$")) { + isExcel2003 = false; + } + InputStream is = file.getInputStream(); + //1. 创建一个 workbook 对象 + Workbook workbook = null; + if (isExcel2003) { + workbook = new HSSFWorkbook(is); + } else { + workbook = new XSSFWorkbook(is); + } + //2. 获取 workbook 中表单的数量 + int numberOfSheets = workbook.getNumberOfSheets(); + for (int i = 0; i < numberOfSheets; i++) { + //3. 获取表单 + Sheet sheet = workbook.getSheetAt(i); + //4. 获取表单中的行数 + int physicalNumberOfRows = sheet.getPhysicalNumberOfRows(); + for (int j = 0; j < physicalNumberOfRows; j++) { + //5. 跳过标题行 + if (j == 0) { + if (sheet.getRow(j).getLastCellNum() != 16) { + warningMsg += "合同导入模板格式不对!" + chgrow; + break; + } else { + continue;//跳过标题行 + } + } + int rowCount = j + 1; + //6. 获取行 + Row row = sheet.getRow(j); + if (row == null) { + continue;//防止数据中间有空行 + } + //7. 获取列数 + //int physicalNumberOfCells = row.getPhysicalNumberOfCells(); + int physicalNumberOfCells = row.getLastCellNum(); + cont = new ContractInfo(); + for (int k = 0; k < physicalNumberOfCells; k++) { + Cell cell = row.getCell(k); + //System.out.println("k:" + k+" j:"+j); + String cellValue = null; + if (cell != null) { + cell.setCellType(CellType.STRING); + cellValue = cell.getStringCellValue(); + } + LasCodeItem lasCodeItem = null; + switch (k) { + case 0: + //部门 + if (cellValue == null || "".equals(cellValue)) { + warningMsg += "第" + rowCount + "行部门名称为空 " + chgrow; + } else { + lasCodeItem = codeDetailService.selectByItemDesc("101", cellValue); + if (lasCodeItem == null) { + cont.setDepId(codeDetailService.selectByItemDesc("101", "其他").getItemVal()); + } else { + cont.setDepId(lasCodeItem.getItemVal()); + } + } + break; + case 1: + //合同名称 + if (cellValue == null || "".equals(cellValue)) { + warningMsg += "第" + rowCount + "行合同名称为空 " + chgrow; + } else if (contractInfoService.countContractByIdAndName(null, cellValue) > 0) { + warningMsg += "第" + rowCount + "行存在相同的合同名称 " + chgrow; + } else if (cellValue.length() > 100) { + warningMsg += "第" + rowCount + "行合同名称应不大于100字 " + chgrow; + } else { + cont.setContractName(cellValue); + } + break; + case 2: + //合同类别 + lasCodeItem = codeDetailService.selectByItemDesc("102", cellValue); + if (lasCodeItem == null) { + warningMsg += "第" + rowCount + "行合同类别不存在 " + chgrow; + } else { + cont.setContractType(lasCodeItem.getItemVal()); + } + break; + case 3: + //项目编号 + cont.setProId(cellValue); + break; + case 4: + //总金额 + if (cellValue == null || "".equals(cellValue)) { + warningMsg += "第" + rowCount + "行总金额为空 " + chgrow; + } else if (!isNumber(cellValue)) { + warningMsg += "第" + rowCount + "行总金额不是数字 " + chgrow; + } else { + cont.setTotalAmount(new BigDecimal(StringToDoubleUtil.convert(cellValue))); + } + break; + case 5: + //甲方 + if (cellValue == null || "".equals(cellValue)) { + warningMsg += "第" + rowCount + "行甲方为空 " + chgrow; + } else if (cellValue.length() > 100) { + warningMsg += "第" + rowCount + "行甲方名称应不大于100字 " + chgrow; + } else { + cont.setPartA(cellValue); + } + break; + case 6: + //乙方 + if (cellValue == null || "".equals(cellValue)) { + warningMsg += "第" + rowCount + "行乙方为空 " + chgrow; + } else if (cellValue.length() > 100) { + warningMsg += "第" + rowCount + "行合乙方称应不大于100字 " + chgrow; + } else { + cont.setPartB(cellValue); + } + break; + case 7: + //其他签约方 + if (cellValue != null && !"".equals(cellValue) && cellValue.length() > 100) { + warningMsg += "第" + rowCount + "行其他签约方名称应不大于100字 " + chgrow; + } else { + cont.setPartC(cellValue); + } + break; + case 8: + //签约日期 + if (!isDate(cellValue)) { + warningMsg += "第" + rowCount + "行签约日期格式错误!日期样式:【20100101】" + chgrow; + } else { + cont.setSignTime(StringToDate(cellValue)); + } + break; + case 9: + //签约地点 + if (cellValue == null || "".equals(cellValue)) { + warningMsg += "第" + rowCount + "行签约地点为空" + chgrow; + } else { + cont.setSignAddr(cellValue); + } + break; + case 10: + //起始日期 + if (!isDate(cellValue)) { + warningMsg += "第" + rowCount + "行起始日期格式错误!日期样式:【20100101】" + chgrow; + } else { + cont.setBeginDate(StringToDate(cellValue)); + } + break; + case 11: + //终止日期 + if (!isDate(cellValue)) { + warningMsg += "第" + rowCount + "行终止日期格式错误!日期样式:【20100101】" + chgrow; + } else { + cont.setEndDate(StringToDate(cellValue)); + } + if (cont.getBeginDate() != null && cont.getEndDate() != null) { + if (cont.getBeginDate().after(cont.getEndDate())) { + warningMsg += "第" + rowCount + "行起始日期大于终止日期 " + chgrow; + } + } + break; + + case 12: + //付款方式 + if (cellValue == null || "".equals(cellValue)) { + warningMsg += "第" + rowCount + "行付款方式为空 " + chgrow; + } else if (cellValue.length() > 500) { + warningMsg += "第" + rowCount + "行付款方式应不大于500字 " + chgrow; + } else { + cont.setPayment(cellValue); + } + break; + case 13: + //备注 + if (cellValue != null && !"".equals(cellValue) && cellValue.length() > 1000) { + warningMsg += "第" + rowCount + "行备注应不大于1000字 " + chgrow; + } else { + cont.setNote(cellValue); + } + break; + case 14: + //合同性质 + lasCodeItem = codeDetailService.selectByItemDesc("104", cellValue); + if (lasCodeItem == null) { + warningMsg += "第" + rowCount + "行合同性质不存在 " + chgrow; + } else { + cont.setContractNature(lasCodeItem.getItemVal()); + } + break; + case 15: + //合同内容 + if (cellValue != null && !"".equals(cellValue) && cellValue.length() > 1000) { + warningMsg += "第" + rowCount + "行合同内容应不大于1000字 " + chgrow; + } else { + cont.setContractContent(cellValue); + } + break; + } + } + contractInfoList.add(cont); + } + } + map.put("warningMsg", warningMsg); + map.put("contractInfoList", contractInfoList); + } catch (Exception e) { + e.printStackTrace(); + } finally { + return map; + } + } + + public static String dateToString(Date date) { + if (date != null) { + SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); + return sdf.format(date); + } else { + return ""; + } + } + + /** + * 判断字符串是否是数字 + */ + public static boolean isNumber(String value) { + return isInteger(value) || isDouble(value) || isIntegerDouble(value); + } + + /** + * 判断字符串是否是整数 + */ + public static boolean isInteger(String value) { + try { + Integer.parseInt(value); + return true; + } catch (NumberFormatException e) { + return false; + } + } + + /** + * 判断字符串是否是浮点数 + */ + public static boolean isDouble(String value) { + try { + Double.parseDouble(value); + if (value.contains(".")) { + return true; + } + return false; + } catch (NumberFormatException e) { + return false; + } + } + + /** + * 判断字符串是否是浮点数(不包含小数点) + */ + public static boolean isIntegerDouble(String value) { + try { + Double.parseDouble(value); + if (value.contains(".")) { + return false; + } + return true; + } catch (NumberFormatException e) { + return false; + } + } + + //判断是否日期。格式yyyymmdd,基本上把闰年和2月等的情况都考虑进去了 + public static boolean isDate(String date) { +// String s = "^((((1[6-9]|[2-9]\\d)\\d{2})(0?[13578]|1[02])(0?[1-9]|[12]\\d|3[01]))|(((1[6-9]|[2-9]\\d)\\d{2})(0?[13456789]|1[012])(0?[1-9]|[12]\\d|30))|(((1[6-9]|[2-9]\\d)\\d{2})0?2(0?[1-9]|1\\d|2[0-8]))|(((1[6-9]|[2-9]\\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00))0?229))$"; + String s = "(([0-9]{3}[1-9]|[0-9]{2}[1-9][0-9]{1}|[0-9]{1}[1-9][0-9]{2}|[1-9][0-9]{3})(((0[13578]|1[02])(0[1-9]|[12][0-9]|3[01]))|((0[469]|11)(0[1-9]|[12][0-9]|30))|(02(0[1-9]|[1][0-9]|2[0-8]))))|((([0-9]{2})(0[48]|[2468][048]|[13579][26])|((0[48]|[2468][048]|[3579][26])00))0229)"; + Pattern p = Pattern.compile(s); + Matcher m = p.matcher(date); + if (m.matches()) { + return true; + } else { + return false; + } + } + + public static Date StringToDate(String source) { + Date date = null; + boolean flag = false; + DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); + try { + if (source == null || source.length() == 0) { + return date; + } else { + source = source.trim(); + date = dateFormat.parse(source); + flag = true; + } + } catch (ParseException e) { + e.printStackTrace(); + } + + if (flag) { + return date; + } else { + throw new IllegalArgumentException("不能解析日期:" + source); + } + + } + +} diff --git a/src/main/java/com/soft/line/util/redis/JedisProperties.java b/src/main/java/com/soft/line/util/redis/JedisProperties.java new file mode 100644 index 0000000000000000000000000000000000000000..297acb465fa6f2c8a5a262055676a2415d0bd930 --- /dev/null +++ b/src/main/java/com/soft/line/util/redis/JedisProperties.java @@ -0,0 +1,81 @@ +package com.soft.line.util.redis; + + +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties(prefix = JedisProperties.JEDIS_PREFIX) +public class JedisProperties { + + public static final String JEDIS_PREFIX = "spring.jedis"; + + private String host; + + private String password; + + private int port; + + private String uri; + + private int maxTotal; + + private int maxIdle; + + private int maxWaitMillis; + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public int getPort() { + return port; + } + + public void setPort(int port) { + this.port = port; + } + + public String getUri() { + return uri; + } + + public void setUri(String uri) { + this.uri = uri; + } + + public int getMaxTotal() { + return maxTotal; + } + + public void setMaxTotal(int maxTotal) { + this.maxTotal = maxTotal; + } + + public int getMaxIdle() { + return maxIdle; + } + + public void setMaxIdle(int maxIdle) { + this.maxIdle = maxIdle; + } + + public int getMaxWaitMillis() { + return maxWaitMillis; + } + + public void setMaxWaitMillis(int maxWaitMillis) { + this.maxWaitMillis = maxWaitMillis; + } + +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/util/redis/RedisClient.java b/src/main/java/com/soft/line/util/redis/RedisClient.java new file mode 100644 index 0000000000000000000000000000000000000000..6256b94e8a59e0b3e940d4ca34f816ea1d78a5f7 --- /dev/null +++ b/src/main/java/com/soft/line/util/redis/RedisClient.java @@ -0,0 +1,420 @@ +package com.soft.line.util.redis; + +import org.slf4j.LoggerFactory; +import redis.clients.jedis.*; +import redis.clients.jedis.exceptions.JedisException; + +import java.util.ArrayList; +import java.util.List; +import java.util.Set; + + + +public class RedisClient { + + private ShardedJedisPool pool; + + private JedisPool jpool; + + private static org.slf4j.Logger logger = LoggerFactory.getLogger(RedisClient.class); + + public void setShardedJedisPool(ShardedJedisPool pool) { + + this.pool = pool; + } + public void setJedisPool(JedisPool jpool) { + + this.jpool = jpool; + } + + /** + * Get ShardedJedis (lock mechanism, high concurrency) + */ + public synchronized ShardedJedis getJedis() { + ShardedJedis jedis = null; + try { + if (pool != null) { + jedis = pool.getResource(); + return jedis; + } + } catch (final Exception e) { + logger.error("Get jedis error : " + e); + } + return null; + } + public synchronized Jedis jgetJedis() { + Jedis jedis = null; + try { + if (jpool != null) { + jedis = jpool.getResource(); + return jedis; + } + } catch (final Exception e) { + logger.error("Get jedis error : " + e); + } + return null; + } + /** + * the ordered set adds or updates the scores of the existing members. + * @param key + * @param score + * @param member + * + * @return boolean + */ + public boolean zaddSorted(final String key, final Integer score, final String member) { + final ShardedJedis jedis = getJedis(); + try { + return jedis.zadd(key, score, member) > 0L; + + } catch (final Exception e) { + } finally { + if (jedis != null) { + jedis.close(); + } + } + return false; + } + + /** + * an ordered set of values (in terms of fractions). + * @param key + * @param score + * + * @return object + */ + public Object getSorted(final String key, final Integer score) { + + final ShardedJedis jedis = getJedis(); + try { + final Set memberSet = jedis.zrevrange(key, 0, score); + return memberSet; + } catch (final Exception e) { + } finally { + if (jedis != null) { + jedis.close(); + } + } + return null; + } + + /** + * increase acquisition of correlation key words by ordered set. + * @param key + * @param fuzzy + * @param size + * + * @return object + */ + public Object getMatchMember(final String key, final String fuzzy, final int size) { + final ShardedJedis jedis = getJedis(); + try { + + final ScanParams scanParams = new ScanParams(); + scanParams.count(size); + scanParams.match("*" + fuzzy + "*"); + final ScanResult memberSet = jedis.zscan(key, "", scanParams); + return memberSet; + } catch (final Exception e) { + } finally { + if (jedis != null) { + jedis.close(); + } + } + return null; + + } + + /** + * increase the score of an ordered set of a certain value. + * @param key + * @param score + * @param member + * + * @return boolean + */ + public boolean incrbySocre(final String key, final Integer score, final String member) { + final ShardedJedis jedis = getJedis(); + try { + return jedis.zincrby(key, score, member) > 0l; + + } catch (final Exception e) { + } finally { + if (jedis != null) { + jedis.close(); + } + } + return false; + } + + /** + * add key value pairs in the specified domain + * @param value + * @param key + * @param field + * + * @return boolean + */ + public boolean set(final Object value, final String key, final String field) { + + final ShardedJedis jedis = getJedis(); + try { + return jedis.hset(key, field, value.toString()) > 0l; + } catch (final JedisException e) { + logger.error(e.getMessage()); + } finally { + if (jedis != null) { + jedis.close(); + } + } + return false; + } + + public boolean delList(final String key) { + final ShardedJedis jedis = getJedis(); + try { + return jedis.del(key.getBytes()) > 0l; + } catch (final JedisException e) { + logger.error(e.getMessage()); + } finally { + if (jedis != null) { + jedis.close(); + } + } + return false; + } + + public boolean del(final String key) { + final ShardedJedis jedis = getJedis(); + try { + return jedis.del(key) > 0l; + } catch (final JedisException e) { + logger.error(e.getMessage()); + } finally { + if (jedis != null) { + jedis.close(); + } + } + return false; + } + + public void dels(final String key) { + final Jedis jedis = jgetJedis(); + try { +// Set set = jedis.keys(key+"*"); +// for (String akey : set) { +// jedis.del(akey); +// } + jedis.select(8); + Set set = jedis.keys(key+":*"); + for (String akey : set) { + jedis.del(akey); + } + } catch (final JedisException e) { + logger.error(e.getMessage()); + } finally { + if (jedis != null) { + jedis.close(); + } + } + } + + public boolean listSet(final String key, final List value) { + final ShardedJedis jedis = getJedis(); + try { + for (final String code : value) { + jedis.rpush(key.getBytes(), code.getBytes()); + } + return true; + } catch (final JedisException e) { + logger.error(e.getMessage()); + } finally { + if (jedis != null) { + jedis.close(); + } + } + return false; + } + + public List hasApp(final String key) { + final ShardedJedis jedis = getJedis(); + try { + return jedis.lrange(key, 0, -1); + } catch (final JedisException e) { + logger.error(e.getMessage()); + } finally { + if (jedis != null) { + jedis.close(); + } + } + return null; + } + + /** + * get the value of the corresponding key in the specified domain. + * @param key + * @param field + * + * @return Object + */ + public Object get(final String key, final String field) { + + final ShardedJedis jedis = getJedis(); + try { + + if (jedis.hget(key, field) == null) { + return null; + } + final Object value = jedis.hget(key, field); + return value.toString(); + } catch (final JedisException e) { + logger.error(e.getMessage()); + return null; + } finally { + if (jedis != null) { + jedis.close(); + } + } + } + + /** + * delete key value pairs in the specified key name hash table. + * @param key + * @param field + * + * @return boolean + */ + public boolean del(final String key, final String field) { + + final ShardedJedis jedis = getJedis(); + try { + return jedis.hdel(key, field) > 0; + } catch (final JedisException e) { + logger.error(e.getMessage()); + } finally { + if (jedis != null) { + jedis.close(); + } + } + return false; + } + + /** + * delete all key value pairs in the specified key key + * @param key + * + * @return boolean + */ + public boolean mdel(final String key) { + + final ShardedJedis jedis = getJedis(); + try { + final List keys = scan(key); + if (keys != null) { + for (final String k : keys) { + del(key, k); + } + return true; + } else { + return false; + } + } catch (final JedisException e) { + logger.error(e.getMessage()); + } finally { + if (jedis != null) { + jedis.close(); + } + } + return false; + } + + /** + * Get all keys in the specified key name hash table. + * @param key + * + * @return List + */ + public List scan(final String key) { + + final ShardedJedis jedis = getJedis(); + try { + final List list = new ArrayList(); + list.addAll(jedis.hkeys(key)); + return list; + } catch (final JedisException e) { + logger.error(e.getMessage()); + } finally { + if (jedis != null) { + jedis.close(); + } + } + return null; + } + + /** + * set value by key、value、seconds + * + * @param key + * @param value + * @param seconds + */ + public Boolean setKeyValue(final String key, final String value, final Integer seconds) { + + final ShardedJedis jedis = getJedis(); + try { + String tt = jedis.set(key, value); + if ("OK".equals(jedis.set(key, value))) { + jedis.expire(key, seconds); + return true; + } + } catch (final JedisException e) { + logger.error(e.getMessage()); + } finally { + if (jedis != null) { + jedis.close(); + } + } + return false; + } + + /** + * get value by key + * + * @param key + */ + public String getKeyValue(final String key) { + + final ShardedJedis jedis = getJedis(); + try { + return jedis.get(key); + } catch (final JedisException e) { + logger.error(e.getMessage()); + } finally { + if (jedis != null) { + jedis.close(); + } + } + return null; + } + + /** + * set outTime + * + * @param key + * @param seconds + */ + public Boolean setKeyTimeout(final String key, final Integer seconds) { + + final ShardedJedis jedis = getJedis(); + try { + return jedis.expire(key, seconds) == 1L; + } catch (final JedisException e) { + logger.error(e.getMessage()); + } finally { + if (jedis != null) { + jedis.close(); + } + } + return false; + } +} diff --git a/src/main/java/com/soft/line/util/redis/RedisConfig.java b/src/main/java/com/soft/line/util/redis/RedisConfig.java new file mode 100644 index 0000000000000000000000000000000000000000..fbaf21eae7d65d1ee6044ac95360559055496b72 --- /dev/null +++ b/src/main/java/com/soft/line/util/redis/RedisConfig.java @@ -0,0 +1,50 @@ +package com.soft.line.util.redis; + + +import com.soft.line.util.redis.JedisProperties; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Qualifier; +import org.springframework.boot.autoconfigure.EnableAutoConfiguration; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import redis.clients.jedis.JedisPoolConfig; +import redis.clients.jedis.JedisShardInfo; +import redis.clients.jedis.ShardedJedisPool; + +import java.util.ArrayList; +import java.util.List; + + +@Configuration +@EnableAutoConfiguration +@EnableConfigurationProperties(JedisProperties.class) +@ConditionalOnClass(RedisClient.class) +public class RedisConfig { + @Autowired + private JedisProperties prop; + + @Bean(name="shardedJedisPool") + public ShardedJedisPool shardedJedisPool() { + JedisPoolConfig config = new JedisPoolConfig(); + config.setMaxTotal(prop.getMaxTotal()); + config.setMaxIdle(prop.getMaxIdle()); + config.setMaxWaitMillis(prop.getMaxWaitMillis()); + List jedisShardInfoList = new ArrayList<>(); + JedisShardInfo jsi =new JedisShardInfo(prop.getUri()); + jsi.setPassword(prop.getPassword()); + jedisShardInfoList.add(jsi); + ShardedJedisPool shardedJedisPool = new ShardedJedisPool(config, jedisShardInfoList); + return shardedJedisPool; + } + + @Bean + @ConditionalOnMissingBean(RedisClient.class) + public RedisClient redisClient(@Qualifier("shardedJedisPool")ShardedJedisPool shardedJedisPool) { + RedisClient redisClient = new RedisClient(); + redisClient.setShardedJedisPool(shardedJedisPool); + return redisClient; + } +} diff --git a/src/main/java/com/soft/line/xss/HTMLFilter.java b/src/main/java/com/soft/line/xss/HTMLFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..825f3215f83e7f2a7964eca0a253753b8881ec62 --- /dev/null +++ b/src/main/java/com/soft/line/xss/HTMLFilter.java @@ -0,0 +1,554 @@ +package com.soft.line.xss; + +import java.util.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.logging.Logger; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * HTML filtering utility for protecting against XSS (Cross Site Scripting). + *

+ * This code is licensed LGPLv3 + *

+ * This code is a Java port of the original work in PHP by Cal Hendersen. + * http://code.iamcal.com/php/lib_filter/ + *

+ * The trickiest part of the translation was handling the differences in regex handling + * between PHP and Java. These resources were helpful in the process: + *

+ * http://java.sun.com/j2se/1.4.2/docs/api/java/util/regex/Pattern.html + * http://us2.php.net/manual/en/reference.pcre.pattern.modifiers.php + * http://www.regular-expressions.info/modifiers.html + *

+ * A note on naming conventions: instance variables are prefixed with a "v"; global + * constants are in all caps. + *

+ * Sample use: + * String input = ... + * String clean = new HTMLFilter().filter( input ); + *

+ * The class is not thread safe. Create a new instance if in doubt. + *

+ * If you find bugs or have suggestions on improvement (especially regarding + * performance), please contact us. The latest version of this + * source, and our contact details, can be found at http://xss-html-filter.sf.net + * + * @author Joseph O'Connell + * @author Cal Hendersen + * @author Michael Semb Wever + */ +public final class HTMLFilter { + + /** + * regex flag union representing /si modifiers in php + **/ + private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL; + private static final Pattern P_COMMENTS = Pattern.compile("", Pattern.DOTALL); + private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI); + private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL); + private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI); + private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI); + private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI); + private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI); + private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI); + private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?"); + private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?"); + private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?"); + private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))"); + private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL); + private static final Pattern P_END_ARROW = Pattern.compile("^>"); + private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_AMP = Pattern.compile("&"); + private static final Pattern P_QUOTE = Pattern.compile("<"); + private static final Pattern P_LEFT_ARROW = Pattern.compile("<"); + private static final Pattern P_RIGHT_ARROW = Pattern.compile(">"); + private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>"); + + // @xxx could grow large... maybe use sesat's ReferenceMap + private static final ConcurrentMap P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap(); + private static final ConcurrentMap P_REMOVE_SELF_BLANKS = new ConcurrentHashMap(); + + /** + * set of allowed html elements, along with allowed attributes for each element + **/ + private final Map> vAllowed; + /** + * counts of open tags for each (allowable) html element + **/ + private final Map vTagCounts = new HashMap(); + + /** + * html elements which must always be self-closing (e.g. "") + **/ + private final String[] vSelfClosingTags; + /** + * html elements which must always have separate opening and closing tags (e.g. "") + **/ + private final String[] vNeedClosingTags; + /** + * set of disallowed html elements + **/ + private final String[] vDisallowed; + /** + * attributes which should be checked for valid protocols + **/ + private final String[] vProtocolAtts; + /** + * allowed protocols + **/ + private final String[] vAllowedProtocols; + /** + * tags which should be removed if they contain no content (e.g. "" or "") + **/ + private final String[] vRemoveBlanks; + /** + * entities allowed within html markup + **/ + private final String[] vAllowedEntities; + /** + * flag determining whether comments are allowed in input String. + */ + private final boolean stripComment; + private final boolean encodeQuotes; + private boolean vDebug = false; + /** + * flag determining whether to try to make tags when presented with "unbalanced" + * angle brackets (e.g. "" becomes " text "). If set to false, + * unbalanced angle brackets will be html escaped. + */ + private final boolean alwaysMakeTags; + + /** + * Default constructor. + */ + public HTMLFilter() { + vAllowed = new HashMap<>(); + + final ArrayList a_atts = new ArrayList(); + a_atts.add("href"); + a_atts.add("target"); + vAllowed.put("a", a_atts); + + final ArrayList img_atts = new ArrayList(); + img_atts.add("src"); + img_atts.add("width"); + img_atts.add("height"); + img_atts.add("alt"); + vAllowed.put("img", img_atts); + + final ArrayList no_atts = new ArrayList(); + vAllowed.put("b", no_atts); + vAllowed.put("strong", no_atts); + vAllowed.put("i", no_atts); + vAllowed.put("em", no_atts); + + vSelfClosingTags = new String[]{"img"}; + vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"}; + vDisallowed = new String[]{}; + vAllowedProtocols = new String[]{"http", "mailto", "https"}; // no ftp. + vProtocolAtts = new String[]{"src", "href"}; + vRemoveBlanks = new String[]{"a", "b", "strong", "i", "em"}; + vAllowedEntities = new String[]{"amp", "gt", "lt", "quot"}; + stripComment = true; + encodeQuotes = true; + alwaysMakeTags = true; + } + + /** + * Set debug flag to true. Otherwise use default settings. See the default constructor. + * + * @param debug turn debug on with a true argument + */ + public HTMLFilter(final boolean debug) { + this(); + vDebug = debug; + + } + + /** + * Map-parameter configurable constructor. + * + * @param conf map containing configuration. keys match field names. + */ + public HTMLFilter(final Map conf) { + + assert conf.containsKey("vAllowed") : "configuration requires vAllowed"; + assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags"; + assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags"; + assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed"; + assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols"; + assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts"; + assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks"; + assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities"; + + vAllowed = Collections.unmodifiableMap((HashMap>) conf.get("vAllowed")); + vSelfClosingTags = (String[]) conf.get("vSelfClosingTags"); + vNeedClosingTags = (String[]) conf.get("vNeedClosingTags"); + vDisallowed = (String[]) conf.get("vDisallowed"); + vAllowedProtocols = (String[]) conf.get("vAllowedProtocols"); + vProtocolAtts = (String[]) conf.get("vProtocolAtts"); + vRemoveBlanks = (String[]) conf.get("vRemoveBlanks"); + vAllowedEntities = (String[]) conf.get("vAllowedEntities"); + stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true; + encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true; + alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true; + } + + private void reset() { + vTagCounts.clear(); + } + + private void debug(final String msg) { + if (vDebug) { + Logger.getAnonymousLogger().info(msg); + } + } + + //--------------------------------------------------------------- + // my versions of some PHP library functions + public static String chr(final int decimal) { + return String.valueOf((char) decimal); + } + + public static String htmlSpecialChars(final String s) { + String result = s; + result = regexReplace(P_AMP, "&", result); + result = regexReplace(P_QUOTE, """, result); + result = regexReplace(P_LEFT_ARROW, "<", result); + result = regexReplace(P_RIGHT_ARROW, ">", result); + return result; + } + + //--------------------------------------------------------------- + + /** + * given a user submitted input String, filter out any invalid or restricted + * html. + * + * @param input text (i.e. submitted by a user) than may contain html + * @return "clean" version of input, with only valid, whitelisted html elements allowed + */ + public String filter(final String input) { + reset(); + String s = input; + + debug("************************************************"); + debug(" INPUT: " + input); + + s = escapeComments(s); + debug(" escapeComments: " + s); + + s = balanceHTML(s); + debug(" balanceHTML: " + s); + + s = checkTags(s); + debug(" checkTags: " + s); + + s = processRemoveBlanks(s); + debug("processRemoveBlanks: " + s); + + s = validateEntities(s); + debug(" validateEntites: " + s); + + debug("************************************************\n\n"); + return s; + } + + public boolean isAlwaysMakeTags() { + return alwaysMakeTags; + } + + public boolean isStripComments() { + return stripComment; + } + + private String escapeComments(final String s) { + final Matcher m = P_COMMENTS.matcher(s); + final StringBuffer buf = new StringBuffer(); + if (m.find()) { + final String match = m.group(1); //(.*?) + m.appendReplacement(buf, Matcher.quoteReplacement("")); + } + m.appendTail(buf); + + return buf.toString(); + } + + private String balanceHTML(String s) { + if (alwaysMakeTags) { + // + // try and form html + // + s = regexReplace(P_END_ARROW, "", s); + s = regexReplace(P_BODY_TO_END, "<$1>", s); + s = regexReplace(P_XML_CONTENT, "$1<$2", s); + + } else { + // + // escape stray brackets + // + s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s); + s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s); + + // + // the last regexp causes '<>' entities to appear + // (we need to do a lookahead assertion so that the last bracket can + // be used in the next pass of the regexp) + // + s = regexReplace(P_BOTH_ARROWS, "", s); + } + + return s; + } + + private String checkTags(String s) { + Matcher m = P_TAGS.matcher(s); + + final StringBuffer buf = new StringBuffer(); + while (m.find()) { + String replaceStr = m.group(1); + replaceStr = processTag(replaceStr); + m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr)); + } + m.appendTail(buf); + + s = buf.toString(); + + // these get tallied in processTag + // (remember to reset before subsequent calls to filter method) + for (String key : vTagCounts.keySet()) { + for (int ii = 0; ii < vTagCounts.get(key); ii++) { + s += ""; + } + } + + return s; + } + + private String processRemoveBlanks(final String s) { + String result = s; + for (String tag : vRemoveBlanks) { + if (!P_REMOVE_PAIR_BLANKS.containsKey(tag)) { + P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?>")); + } + result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result); + if (!P_REMOVE_SELF_BLANKS.containsKey(tag)) { + P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>")); + } + result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result); + } + + return result; + } + + private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) { + Matcher m = regex_pattern.matcher(s); + return m.replaceAll(replacement); + } + + private String processTag(final String s) { + // ending tags + Matcher m = P_END_TAG.matcher(s); + if (m.find()) { + final String name = m.group(1).toLowerCase(); + if (allowed(name)) { + if (!inArray(name, vSelfClosingTags)) { + if (vTagCounts.containsKey(name)) { + vTagCounts.put(name, vTagCounts.get(name) - 1); + return ""; + } + } + } + } + + // starting tags + m = P_START_TAG.matcher(s); + if (m.find()) { + final String name = m.group(1).toLowerCase(); + final String body = m.group(2); + String ending = m.group(3); + + //debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" ); + if (allowed(name)) { + String params = ""; + + final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body); + final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body); + final List paramNames = new ArrayList(); + final List paramValues = new ArrayList(); + while (m2.find()) { + paramNames.add(m2.group(1)); //([a-z0-9]+) + paramValues.add(m2.group(3)); //(.*?) + } + while (m3.find()) { + paramNames.add(m3.group(1)); //([a-z0-9]+) + paramValues.add(m3.group(3)); //([^\"\\s']+) + } + + String paramName, paramValue; + for (int ii = 0; ii < paramNames.size(); ii++) { + paramName = paramNames.get(ii).toLowerCase(); + paramValue = paramValues.get(ii); + +// debug( "paramName='" + paramName + "'" ); +// debug( "paramValue='" + paramValue + "'" ); +// debug( "allowed? " + vAllowed.get( name ).contains( paramName ) ); + + if (allowedAttribute(name, paramName)) { + if (inArray(paramName, vProtocolAtts)) { + paramValue = processParamProtocol(paramValue); + } + params += " " + paramName + "=\"" + paramValue + "\""; + } + } + + if (inArray(name, vSelfClosingTags)) { + ending = " /"; + } + + if (inArray(name, vNeedClosingTags)) { + ending = ""; + } + + if (ending == null || ending.length() < 1) { + if (vTagCounts.containsKey(name)) { + vTagCounts.put(name, vTagCounts.get(name) + 1); + } else { + vTagCounts.put(name, 1); + } + } else { + ending = " /"; + } + return "<" + name + params + ending + ">"; + } else { + return ""; + } + } + + // comments + m = P_COMMENT.matcher(s); + if (!stripComment && m.find()) { + return "<" + m.group() + ">"; + } + + return ""; + } + + private String processParamProtocol(String s) { + s = decodeEntities(s); + final Matcher m = P_PROTOCOL.matcher(s); + if (m.find()) { + final String protocol = m.group(1); + if (!inArray(protocol, vAllowedProtocols)) { + // bad protocol, turn into local anchor link instead + s = "#" + s.substring(protocol.length() + 1, s.length()); + if (s.startsWith("#//")) { + s = "#" + s.substring(3, s.length()); + } + } + } + + return s; + } + + private String decodeEntities(String s) { + StringBuffer buf = new StringBuffer(); + + Matcher m = P_ENTITY.matcher(s); + while (m.find()) { + final String match = m.group(1); + final int decimal = Integer.decode(match).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENTITY_UNICODE.matcher(s); + while (m.find()) { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENCODE.matcher(s); + while (m.find()) { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + s = validateEntities(s); + return s; + } + + private String validateEntities(final String s) { + StringBuffer buf = new StringBuffer(); + + // validate entities throughout the string + Matcher m = P_VALID_ENTITIES.matcher(s); + while (m.find()) { + final String one = m.group(1); //([^&;]*) + final String two = m.group(2); //(?=(;|&|$)) + m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two))); + } + m.appendTail(buf); + + return encodeQuotes(buf.toString()); + } + + private String encodeQuotes(final String s) { + if (encodeQuotes) { + StringBuffer buf = new StringBuffer(); + Matcher m = P_VALID_QUOTES.matcher(s); + while (m.find()) { + final String one = m.group(1); //(>|^) + final String two = m.group(2); //([^<]+?) + final String three = m.group(3); //(<|$) + m.appendReplacement(buf, Matcher.quoteReplacement(one + regexReplace(P_QUOTE, """, two) + three)); + } + m.appendTail(buf); + return buf.toString(); + } else { + return s; + } + } + + private String checkEntity(final String preamble, final String term) { + + return ";".equals(term) && isValidEntity(preamble) + ? '&' + preamble + : "&" + preamble; + } + + private boolean isValidEntity(final String entity) { + return inArray(entity, vAllowedEntities); + } + + private static boolean inArray(final String s, final String[] array) { + for (String item : array) { + if (item != null && item.equals(s)) { + return true; + } + } + return false; + } + + private boolean allowed(final String name) { + return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed); + } + + private boolean allowedAttribute(final String name, final String paramName) { + return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName)); + } +} \ No newline at end of file diff --git a/src/main/java/com/soft/line/xss/XssFilter.java b/src/main/java/com/soft/line/xss/XssFilter.java new file mode 100644 index 0000000000000000000000000000000000000000..a53afbc45d843b50f385fe125e566f772fae04b7 --- /dev/null +++ b/src/main/java/com/soft/line/xss/XssFilter.java @@ -0,0 +1,37 @@ +package com.soft.line.xss; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.core.annotation.Order; + +import javax.servlet.*; +import javax.servlet.annotation.WebFilter; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +/** + * @Description Xss过滤器 + * @Author wu.xueqiao + * @Date 2020/05/08 12:47 + */ +@Order(1) +@Slf4j +@WebFilter(filterName = "xssFilter", urlPatterns = "/*", asyncSupported = true) +public class XssFilter implements Filter { + @Override + public void init(FilterConfig filterConfig) throws ServletException { + log.debug("-----XssFilter init-----"); + + } + + @Override + public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { + HttpServletRequest request = (HttpServletRequest) servletRequest; + XssHttpServletRequestWrapper xssHttpServletRequestWrapper = new XssHttpServletRequestWrapper(request); + filterChain.doFilter(xssHttpServletRequestWrapper, servletResponse); + } + + @Override + public void destroy() { + + } +} diff --git a/src/main/java/com/soft/line/xss/XssHttpServletRequestWrapper.java b/src/main/java/com/soft/line/xss/XssHttpServletRequestWrapper.java new file mode 100644 index 0000000000000000000000000000000000000000..c15428a739415489cd660392db3d20be90558c18 --- /dev/null +++ b/src/main/java/com/soft/line/xss/XssHttpServletRequestWrapper.java @@ -0,0 +1,43 @@ +package com.soft.line.xss; + +import org.apache.commons.lang3.ArrayUtils; +import org.apache.commons.text.StringEscapeUtils; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; + + +/** + * @Description XSS 跨站脚本攻击(Cross Site Scripting) 处理 + */ +public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper { + + public XssHttpServletRequestWrapper(HttpServletRequest request) { + super(request); + } + + @Override + public String getQueryString() { + return StringEscapeUtils.escapeHtml4(super.getQueryString()); + } + + @Override + public String getParameter(String name) { + return StringEscapeUtils.escapeHtml4(super.getParameter(name)); + } + + @Override + public String[] getParameterValues(String name) { + String[] values = super.getParameterValues(name); + if (ArrayUtils.isEmpty(values)) { + return values; + } + int length = values.length; + String[] escapeValues = new String[length]; + for (int i = 0; i < length; i++) { + escapeValues[i] = StringEscapeUtils.escapeHtml4(values[i]); + } + return escapeValues; + } + +} diff --git a/src/main/java/com/soft/line/xss/XssJacksonDeserializer.java b/src/main/java/com/soft/line/xss/XssJacksonDeserializer.java new file mode 100644 index 0000000000000000000000000000000000000000..5104ce1ee48048c21536f64f640f7ff984d7c688 --- /dev/null +++ b/src/main/java/com/soft/line/xss/XssJacksonDeserializer.java @@ -0,0 +1,24 @@ +package com.soft.line.xss; + +import com.fasterxml.jackson.core.JsonParser; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationContext; +import com.fasterxml.jackson.databind.JsonDeserializer; +import org.apache.commons.text.StringEscapeUtils; + +import java.io.IOException; + + +/** + * @Description Jackson请求参数字符串转义处理 + * @Author wu.xueqiao + * @Date 2020/05/08 12:47 + */ +public class XssJacksonDeserializer extends JsonDeserializer { + + @Override + public String deserialize(JsonParser jsonParser, DeserializationContext deserializationContext) throws IOException, JsonProcessingException { + return StringEscapeUtils.escapeHtml4(jsonParser.getText()); + } + +} diff --git a/src/main/java/com/soft/line/xss/XssJacksonSerializer.java b/src/main/java/com/soft/line/xss/XssJacksonSerializer.java new file mode 100644 index 0000000000000000000000000000000000000000..e6316983cdd1d7509c91adb1f2477126fe3060f3 --- /dev/null +++ b/src/main/java/com/soft/line/xss/XssJacksonSerializer.java @@ -0,0 +1,24 @@ +package com.soft.line.xss; + +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.SerializerProvider; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.text.StringEscapeUtils; + +import java.io.IOException; + +/** + * @Description Jackson响应参数字符串转义处理 + * @Author wu.xueqiao + * @Date 2020/05/08 12:47 + */ +@Slf4j +public class XssJacksonSerializer extends JsonSerializer { + + @Override + public void serialize(String s, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { + jsonGenerator.writeString(StringEscapeUtils.escapeHtml4(s)); + } + +} diff --git a/src/main/resources/api/API.json b/src/main/resources/api/API.json new file mode 100644 index 0000000000000000000000000000000000000000..ecd6caf0ac7ab4f6a3d9a6fd276aa837fd82d3b9 --- /dev/null +++ b/src/main/resources/api/API.json @@ -0,0 +1,131 @@ +{ + "common": [ + { + "url": "/codeDetail", + "method": "get", + "desc": "获取codeDetail", + "params": { + "codeType": "" + }, + "response": [{ + "CodeDetail": "Bean" + }] + }, { + "url": "/pageMenu", + "method": "get", + "desc": "获取所有在前端有页面的菜单", + "params": { + }, + "response": { + "data": "返回所有有按钮的菜单(子菜单),和该页面包含的按钮列表" + } + }, { + "url": "/roleNames", + "method": "get", + "desc": "获取所有角色名称", + "params": { + }, + "response": { + "data": [ + { + "id": "1", + "roleName": "管理员" + } + ] + } + } + ], + "登录": [ + { + "url": "/auth/login", + "method": "post", + "desc": "登录", + "params": { + "userName": "", + "password": "" + } + }, { + "url": "/auth/logout", + "method": "post", + "desc": "登出", + "params": {} + }, { + "url": "/auth/userInfo", + "method": "get", + "desc": "获取登录用户有权限的页面和页面上的按钮", + "params": { + "userId": "" + }, + "response": { + "userInfo": { + "menuList": [{ + "buttonList": [{ + + }] + }] + } + } + } + ], + "用户管理": [ + { + "url": "/systemAdmin/accounts", + "method": "get", + "desc": "查询用户列表", + "params": { + "pageNo": 1, + "pageSize": 10, + "userName": "", + "roleId": "", + "status": "" + }, + "response": { + "data": [], + "pageSize": 10, + "pageNo": 0, + "totalPage": 1, + "totalCount": 2 + } + } + ], + "角色管理": [ + { + "url": "/systemAdmin/roles", + "method": "get", + "desc": "查询角色列表", + "params": { + "pageNo": 1, + "pageSize": 10, + "roleName": "", + "status": "" + }, + "response": { + "data": [], + "pageSize": 10, + "pageNo": 0, + "totalPage": 1, + "totalCount": 2 + } + } + ], + "菜单管理": [ + { + "url": "/systemAdmin/menus", + "method": "get", + "desc": "查询所有菜单列表", + "params": { + "pageNo": 1, + "pageSize": 10, + "menuName": "", + "menuUrl": "" + }, + "response": { + "data": [], + "pageSize": 10, + "pageNo": 0, + "totalPage": 1, + "totalCount": 2 + } + } + ] +} diff --git a/src/main/resources/api/Api doc.md b/src/main/resources/api/Api doc.md new file mode 100644 index 0000000000000000000000000000000000000000..06ad7dc1d4ccf2a34568a860a814a31709e0603f --- /dev/null +++ b/src/main/resources/api/Api doc.md @@ -0,0 +1,1294 @@ +# Api doc + +## 通用说明 + +* 接口通用前缀 + + > http://192.168.0.168:8081/softline + > + > + +* 请求头部 + + >Access-Token: 4291d7da9005377ec9aec4a71ea837f + > + >content-Type: application/json + +* 返回体 + + ```javascript + { + 'message': '', + 'timestamp': 0, + 'result': [], //返回数据 + 'code': 200 // 200 500 401 .. + }, + { + 'message': '', + 'timestamp': 0, + 'result': { + 'list': [{ Object }], + 'pageSize': 10, // 页面大小 + 'pageNum': 0, // 当前页 + 'pages': 1, // 总页数 + 'total': 2 // 数据总数 + }, + 'code': 200 + } + ``` + +* 错误码 + + | 错误代码 | 返回msg | + | :------: | :------------: | + | 400 | 请求参数有误 | + | 401 | 用户未登录 | + | 404 | 资源未找到 | + | 405 | 请求方式不支持 | + | 500 | 服务器错误 | + +## 1.通用接口 (common) + +### 1.1 枚举值 + +* 说明 + + 获取枚举值codeDetail + +* URL + + >`GET` + > + >[/codeDetail/{codeType}](/codeDetail/{codeType}) + +* path参数 + +| 参数名 | 必填 | 说明 | +| :------- | ---- | ---- | +| codeType | yes | | + +* 返回结果(data) + +``` javascript +[{ + codeType: 1, + codeDetail: 1, + codeContent1: '金融科技与服务事业部', + codeContent2: '', + codeContent3: '', + codeContent4: '', + note: '' +}, { + codeType: 1, + codeDetail: 2, + codeContent1: '国资与企业管控', + codeContent2: '', + codeContent3: '', + codeContent4: '', + note: '' +}...] +``` + +### 1.2 按钮列表 + + * 说明 + + 获取所有按钮列表 + +* URL + + > `get` + > + > [/buttons](/button) + +* 无参数 + +* 返回结果(data) + +```javascript +[{ + id: 1, + buttonName: '查询', + buttonType: 'query' +}, { + id: 2, + buttonName: '新增', + buttonType: 'add' +}, { + id: 3, + buttonName: '修改', + buttonType: 'edit' +}, { + id: 4, + buttonName: '删除', + buttonType: 'delete' +} + ... +] +``` + + +### 1.3 获取所有有操作按钮的页面 + +* 说明 + + 获取所有有操作按钮的页面(子菜单),用于角色管理页面,供角色选择权限 + +* URL + + > `GET` + > + > [/pageMenu](pageMenu) + +* 无参数 + +* 返回结果(data) + +``` javascript +[ + { + id: '1', + menuName: '用户管理', + buttonList: [{ buttonName: '新增', buttonType: 'add' }, { buttonName: '查询', buttonType: 'query' }, + { buttonName: '删除', buttonType: 'delete' }, { buttonName: '编辑', buttonType: 'edit' }, + { buttonName: '修改密码', buttonType: 'changePassword' }] + }, { + id: '2', + menuName: '角色管理', + buttonList: [{ buttonName: '新增', buttonType: 'add' }, { buttonName: '查询', buttonType: 'query' }, + { buttonName: '删除', buttonType: 'delete' }, { buttonName: '编辑', buttonType: 'edit' }] + }, { + id: '3', + menuName: '菜单管理', + buttonList: [{ buttonName: '新增', buttonType: 'add' }, { buttonName: '查询', buttonType: 'query' }, + { buttonName: '删除', buttonType: 'delete' }, { buttonName: '编辑', buttonType: 'edit' }] + } +] +``` + +### 1.4 获取所有顶级菜单 + +* 说明 + + 获取所有顶级菜单,在菜单管理页面下拉框展示 + +* URL + + > `GET` + > + > [/topMenu](/topMenu) + +* 无参数 + +* 返回结果(data) + +```javascript +[{ + id: '1', + menuName: '系统管理' +},{ + id: '5', + menuName: '数据管理' +},{ + id: '8', + menuName: '统计管理' +}] +``` + +### 1.5 获取所有角色名 + +* 说明 + + 获取所有角色名,在用户管理页面,下拉框选择角色 + +* URL + + >`GET` + > + >[/roleNames](/roleNames) + +* 无参数 + +* 返回结果(data) + +```javascript +[ + { + id: '1', + roleName: '管理员' + }, { + id: '2', + roleName: '普通用户' + }, { + id: '3', + roleName: '其他' + } +] +``` + +## 2 用户接口 (auth) + +### 2.1 用户登录 + +* 说明 + + 登录系统,颁发token + +* URL + + > `POST` + > + > [/auth/login](/auth/login) + +* body参数 + +| 参数名 | 必填 | 说明 | +| -------- | ---- | ---- | +| userName | yes | | +| password | yes | | + +* 返回结果(data) + +``` javascript +{ + 'message': '登录成功', + 'timestamp': 0, + 'data': { + 'token': '4291d7da9005377ec9aec4a71ea837f', + 'roleId': '1' + } + 'code': 200 +} +``` + +### 2.2 用户登出 + +* 说明 + + 用户退出系统,注销token + +* URL + + >`POST` + > + >[/auth/logout](/auth/logout) + +* 无参数 + +* 返回结果 + +``` javascript + +``` + +### 2.3 获取用户的权限列表 + +* 说明 + + 获取用户角色对应的权限列表,形成前端路由 + +* URL + + > `GET` + > + > [/auth/userInfo](/auth/userInfo) + +* 无参数 + +* 返回结果 + +```javascript + +``` + +## 3 用户管理接口 (systemAdmin) + +### 3.1 获取所有用户列表 + +* 说明 + + 获取所有用户列表 + +* URL + + >`GET` + > + >[/accounts](/accounts) + +* body参数 + +| 参数名 | 必填 | 说明 | +| -------- | ---- | ---- | +| userName | no | | +| roleId | no | | +| status | no | | +| pageNum | yes | | +| pageSize | yes | | + +* 返回结果(list) + +``` javascript +[{ + id: 1, + userName: 'admin', + status: 1, + phone: 13312345678, + modifyTime: 1497160610259, + avatar: '', + roleId: 1 +}, { + id: 2, + userName: '迪迦', + status: 2, + phone: 13312345678, + modifyTime: 1497160610259, + avatar: '', + roleId: 2 +}, { + id: 3, + userName: '海泽王', + status: 2, + phone: 13312345678, + modifyTime: 1497160610259, + avatar: '', + roleId: 2 +}] +``` + +### 3.2 新增用户 + +* 说明 + + 新增用户 + +* URL + + > `POST` + > + > [/accounts](/accounts) + +* body参数 + +| 参数名 | 必填 | 说明 | +| ---------- | ---- | ------------ | +| userName | yes | | +| password | yes | | +| phone | yes | | +| roleId | yes | | +| userStatus | yes | | +| avatar | no | 系统默认生成 | + +* 返回结果 + +``` javascript +{ + 'message': '保存成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +### 3.3 修改用户 + +* 说明 + + 修改用户 + +* URL + + > `PUT` + > + > [/accounts](/accounts) + +* body参数 + +| 参数名 | 必填 | 说明 | +| ---------- | ---- | ------ | +| id | yes | 用户id | +| userName | yes | | +| phone | yes | | +| roleId | yes | | +| userStatus | yes | | +| avatar | no | | + +* 返回结果 + +``` javascript +{ + 'message': '保存成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +### 3.4 删除用户 + +* 说明 + + 删除用户 + +* URL + + >`DELETE` + > + >[/accounts](/accounts) + +* body参数 + +| 参数名 | 必填 | 说明 | +| ------ | ---- | ------ | +| id | 必填 | 用户Id | + +* 返回结果 + +``` javascript +{ + 'message': '删除成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +### 3.5 修改密码 + +* 说明 + + 修改密码 + +* URL + + > `POST` + > + > [/changePassword](/changePassword) + +* body参数 + +| 参数名 | 必填 | 说明 | +| -------------- | ---- | ------------ | +| id | 必填 | 修改用户的id | +| oldPassword | 必填 | 老密码 | +| newPassword | 必填 | 新密码 | +| confimPassword | 必填 | 确认密码 | + +* 返回结果 + +``` javascript +{ + 'message': '修改成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +## 4 角色管理接口 (systemAdmin) + +### 4.1 获取所有角色列表 + +* 说明 + + 获取所有角色列表,包含该角色对应的菜单按钮 + +* URL + + > `GET` + > + > [/roles](/roles) + +* body参数 + +| 参数名 | 必填 | 说明 | +| -------- | ---- | ---- | +| roleName | no | | +| pageNum | yes | | +| pageSize | yes | | + +* 返回结果(list) + +``` javascript +[{ + 'id': '1', + 'roleName': '管理员', + 'status': 1, + 'describe': '管理员权限', + 'menuList': [{ + 'menuId': '1', + 'menuName': '用户管理', + 'buttonList': ['query', 'delete', 'edit', 'add', 'changePassword'] + }, { + 'menuId': '2', + 'menuName': '角色管理', + 'buttonList': ['query', 'delete', 'edit', 'add'] + }, { + 'menuId': '3', + 'menuName': '菜单管理', + 'buttonList': ['query', 'delete', 'edit', 'add'] + }, { + 'menuId': '4', + 'menuName': '合同管理', + 'buttonList': ['query', 'delete', 'edit', 'add', 'import', 'export'] + }, { + 'menuId': '5', + 'menuName': '证书管理', + 'buttonList': ['query', 'delete', 'edit', 'add', 'import'] + }] +}] +``` + +### 4.2 新增角色 ? + +* 说明 + + 新增角色 + +* URL + + > `POST` + > + > [/roles](/roles) + +* body参数 + +| 参数名 | 必填 | 说明 | +| -------- | ---- | ---- | +| roleName | yes | | +| describe | no | | +| menu | yes | | + +* 参数举例 + +``` javascript +{ + 'roleName': '管理员' + 'describe': '描述字段' + 'menu': [{ + 'menuId': '1', + 'buttonList': ['query', 'edit', 'add'] + }, { + 'menuId': '2', + 'buttonList': ['add', 'edit'] + }...] +} +``` + +* 返回结果 + +``` javascript +{ + 'message': '保存成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +### 4.3 修改角色 ? + +* 说明 + + 修改角色 + +* URL + + > `PUT` + > + > [/roles](/roles) + +* body参数 + +| 参数名 | 必填 | 说明 | +| -------- | ---- | ------ | +| id | yes | 角色Id | +| roleName | yes | | +| describe | no | | +| menu | yes | | + +* 参数举例 + +``` javascript +{ + 'id': 1 + 'roleName': '管理员' + 'describe': '描述字段' + 'menu': [{ + 'menuId': '1', + 'buttonList': ['query', 'edit', 'add'] + }, { + 'menuId': '2', + 'buttonList': ['add', 'edit'] + }...] +} +``` + +* 返回结果 + +``` javascript +{ + 'message': '保存成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +### 4.4 删除角色 + +* 说明 + + 删除角色 + +* URL + + >`DELETE` + > + >[/roles](/roles) + +* body参数 + +| 参数名 | 必填 | 说明 | +| ------ | ---- | ------ | +| id | 必填 | roleId | + +* 返回结果 + +``` javascript +{ + 'message': '删除成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +## 5 菜单管理接口 (systemAdmin) + +### 5.1 获取所有菜单列表 + +* 说明 + + 获取所有菜单列表,包含该角色对应的按钮列表 + +* URL + + > `GET` + > + > [/menu](/menu) + +* body参数 + +| 参数名 | 必填 | 说明 | +| -------- | ---- | ---- | +| menuName | no | | +| menuUrl | no | | +| pageNum | yes | | +| pageSize | yes | | + +* 返回结果(list) + +``` javascript +[ + { + id: '1', + menuName: '系统管理', + menuIcon: 'setting', + state: '1', + menuUrl: '/systemAdmin', + orderBy: '1', + pId: '-1', + modifyTime: '202005211526', + buttonList: [] + }, + { + id: '2', + menuName: '用户管理', + menuIcon: 'setting', + state: '2', + menuUrl: '/systemAdmin/account', + orderBy: '1', + pId: '1', + modifyTime: '202005211526', + buttonList: [{ + buttonName: '新增', buttonType: 'add' + }, { + buttonName: '查询', buttonType: 'query' + }, { + buttonName: '删除', buttonType: 'delete' + }, { + buttonName: '编辑', buttonType: 'edit' + }] + }... +] +``` + +### 5.2 新增菜单 + +* 说明 + + 新增菜单 + +* URL + + > `POST` + > + > [/menus](/menus) + +* body参数 + +| 参数名 | 必填 | 说明 | +| ---------- | ---- | ------------------ | +| menuName | yes | | +| menuUrl | yes | | +| menuIcon | yes | | +| pId | yes | 顶级菜单-1 | +| buttonList | no | 顶级菜单没有button | + +* 参数举例 + +``` javascript +{ + menuName: '用户管理' + menuUrl: '/accounts' + menuIcon: 'setting' + pId: '1' + buttonList: ['add', 'edit', 'query'] +} +``` + +* 返回结果 + +``` javascript +{ + 'message': '保存成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +### 5.3 修改菜单 + +* 说明 + + 修改菜单 + +* URL + + > `PUT` + > + > [/menus](/menus) + +* body参数 + +| 参数名 | 必填 | 说明 | +| ---------- | ---- | ------------------ | +| id | yes | 菜单id | +| menuName | yes | | +| menuUrl | yes | | +| menuIcon | yes | | +| pId | yes | | +| buttonList | no | 顶级菜单没有button | + +* 参数举例 + +``` javascript +{ + 'id': 1 + 'roleName': '管理员' + 'describe': '描述字段' + 'menu': [{ + 'menuId': '1', + 'buttonList': ['query', 'edit', 'add'] + }, { + 'menuId': '2', + 'buttonList': ['add', 'edit'] + }...] +} +``` + +* 返回结果 + +``` javascript +{ + 'message': '保存成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +### 5.4 删除菜单 + +* 说明 + + 删除菜单 + +* URL + + >`DELETE` + > + >[/menus](/menus) + +* body参数 + +| 参数名 | 必填 | 说明 | +| ------ | ---- | ------ | +| id | 必填 | 菜单ID | + +* 返回结果 + +``` javascript +{ + 'message': '删除成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +## 6 合同管理接口 (dataManage) + +### 6.1 获取所有合同 + +* 说明 + + 获取所有合同 + +* URL + + > `GET` + > + > [/contract](/contract) + +* body参数 + +| 参数名 | 必填 | 说明 | +| ------------ | ---- | ------------ | +| depId | no | 部门id | +| contractName | no | | +| proId | no | 项目id | +| totalAmount | no | 大于这个金额 | +| partA | no | | +| partB | no | | +| signTime | no | | +| signAddr | no | | +| beginDate | no | | +| endDate | no | | +| payment | no | | +| pageNum | yes | | +| pageSize | yes | | + +* 返回结果(list) + +``` javascript +[{ + id: 1, + depId: 1, + contractName: '合同1', + proId: 1, + totalAmount: '10000000', + partA: 'A', + partB: 'B', + signTime: '20200521', + signAddr: 'SH', + beginDate: '20200521', + endDate: '20250521', + payment: 'cash', + note: 'xxxx', + modifyTime: '20200521223000', + modifyPerson: 'admin' +}] +``` + +### 6.2 新增合同 + +* 说明 + + 新增合同 + +* URL + + > `POST` + > + > [/contract](/contract) + +* body参数 + +| 参数名 | 必填 | 说明 | +| ------------ | ---- | ------------ | +| depId | yes | 部门id | +| contractName | yes | | +| proId | yes | 项目id | +| totalAmount | yes | 大于这个金额 | +| partA | yes | | +| partB | yes | | +| signTime | yes | | +| signAddr | yes | | +| beginDate | yes | | +| endDate | yes | | +| payment | yes | | +| note | no | | + +* 参数举例 + +``` javascript +{ + beginDate: "20200501" + contractName: "请问" + depId: 1 + endDate: "20200610" + note: "请问" + partA: "请问" + partB: " 请问" + payment: 1 + proId: 1 + signAddr: "请问" + signTime: "20200519" + totalAmount: " 请问" +} +``` + +* 返回结果 + +``` javascript +{ + 'message': '保存成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +### 6.3 修改合同 + +* 说明 + + 修改合同 + +* URL + + > `PUT` + > + > [/contract](/contract) + +* body参数 + +| 参数名 | 必填 | 说明 | +| ------------ | ---- | ------------ | +| depId | yes | 部门id | +| contractName | yes | | +| proId | yes | 项目id | +| totalAmount | yes | 大于这个金额 | +| partA | yes | | +| partB | yes | | +| signTime | yes | | +| signAddr | yes | | +| beginDate | yes | | +| endDate | yes | | +| payment | yes | | +| note | no | | + +* 参数举例 + +``` javascript +{ + id: 1 + beginDate: "20200501" + contractName: "请问" + depId: 1 + endDate: "20200610" + note: "请问" + partA: "请问" + partB: " 请问" + payment: 1 + proId: 1 + signAddr: "请问" + signTime: "20200519" + totalAmount: " 请问" +} +``` + +* 返回结果 + +``` javascript +{ + 'message': '保存成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +### 6.4 删除合同 + +* 说明 + + 删除合同 + +* URL + + >`DELETE` + > + >[/contract](/contract) + +* body参数 + +| 参数名 | 必填 | 说明 | +| ------ | ---- | ------ | +| id | 必填 | 合同id | + +* 返回结果 + +``` javascript +{ + 'message': '删除成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +## 7 证书管理接口 (dataManage) + +### 5.1 获取所有菜单列表 + +* 说明 + + 获取所有菜单列表,包含该角色对应的按钮列表 + +* URL + + > `GET` + > + > [/menu](/menu) + +* body参数 + +| 参数名 | 必填 | 说明 | +| -------- | ---- | ---- | +| menuName | no | | +| menuUrl | no | | +| pageNum | yes | | +| pageSize | yes | | + +* 返回结果(list) + +``` javascript +[ + { + id: '1', + menuName: '系统管理', + menuIcon: 'setting', + state: '1', + menuUrl: '/systemAdmin', + orderBy: '1', + pId: '-1', + modifyTime: '202005211526', + buttonList: [] + }, + { + id: '2', + menuName: '用户管理', + menuIcon: 'setting', + state: '2', + menuUrl: '/systemAdmin/account', + orderBy: '1', + pId: '1', + modifyTime: '202005211526', + buttonList: [{ + buttonName: '新增', buttonType: 'add' + }, { + buttonName: '查询', buttonType: 'query' + }, { + buttonName: '删除', buttonType: 'delete' + }, { + buttonName: '编辑', buttonType: 'edit' + }] + }... +] +``` + +### 4.2 新增菜单 + +* 说明 + + 新增菜单 + +* URL + + > `POST` + > + > [/menus](/menus) + +* body参数 + +| 参数名 | 必填 | 说明 | +| ---------- | ---- | ------------------ | +| menuName | yes | | +| menuUrl | yes | | +| menuIcon | yes | | +| pId | yes | 顶级菜单-1 | +| buttonList | no | 顶级菜单没有button | + +* 参数举例 + +``` javascript +{ + menuName: '用户管理' + menuUrl: '/accounts' + menuIcon: 'setting' + pId: '1' + buttonList: ['add', 'edit', 'query'] +} +``` + +* 返回结果 + +``` javascript +{ + 'message': '保存成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +### 4.3 修改菜单 + +* 说明 + + 修改菜单 + +* URL + + > `PUT` + > + > [/menus](/menus) + +* body参数 + +| 参数名 | 必填 | 说明 | +| ---------- | ---- | ------------------ | +| id | yes | 菜单id | +| menuName | yes | | +| menuUrl | yes | | +| menuIcon | yes | | +| pId | yes | | +| buttonList | no | 顶级菜单没有button | + +* 参数举例 + +``` javascript +{ + 'id': 1 + 'roleName': '管理员' + 'describe': '描述字段' + 'menu': [{ + 'menuId': '1', + 'buttonList': ['query', 'edit', 'add'] + }, { + 'menuId': '2', + 'buttonList': ['add', 'edit'] + }...] +} +``` + +* 返回结果 + +``` javascript +{ + 'message': '保存成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +### 4.4 删除菜单 + +* 说明 + + 删除菜单 + +* URL + + >`DELETE` + > + >[/menus](/menus) + +* body参数 + +| 参数名 | 必填 | 说明 | +| ------ | ---- | ------ | +| id | 必填 | 菜单ID | + +* 返回结果 + +``` javascript +{ + 'message': '删除成功', + 'timestamp': 0, + 'data': null, + 'code': 200 +} +``` + +## 8 附件管理接口 (attachment) + +### 8.1 获取附件列表 + +* 说明 + + 获取合同或是证书的附件列表 + +* URL + + > `GET` + > + > [/attachment/{attachmentType}/{id}](/attachment/{attachmentType}/{id}) + +* path参数 + +| 参数名 | 必填 | 说明 | +| -------------- | ---- | ------------------------ | +| attachmentType | yes | 合同附件:1,证书附件:2 | +| id | yes | 合同id,或是证书id | + +* 返回结果(result) + +``` javascript +[{ + id: '1', + attachmentName: '附件1.doc', + attachmentUrl: 'blob:http://149.25.11.1/qweasdczxc156qwead.doc' +}, { + id: '2', + attachmentName: '附件2.doc', + attachmentUrl: 'blob:http://149.25.11.1/qweasdczxc156qwead.doc' +}, { + id: '3', + attachmentName: '附件3.doc', + attachmentUrl: 'blob:http://149.25.11.1/qweasdczxc156qwead.doc' +}] +``` + +### 8.2 上传附件 + +* 说明 + + 上传附件 + +* URL + + > `POST` + > + > [/upload](/upload) + +* body参数 + +|参数名|必填|说明| +|||| +|| + diff --git a/src/main/resources/application-dev.properties b/src/main/resources/application-dev.properties new file mode 100644 index 0000000000000000000000000000000000000000..cb72a44a4a1b87e93150970d2da21d1499762d63 --- /dev/null +++ b/src/main/resources/application-dev.properties @@ -0,0 +1,41 @@ +spring.datasource.url= jdbc:mysql://192.168.1.178:3306/las?characterEncoding=utf-8&useSSL=false +spring.datasource.username=root +spring.datasource.password=root123 +spring.datasource.driver-class-name=com.mysql.jdbc.Driver +#ݿӳ +spring.datasource.type=com.alibaba.druid.pool.DruidDataSource +spring.datasource.druid.initialSize=5 +spring.datasource.druid.minIdle=5 +spring.datasource.druid.maxActive=20 +spring.datasource.druid.maxWait=60000 +spring.datasource.druid.timeBetweenEvictionRunsMillis=60000 +spring.datasource.druid.minEvictableIdleTimeMillis=300000 +spring.datasource.druid.validationQuery=SELECT?1?FROM?DUAL +spring.datasource.druid.testWhileIdle=true +spring.datasource.druid.testOnBorrow=true +spring.datasource.druid.testOnReturn=true +spring.datasource.druid.poolPreparedStatements=true +spring.datasource.druid.filters=stat,wall +spring.datasource.druid.maxPoolPreparedStatementPerConnectionSize=20 +spring.datasource.druid.useGlobalDataSourceStat=true +spring.datasource.druid.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500 + +#redisӵַ +spring.jedis.host = 192.168.1.178 +spring.jedis.password= las@123 +spring.jedis.port = 6379 +spring.jedis.uri=redis://192.168.1.178:6379/0 + +spring.jedis.maxTotal=100 +spring.jedis.maxIdle= 10 +spring.jedis.maxWaitMillis =100000 + +spring.http.encoding.force=true +spring.http.encoding.charset=UTF-8 +spring.http.encoding.enabled=true +server.tomcat.uri-encoding=UTF-8 +### ļϴ +# ֵ֧ļ +spring.servlet.multipart.max-file-size=100MB +# ļ +spring.servlet.multipart.max-request-size=100MB \ No newline at end of file diff --git a/src/main/resources/application-pro.properties b/src/main/resources/application-pro.properties new file mode 100644 index 0000000000000000000000000000000000000000..a564661ca3181520a657a1988eb90e9a7c4589c7 --- /dev/null +++ b/src/main/resources/application-pro.properties @@ -0,0 +1,41 @@ +spring.datasource.url= jdbc:mysql://192.168.1.166:3306/las?characterEncoding=utf-8&useSSL=false +spring.datasource.username=root +spring.datasource.password=Leave@2020 +spring.datasource.driver-class-name=com.mysql.jdbc.Driver +#ݿӳ +spring.datasource.type=com.alibaba.druid.pool.DruidDataSource +spring.datasource.druid.initialSize=5 +spring.datasource.druid.minIdle=5 +spring.datasource.druid.maxActive=20 +spring.datasource.druid.maxWait=60000 +spring.datasource.druid.timeBetweenEvictionRunsMillis=60000 +spring.datasource.druid.minEvictableIdleTimeMillis=300000 +spring.datasource.druid.validationQuery=SELECT?1?FROM?DUAL +spring.datasource.druid.testWhileIdle=true +spring.datasource.druid.testOnBorrow=true +spring.datasource.druid.testOnReturn=true +spring.datasource.druid.poolPreparedStatements=true +spring.datasource.druid.filters=stat,wall +spring.datasource.druid.maxPoolPreparedStatementPerConnectionSize=20 +spring.datasource.druid.useGlobalDataSourceStat=true +spring.datasource.druid.connectionProperties=druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500 + +#redisӵַ +spring.jedis.host = 192.168.1.166 +spring.jedis.password= las@123 +spring.jedis.port = 6379 +spring.jedis.uri=redis://192.168.1.166:6379/0 + +spring.jedis.maxTotal=100 +spring.jedis.maxIdle= 10 +spring.jedis.maxWaitMillis =100000 + +spring.http.encoding.force=true +spring.http.encoding.charset=UTF-8 +spring.http.encoding.enabled=true +server.tomcat.uri-encoding=UTF-8 +### ļϴ +# ֵ֧ļ +spring.servlet.multipart.max-file-size=100MB +# ļ +spring.servlet.multipart.max-request-size=100MB \ No newline at end of file diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000000000000000000000000000000000000..ce67c4d18abab5a434be4a0a1dd62d57752b695b --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,27 @@ +server.port=9101 +server.servlet.context-path=/softline + +spring.profiles.active=dev + +#mybatis log +logging.level.com.soft.line.mapper = debug +pagehelper.helper-dialect=mysql +pagehelper.params=count=countSql +pagehelper.reasonable=true +pagehelper.support-methods-arguments=false +#mybatisӳļ· +#mybatis.mapper-locations=com.soft.line.mapper/*.xml +#ʵ· +mybatis.type-aliases-package=com.soft.line.entity + +#ʹmapʱ ѯijһȫΪnullʱҲش +mybatis.configuration.call-setters-on-nulls=true + +#ļϴַ +#windows +#uploadFileDir=D:/softline-files-manage-uploadFiles/ +#linux +uploadFileDir=/user/softline-files-manage-uploadFiles/ + +#ļϴӳַ +uploadFileMapping=uploadFiles/ diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties new file mode 100644 index 0000000000000000000000000000000000000000..014f7e3ed89fd8fe4ad583ba75dcaed71e3a5b8f --- /dev/null +++ b/src/main/resources/log4j.properties @@ -0,0 +1,10 @@ +log4j.rootLogger=debug, stdout, R +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%5p - %m%n +log4j.appender.R=org.apache.log4j.RollingFileAppender +log4j.appender.R.File=firestorm.log +log4j.appender.R.MaxFileSize=100KB +log4j.appender.R.MaxBackupIndex=1 +log4j.appender.R.layout=org.apache.log4j.PatternLayout +log4j.appender.R.layout.ConversionPattern=%p %t %c - %m%n \ No newline at end of file diff --git a/src/test/java/com/soft/line/SoftlineFilesManageApplicationTests.java b/src/test/java/com/soft/line/SoftlineFilesManageApplicationTests.java new file mode 100644 index 0000000000000000000000000000000000000000..e27def9ef9cd85f544dbefce5f7072683c559076 --- /dev/null +++ b/src/test/java/com/soft/line/SoftlineFilesManageApplicationTests.java @@ -0,0 +1,13 @@ +package com.soft.line; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class SoftlineFilesManageApplicationTests { + + @Test + void contextLoads() { + } + +}