commit 6fbb29ed7484b33365790785a220463e90a12bc5 Author: XinYi Song <2037158277@qq.com> Date: Wed Dec 15 15:14:39 2021 +0800 1、搭建了乐益播商家版app的开发框架。 2、开发了用户注册,账号密码登录,手机验证码登录的功能模块。 3、开发了商家模块的部分功能。 4、开发了总部审核用户,禁用,启用用户等功能模块。 5、整合了七牛云存储的功能模块(暂时没有账号,密钥等信息,待测试)。 6、创建了联盟商家,商品的数据库表 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..549e00a --- /dev/null +++ b/.gitignore @@ -0,0 +1,33 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java new file mode 100644 index 0000000..e76d1f3 --- /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 0000000..2cc7d4a 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 0000000..a9f1ef8 --- /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.8.3/apache-maven-3.8.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/mvnw b/mvnw new file mode 100644 index 0000000..a16b543 --- /dev/null +++ b/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd new file mode 100644 index 0000000..c8d4337 --- /dev/null +++ b/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..98131ad --- /dev/null +++ b/pom.xml @@ -0,0 +1,268 @@ + + + 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 2.4.1 + + + com.xkrs + business_shopping + 0.0.1-SNAPSHOT + business_shopping + Demo project for Spring Boot + + 5.19 + 0.11.2 + 4.5.12 + 6.1.5.Final + 5.4.20.Final + UTF-8 + UTF-8 + 11 + 11 + 11 + 1.2.76 + 2.10.5 + 2.10.5 + 5.0.0 + 5.0.0 + 4.5.2 + 5.0.0 + 5.0.0 + 2.0.4 + 4.4.3 + 0.4.0 + + + + + org.springframework.boot + spring-boot-starter-aop + + + org.springframework.boot + spring-boot-starter-data-redis + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-actuator + + + org.springframework.boot + spring-boot-starter-security + + + org.springframework.security + spring-security-messaging + + + org.springframework.boot + spring-boot-devtools + true + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-webflux + + + org.springframework.boot + spring-boot-starter + + + org.springframework.boot + spring-boot-starter-logging + + + + + + org.springframework.boot + spring-boot-starter-log4j2 + + + org.apache.commons + commons-pool2 + + + org.postgresql + postgresql + + + mysql + mysql-connector-java + + + io.jsonwebtoken + jjwt-api + ${jjwt.version} + + + io.jsonwebtoken + jjwt-impl + ${jjwt.version} + runtime + + + io.jsonwebtoken + jjwt-jackson + ${jjwt.version} + runtime + + + nl.basjes.parse.useragent + yauaa + ${yauaa.version} + + + org.apache.httpcomponents + httpmime + ${httpmime.version} + + + org.hibernate.validator + hibernate-validator + ${hibernate-validator.version} + + + org.hibernate + hibernate-spatial + ${hibernate-spatial.version} + + + com.alibaba + fastjson + ${fastjson.version} + + + + + io.springfox + springfox-swagger-ui + ${springfox-swagger-ui.version} + + + + io.springfox + springfox-swagger2 + ${springfox-swagger2.version} + + + + + org.apache.poi + poi + ${poi.version} + + + + org.apache.poi + poi-ooxml + ${poi-ooxml.version} + + + + net.sf.json-lib + json-lib + 2.4 + jdk15 + + + org.apache.httpcomponents + httpclient + ${httpclient.version} + + + + org.apache.poi + poi + ${poi.version} + + + + org.apache.poi + poi-ooxml + ${poi-ooxml.version} + + + + + com.aliyun + aliyun-java-sdk-core + 4.0.6 + + + com.aliyun + aliyun-java-sdk-dysmsapi + 1.1.0 + + + cn.hutool + hutool-all + ${hutool-all.version} + + + io.tus.java.client + tus-java-client + ${tus-client.version} + + + org.springframework.kafka + spring-kafka + 2.5.10.RELEASE + + + + com.qiniu + qiniu-java-sdk + [7.2.0, 7.2.99] + + + com.google.code.gson + gson + + + + + + + + + src/main/java + + **/*.properties + **/*.xml + + false + + + src/main/resources + + **/*.properties + **/*.xml + **/*.txt + + false + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/src/main/java/com/xkrs/BusinessShoppingApplication.java b/src/main/java/com/xkrs/BusinessShoppingApplication.java new file mode 100644 index 0000000..bca3c47 --- /dev/null +++ b/src/main/java/com/xkrs/BusinessShoppingApplication.java @@ -0,0 +1,13 @@ +package com.xkrs; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class BusinessShoppingApplication { + + public static void main(String[] args) { + SpringApplication.run(BusinessShoppingApplication.class, args); + } + +} diff --git a/src/main/java/com/xkrs/common/account/AccountCredentials.java b/src/main/java/com/xkrs/common/account/AccountCredentials.java new file mode 100644 index 0000000..8513b0f --- /dev/null +++ b/src/main/java/com/xkrs/common/account/AccountCredentials.java @@ -0,0 +1,36 @@ +package com.xkrs.common.account; + +/** + * 账户实体 + * @author tajochen + */ +public class AccountCredentials { + + private String userName; + private String password; + private boolean remember; + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public boolean isRemember() { + return remember; + } + + public void setRemember(boolean remember) { + this.remember = remember; + } +} diff --git a/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java b/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java new file mode 100644 index 0000000..edd61a7 --- /dev/null +++ b/src/main/java/com/xkrs/common/account/CustomAuthenticationProvider.java @@ -0,0 +1,123 @@ +package com.xkrs.common.account; + +import com.xkrs.model.entity.SysAuthorityEntity; +import com.xkrs.model.entity.SysUserEntity; +import com.xkrs.service.SysAuthorityService; +import com.xkrs.service.SysRoleService; +import com.xkrs.service.SysUserService; +import org.springframework.security.authentication.AuthenticationProvider; +import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.security.authentication.DisabledException; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.stereotype.Component; + +import javax.annotation.PostConstruct; +import javax.annotation.Resource; +import java.util.ArrayList; +import java.util.List; + +import static com.xkrs.utils.EncryptDecryptUtil.encry256; + +/** + * 自定义认证Provider + * @author tajochen + */ +@Component +public class CustomAuthenticationProvider implements AuthenticationProvider { + + @Resource + private SysUserService sysUserService; + + @Resource + private SysRoleService sysRoleService; + + @Resource + private SysAuthorityService sysAuthorityService; + + /** + * 初使化时将已静态化的Service实例化 + */ + protected static CustomAuthenticationProvider customAuthenticationProvider; + + /** + * 通过@PostConstruct实现初始化bean之前进行的操作 + */ + @PostConstruct + public void init() { + customAuthenticationProvider = this; + customAuthenticationProvider.sysUserService = this.sysUserService; + customAuthenticationProvider.sysRoleService = this.sysRoleService; + customAuthenticationProvider.sysAuthorityService = this.sysAuthorityService; + } + + /** + * 用户认证授权 + * @param authentication + * @return + * @throws AuthenticationException + */ + @Override + public Authentication authenticate(Authentication authentication) throws AuthenticationException { + // 获取认证的用户名 & 密码 + String userName = authentication.getName(); + String password = authentication.getCredentials().toString(); + + SysUserEntity userEntity = customAuthenticationProvider.sysUserService.getSysUserByUserName(userName); + + // 检查用户是否存在 + if(userEntity == null){ + throw new BadCredentialsException("user don't exist"); + } + + // 检查用户是否激活 + if(userEntity.getActiveFlag().intValue() != 0){ + throw new DisabledException("user not activated"); + } + + //检查用户状态是否正常 + if(userEntity.getStatusCode() != 0){ + throw new DisabledException("user state exception"); + } + // 认证逻辑 + String encryptPassword = encry256(password + userEntity.getSalt()); + if (encryptPassword.equals(userEntity.getPassword())) { + // 设置权限列表 + ArrayList permissions = new ArrayList<>(); + List permissionList = customAuthenticationProvider.sysAuthorityService. + getSysAuthorityListByUserName(userName); + for(SysAuthorityEntity sysAuthorityEntity : permissionList) { + permissions.add(new GrantedAuthorityImpl(sysAuthorityEntity.getAuthorityName())); + } + // 生成令牌 + Authentication authToken = new UsernamePasswordAuthenticationToken(userName, encryptPassword, permissions); + return authToken; + }else if(password.equals(userEntity.getPassword())){ + // 设置权限列表 + ArrayList permissions = new ArrayList<>(); + List permissionList = customAuthenticationProvider.sysAuthorityService. + getSysAuthorityListByUserName(userName); + for(SysAuthorityEntity sysAuthorityEntity : permissionList) { + permissions.add(new GrantedAuthorityImpl(sysAuthorityEntity.getAuthorityName())); + } + // 生成令牌 + Authentication authToken = new UsernamePasswordAuthenticationToken(userName, encryptPassword, permissions); + return authToken; + } + else { + throw new BadCredentialsException("user password error"); + } + } + + /** + * 是否可以提供输入类型的认证服务 + * @param authentication + * @return + */ + @Override + public boolean supports(Class authentication) { + return authentication.equals(UsernamePasswordAuthenticationToken.class); + } +} diff --git a/src/main/java/com/xkrs/common/account/GrantedAuthorityImpl.java b/src/main/java/com/xkrs/common/account/GrantedAuthorityImpl.java new file mode 100644 index 0000000..318a217 --- /dev/null +++ b/src/main/java/com/xkrs/common/account/GrantedAuthorityImpl.java @@ -0,0 +1,25 @@ +package com.xkrs.common.account; + +import org.springframework.security.core.GrantedAuthority; + +/** + * 权限认证服务 + * @author tajochen + */ +public class GrantedAuthorityImpl implements GrantedAuthority { + + private String authority; + + public GrantedAuthorityImpl(String authority) { + this.authority = authority; + } + + public void setAuthority(String authority) { + this.authority = authority; + } + + @Override + public String getAuthority() { + return this.authority; + } +} diff --git a/src/main/java/com/xkrs/common/account/JwtAuthenticationFilter.java b/src/main/java/com/xkrs/common/account/JwtAuthenticationFilter.java new file mode 100644 index 0000000..da3a512 --- /dev/null +++ b/src/main/java/com/xkrs/common/account/JwtAuthenticationFilter.java @@ -0,0 +1,28 @@ +package com.xkrs.common.account; + +import org.springframework.security.core.Authentication; +import org.springframework.security.core.context.SecurityContextHolder; +import org.springframework.web.filter.GenericFilterBean; + +import javax.servlet.FilterChain; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import java.io.IOException; + +/** + * 拦截所有需要JWT的请求,然后调用TokenAuthenticationService类的静态方法去做JWT验证 + * @author tajochen + */ +public class JwtAuthenticationFilter extends GenericFilterBean { + + @Override + public void doFilter(ServletRequest request, + ServletResponse response, + FilterChain filterChain) throws IOException, ServletException { + Authentication authentication = TokenAuthenticationService.getAuthentication((HttpServletRequest)request); + SecurityContextHolder.getContext().setAuthentication(authentication); + filterChain.doFilter(request,response); + } +} diff --git a/src/main/java/com/xkrs/common/account/JwtLoginFilter.java b/src/main/java/com/xkrs/common/account/JwtLoginFilter.java new file mode 100644 index 0000000..a533aff --- /dev/null +++ b/src/main/java/com/xkrs/common/account/JwtLoginFilter.java @@ -0,0 +1,132 @@ +package com.xkrs.common.account; + +import com.xkrs.common.encapsulation.OutputEncapsulation; +import com.xkrs.common.encapsulation.PromptMessageEnum; +import com.xkrs.model.vo.SysUserVo; +import com.xkrs.service.SysUserService; +import com.xkrs.utils.IpUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.authentication.BadCredentialsException; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.AuthenticationException; +import org.springframework.security.web.authentication.AbstractAuthenticationProcessingFilter; +import org.springframework.security.web.util.matcher.AntPathRequestMatcher; +import org.springframework.web.context.WebApplicationContext; +import org.springframework.web.context.support.WebApplicationContextUtils; + +import javax.annotation.Resource; +import javax.servlet.FilterChain; +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.io.UnsupportedEncodingException; +import java.util.Locale; + +/** + * jwt登录过滤器 + * @author tajochen + */ +public class JwtLoginFilter extends AbstractAuthenticationProcessingFilter { + + private static final Logger logger = LoggerFactory.getLogger(JwtLoginFilter.class); + + + @Resource + private SysUserService sysUserService; + + public JwtLoginFilter(String url, AuthenticationManager authManager) { + super(new AntPathRequestMatcher(url)); + setAuthenticationManager(authManager); + } + + /** + * 登录时验证 + * @param req + * @param res + * @return + */ + @Override + public Authentication attemptAuthentication(HttpServletRequest req, HttpServletResponse res) throws UnsupportedEncodingException { + req.setCharacterEncoding("UTF-8"); + res.setHeader("Access-Control-Allow-Origin","*"); + res.setHeader("Access-Control-Allow-Credentials", "false"); + AccountCredentials creds = new AccountCredentials(); + //获取表单数据 + String userName = req.getParameter("userName"); + String password = req.getParameter("password"); + String rememberMe = req.getParameter("remember"); + //如果用户名密码为空 + if(userName == null||password == null|| userName.trim().isEmpty()||password.trim().isEmpty()){ + throw new BadCredentialsException("user or password is null"); + } + if(rememberMe == null||rememberMe.isEmpty()){ + rememberMe = "false"; + } + creds.setUserName(userName.trim()); + creds.setPassword(password.trim()); + creds.setRemember(Boolean.parseBoolean(rememberMe)); + // 返回一个验证令牌 + return getAuthenticationManager().authenticate( + new UsernamePasswordAuthenticationToken( + creds.getUserName(), + creds.getPassword() + ) + ); + } + + /** + * 验证成功后调用 + * @param req + * @param response + * @param chain + * @param auth + * @throws IOException + * @throws ServletException + */ + @Override + protected void successfulAuthentication( + HttpServletRequest req, HttpServletResponse response, FilterChain chain, Authentication auth) { + if(sysUserService==null){ + ServletContext servletContext = req.getServletContext(); + WebApplicationContext webApplicationContext = WebApplicationContextUtils.getWebApplicationContext(servletContext); + sysUserService = webApplicationContext.getBean(SysUserService.class); + } + //更新用户登录信息 + sysUserService.updateSysUserLogin(auth.getName(), IpUtil.getIpAddr(req)); + SysUserVo sysUserVo = sysUserService.selectUserByUserName(auth.getName()); + response.setHeader("Access-Control-Allow-Origin", "*"); + response.setHeader("Access-Control-Allow-Credentials", "false"); + response.setContentType("application/json"); + response.setCharacterEncoding("UTF-8"); + TokenAuthenticationService.addAuthentication(response, auth.getName(),auth.getAuthorities(),sysUserVo); + } + + /** + * 验证失败后调用 + * @param request + * @param response + * @param failed + * @throws IOException + */ + @Override + protected void unsuccessfulAuthentication(HttpServletRequest request, + HttpServletResponse response, + AuthenticationException failed) throws IOException { + Locale locale = LocaleContextHolder.getLocale(); + response.setHeader("Access-Control-Allow-Origin", "*"); + response.setHeader("Access-Control-Allow-Credentials", "false"); + response.setContentType("application/json"); + response.setCharacterEncoding("UTF-8"); + // 将 JWT 写入 body + PrintWriter out = response.getWriter(); + out.append(OutputEncapsulation.outputEncapsulationObject(PromptMessageEnum.DATA_WRONG, failed.getLocalizedMessage(), locale)); + response.setStatus(HttpServletResponse.SC_OK); + } +} diff --git a/src/main/java/com/xkrs/common/account/TokenAuthenticationService.java b/src/main/java/com/xkrs/common/account/TokenAuthenticationService.java new file mode 100644 index 0000000..94b943c --- /dev/null +++ b/src/main/java/com/xkrs/common/account/TokenAuthenticationService.java @@ -0,0 +1,129 @@ +package com.xkrs.common.account; + +import com.xkrs.common.encapsulation.OutputEncapsulation; +import com.xkrs.common.encapsulation.PromptMessageEnum; +import com.xkrs.model.vo.SysUserVo; +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.security.Keys; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; +import org.springframework.security.core.Authentication; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.AuthorityUtils; + +import javax.crypto.SecretKey; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; +import java.util.*; + +/** + * token认证服务 + * @author tajochen + */ +public class TokenAuthenticationService { + + private static final Logger logger = LoggerFactory.getLogger(TokenAuthenticationService.class); + /** + * 过期时间6小时 + */ + static public final long EXPIRATIONTIME = 21_600_000; + /** + * 加密密钥 + */ + static public final String SECRET_KEY = "0Y9H364Q9Y908262F25LMXGIKIN5N858XM3674GWL2DD8X1DS4W6I722IRY8PS4XPNB6U303" + + "45HBVCUL94STG8C3Z53T7A09JJ100I56YE9894CI11PX9J71HIZ8L5Y2O504C4E2K8276425UA8734833F45K36878FXAG799QV9LXU" + + "JOI3XA2046UPG8TB2OT84R5T6ZB127N9ZPJ7AJMC41JVHB2WK2B6H8NL45LZNAZ666KHZH3QUT65UX6F8"; + /** + * Token前缀 + */ + static public final String TOKEN_PREFIX = "Bearer"; + + /** + * 存放Token的Header Key + */ + static final String HEADER_STRING = "Authorization"; + static SecretKey key = Keys.hmacShaKeyFor(SECRET_KEY.getBytes()); + + /** + * JWT生成方法 + * @param response + * @param userName + * @param authorities + */ + static void addAuthentication(HttpServletResponse response, String userName, + Collection authorities, SysUserVo sysUserVo) { + + Locale locale = new Locale("zh", "CN"); + Map map = new HashMap(3); + StringBuffer auths = new StringBuffer(); + String authsList = ""; + for(GrantedAuthority r : authorities) { + auths.append("," + r.getAuthority()); + } + authsList = auths.toString(); + if(authsList.length()>1){ + authsList=authsList.substring(1,authsList.length()); + }else{ + logger.warn(userName +" has no permission!"); + } + // 生成JWT + String jwt = Jwts.builder() + .setSubject(userName) + .setIssuer("https://www.microservice.com") + .setAudience(userName) + // 保存权限 + .claim("auths", authsList) + // 有效期设置 + .setExpiration(new Date(System.currentTimeMillis() + EXPIRATIONTIME)) + // 签名设置 + .signWith(key) + .compact(); + // 将 JWT 写入 body + PrintWriter out = null; + try { + out = response.getWriter(); + } + catch (IOException e) { + e.printStackTrace(); + } + response.setStatus(HttpServletResponse.SC_OK); + map.put("user",sysUserVo); + map.put("token",jwt); + map.put("role",authsList); + out.append(OutputEncapsulation.outputEncapsulationObject(PromptMessageEnum.SUCCESS, map, locale)); + } + + /** + * JWT验证方法 + * @param request + * @return + */ + static Authentication getAuthentication(HttpServletRequest request) { + // 从Header中拿到token + String token = request.getHeader(HEADER_STRING); + if (token != null) { + try { + // 解析 Token + Claims claims = Jwts.parserBuilder() + .setSigningKey(key).build() + // 去掉 Bearer + .parseClaimsJws(token.replace(TOKEN_PREFIX, "")) + .getBody(); + // 获取用户名 + String userName = claims.getSubject(); + // 获取权限 + List authorities = AuthorityUtils.commaSeparatedStringToAuthorityList((String) claims.get("auths")); + return new UsernamePasswordAuthenticationToken(userName, null, authorities); + } catch(Exception e) { + // the sub field was missing or did not have a value + return null; + } + } else { + return null; + } + } +} diff --git a/src/main/java/com/xkrs/common/config/CorsConfig.java b/src/main/java/com/xkrs/common/config/CorsConfig.java new file mode 100644 index 0000000..7f8c32f --- /dev/null +++ b/src/main/java/com/xkrs/common/config/CorsConfig.java @@ -0,0 +1,23 @@ +package com.xkrs.common.config; + +import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.InterceptorRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +import javax.annotation.Resource; + +/** + * 系统跨域配置 + * @author tajochen + */ +@Configuration +public class CorsConfig implements WebMvcConfigurer { + + @Resource + private CorsInterceptor corsInterceptor; + + @Override + public void addInterceptors(InterceptorRegistry registry) { + registry.addInterceptor(corsInterceptor); + } +} diff --git a/src/main/java/com/xkrs/common/config/CorsInterceptor.java b/src/main/java/com/xkrs/common/config/CorsInterceptor.java new file mode 100644 index 0000000..e2103c5 --- /dev/null +++ b/src/main/java/com/xkrs/common/config/CorsInterceptor.java @@ -0,0 +1,29 @@ +package com.xkrs.common.config; + +import org.springframework.stereotype.Component; +import org.springframework.web.servlet.HandlerInterceptor; + +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +/** + * 跨域处理 + * @author tajochen + */ +@Component +public class CorsInterceptor implements HandlerInterceptor { + + @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) { + + //添加跨域CORS + response.setHeader("Access-Control-Allow-Origin", "*"); + response.setHeader("Access-Control-Allow-Credentials", "false"); + response.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS"); + response.setHeader("Access-Control-Allow-Headers", "Content-Type , Authorization," + + "Accept,Origin,X-Requested-With"); + response.setHeader("Access-Control-Max-Age", "216000"); + response.setHeader("Content-Type","application/json;charset=UTF-8"); + return true; + } +} + diff --git a/src/main/java/com/xkrs/common/config/MvcConfig.java b/src/main/java/com/xkrs/common/config/MvcConfig.java new file mode 100644 index 0000000..edce463 --- /dev/null +++ b/src/main/java/com/xkrs/common/config/MvcConfig.java @@ -0,0 +1,37 @@ +package com.xkrs.common.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.TaskScheduler; +import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; +import org.springframework.web.servlet.config.annotation.CorsRegistry; +import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; + +/** + * WebMVC配置 + * @author Tajochen + */ +@Configuration +public class MvcConfig implements WebMvcConfigurer { + + /** + * 放行跨域请求 + */ + @Override + public void addCorsMappings(CorsRegistry registry) { + registry.addMapping("/**") + .allowedOrigins("*") + .allowedMethods("*") + .allowedHeaders("*"); + } + + /** + * 定时任务线程池更改,防止多个任务并行 + */ + @Bean + public TaskScheduler taskScheduler() { + final ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); + scheduler.setPoolSize(5); + return scheduler; + } +} diff --git a/src/main/java/com/xkrs/common/config/RedisCacheAutoConfiguration.java b/src/main/java/com/xkrs/common/config/RedisCacheAutoConfiguration.java new file mode 100644 index 0000000..6a0970b --- /dev/null +++ b/src/main/java/com/xkrs/common/config/RedisCacheAutoConfiguration.java @@ -0,0 +1,30 @@ +package com.xkrs.common.config; + +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; +import org.springframework.data.redis.serializer.StringRedisSerializer; + +import java.io.Serializable; + +/** + * Redis 缓存自动配置 + * @author tajochen + */ +@Configuration +@AutoConfigureAfter(RedisAutoConfiguration.class) +public class RedisCacheAutoConfiguration { + + @Bean + public RedisTemplate redisCacheTemplate(LettuceConnectionFactory redisConnectionFactory) { + RedisTemplate template = new RedisTemplate<>(); + template.setKeySerializer(new StringRedisSerializer()); + template.setValueSerializer(new GenericJackson2JsonRedisSerializer()); + template.setConnectionFactory(redisConnectionFactory); + return template; + } +} diff --git a/src/main/java/com/xkrs/common/config/RedisConfig.java b/src/main/java/com/xkrs/common/config/RedisConfig.java new file mode 100644 index 0000000..fb6641d --- /dev/null +++ b/src/main/java/com/xkrs/common/config/RedisConfig.java @@ -0,0 +1,187 @@ +package com.xkrs.common.config; + +import com.fasterxml.jackson.annotation.JsonAutoDetect; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.PropertyAccessor; +import com.fasterxml.jackson.core.JsonGenerator; +import com.fasterxml.jackson.databind.JsonSerializer; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.databind.SerializerProvider; +import com.fasterxml.jackson.databind.jsontype.impl.LaissezFaireSubTypeValidator; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cache.CacheManager; +import org.springframework.cache.annotation.CachingConfigurerSupport; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cache.interceptor.CacheErrorHandler; +import org.springframework.cache.interceptor.CacheResolver; +import org.springframework.cache.interceptor.KeyGenerator; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.data.redis.cache.RedisCacheConfiguration; +import org.springframework.data.redis.cache.RedisCacheManager; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.serializer.*; + +import javax.annotation.Resource; +import java.io.IOException; +import java.time.Duration; + +/** + * redis配置 + * @author tajochen + */ +@Configuration +@EnableCaching +public class RedisConfig extends CachingConfigurerSupport{ + + private static final Logger logger = LoggerFactory.getLogger(RedisConfig.class); + + @Resource + private LettuceConnectionFactory lettuceConnectionFactory; + + private static final Duration TIME_TO_LIVE = Duration.ofSeconds(3600*6); + + @Bean + @Override + public KeyGenerator keyGenerator() { + + // 设置自动key的生成规则,配置spring boot的注解,进行方法级别的缓存 + return (target, method, params) -> { + StringBuilder sb = new StringBuilder(); + sb.append(target.getClass().getName()); + sb.append(":"); + sb.append(method.getName()); + for (Object obj : params) { + sb.append(":").append(obj); + } + // logger.info("自动生成Redis Key -> [{}]", rsToUse); + return String.valueOf(sb); + }; + } + + @Bean + @Override + public CacheManager cacheManager() { + // 关键点,spring cache的注解使用的序列化都从这来,没有这个配置的话使用的jdk自己的序列化 + RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig() + //key序列化方式 + .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(keySerializer())) + //value序列化方式 + .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(valueSerializer())) + .disableCachingNullValues() + .entryTtl(TIME_TO_LIVE); + + RedisCacheManager.RedisCacheManagerBuilder builder = RedisCacheManager.RedisCacheManagerBuilder + .fromConnectionFactory(lettuceConnectionFactory) + .cacheDefaults(config) + .transactionAware(); + + return builder.build(); + } + + + /** + * RedisTemplate配置 在单独使用redisTemplate的时候 重新定义序列化方式 + */ + @Bean(name = "redisTemplate") + public RedisTemplate redisTemplate(LettuceConnectionFactory lettuceConnectionFactory) { + // 设置序列化 + Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); + ObjectMapper om = new ObjectMapper(); + // 配置null值序列化成空字符串 + om.getSerializerProvider().setNullValueSerializer(new JsonSerializer<>() { + @Override + public void serialize(Object o, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException { + jsonGenerator.writeString(""); + } + }); + // 解决jackson无法反序列化LocalDateTime的问题,引入jsr310标准 + JavaTimeModule javaTimeModule = new JavaTimeModule(); + om.registerModule(javaTimeModule); + om.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + // 其他设置 + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance , + ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY); + jackson2JsonRedisSerializer.setObjectMapper(om); + // 配置redisTemplate + RedisTemplate redisTemplate = new RedisTemplate<>(); + redisTemplate.setConnectionFactory(lettuceConnectionFactory); + RedisSerializer stringSerializer = new StringRedisSerializer(); + redisTemplate.setKeySerializer(stringSerializer); + redisTemplate.setValueSerializer(jackson2JsonRedisSerializer); + redisTemplate.setHashKeySerializer(stringSerializer); + redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer); + redisTemplate.afterPropertiesSet(); + return redisTemplate; + } + + private RedisSerializer keySerializer() { + return new StringRedisSerializer(); + } + + private RedisSerializer valueSerializer() { + // 设置序列化 + Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer<>( + Object.class); + ObjectMapper om = new ObjectMapper(); + // 解决jackson无法反序列化LocalDateTime的问题,引入jsr310标准 + JavaTimeModule javaTimeModule = new JavaTimeModule(); + om.registerModule(javaTimeModule); + om.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + // 其他设置 + om.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); + om.activateDefaultTyping(LaissezFaireSubTypeValidator.instance , + ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY); + jackson2JsonRedisSerializer.setObjectMapper(om); + return jackson2JsonRedisSerializer; + } + + @Override + public CacheResolver cacheResolver() { + return null; + } + + /** + * 设置数据存入 redis 的序列化方式,并开启事务 + * + * @param redisTemplate + * @param factory + */ + private void initRedisTemplate(RedisTemplate redisTemplate, RedisConnectionFactory factory) { + //如果不配置Serializer,那么存储的时候缺省使用String,如果用User类型存储,那么会提示错误User can't cast to String! + redisTemplate.setKeySerializer(new StringRedisSerializer()); + redisTemplate.setHashKeySerializer(new StringRedisSerializer()); + redisTemplate.setHashValueSerializer(new GenericJackson2JsonRedisSerializer()); + redisTemplate.setValueSerializer(new GenericJackson2JsonRedisSerializer()); + // 开启事务 + redisTemplate.setEnableTransactionSupport(true); + redisTemplate.setConnectionFactory(factory); + } + + /** + * 注入封装RedisTemplate 给RedisUtil提供操作类 + * @param redisTemplate + * @return RedisUtil + */ + @Bean(name = "redisUtil") + public RedisUtil redisUtil(RedisTemplate redisTemplate) { + RedisUtil redisUtil = new RedisUtil(); + redisUtil.setRedisTemplate(redisTemplate); + return redisUtil; + } + + @Override + @Bean + public CacheErrorHandler errorHandler() { + // 异常处理,当Redis发生异常时,打印日志,但是程序正常走 + logger.info("初始化 -> [{}]", "Redis CacheErrorHandler"); + return null; + } + +} diff --git a/src/main/java/com/xkrs/common/config/RedisUtil.java b/src/main/java/com/xkrs/common/config/RedisUtil.java new file mode 100644 index 0000000..25bd3a7 --- /dev/null +++ b/src/main/java/com/xkrs/common/config/RedisUtil.java @@ -0,0 +1,533 @@ +package com.xkrs.common.config; + +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.util.CollectionUtils; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.TimeUnit; + +/** + * redis工具类 + * @author tajochen + */ +public class RedisUtil { + + private RedisTemplate redisTemplate; + + public void setRedisTemplate(RedisTemplate redisTemplate) { + this.redisTemplate = redisTemplate; + } + + /** + * 指定缓存失效时间 + * @param key 键 + * @param time 时间(秒) + * @return + */ + public boolean expire(String key,long time){ + try { + if(time>0){ + redisTemplate.expire(key, time, TimeUnit.SECONDS); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 根据key 获取过期时间 + * @param key 键 不能为null + * @return 时间(秒) 返回0 代表为永久有效 + */ + public long getExpire(String key){ + return redisTemplate.getExpire(key,TimeUnit.SECONDS); + } + + /** + * 判断key是否存在 + * @param key 键 + * @return true 存在 false不存在 + */ + public boolean hasKey(String key){ + try { + return redisTemplate.hasKey(key); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 删除缓存 + * @param key 可以传一个值 或多个 + */ + @SuppressWarnings("unchecked") + public void del(String ... key){ + if(key!=null&&key.length>0){ + if(key.length==1){ + redisTemplate.delete(key[0]); + }else{ + redisTemplate.delete(String.valueOf(CollectionUtils.arrayToList(key))); + } + } + } + + //============================String============================= + /** + * 普通缓存获取 + * @param key 键 + * @return 值 + */ + public Object get(String key){ + return key==null?null:redisTemplate.opsForValue().get(key); + } + + /** + * 普通缓存放入 + * @param key 键 + * @param value 值 + * @return true成功 false失败 + */ + public boolean set(String key,Object value) { + try { + redisTemplate.opsForValue().set(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + + } + + /** + * 普通缓存放入并设置时间 + * @param key 键 + * @param value 值 + * @param time 时间(秒) time要大于0 如果time小于等于0 将设置无限期 + * @return true成功 false 失败 + */ + public boolean set(String key,Object value,long time){ + try { + if(time>0){ + redisTemplate.opsForValue().set(key, value, time, TimeUnit.SECONDS); + } else { + set(key, value); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 递增 + * @param key 键 + * @param delta 要增加几(大于0) + * @return + */ + public long incr(String key, long delta){ + if(delta<0){ + throw new RuntimeException("递增因子必须大于0"); + } + return redisTemplate.opsForValue().increment(key, delta); + } + + /** + * 递减 + * @param key 键 + * @param delta 要减少几(小于0) + * @return + */ + public long decr(String key, long delta){ + if(delta<0){ + throw new RuntimeException("递减因子必须大于0"); + } + return redisTemplate.opsForValue().increment(key, -delta); + } + + //================================Map================================= + /** + * HashGet + * @param key 键 不能为null + * @param item 项 不能为null + * @return 值 + */ + public Object hget(String key,String item){ + return redisTemplate.opsForHash().get(key, item); + } + + /** + * 获取hashKey对应的所有键值 + * @param key 键 + * @return 对应的多个键值 + */ + public Map hmget(String key){ + return redisTemplate.opsForHash().entries(key); + } + + /** + * HashSet + * @param key 键 + * @param map 对应多个键值 + * @return true 成功 false 失败 + */ + public boolean hmset(String key, Map map){ + try { + redisTemplate.opsForHash().putAll(key, map); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * HashSet 并设置时间 + * @param key 键 + * @param map 对应多个键值 + * @param time 时间(秒) + * @return true成功 false失败 + */ + public boolean hmset(String key, Map map, long time){ + try { + redisTemplate.opsForHash().putAll(key, map); + if(time>0){ + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 向一张hash表中放入数据,如果不存在将创建 + * @param key 键 + * @param item 项 + * @param value 值 + * @return true 成功 false失败 + */ + public boolean hset(String key,String item,Object value) { + try { + redisTemplate.opsForHash().put(key, item, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 向一张hash表中放入数据,如果不存在将创建 + * @param key 键 + * @param item 项 + * @param value 值 + * @param time 时间(秒) 注意:如果已存在的hash表有时间,这里将会替换原有的时间 + * @return true 成功 false失败 + */ + public boolean hset(String key,String item,Object value,long time) { + try { + redisTemplate.opsForHash().put(key, item, value); + if(time>0){ + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 删除hash表中的值 + * @param key 键 不能为null + * @param item 项 可以使多个 不能为null + */ + public void hdel(String key, Object... item){ + redisTemplate.opsForHash().delete(key,item); + } + + /** + * 判断hash表中是否有该项的值 + * @param key 键 不能为null + * @param item 项 不能为null + * @return true 存在 false不存在 + */ + public boolean hHasKey(String key, String item){ + return redisTemplate.opsForHash().hasKey(key, item); + } + + /** + * hash递增 如果不存在,就会创建一个 并把新增后的值返回 + * @param key 键 + * @param item 项 + * @param by 要增加几(大于0) + * @return + */ + public double hincr(String key, String item,double by){ + return redisTemplate.opsForHash().increment(key, item, by); + } + + /** + * hash递减 + * @param key 键 + * @param item 项 + * @param by 要减少记(小于0) + * @return + */ + public double hdecr(String key, String item,double by){ + return redisTemplate.opsForHash().increment(key, item,-by); + } + + //============================set============================= + /** + * 根据key获取Set中的所有值 + * @param key 键 + * @return + */ + public Set sGet(String key){ + try { + return redisTemplate.opsForSet().members(key); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 根据value从一个set中查询,是否存在 + * @param key 键 + * @param value 值 + * @return true 存在 false不存在 + */ + public boolean sHasKey(String key,Object value){ + try { + return Boolean.TRUE.equals(redisTemplate.opsForSet().isMember(key, value)); + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将数据放入set缓存 + * @param key 键 + * @param values 值 可以是多个 + * @return 成功个数 + */ + public long sSet(String key, Object...values) { + try { + return redisTemplate.opsForSet().add(key, values); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 将set数据放入缓存 + * @param key 键 + * @param time 时间(秒) + * @param values 值 可以是多个 + * @return 成功个数 + */ + public long sSetAndTime(String key,long time,Object...values) { + try { + Long count = redisTemplate.opsForSet().add(key, values); + if(time>0) + {expire(key, time);} + return count; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 获取set缓存的长度 + * @param key 键 + * @return + */ + public long sGetSetSize(String key){ + try { + return redisTemplate.opsForSet().size(key); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 移除值为value的 + * @param key 键 + * @param values 值 可以是多个 + * @return 移除的个数 + */ + public long setRemove(String key, Object ...values) { + try { + Long count = redisTemplate.opsForSet().remove(key, values); + return count; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + //===============================list================================= + + /** + * 获取list缓存的内容 + * @param key 键 + * @param start 开始 + * @param end 结束 0 到 -1代表所有值 + * @return + */ + public List lGet(String key, long start, long end){ + try { + return redisTemplate.opsForList().range(key, start, end); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 获取list缓存的长度 + * @param key 键 + * @return + */ + public long lGetListSize(String key){ + try { + return redisTemplate.opsForList().size(key); + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } + + /** + * 通过索引 获取list中的值 + * @param key 键 + * @param index 索引 index>=0时, 0 表头,1 第二个元素,依次类推;index<0时,-1,表尾,-2倒数第二个元素,依次类推 + * @return + */ + public Object lGetIndex(String key,long index){ + try { + return redisTemplate.opsForList().index(key, index); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @return + */ + public boolean lSet(String key, Object value) { + try { + redisTemplate.opsForList().rightPush(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @param time 时间(秒) + * @return + */ + public boolean lSet(String key, Object value, long time) { + try { + redisTemplate.opsForList().rightPush(key, value); + if (time > 0) + {expire(key, time);} + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @return + */ + public boolean lSet(String key, List value) { + try { + redisTemplate.opsForList().rightPushAll(key, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 将list放入缓存 + * @param key 键 + * @param value 值 + * @param time 时间(秒) + * @return + */ + public boolean lSet(String key, List value, long time) { + try { + redisTemplate.opsForList().rightPushAll(key, value); + if (time > 0) { + expire(key, time); + } + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 根据索引修改list中的某条数据 + * @param key 键 + * @param index 索引 + * @param value 值 + * @return + */ + public boolean lUpdateIndex(String key, long index,Object value) { + try { + redisTemplate.opsForList().set(key, index, value); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + } + + /** + * 移除N个值为value + * @param key 键 + * @param count 移除多少个 + * @param value 值 + * @return 移除的个数 + */ + public long lRemove(String key,long count,Object value) { + try { + Long remove = redisTemplate.opsForList().remove(key, count, value); + return remove; + } catch (Exception e) { + e.printStackTrace(); + return 0; + } + } +} + diff --git a/src/main/java/com/xkrs/common/config/WebSecurityConfig.java b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java new file mode 100644 index 0000000..96686fc --- /dev/null +++ b/src/main/java/com/xkrs/common/config/WebSecurityConfig.java @@ -0,0 +1,63 @@ +package com.xkrs.common.config; + +import com.xkrs.common.account.CustomAuthenticationProvider; +import com.xkrs.common.account.JwtAuthenticationFilter; +import com.xkrs.common.account.JwtLoginFilter; +import org.springframework.context.annotation.Configuration; +import org.springframework.http.HttpMethod; +import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; +import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; + +@Configuration +@EnableWebSecurity +@EnableGlobalMethodSecurity(prePostEnabled=true) +class WebSecurityConfig extends WebSecurityConfigurerAdapter { + + /** + * 设置 HTTP 验证规则 + * @param http + * @throws Exception + */ + @Override + protected void configure(HttpSecurity http) throws Exception { + // 关闭csrf验证 + http.csrf().disable() + // 对请求进行认证 + .authorizeRequests() + // 所有 / 的所有请求 都放行 + .antMatchers("/").permitAll() + // 所有OPTIONS请求都放行 + .antMatchers(HttpMethod.OPTIONS).permitAll() + // 所有 /user/add 用户注册 的POST请求 都放行 + .antMatchers(HttpMethod.POST, "/api/user/add").permitAll() + // 所有 /user/check/duplicate 检查用户名是否重复 的POST请求 都放行 + .antMatchers(HttpMethod.POST, "/api/user/check/duplicate").permitAll() + // 所有 /login 用户登录 的POST请求 都放行 + .antMatchers(HttpMethod.POST, "/api/login").permitAll() + // 所有 app 用户注册 的POST请求 都放行 + .antMatchers(HttpMethod.POST, "/api/person-investigator/add").permitAll() + .antMatchers(HttpMethod.GET,"/api/user/verificationCode").permitAll() + // 手机号登录 + .antMatchers(HttpMethod.POST,"/api/user/loginByPhone").permitAll() + // 所有其它请求需要身份认证 + .anyRequest().authenticated() + .and() + // 添加一个过滤器 所有访问 /login 的请求交给 JWTLoginFilter 来处理 这个类处理所有的JWT相关内容 + .addFilterBefore(new JwtLoginFilter("/api/login", authenticationManager()), + UsernamePasswordAuthenticationFilter.class) + // 添加一个过滤器验证其他请求的Token是否合法 + .addFilterBefore(new JwtAuthenticationFilter(), + UsernamePasswordAuthenticationFilter.class); + ;} + + @Override + protected void configure(AuthenticationManagerBuilder auth) throws Exception { + // 使用自定义身份验证组件 + auth.authenticationProvider(new CustomAuthenticationProvider()); + } +} + diff --git a/src/main/java/com/xkrs/common/encapsulation/EncapsulationObejct.java b/src/main/java/com/xkrs/common/encapsulation/EncapsulationObejct.java new file mode 100644 index 0000000..e11fea7 --- /dev/null +++ b/src/main/java/com/xkrs/common/encapsulation/EncapsulationObejct.java @@ -0,0 +1,59 @@ +package com.xkrs.common.encapsulation; + +import java.io.Serializable; + +/** + * 输出信息对象 + * @author tajochen + * @param + */ +public class EncapsulationObejct implements Serializable { + + /** + * 状态码 + */ + int status; + + /** + * 提示信息 + */ + String msg; + + /** + * 数据 + */ + T data; + + public int getStatus() { + return status; + } + + public void setStatus(int status) { + this.status = status; + } + + public String getMsg() { + return msg; + } + + public void setMsg(String msg) { + this.msg = msg; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } + + @Override + public String toString() { + return "EncapsulationObejct{" + + "status=" + status + + ", msg='" + msg + '\'' + + ", data=" + data + + '}'; + } +} diff --git a/src/main/java/com/xkrs/common/encapsulation/OutputEncapsulation.java b/src/main/java/com/xkrs/common/encapsulation/OutputEncapsulation.java new file mode 100644 index 0000000..9bee083 --- /dev/null +++ b/src/main/java/com/xkrs/common/encapsulation/OutputEncapsulation.java @@ -0,0 +1,96 @@ +package com.xkrs.common.encapsulation; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.MessageSource; +import org.springframework.context.support.ResourceBundleMessageSource; +import org.springframework.stereotype.Component; +import org.springframework.validation.FieldError; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Properties; + +/** + * 输出信息封装 + * @author tajochen + */ +@Component +public class OutputEncapsulation { + + private static final Logger logger = LoggerFactory.getLogger(OutputEncapsulation.class); + + /** + * 读取多国语言文件 + * @return + */ + public static MessageSource messageSource() { + Properties properties = new Properties(); + // 使用ClassLoader加载properties配置文件生成对应的输入流 + InputStream in = Thread.currentThread().getContextClassLoader().getResourceAsStream("application.properties"); + // 使用properties对象加载输入流 + try { + properties.load(in); + } catch (IOException e) { + e.printStackTrace(); + } + ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource(); + messageSource.setBasename("i18n/messages"); + messageSource.setDefaultEncoding("UTF-8"); + return messageSource; + } + + /** + * 封装输出数据 + * @param promptMessageEnum + * @param obj + * @return + */ + public static String outputEncapsulationObject(PromptMessageEnum promptMessageEnum, Object obj, Locale locale) { + + EncapsulationObejct encapsulationObejct = new EncapsulationObejct(); + encapsulationObejct.setStatus(promptMessageEnum.getCode()); + encapsulationObejct.setMsg(messageSource().getMessage(promptMessageEnum.getText(),null,locale)); + encapsulationObejct.setData(obj); + + ObjectMapper objectMapper = new ObjectMapper(); + // 忽略无法转换的对象 + objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS,false); + // 忽略json字符串中不识别的属性 + objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + // 解决jackson无法反序列化LocalDateTime的问题,引入jsr310标准 + JavaTimeModule javaTimeModule = new JavaTimeModule(); + objectMapper.registerModule(javaTimeModule); + objectMapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + String strByEo = ""; + try { + strByEo = objectMapper.writeValueAsString(encapsulationObejct); + } catch (JsonProcessingException e) { + e.printStackTrace(); + logger.warn(e.toString()); + } + return strByEo; + } + + /** + * 输出请求值检验错误信息 + * @param fieldErrors + * @return + */ + public static String outputEncapsulationErrorList(List fieldErrors, Locale locale){ + List errorMsg = new ArrayList<>(); + for (FieldError fieldError : fieldErrors) { + String errMessage = fieldError.getDefaultMessage().subSequence(1,fieldError.getDefaultMessage().length()-1).toString(); + errorMsg.add(messageSource().getMessage(errMessage,null,locale)); + } + return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,errorMsg,locale); + } +} diff --git a/src/main/java/com/xkrs/common/encapsulation/PromptMessageEnum.java b/src/main/java/com/xkrs/common/encapsulation/PromptMessageEnum.java new file mode 100644 index 0000000..68e7103 --- /dev/null +++ b/src/main/java/com/xkrs/common/encapsulation/PromptMessageEnum.java @@ -0,0 +1,62 @@ +package com.xkrs.common.encapsulation; + +/** + * 提示信息枚举 + * @author tajochen + */ +public enum PromptMessageEnum{ + + // 执行成功 + SUCCESS(0, "sys.message.success"), + + // 用户权限错误或非法操作: 1001-1999 + USER_NOT_LOGGED(1001, "sys.message.user.not_logged_in"), + USER_LOGIN_ERROR(1002, "sys.message.user.login_error"), + USER_ACCOUNT_FORBIDDEN(1003, "sys.message.user.account_forbidden"), + USER_ACCOUNT_NOT_ACTIVATED(1004, "sys.message.user.account_not_activated"), + USER_HAS_OVERTIME(1005, "sys.message.user.overtime"), + USER_NO_PERMISSION(1006,"sys.message.user.no_permission"), + USER_ALREADY_LOGGED(1007, "sys.message.user.already_logged"), + + // 请求参数错误或非法:2001-2999 + PARAM_NULL(2001, "sys.message.param.null"), + PARAM_ILLEGAL(2002, "sys.message.param.illegal"), + + // 数据返回错误:3001-3999 + DATA_NONE(3001, "sys.message.data.none"), + DATA_WRONG(3002, "sys.message.data.wrong"), + + // 操作失败:4001-4999 + PROCESS_FAIL(4001,"sys.message.process.fail"), + PROCESS_OVERTIME(4002,"sys.message.process.overtime"), + FILE_EXISTS(4003,"sys.message.file.exists"), + FILE_WRITE_ERROR(4004,"sys.message.file.write.error"), + FILE_READ_ERROR(4005,"sys.message.file.read.error"), + + // 系统内部错误或异常:5001-5999 + SYSTEM_INNER_ERROR(5001,"sys.message.system.inner_error"), + SYSTEM_ABNORMAL(5002,"sys.message.system.abnormal"), + SYSTEM_BUSY(5003,"sys.message.system.busy"), + SYSTEM_MAINTAIN(5004,"sys.message.system.maintain"), + + // 数据库错误:6001-6999 + DATABASE_ERROR(6001,"sys.message.database.error"); + + private int code; + + private String text; + + private PromptMessageEnum(int code,String text) { + this.code = code; + this.text = text; + } + + public String getText() { + return this.text; + } + + public int getCode() { + return this.code; + } + +} diff --git a/src/main/java/com/xkrs/common/tool/CompareVersion.java b/src/main/java/com/xkrs/common/tool/CompareVersion.java new file mode 100644 index 0000000..7d2d6e7 --- /dev/null +++ b/src/main/java/com/xkrs/common/tool/CompareVersion.java @@ -0,0 +1,33 @@ +package com.xkrs.common.tool; + +/** + * CompareVersion 比较版本号 + * @author tajochen + */ +public class CompareVersion { + + /** + * 比较三位版本号 ,若 版本1>版本2 返回 1,若版本1<版本2 返回 -1,否则返回0 + * @param version1 版本1 + * @param version2 版本2 + * @return + */ + public static int compareVersion(String version1, String version2) { + String[] v1 = version1.split("\\."); + String[] v2 = version2.split("\\."); + int n = Math.max(v1.length, v2.length); + for (int i = 0; i < n; i++) { + int v1Int = i < v1.length ? Integer.parseInt(v1[i]) : 0; + int v2Int = i < v2.length ? Integer.parseInt(v2[i]) : 0; + if (v1Int == v2Int) { + continue; + } + if (v1Int > v2Int){ + return 1; + } else { + return -1; + } + } + return 0; + } +} diff --git a/src/main/java/com/xkrs/common/tool/EntityUtil.java b/src/main/java/com/xkrs/common/tool/EntityUtil.java new file mode 100644 index 0000000..70c54b6 --- /dev/null +++ b/src/main/java/com/xkrs/common/tool/EntityUtil.java @@ -0,0 +1,98 @@ +package com.xkrs.common.tool; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * dao接口类处理工具 + * @author tajochen + */ +public class EntityUtil { + private static final Logger logger = LoggerFactory.getLogger(EntityUtil.class); + + /** + * 将数组数据转换为实体类 + * 此处数组元素的顺序必须与实体类构造函数中的属性顺序一致 + * @param list 数组对象集合 + * @param clazz 实体类 + * @param 实体类 + * @param model 实例化的实体类 + * @return 实体类集合 + */ + public static List castEntity(List list, Class clazz, Object model) { + List returnList = new ArrayList(); + if (list.isEmpty()) { + return returnList; + } + //获取每个数组集合的元素个数 + Object[] co = list.get(0); + + //获取当前实体类的属性名、属性值、属性类别 + List attributeInfoList = getFiledsInfo(model); + //创建属性类别数组 + Class[] c2 = new Class[attributeInfoList.size()]; + //如果数组集合元素个数与实体类属性个数不一致则发生错误 + if (attributeInfoList.size() != co.length) { + return returnList; + } + //确定构造方法 + for (int i = 0; i < attributeInfoList.size(); i++) { + c2[i] = (Class) attributeInfoList.get(i).get("type"); + } + try { + for (Object[] o : list) { + Constructor constructor = clazz.getConstructor(c2); + returnList.add(constructor.newInstance(o)); + } + } catch (Exception ex) { + logger.error("实体数据转化为实体类发生异常:异常信息:{}", ex.getMessage()); + return returnList; + } + return returnList; + } + + /** + * 根据属性名获取属性值 + * @param fieldName 属性名 + * @param modle 实体类 + * @return 属性值 + */ + private static Object getFieldValueByName(String fieldName, Object modle) { + try { + String firstLetter = fieldName.substring(0, 1).toUpperCase(); + String getter = "get" + firstLetter + fieldName.substring(1); + Method method = modle.getClass().getMethod(getter, new Class[]{}); + Object value = method.invoke(modle, new Object[]{}); + return value; + } catch (Exception e) { + return null; + } + } + + /** + * 获取属性类型(type),属性名(name),属性值(value)的map组成的list + * @param model 实体类 + * @return list集合 + */ + private static List getFiledsInfo(Object model) { + Field[] fields = model.getClass().getDeclaredFields(); + List list = new ArrayList(fields.length); + Map infoMap = null; + for (int i = 0; i < fields.length; i++) { + infoMap = new HashMap(3); + infoMap.put("type", fields[i].getType()); + infoMap.put("name", fields[i].getName()); + infoMap.put("value", getFieldValueByName(fields[i].getName(), model)); + list.add(infoMap); + } + return list; + } +} diff --git a/src/main/java/com/xkrs/common/tool/TokenUtil.java b/src/main/java/com/xkrs/common/tool/TokenUtil.java new file mode 100644 index 0000000..0c4a642 --- /dev/null +++ b/src/main/java/com/xkrs/common/tool/TokenUtil.java @@ -0,0 +1,51 @@ +package com.xkrs.common.tool; + +import io.jsonwebtoken.Claims; +import io.jsonwebtoken.Jwts; +import io.jsonwebtoken.security.Keys; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.AuthorityUtils; + +import javax.crypto.SecretKey; +import java.util.List; + +/** + * token工具 + * @author tajochen + */ +public class TokenUtil { + /** + * Token前缀 + */ + static public final String TOKEN_PREFIX = "Bearer"; + + static public final String SECRETKEY = "0Y9H364Q9Y908262F25LMXGIKIN5N858XM3674GWL2DD8X1DS4W6I722IRY8PS4XPNB6U30345" + + "HBVCUL94STG8C3Z53T7A09JJ100I56YE9894CI11PX9J71HIZ8L5Y2O504C4E2K8276425UA8734833F45K36878FXAG799QV9LXUJ" + + "OI3XA2046UPG8TB2OT84R5T6ZB127N9ZPJ7AJMC41JVHB2WK2B6H8NL45LZNAZ666KHZH3QUT65UX6F8"; + + static SecretKey key = Keys.hmacShaKeyFor(SECRETKEY.getBytes()); + + public static String getTokenUserName(String token) { + String userName = ""; + if (token != null) { + try { + // 解析 Token + Claims claims = Jwts.parserBuilder() + .setSigningKey(key).build() + // 去掉 Bearer + .parseClaimsJws(token.replace(TOKEN_PREFIX, "")) + .getBody(); + // 获取用户名 + userName = claims.getSubject(); + // 获取权限 + List authorities = AuthorityUtils.commaSeparatedStringToAuthorityList((String) claims.get("auths")); + } catch(Exception e) { + // the sub field was missing or did not have a 'jsmith' value + return null; + } + } else { + return null; + } + return userName; + } +} diff --git a/src/main/java/com/xkrs/controller/FileDocumentController.java b/src/main/java/com/xkrs/controller/FileDocumentController.java new file mode 100644 index 0000000..a8de379 --- /dev/null +++ b/src/main/java/com/xkrs/controller/FileDocumentController.java @@ -0,0 +1,86 @@ +package com.xkrs.controller; + +import com.xkrs.common.encapsulation.PromptMessageEnum; +import com.xkrs.model.entity.FileDocumentEntity; +import com.xkrs.model.qo.FileDocumentQo; +import com.xkrs.model.validation.FileDocumentQoInsert; +import com.xkrs.model.vo.FileServerResultVo; +import com.xkrs.service.FileDocumentService; +import com.xkrs.service.FileServerService; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.BindingResult; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.Locale; +import java.util.Optional; + +import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; +import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; +import static com.xkrs.common.tool.TokenUtil.getTokenUserName; +import static com.xkrs.utils.NumberUtil.isStrNumeric; + +/** + * 文档管理服务 + * @author tajochen + */ +@RestController +@RequestMapping("/api/document") +public class FileDocumentController { + + @Resource + private FileDocumentService fileDocumentService; + + @Resource + private FileServerService fileServerService; + + @RequestMapping(value="/get/all",method = RequestMethod.GET) + public String getAllFiles() { + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + Iterable list = fileDocumentService.getAllFile(); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,list,locale); + } + + @RequestMapping(value="/add",method = RequestMethod.POST) + @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user','auth_administor')") + @CrossOrigin + public String fileUpload(@Validated({FileDocumentQoInsert.class}) @RequestBody FileDocumentQo fileDocumentQo, + BindingResult bindingResult, @RequestHeader(value="Authorization") String token) { + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + // 验证数据合法性 + if(bindingResult.hasErrors()){ + return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); + } + // 获取当前用户名 + String userName = getTokenUserName(token); + fileDocumentService.add(fileDocumentQo,userName); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); + } + + @RequestMapping(value="/delete",method = RequestMethod.DELETE) + @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") + @CrossOrigin + public String fileDelete(@RequestParam("id") String id) { + //获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + if(!isStrNumeric(id)){ + return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"参数错误",locale); + } + Optional sf = fileDocumentService.getById(Integer.parseInt(id)); + if(!sf.isPresent()){ + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"指定id文件不存在",locale); + } + try { + FileServerResultVo fileServerResultVo = fileServerService.deleteFile(sf.get().getMd5(),""); + fileDocumentService.delete(Integer.parseInt(id)); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,fileServerResultVo,locale); + } catch (Exception e) { + e.printStackTrace(); + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"文件服务器出错",locale); + } + } +} diff --git a/src/main/java/com/xkrs/controller/FileServerController.java b/src/main/java/com/xkrs/controller/FileServerController.java new file mode 100644 index 0000000..9e5664b --- /dev/null +++ b/src/main/java/com/xkrs/controller/FileServerController.java @@ -0,0 +1,114 @@ +package com.xkrs.controller; + +import com.xkrs.model.vo.FileServerResultVo; +import com.xkrs.service.FileServerService; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; + +/** + * 文件服务器管理服务 + * @author tajochen + */ +@RestController +@RequestMapping("/api/file") +public class FileServerController { + + @Resource + private FileServerService fileServerService; + + /** + * 文件统计 + * @return + */ + @RequestMapping(value="/stat",method = RequestMethod.GET) + @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") + @CrossOrigin + public FileServerResultVo getFileStat() { + + return fileServerService.getFileStat(); + } + + /** + * 文件删除 + * @param md5 信息摘要 + * @param path 路径 + * @return + */ + @RequestMapping(value="/delete",method = RequestMethod.DELETE) + @PreAuthorize("hasAnyAuthority('auth_system_manager','role_administor')") + @CrossOrigin + public FileServerResultVo deleteFile(@RequestParam(value = "md5",required = false) String md5, + @RequestParam(value = "path",required = false) String path) { + FileServerResultVo fileServerResultVo = new FileServerResultVo(); + Boolean existed = (md5==null||md5.isEmpty())&&(path==null||path.isEmpty()); + if(existed){ + fileServerResultVo.setStatus("fail"); + fileServerResultVo.setData(""); + fileServerResultVo.setMessage("参数为空"); + return fileServerResultVo; + } + return fileServerService.deleteFile(md5,path); + } + + /** + * 获取文件信息 + * @param md5 信息摘要 + * @param path 路径 + * @return + */ + @RequestMapping(value="/get/info",method = RequestMethod.DELETE) + @PreAuthorize("hasAnyAuthority('auth_system_manager','role_administor')") + @CrossOrigin + public FileServerResultVo getFileInfo(@RequestParam(value = "md5",required = false) String md5, + @RequestParam(value = "path",required = false) String path) { + + FileServerResultVo fileServerResultVo = new FileServerResultVo(); + Boolean existed = (md5==null||md5.isEmpty())&&(path==null||path.isEmpty()); + if(existed){ + fileServerResultVo.setStatus("fail"); + fileServerResultVo.setData(""); + fileServerResultVo.setMessage("参数为空"); + return fileServerResultVo; + } + return fileServerService.getFileInfo(md5,path); + } + + /** + * 获取文件列表 + * @param dir 文件夹 + * @return + */ + @RequestMapping(value="/get/list",method = RequestMethod.DELETE) + @PreAuthorize("hasAnyAuthority('auth_system_manager','role_administor')") + @CrossOrigin + public FileServerResultVo getFileList(@RequestParam(value = "dir") String dir) { + return fileServerService.getFileList(dir); + } + + /** + * 修复统计信息 + * @param date 要修复的日期,格式如:20190725 + * @return + */ + @RequestMapping(value="/get/repair_stat",method = RequestMethod.DELETE) + @PreAuthorize("hasAnyAuthority('auth_system_manager','role_administor')") + @CrossOrigin + public FileServerResultVo getFileRepairStat(@RequestParam(value = "date") String date) { + return fileServerService.getFileRepairStat(date); + } + + /** + * 同步失败修复 + * @param force 是否强行修复(0|1) + * @return + */ + @RequestMapping(value="/get/repair",method = RequestMethod.DELETE) + @PreAuthorize("hasAnyAuthority('auth_system_manager','role_administor')") + @CrossOrigin + public FileServerResultVo getFileRepair(@RequestParam(value = "force") String force) { + return fileServerService.getFileRepair(force); + } + +} diff --git a/src/main/java/com/xkrs/controller/MerchantSettlementController.java b/src/main/java/com/xkrs/controller/MerchantSettlementController.java new file mode 100644 index 0000000..25133cc --- /dev/null +++ b/src/main/java/com/xkrs/controller/MerchantSettlementController.java @@ -0,0 +1,104 @@ +package com.xkrs.controller; + +import com.xkrs.common.config.RedisUtil; +import com.xkrs.common.encapsulation.PromptMessageEnum; +import com.xkrs.common.tool.TokenUtil; +import com.xkrs.dao.SysUserDao; +import com.xkrs.model.entity.SysUserEntity; +import com.xkrs.model.qo.BankCardQo; +import com.xkrs.model.qo.BusinessQo; +import com.xkrs.service.MerchantSettlementService; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.IOException; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; + +/** + * @Author: XinYi Song + * @Date: 2021/12/14 14:40 + */ +@RestController +public class MerchantSettlementController { + + @Resource + private MerchantSettlementService merchantSettlementService; + + @Resource + private SysUserDao sysUserDao; + + @Resource + private RedisUtil redisUtil; + + /** + * 商家入驻 + * @param + * @param businessPhoto + * @param businessLicense + * @param + * @param + * @return + */ + @PostMapping("/merchantSettlement") + public String merchantSettlement(@RequestBody Map map, @RequestParam("businessPhoto") MultipartFile businessPhoto, + @RequestParam("businessLicense") MultipartFile businessLicense) throws IOException { + Locale locale = LocaleContextHolder.getLocale(); + String businessName = (String) map.get("businessName"); + String businessPro = (String) map.get("businessPro"); + String businessCity = (String) map.get("businessCity"); + String businessCountry = (String) map.get("businessCountry"); + String businessAddress = (String) map.get("businessAddress"); + String businessPhone = (String) map.get("businessPhone"); + Double businessDiscount = (Double) map.get("businessDiscount"); + String headIdentifier = (String) map.get("headIdentifier"); + List bankCardQos = (List) map.get("bankCardQos"); + String verificationCode = (String) map.get("verificationCode"); + BusinessQo businessQo = new BusinessQo(); + businessQo.setBusinessName(businessName); + businessQo.setBusinessPro(businessPro); + businessQo.setBusinessCity(businessCity); + businessQo.setBusinessCountry(businessCountry); + businessQo.setBusinessAddress(businessAddress); + businessQo.setBusinessPhone(businessPhone); + businessQo.setBusinessDiscount(businessDiscount); + businessQo.setHeadIdentifier(headIdentifier); + String o = (String) redisUtil.get(businessPhone); + if("".equals(o) || o == null){ + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"请先发送验证码!",locale); + } + if(!redisUtil.get(businessPhone).equals(verificationCode)){ + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"验证码错误,请重新输入!",locale); + } + return merchantSettlementService.merchantSettlement(businessQo,businessPhoto,businessLicense,bankCardQos); + } + + /** + * 根据商家入驻状态查询待审核,审核通过,审核不通过商家的信息 + * @param type + * @return + */ + @GetMapping("/findAllByBusinessType") + @PreAuthorize("hasAnyAuthority('auth_administor')") + public String findAllByBusinessType(@RequestParam("type") String type){ + return merchantSettlementService.findAllByBusinessType(type); + } + + /** + * 商家查询自己的入驻信息 + * @param token + * @return + */ + @GetMapping("/findBusinessById") + public String findBusinessById(@RequestHeader(value="Authorization") String token){ + String tokenUserName = TokenUtil.getTokenUserName(token); + SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName); + return merchantSettlementService.findBusinessById(sysUserEntity.getId()); + } +} diff --git a/src/main/java/com/xkrs/controller/SysManageController.java b/src/main/java/com/xkrs/controller/SysManageController.java new file mode 100644 index 0000000..08c1164 --- /dev/null +++ b/src/main/java/com/xkrs/controller/SysManageController.java @@ -0,0 +1,57 @@ +package com.xkrs.controller; + +import com.xkrs.common.encapsulation.PromptMessageEnum; +import nl.basjes.parse.useragent.UserAgent; +import nl.basjes.parse.useragent.UserAgentAnalyzer; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.*; + +import java.util.Locale; + +import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; + +/** + * 系统管理测试服务 + * @author tajochen + */ +@RestController +@RequestMapping(value = "/api") +public class SysManageController { + + @RequestMapping(value="/hello/role",method = RequestMethod.GET) + @PreAuthorize("hasAnyRole('role_administor','role_system_manager')") + public String hello() { + //获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"hello vip",locale); + } + + @RequestMapping(value="/hello/auth",method = RequestMethod.GET) + @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user')") + public String world() { + //获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"world",locale); + } + + @RequestMapping(value="/greeting",method = RequestMethod.GET) + public String greeting(@RequestParam(required=false, defaultValue="World") String name, + @RequestHeader(value="User-Agent") String userAgent) { + //获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + System.out.println("==== in greeting ===="); + System.out.println(userAgent); + UserAgentAnalyzer uaa = UserAgentAnalyzer + .newBuilder() + .hideMatcherLoadStats() + .withCache(10000) + .build(); + + UserAgent agent = uaa.parse(userAgent); + for (String fieldName: agent.getAvailableFieldNamesSorted()) { + System.out.println(fieldName + " = " + agent.getValue(fieldName)); + } + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,name,locale); + } +} diff --git a/src/main/java/com/xkrs/controller/SysUserController.java b/src/main/java/com/xkrs/controller/SysUserController.java new file mode 100644 index 0000000..67222b5 --- /dev/null +++ b/src/main/java/com/xkrs/controller/SysUserController.java @@ -0,0 +1,299 @@ +package com.xkrs.controller; + +import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; +import com.aliyuncs.exceptions.ClientException; +import com.xkrs.common.config.RedisUtil; +import com.xkrs.common.encapsulation.PromptMessageEnum; +import com.xkrs.common.tool.TokenUtil; +import com.xkrs.dao.SysUserDao; +import com.xkrs.model.entity.SysUserEntity; +import com.xkrs.model.qo.SysUserQo; +import com.xkrs.model.qo.UserUpdate; +import com.xkrs.model.validation.SysUserQoInsert; +import com.xkrs.model.validation.SysUserQoUpdate; +import com.xkrs.model.vo.SysUserVo; +import com.xkrs.service.SysUserService; +import com.xkrs.utils.RandomUtil; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.BindingResult; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.IOException; +import java.util.HashMap; +import java.util.Locale; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationErrorList; +import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; +import static com.xkrs.utils.AliYunSmsUtils.sendSms; + +/** + * 系统用户Controller + * @author tajocehn + */ +@RestController +@RequestMapping(value = "/api/user") +public class SysUserController { + + @Resource + private SysUserService sysUserService; + + @Resource + private SysUserDao sysUserDao; + + @Resource + private RedisUtil redisUtil; + + /** + * 登录用户Token验证 + * @return + */ + @RequestMapping(value = "/logged/check",method = RequestMethod.POST) + public String loginUserTokenCheck(){ + Locale locale = LocaleContextHolder.getLocale(); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); + } + + @RequestMapping(value = "/check/duplicate", method = RequestMethod.POST) + public String checkDuplicate(@RequestParam(value="userName", required=false) String userName){ + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + // 验证用户名是否重复 + if(!sysUserService.checkUserName(userName)){ + return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"",locale); + } + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"OK",locale); + } + + + @RequestMapping(value = "/add", method = RequestMethod.POST) + public String addUser(@Validated({SysUserQoInsert.class}) @RequestBody SysUserQo userQo, + BindingResult bindingResult){ + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + // 验证数据合法性 + if(bindingResult.hasErrors()){ + return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); + } + // 验证用户名是否重复 + if(!sysUserService.checkUserName(userQo.getUserName())){ + return outputEncapsulationObject(PromptMessageEnum.PARAM_ILLEGAL,"该账号已注册,请勿重复注册!",locale); + } + // 添加新用户 + sysUserService.addUser(userQo); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"OK",locale); + } + + + /*@RequestMapping(value="/get/all", method = RequestMethod.GET) + @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") + public String getAllSysUser(){ + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + Iterable sysUserDtoList = sysUserService.getAllSysUser(); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,sysUserDtoList,locale); + }*/ + + /** + * 软删除指定id的普通用户 + * @param id + * @return + */ + @RequestMapping(value = "/general/delete", method = RequestMethod.DELETE) + @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_general_user')") + public String deleteCustomUser(@RequestParam(value="userId", required=false) int id){ + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + // 验证数据合法性 + int res = sysUserService.softDeleteGeneralUser(id); + if(res==1){ + return outputEncapsulationObject(PromptMessageEnum.PROCESS_FAIL,"",locale); + } else { + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); + } + } + + @RequestMapping(value = "/update", method = RequestMethod.POST) + @PreAuthorize("hasAnyAuthority('auth_system_manager','auth_administor')") + public String updateUser(@Validated({SysUserQoUpdate.class}) @RequestBody SysUserQo userQo, + BindingResult bindingResult){ + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + // 验证数据合法性 + if(bindingResult.hasErrors()){ + return outputEncapsulationErrorList(bindingResult.getFieldErrors(),locale); + } + // 修改用户 + sysUserService.updateSysUser(userQo); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"OK",locale); + } + + /** + * 绑定手机号 + * @param map + * @param token + * @return + */ + @PostMapping("/bindPhone") + public String bindPhone(@RequestBody Map map,@RequestHeader(value="Authorization") String token){ + Locale locale = LocaleContextHolder.getLocale(); + String phone = (String) map.get("phone"); + String verificationCode = (String) map.get("verificationCode"); + // 验证token + String tokenUserName = TokenUtil.getTokenUserName(token); + SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName); + if(sysUserEntity == null){ + return outputEncapsulationObject(PromptMessageEnum.USER_LOGIN_ERROR,"您还没有注册登录,请先注册登录",locale); + } + String o = (String) redisUtil.get(phone); + if("".equals(o) || o == null){ + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"请先发送验证码!",locale); + } + if(!redisUtil.get(phone).equals(verificationCode)){ + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"验证码错误,请重新输入!",locale); + } + return sysUserService.bindPhone(sysUserEntity.getId(),phone); + } + + /** + * 发送手机号 + * @param phone + * @return + * @throws ClientException + */ + @GetMapping("/verificationCode") + public String verificationCode(@RequestParam("phone") String phone) throws ClientException { + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + String optCode = String.valueOf(RandomUtil.returnCode()); + redisUtil.set(phone,optCode,60*10); + SendSmsResponse response =sendSms(phone,optCode); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); } + + /** + * 手机号登录 + * @param map + * @return + */ + @PostMapping("/loginByPhone") + public String loginByPhone(@RequestBody Map map){ + String phone = (String) map.get("phone"); + String verificationCode = (String) map.get("verificationCode"); + return sysUserService.loginByPhone(phone,verificationCode); + } + + /** + * 填写手机号发送验证码,用于用户忘记密码 + * @param phone + * @return + * @throws ClientException + */ + @GetMapping("/verificationCodeUpdate") + public String verificationCodeUpdate(@RequestParam("phone") String phone) throws ClientException { + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + SysUserVo sysUserVo = sysUserDao.selectUserByUserName(phone); + if(sysUserVo == null){ + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"手机号错误,请使用您注册的手机号",locale); + } + String optCode = String.valueOf(RandomUtil.returnCode()); + redisUtil.set(phone,optCode,60*10); + SendSmsResponse response =sendSms(phone,optCode); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"",locale); + } + + /** + * 输入验证码进行判断 + * @param phone + * @param verificationCode + * @return + */ + @GetMapping("/getVerificationCode") + public String getVerificationCode(@RequestParam("phone") String phone, @RequestParam("verificationCode") String verificationCode){ + Locale locale = LocaleContextHolder.getLocale(); + String o = (String) redisUtil.get(phone); + if("".equals(o) || o == null){ + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"请先发送验证码!",locale); + } + if(!redisUtil.get(phone).equals(verificationCode)){ + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"验证码错误,请重新输入!",locale); + } + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"true",locale); + } + + /** + * 用户完善信息 + * @param files + * @param userUpdate + * @param token + * @return + */ + @PostMapping("/updateUserByUserId") + public String updateUserByUserId(@RequestParam("file") MultipartFile files, UserUpdate userUpdate, @RequestHeader(value="Authorization") String token) throws IOException { + Locale locale = LocaleContextHolder.getLocale(); + if(userUpdate.getNickName() != null){ + SysUserEntity byNickName = sysUserDao.findByNickName(userUpdate.getNickName()); + if(byNickName != null){ + return outputEncapsulationObject(PromptMessageEnum.FILE_EXISTS,"该昵称已存在!",locale); + } + } + String tokenUserName = TokenUtil.getTokenUserName(token); + SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName); + return sysUserService.updateUserByUserId(files,userUpdate,sysUserEntity.getId()); + } + + /** + * 管理员进行启用禁用的操作 + * @param map + * @param token + * @return + */ + @PostMapping("/operateActiveFlag") + @PreAuthorize("hasAnyAuthority('auth_administor')") + public String operateActiveFlag(@RequestBody Map map,@RequestHeader(value="Authorization") String token){ + Integer userId = (Integer) map.get("userId"); + String keepType = (String) map.get("keepType"); + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + // 验证token + String tokenUserName = TokenUtil.getTokenUserName(token); + SysUserEntity sysUserEntity = sysUserDao.selectByUserName(tokenUserName); + if(sysUserEntity == null){ + return outputEncapsulationObject(PromptMessageEnum.USER_LOGIN_ERROR,"您还没有注册登录,请先注册登录",locale); + } + // 如果keepType等于1进行启用操作 + if("1".equals(keepType)){ + sysUserService.updateEnable(userId); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"启用成功",locale); + }else { + sysUserService.updateDisable(userId); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"禁用成功",locale); + } + } + + /** + * 判断用户名是否存在 + * @param userName + * @return + */ + @GetMapping("/booleanUserName") + public String booleanUserName(@RequestParam("userName") String userName){ + // 获取区域信息 + Locale locale = LocaleContextHolder.getLocale(); + Map map = new HashMap(3); + SysUserEntity sysUserEntity = sysUserDao.selectByUserName(userName); + if(sysUserEntity == null){ + map.put("status",0); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,map,locale); + }else { + map.put("status",1); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,map,locale); + } + } + +} diff --git a/src/main/java/com/xkrs/dao/BankCardDao.java b/src/main/java/com/xkrs/dao/BankCardDao.java new file mode 100644 index 0000000..6812611 --- /dev/null +++ b/src/main/java/com/xkrs/dao/BankCardDao.java @@ -0,0 +1,11 @@ +package com.xkrs.dao; + +import com.xkrs.model.entity.BankCardEntity; +import org.springframework.data.jpa.repository.JpaRepository; + +/** + * @Author: XinYi Song + * @Date: 2021/12/14 9:38 + */ +public interface BankCardDao extends JpaRepository { +} diff --git a/src/main/java/com/xkrs/dao/BusinessDao.java b/src/main/java/com/xkrs/dao/BusinessDao.java new file mode 100644 index 0000000..8c9edee --- /dev/null +++ b/src/main/java/com/xkrs/dao/BusinessDao.java @@ -0,0 +1,65 @@ +package com.xkrs.dao; + +import com.xkrs.model.entity.BusinessEntity; +import org.springframework.data.jpa.repository.JpaRepository; + +import java.util.List; + +/** + * @Author: XinYi Song + * @Date: 2021/12/14 9:37 + */ +public interface BusinessDao extends JpaRepository { + + /** + * 根据商家名称查询商家信息 + * @param name + * @return + */ + BusinessEntity findByBusinessName(String name); + + /** + * 根据手机号查询商家入驻信息 + * @param phone + * @return + */ + BusinessEntity findByBusinessPhone(String phone); + + /** + * 根据商家入驻状态查询待审核,审核通过,审核不通过商家的信息 + * @param type + * @return + */ + List findAllByBusinessType(String type); + + /** + * 根据省查询审核通过的商家的信息 + * @param businessPro + * @param type + * @return + */ + List findAllByBusinessProAndAndBusinessType(String businessPro, String type); + + /** + * 根据市查询审核通过的商家的信息 + * @param businessCity + * @param type + * @return + */ + List findAllByBusinessCityAndAndBusinessType(String businessCity, String type); + + /** + * 根据区县查询审核通过的商家的信息 + * @param businessCounty + * @param type + * @return + */ + List findAllByBusinessCountryAndAndBusinessType(String businessCounty, String type); + + /**| + * 根据商家用户id查询自己的入驻信息 + * @param id + * @return + */ + BusinessEntity findByBusinessId(Integer id); +} diff --git a/src/main/java/com/xkrs/dao/FileDocumentDao.java b/src/main/java/com/xkrs/dao/FileDocumentDao.java new file mode 100644 index 0000000..dd8f611 --- /dev/null +++ b/src/main/java/com/xkrs/dao/FileDocumentDao.java @@ -0,0 +1,12 @@ +package com.xkrs.dao; + +import com.xkrs.model.entity.FileDocumentEntity; +import org.springframework.data.jpa.repository.JpaRepository; + +/** + * FileDocumentDao + * @author tajochen + */ +public interface FileDocumentDao extends JpaRepository { + +} diff --git a/src/main/java/com/xkrs/dao/ProductCoverDao.java b/src/main/java/com/xkrs/dao/ProductCoverDao.java new file mode 100644 index 0000000..28ac9d0 --- /dev/null +++ b/src/main/java/com/xkrs/dao/ProductCoverDao.java @@ -0,0 +1,11 @@ +package com.xkrs.dao; + +import com.xkrs.model.entity.ProductCoverEntity; +import org.springframework.data.jpa.repository.JpaRepository; + +/** + * @Author: XinYi Song + * @Date: 2021/12/15 11:42 + */ +public interface ProductCoverDao extends JpaRepository { +} diff --git a/src/main/java/com/xkrs/dao/RelRoleAuthorityDao.java b/src/main/java/com/xkrs/dao/RelRoleAuthorityDao.java new file mode 100644 index 0000000..c34eea7 --- /dev/null +++ b/src/main/java/com/xkrs/dao/RelRoleAuthorityDao.java @@ -0,0 +1,10 @@ +package com.xkrs.dao; + +import com.xkrs.model.entity.RelRoleAuthorityEntity; +import org.springframework.data.jpa.repository.JpaRepository; + +/** + * @author XinYi Song + */ +public interface RelRoleAuthorityDao extends JpaRepository { +} diff --git a/src/main/java/com/xkrs/dao/RelUserRoleDao.java b/src/main/java/com/xkrs/dao/RelUserRoleDao.java new file mode 100644 index 0000000..ebd8e96 --- /dev/null +++ b/src/main/java/com/xkrs/dao/RelUserRoleDao.java @@ -0,0 +1,10 @@ +package com.xkrs.dao; + +import com.xkrs.model.entity.RelUserRoleEntity; +import org.springframework.data.jpa.repository.JpaRepository; + +/** + * @author XinYi Song + */ +public interface RelUserRoleDao extends JpaRepository { +} diff --git a/src/main/java/com/xkrs/dao/SysAuthorityDao.java b/src/main/java/com/xkrs/dao/SysAuthorityDao.java new file mode 100644 index 0000000..3afffb6 --- /dev/null +++ b/src/main/java/com/xkrs/dao/SysAuthorityDao.java @@ -0,0 +1,25 @@ +package com.xkrs.dao; + +import com.xkrs.model.entity.SysAuthorityEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +/** + * SysAuthorityDao + * @author tajochen + */ +public interface SysAuthorityDao extends JpaRepository { + /** + * 查询权限实体列表根据用户名 Object[] + * @param userName 用户名 + * @return 用户实体 + */ + @Query(value = "SELECT a.id, a.authority_name, a.authority_name_zh, a.authority_desc " + + "FROM sys_authority a,rel_role_authority ra,sys_role r WHERE r.id = ra.role_id AND ra.authority_id = a.id AND r.id " + + "IN (SELECT r.id FROM sys_user u,sys_role r,rel_user_role ur " + + " WHERE u.user_name = :userName AND u.id = ur.user_id AND ur.role_id = r.id)", nativeQuery = true) + List selectByUserName(@Param("userName") String userName); +} diff --git a/src/main/java/com/xkrs/dao/SysRoleDao.java b/src/main/java/com/xkrs/dao/SysRoleDao.java new file mode 100644 index 0000000..04e704d --- /dev/null +++ b/src/main/java/com/xkrs/dao/SysRoleDao.java @@ -0,0 +1,60 @@ +package com.xkrs.dao; + +import com.xkrs.model.entity.SysRoleEntity; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +import java.util.List; + +/** + * SysRoleDao + * @author tajochen + */ +public interface SysRoleDao extends JpaRepository { + + /** + * 查询用户角色列表根据用户id + * @param id + * @return + */ + @Query(value = "SELECT sys_role.id,sys_role.role_name,sys_role.role_name_zh,sys_role.role_desc " + + "FROM sys_role,rel_user_role " + + "WHERE sys_role.id = rel_user_role.role_id " + + "AND rel_user_role.user_id = :id ", nativeQuery = true) + List selectByUserId(@Param("id") Integer id); + + /** + * 查询用户角色列表根据用户名 + * @param userName + * @return + */ + @Query(value = "SELECT sys_role.id,sys_role.role_name,sys_role.role_name_zh,sys_role.role_desc " + + "FROM sys_role.ID = rel_user_role.role_id " + + "WHERE rel_user_role.user_id = sys_user.id " + + "AND rel_user_role.user_id = sys_user.id " + + "AND sys_user.user_name = :userName ", nativeQuery = true) + List selectByUserName(@Param("userName") String userName); + + +// /** +// * 根据用户名修改用户角色 +// */ +// @Modifying +// @Query(value = "UPDATE sys_user SET last_entry_time = now(), last_entry_ip = :ipAddress " + +// "WHERE user_name = :userName ;", nativeQuery = true) +// int updateUserRoleByUserName(@Param("userName") String userName); + + /** + * 添加用户角色根据用户名和角色名 + * @param userName + * @param roleName + * @return + */ + @Modifying + @Query(value = "INSERT INTO rel_user_role (id,role_id, user_id) " + + "SELECT nextval('rel_user_role_seq'),sys_role.ID,sys_user.ID FROM sys_role,sys_user " + + "WHERE sys_role.role_name = :roleName AND sys_user.user_name = :userName ", nativeQuery = true) + int insertRelUserRole(@Param("userName") String userName, @Param("roleName") String roleName); +} diff --git a/src/main/java/com/xkrs/dao/SysUserDao.java b/src/main/java/com/xkrs/dao/SysUserDao.java new file mode 100644 index 0000000..934792d --- /dev/null +++ b/src/main/java/com/xkrs/dao/SysUserDao.java @@ -0,0 +1,144 @@ +package com.xkrs.dao; + +import com.xkrs.model.entity.SysUserEntity; +import com.xkrs.model.vo.SysUserVo; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.data.jpa.repository.Modifying; +import org.springframework.data.jpa.repository.Query; +import org.springframework.data.repository.query.Param; + +/** + * SysUserDao + * @author tajochen + */ +public interface SysUserDao extends JpaRepository { + + /** + * 检查系统用户名是否存在 + * @param userName + * @return + */ + @Query(value = "SELECT COUNT(*) FROM sys_user WHERE user_name = :userName", nativeQuery = true) + int checkUserName(@Param("userName") String userName); + + /** + * 查找用户实体根据用户名 + * @param userName + * @return + */ + @Query(value = "SELECT * FROM sys_user WHERE user_name = :userName", nativeQuery = true) + SysUserEntity selectByUserName(@Param("userName") String userName); + + /** + * 根据用户名查询实体信息 + * @param userName + * @return + */ + @Query(value = "select new com.xkrs.model.vo.SysUserVo (id,userName,nickName,telephone,addTime,lastEntryTime,lastEntryIp,avatar,province,city,county,identifier,identity) " + + "from SysUserEntity where userName = :userName") + SysUserVo selectUserByUserName(String userName); + + /** + * 更新用户登录信息 + * @param userName + * @param ipAddress + * @return + */ + @Modifying + @Query(value = "UPDATE sys_user SET last_entry_time = now(), last_entry_ip = :ipAddress " + + "WHERE user_name = :userName ;", nativeQuery = true) + int updateSysUserLogin(@Param("userName") String userName, @Param("ipAddress") String ipAddress); + + /** + * 软删除系统用户根据用户名 + * @param userName + * @return + */ + @Modifying + @Query(value = "UPDATE sys_user SET delete_flag = 1 " + + "WHERE user_name = :userName ;", nativeQuery = true) + int softDeleteSysUserByUserName(@Param("userName") String userName); + + /** + * 软删除系统用户根据id + * @param id + * @return + */ + @Modifying + @Query(value = "UPDATE sys_user SET delete_flag = 1 " + + "WHERE id = :id ;", nativeQuery = true) + int softDeleteGeneralUserById(@Param("id") Integer id); + + /** + * 删除系统用户(危险操作!) + * @param userName + * @return + */ + @Modifying + @Query(value = "DELETE FROM sys_user WHERE user_name = :userName ;", nativeQuery = true) + int deleteSysUser(@Param("userName") String userName); + + /** + * 获取所有存在的系统用户Vo + * @return + */ + /*@Query(value = "select new com.xkrs.model.vo.SysUserVo (u.id, u.userName, u.nickName, u.userCode, " + + "u.telephone, u.signature," + + "u.statusCode,u.addTime,u.lastEntryTime) from SysUserEntity u ,SysRoleEntity r," + + "RelUserRoleEntity u_r " + + "WHERE u.deleteFlag = 0 AND u.activeFlag = 0 AND r.id = u_r.roleId AND u.id = u_r.userId") + List selectAllSysUser();*/ + + /** + * 通过userId修改手机号(绑定手机号) + * @param userId + * @param phone + */ + @Modifying(clearAutomatically=true) + @Query(value = "update sys_user set telephone = ?2 where id = ?1",nativeQuery = true) + void updatePhoneByUserId(Integer userId, String phone); + + /** + * 根据手机号查询用户信息 + * @param telephone + * @return + */ + SysUserEntity findByTelephone(String telephone); + + /** + * 用户完善信息 + * @param userId + * @param nickName + * @param avatar + * @param province + * @param city + * @param county + */ + @Modifying(clearAutomatically=true) + @Query(value = "update sys_user set nick_name = ?2,avatar = ?3,province = ?4,city = ?5,county = ?6 where id = ?1",nativeQuery = true) + void updateUserByUserId(Integer userId,String nickName,String avatar,String province,String city,String county); + + /** + * 通过用户昵称查询用户信息 + * @param nickName + * @return + */ + SysUserEntity findByNickName(String nickName); + + /** + * 启用 + * @param userId + */ + @Query(value = "update sys_user set active_flag = 0 where id = ?",nativeQuery = true) + @Modifying(clearAutomatically=true) + void updateEnable(Integer userId); + + /** + * 禁用 + * @param userId + */ + @Query(value = "update sys_user set active_flag = 1 where id = ?",nativeQuery = true) + @Modifying(clearAutomatically=true) + void updateDisable(Integer userId); + +} diff --git a/src/main/java/com/xkrs/model/entity/BankCardEntity.java b/src/main/java/com/xkrs/model/entity/BankCardEntity.java new file mode 100644 index 0000000..2d2d024 --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/BankCardEntity.java @@ -0,0 +1,120 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; + +/** + * @Author: XinYi Song + * @Date: 2021/12/13 17:43 + */ +@Entity +@Table(name="bank_card") +public class BankCardEntity { + + /** + * 指定主键,建立自增序列,主键值取自序列 + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "bank_card_seq_gen") + @SequenceGenerator(name = "bank_card_seq_gen", sequenceName = "bank_card_id_seq") + private Integer id; + + /** + * 银行卡号 + */ + @Column(length = 85, columnDefinition = "varchar(85)") + private String bankCardNumber; + + /** + * 开户行 + */ + private String accountBank; + + /** + * 银行名称 + */ + @Column(length = 65, columnDefinition = "varchar(65)") + private String bankName; + + /** + * 商家用户id + */ + private Integer businessId; + + /** + * 商家手机号 + */ + @Column(length = 85, columnDefinition = "varchar(85)") + private String businessPhone; + + public BankCardEntity() { + } + + public BankCardEntity(Integer id, String bankCardNumber, String accountBank, String bankName, Integer businessId, String businessPhone) { + this.id = id; + this.bankCardNumber = bankCardNumber; + this.accountBank = accountBank; + this.bankName = bankName; + this.businessId = businessId; + this.businessPhone = businessPhone; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getBankCardNumber() { + return bankCardNumber; + } + + public void setBankCardNumber(String bankCardNumber) { + this.bankCardNumber = bankCardNumber; + } + + public String getAccountBank() { + return accountBank; + } + + public void setAccountBank(String accountBank) { + this.accountBank = accountBank; + } + + public String getBankName() { + return bankName; + } + + public void setBankName(String bankName) { + this.bankName = bankName; + } + + public Integer getBusinessId() { + return businessId; + } + + public void setBusinessId(Integer businessId) { + this.businessId = businessId; + } + + public String getBusinessPhone() { + return businessPhone; + } + + public void setBusinessPhone(String businessPhone) { + this.businessPhone = businessPhone; + } + + @Override + public String toString() { + return "BankCardEntity{" + + "id=" + id + + ", bankCardNumber='" + bankCardNumber + '\'' + + ", accountBank='" + accountBank + '\'' + + ", bankName='" + bankName + '\'' + + ", businessId=" + businessId + + ", businessPhone='" + businessPhone + '\'' + + '}'; + } +} diff --git a/src/main/java/com/xkrs/model/entity/BusinessEntity.java b/src/main/java/com/xkrs/model/entity/BusinessEntity.java new file mode 100644 index 0000000..adcfc4d --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/BusinessEntity.java @@ -0,0 +1,244 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; + +/** + * @Author: XinYi Song + * @Date: 2021/12/13 16:54 + * 商家信息 + */ +@Entity +@Table(name="business") +public class BusinessEntity { + /** + * 指定主键,建立自增序列,主键值取自序列 + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "business_seq_gen") + @SequenceGenerator(name = "business_seq_gen", sequenceName = "business_id_seq") + private Integer id; + + /** + * 商户名称 + */ + @Column(length = 85, columnDefinition = "varchar(85)") + private String businessName; + + /** + * 省 + */ + @Column(length = 32, columnDefinition = "varchar(32)") + private String businessPro; + + /** + * 市 + */ + @Column(length = 32, columnDefinition = "varchar(32)") + private String businessCity; + + /** + * 区 + */ + private String businessCountry; + + /** + * 详细地址 + */ + private String businessAddress; + + /** + * 商家电话 + */ + @Column(length = 85, columnDefinition = "varchar(85)") + private String businessPhone; + + /** + * 商家图片 + */ + private String businessPhoto; + + /** + * 营业执照 + */ + private String businessLicense; + + /** + * 商家折扣 + */ + private Double businessDiscount; + + /** + * 商家状态(入驻默认0,审核通过1 审核不通过2) + */ + @Column(length = 32, columnDefinition = "varchar(32)") + private String businessType; + + /** + * 团长识别码 + */ + @Column(length = 32, columnDefinition = "varchar(32)") + private String headIdentifier; + + /** + * 商家用户id + */ + private Integer businessId; + + /** + * 商家入驻时间 + */ + @Column(length = 65, columnDefinition = "varchar(65)") + private String settleInTime; + + public BusinessEntity() { + } + + public BusinessEntity(Integer id, String businessName, String businessPro, String businessCity, String businessCountry, String businessAddress, String businessPhone, String businessPhoto, String businessLicense, Double businessDiscount, String businessType, String headIdentifier, Integer businessId, String settleInTime) { + this.id = id; + this.businessName = businessName; + this.businessPro = businessPro; + this.businessCity = businessCity; + this.businessCountry = businessCountry; + this.businessAddress = businessAddress; + this.businessPhone = businessPhone; + this.businessPhoto = businessPhoto; + this.businessLicense = businessLicense; + this.businessDiscount = businessDiscount; + this.businessType = businessType; + this.headIdentifier = headIdentifier; + this.businessId = businessId; + this.settleInTime = settleInTime; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getBusinessName() { + return businessName; + } + + public void setBusinessName(String businessName) { + this.businessName = businessName; + } + + public String getBusinessPro() { + return businessPro; + } + + public void setBusinessPro(String businessPro) { + this.businessPro = businessPro; + } + + public String getBusinessCity() { + return businessCity; + } + + public void setBusinessCity(String businessCity) { + this.businessCity = businessCity; + } + + public String getBusinessCountry() { + return businessCountry; + } + + public void setBusinessCountry(String businessCountry) { + this.businessCountry = businessCountry; + } + + public String getBusinessAddress() { + return businessAddress; + } + + public void setBusinessAddress(String businessAddress) { + this.businessAddress = businessAddress; + } + + public String getBusinessPhone() { + return businessPhone; + } + + public void setBusinessPhone(String businessPhone) { + this.businessPhone = businessPhone; + } + + public String getBusinessPhoto() { + return businessPhoto; + } + + public void setBusinessPhoto(String businessPhoto) { + this.businessPhoto = businessPhoto; + } + + public String getBusinessLicense() { + return businessLicense; + } + + public void setBusinessLicense(String businessLicense) { + this.businessLicense = businessLicense; + } + + public Double getBusinessDiscount() { + return businessDiscount; + } + + public void setBusinessDiscount(Double businessDiscount) { + this.businessDiscount = businessDiscount; + } + + public String getBusinessType() { + return businessType; + } + + public void setBusinessType(String businessType) { + this.businessType = businessType; + } + + public String getHeadIdentifier() { + return headIdentifier; + } + + public void setHeadIdentifier(String headIdentifier) { + this.headIdentifier = headIdentifier; + } + + public Integer getBusinessId() { + return businessId; + } + + public void setBusinessId(Integer businessId) { + this.businessId = businessId; + } + + public String getSettleInTime() { + return settleInTime; + } + + public void setSettleInTime(String settleInTime) { + this.settleInTime = settleInTime; + } + + @Override + public String toString() { + return "BusinessEntity{" + + "id=" + id + + ", businessName='" + businessName + '\'' + + ", businessPro='" + businessPro + '\'' + + ", businessCity='" + businessCity + '\'' + + ", businessCountry='" + businessCountry + '\'' + + ", businessAddress='" + businessAddress + '\'' + + ", businessPhone='" + businessPhone + '\'' + + ", businessPhoto='" + businessPhoto + '\'' + + ", businessLicense='" + businessLicense + '\'' + + ", businessDiscount=" + businessDiscount + + ", businessType='" + businessType + '\'' + + ", headIdentifier='" + headIdentifier + '\'' + + ", businessId=" + businessId + + ", settleInTime='" + settleInTime + '\'' + + '}'; + } +} diff --git a/src/main/java/com/xkrs/model/entity/FileDocumentEntity.java b/src/main/java/com/xkrs/model/entity/FileDocumentEntity.java new file mode 100644 index 0000000..264e389 --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/FileDocumentEntity.java @@ -0,0 +1,132 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * file_document 表实体类 + * @author tajochen + */ +@Entity +@Table(name="file_document") +public class FileDocumentEntity implements Serializable { + + /** + * 指定主键,建立自增序列,主键值取自序列 + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "file_document_seq_gen") + @SequenceGenerator(name = "file_document_seq_gen", sequenceName = "file_document_seq") + private Integer id; + + @Column(length = 64, nullable = false, columnDefinition = "varchar(64)") + private String name; + + @Column( columnDefinition = "int4") + private Integer category; + + @Column(length = 192 , columnDefinition = "varchar(192)") + private String filePath; + + @Column( length = 128, columnDefinition = "varchar(128)") + private String size; + + @Column( length = 192, columnDefinition = "varchar(192)") + private String md5; + + @Column( length = 128, columnDefinition = "varchar(128)") + private String memo; + + @Column( length = 16, columnDefinition = "varchar(16)") + private String addUserName; + + private LocalDateTime addTime; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getCategory() { + return category; + } + + public void setCategory(Integer category) { + this.category = category; + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public String getSize() { + return size; + } + + public void setSize(String size) { + this.size = size; + } + + public String getMd5() { + return md5; + } + + public void setMd5(String md5) { + this.md5 = md5; + } + + public String getMemo() { + return memo; + } + + public void setMemo(String memo) { + this.memo = memo; + } + + public String getAddUserName() { + return addUserName; + } + + public void setAddUserName(String addUserName) { + this.addUserName = addUserName; + } + + public LocalDateTime getAddTime() { + return addTime; + } + + public void setAddTime(LocalDateTime addTime) { + this.addTime = addTime; + } + + @Override + public String toString() { + return "FileDocumentEntity{" + + "id=" + id + + ", name='" + name + '\'' + + ", category=" + category + + ", filePath='" + filePath + '\'' + + ", size='" + size + '\'' + + ", md5='" + md5 + '\'' + + ", memo='" + memo + '\'' + + ", addUserName='" + addUserName + '\'' + + ", addTime=" + addTime + + '}'; + } +} diff --git a/src/main/java/com/xkrs/model/entity/ProductContentPhotoEntity.java b/src/main/java/com/xkrs/model/entity/ProductContentPhotoEntity.java new file mode 100644 index 0000000..5ed8557 --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/ProductContentPhotoEntity.java @@ -0,0 +1,71 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; + +/** + * @Author: XinYi Song + * @Date: 2021/12/15 11:27 + */ +@Entity +@Table(name="product_content_photo") +public class ProductContentPhotoEntity { + /** + * 指定主键,建立自增序列,主键值取自序列 + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "product_content_photo_seq_gen") + @SequenceGenerator(name = "product_content_photo_seq_gen", sequenceName = "product_content_photo_id_seq") + private Integer id; + + /** + * 商品内容图片 + */ + private String productContentPhoto; + + /** + * 商品id + */ + private Integer productId; + + public ProductContentPhotoEntity() { + } + + public ProductContentPhotoEntity(Integer id, String productContentPhoto, Integer productId) { + this.id = id; + this.productContentPhoto = productContentPhoto; + this.productId = productId; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getProductContentPhoto() { + return productContentPhoto; + } + + public void setProductContentPhoto(String productContentPhoto) { + this.productContentPhoto = productContentPhoto; + } + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + @Override + public String toString() { + return "ProductContentPhotoEntity{" + + "id=" + id + + ", productContentPhoto='" + productContentPhoto + '\'' + + ", productId=" + productId + + '}'; + } +} diff --git a/src/main/java/com/xkrs/model/entity/ProductCoverEntity.java b/src/main/java/com/xkrs/model/entity/ProductCoverEntity.java new file mode 100644 index 0000000..7c1f6af --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/ProductCoverEntity.java @@ -0,0 +1,71 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; + +/** + * @Author: XinYi Song + * @Date: 2021/12/15 11:18 + */ +@Entity +@Table(name="product_cover") +public class ProductCoverEntity { + /** + * 指定主键,建立自增序列,主键值取自序列 + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "product_cover_seq_gen") + @SequenceGenerator(name = "product_cover_seq_gen", sequenceName = "product_cover_id_seq") + private Integer id; + + /** + * 商品封面图片 + */ + private String productCoverPhoto; + + /** + * 商品id + */ + private Integer productId; + + public ProductCoverEntity() { + } + + public ProductCoverEntity(Integer id, String productCoverPhoto, Integer productId) { + this.id = id; + this.productCoverPhoto = productCoverPhoto; + this.productId = productId; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getProductCoverPhoto() { + return productCoverPhoto; + } + + public void setProductCoverPhoto(String productCoverPhoto) { + this.productCoverPhoto = productCoverPhoto; + } + + public Integer getProductId() { + return productId; + } + + public void setProductId(Integer productId) { + this.productId = productId; + } + + @Override + public String toString() { + return "ProductCoverEntity{" + + "id=" + id + + ", productCoverPhoto='" + productCoverPhoto + '\'' + + ", productId=" + productId + + '}'; + } +} diff --git a/src/main/java/com/xkrs/model/entity/ProductEntity.java b/src/main/java/com/xkrs/model/entity/ProductEntity.java new file mode 100644 index 0000000..25e7a2b --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/ProductEntity.java @@ -0,0 +1,149 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; +import java.math.BigDecimal; + +/** + * @Author: XinYi Song + * @Date: 2021/12/15 13:41 + */ +@Entity +@Table(name="product") +public class ProductEntity { + /** + * 指定主键,建立自增序列,主键值取自序列 + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "product_seq_gen") + @SequenceGenerator(name = "product_seq_gen", sequenceName = "product_id_seq") + private Integer id; + + /** + * 商品名称 + */ + private String productName; + + /** + * 商品描述 + */ + private String productDescription; + + /** + * 商品分类 + */ + private Integer productCategories; + + /** + * 商品价格 + */ + private BigDecimal productPrice; + + /** + * 商品上架状态(默认0 待审核,1审核通过,2审核不通过) + */ + @Column(length = 32, columnDefinition = "varchar(32)") + private String shelfType; + + /** + * 商家id + */ + private Integer businessId; + + /** + * 商品上架的时间 + */ + @Column(length = 65, columnDefinition = "varchar(65)") + private String productTime; + + public ProductEntity() { + } + + public ProductEntity(Integer id, String productName, String productDescription, Integer productCategories, BigDecimal productPrice, String shelfType, Integer businessId, String productTime) { + this.id = id; + this.productName = productName; + this.productDescription = productDescription; + this.productCategories = productCategories; + this.productPrice = productPrice; + this.shelfType = shelfType; + this.businessId = businessId; + this.productTime = productTime; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getProductName() { + return productName; + } + + public void setProductName(String productName) { + this.productName = productName; + } + + public String getProductDescription() { + return productDescription; + } + + public void setProductDescription(String productDescription) { + this.productDescription = productDescription; + } + + public Integer getProductCategories() { + return productCategories; + } + + public void setProductCategories(Integer productCategories) { + this.productCategories = productCategories; + } + + public BigDecimal getProductPrice() { + return productPrice; + } + + public void setProductPrice(BigDecimal productPrice) { + this.productPrice = productPrice; + } + + public String getShelfType() { + return shelfType; + } + + public void setShelfType(String shelfType) { + this.shelfType = shelfType; + } + + public Integer getBusinessId() { + return businessId; + } + + public void setBusinessId(Integer businessId) { + this.businessId = businessId; + } + + public String getProductTime() { + return productTime; + } + + public void setProductTime(String productTime) { + this.productTime = productTime; + } + + @Override + public String toString() { + return "ProductEntity{" + + "id=" + id + + ", productName='" + productName + '\'' + + ", productDescription='" + productDescription + '\'' + + ", productCategories=" + productCategories + + ", productPrice=" + productPrice + + ", shelfType='" + shelfType + '\'' + + ", businessId=" + businessId + + ", productTime='" + productTime + '\'' + + '}'; + } +} diff --git a/src/main/java/com/xkrs/model/entity/RelRoleAuthorityEntity.java b/src/main/java/com/xkrs/model/entity/RelRoleAuthorityEntity.java new file mode 100644 index 0000000..26b26ce --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/RelRoleAuthorityEntity.java @@ -0,0 +1,60 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * RelRoleAuthority 表实体类 + * @author tajochen + */ +@Entity +@Table(name="rel_role_authority") +public class RelRoleAuthorityEntity implements Serializable { + + /** + * 指定主键,建立自增序列,主键值取自序列 + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "rel_role_authority_seq_gen") + @SequenceGenerator(name = "rel_role_authority_seq_gen", sequenceName = "rel_role_authority_id_seq") + private Integer id; + + @Column(nullable = false) + private Integer roleId; + + @Column(nullable = false) + private Integer authorityId; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + public Integer getAuthorityId() { + return authorityId; + } + + public void setAuthorityId(Integer authorityId) { + this.authorityId = authorityId; + } + + @Override + public String toString() { + return "RelRoleAuthorityEntity{" + + "id=" + id + + ", roleId=" + roleId + + ", authorityId=" + authorityId + + '}'; + } +} diff --git a/src/main/java/com/xkrs/model/entity/RelUserRoleEntity.java b/src/main/java/com/xkrs/model/entity/RelUserRoleEntity.java new file mode 100644 index 0000000..2d52afe --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/RelUserRoleEntity.java @@ -0,0 +1,60 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * RelUserRole 表实体类 + * @author tajochen + */ +@Entity +@Table(name="rel_user_role") +public class RelUserRoleEntity implements Serializable { + + /** + * 指定主键,建立自增序列,主键值取自序列 + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "rel_user_role_seq_gen") + @SequenceGenerator(name = "rel_user_role_seq_gen", sequenceName = "rel_user_role_id_seq") + private Integer id; + + @Column(nullable = false) + private Long userId; + + @Column(nullable = false) + private Integer roleId; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public Long getUserId() { + return userId; + } + + public void setUserId(Long userId) { + this.userId = userId; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + @Override + public String toString() { + return "RelUserRoleEntity{" + + "id=" + id + + ", userId=" + userId + + ", roleId=" + roleId + + '}'; + } +} diff --git a/src/main/java/com/xkrs/model/entity/SysAuthorityEntity.java b/src/main/java/com/xkrs/model/entity/SysAuthorityEntity.java new file mode 100644 index 0000000..f097f50 --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/SysAuthorityEntity.java @@ -0,0 +1,72 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * SysAuthority 表实体类 + * @author tajochen + */ +@Entity +@Table(name="sys_authority") +public class SysAuthorityEntity implements Serializable { + + /** + * 指定主键,建立自增序列,主键值取自序列 + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sys_authority_seq_gen") + @SequenceGenerator(name = "sys_authority_seq_gen", sequenceName = "sys_authority_id_seq") + private Integer id; + + @Column(length = 64, nullable = false, unique = true,columnDefinition = "varchar(64)") + private String authorityName; + + @Column(length = 64, columnDefinition = "varchar(64)") + private String authorityNameZh; + + @Column(length = 128, columnDefinition = "varchar(128)") + private String authorityDesc; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getAuthorityName() { + return authorityName; + } + + public void setAuthorityName(String authorityName) { + this.authorityName = authorityName == null ? null : authorityName.trim(); + } + + public String getAuthorityNameZh() { + return authorityNameZh; + } + + public void setAuthorityNameZh(String authorityNameZh) { + this.authorityNameZh = authorityNameZh == null ? null : authorityNameZh.trim(); + } + + public String getAuthorityDesc() { + return authorityDesc; + } + + public void setAuthorityDesc(String authorityDesc) { + this.authorityDesc = authorityDesc == null ? null : authorityDesc.trim(); + } + + @Override + public String toString() { + return "SysAuthorityEntity{" + + "id=" + id + + ", authorityName='" + authorityName + '\'' + + ", authorityDesc='" + authorityDesc + '\'' + + ", authorityNameZh='" + authorityNameZh + '\'' + + '}'; + } +} diff --git a/src/main/java/com/xkrs/model/entity/SysRoleEntity.java b/src/main/java/com/xkrs/model/entity/SysRoleEntity.java new file mode 100644 index 0000000..0d30389 --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/SysRoleEntity.java @@ -0,0 +1,72 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; +import java.io.Serializable; + +/** + * SysRole 表实体类 + * @author tajochen + */ +@Entity +@Table(name="sys_role") +public class SysRoleEntity implements Serializable { + + /** + * 指定主键,建立自增序列,主键值取自序列 + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sys_role_seq_gen") + @SequenceGenerator(name = "sys_role_seq_gen", sequenceName = "sys_role_id_seq") + private Integer id; + + @Column(length = 32, nullable = false, unique = true,columnDefinition = "varchar(32)") + private String roleName; + + @Column(length = 32, columnDefinition = "varchar(32)") + private String roleNameZh; + + @Column(length = 64, columnDefinition = "varchar(64)") + private String roleDesc; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getRoleName() { + return roleName; + } + + public void setRoleName(String roleName) { + this.roleName = roleName == null ? null : roleName.trim(); + } + + public String getRoleDesc() { + return roleDesc; + } + + public void setRoleDesc(String roleDesc) { + this.roleDesc = roleDesc == null ? null : roleDesc.trim(); + } + + public String getRoleNameZh() { + return roleNameZh; + } + + public void setRoleNameZh(String roleNameZh) { + this.roleNameZh = roleNameZh == null ? null : roleNameZh.trim(); + } + + @Override + public String toString() { + return "SysRoleEntity{" + + "id=" + id + + ", roleName='" + roleName + '\'' + + ", roleNameZh='" + roleNameZh + '\'' + + ", roleDesc='" + roleDesc + '\'' + + '}'; + } +} diff --git a/src/main/java/com/xkrs/model/entity/SysUserEntity.java b/src/main/java/com/xkrs/model/entity/SysUserEntity.java new file mode 100644 index 0000000..ef885da --- /dev/null +++ b/src/main/java/com/xkrs/model/entity/SysUserEntity.java @@ -0,0 +1,278 @@ +package com.xkrs.model.entity; + +import javax.persistence.*; +import java.io.Serializable; +import java.time.LocalDateTime; + + +/** + * SysUser 表实体类 + * @author tajochen + * 用户信息 + */ +@Entity +@Table(name="sys_user") +public class SysUserEntity implements Serializable { + + /** + * 指定主键,建立自增序列,主键值取自序列 + */ + @Id + @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "sys_user_seq_gen") + @SequenceGenerator(name = "sys_user_seq_gen", sequenceName = "sys_user_id_seq") + private Integer id; + + /** + * 用户名 + */ + @Column(length = 16, nullable = false, unique = true, columnDefinition = "varchar(16)") + private String userName; + + /** + * 用户昵称 + */ + @Column(length = 32, columnDefinition = "varchar(32)") + private String nickName; + + /** + * 密码 + */ + @Column(length = 64, nullable = false, columnDefinition = "varchar(64)") + private String password; + + @Column(length = 32, nullable = false, columnDefinition = "varchar(32)") + private String salt; + + @Column(length = 16, unique = true, columnDefinition = "varchar(16)") + private String telephone; + + @Column(columnDefinition = "varchar(192)") + private String signature; + + @Column(nullable = false) + private Integer activeFlag; + + @Column(nullable = false,columnDefinition = "smallint") + private Integer statusCode; + + @Column(nullable = false) + private LocalDateTime addTime; + + private LocalDateTime lastEntryTime; + + @Column(nullable = false) + private Integer deleteFlag; + + @Column(columnDefinition = "varchar(64)") + private String lastEntryIp; + + /** + * 用户头像 + */ + private String avatar; + + /** + * 省 + */ + @Column(columnDefinition = "varchar(32)") + private String province; + + /** + * 市 + */ + @Column(columnDefinition = "varchar(32)") + private String city; + + /** + * 区 + */ + @Column(columnDefinition = "varchar(32)") + private String county; + + /** + * 识别码,身份id + */ + private String identifier; + + /** + * 用户身份 + */ + private String identity; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + public String getSalt() { + return salt; + } + + public void setSalt(String salt) { + this.salt = salt; + } + + public String getTelephone() { + return telephone; + } + + public void setTelephone(String telephone) { + this.telephone = telephone; + } + + public String getSignature() { + return signature; + } + + public void setSignature(String signature) { + this.signature = signature; + } + + public Integer getActiveFlag() { + return activeFlag; + } + + public void setActiveFlag(Integer activeFlag) { + this.activeFlag = activeFlag; + } + + public Integer getStatusCode() { + return statusCode; + } + + public void setStatusCode(Integer statusCode) { + this.statusCode = statusCode; + } + + public LocalDateTime getAddTime() { + return addTime; + } + + public void setAddTime(LocalDateTime addTime) { + this.addTime = addTime; + } + + public LocalDateTime getLastEntryTime() { + return lastEntryTime; + } + + public void setLastEntryTime(LocalDateTime lastEntryTime) { + this.lastEntryTime = lastEntryTime; + } + + public Integer getDeleteFlag() { + return deleteFlag; + } + + public void setDeleteFlag(Integer deleteFlag) { + this.deleteFlag = deleteFlag; + } + + public String getLastEntryIp() { + return lastEntryIp; + } + + public void setLastEntryIp(String lastEntryIp) { + this.lastEntryIp = lastEntryIp; + } + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getCounty() { + return county; + } + + public void setCounty(String county) { + this.county = county; + } + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + public String getIdentity() { + return identity; + } + + public void setIdentity(String identity) { + this.identity = identity; + } + + @Override + public String toString() { + return "SysUserEntity{" + + "id=" + id + + ", userName='" + userName + '\'' + + ", nickName='" + nickName + '\'' + + ", password='" + password + '\'' + + ", salt='" + salt + '\'' + + ", telephone='" + telephone + '\'' + + ", signature='" + signature + '\'' + + ", activeFlag=" + activeFlag + + ", statusCode=" + statusCode + + ", addTime=" + addTime + + ", lastEntryTime=" + lastEntryTime + + ", deleteFlag=" + deleteFlag + + ", lastEntryIp='" + lastEntryIp + '\'' + + ", avatar='" + avatar + '\'' + + ", province='" + province + '\'' + + ", city='" + city + '\'' + + ", county='" + county + '\'' + + ", identifier='" + identifier + '\'' + + ", identity='" + identity + '\'' + + '}'; + } +} diff --git a/src/main/java/com/xkrs/model/qo/BankCardQo.java b/src/main/java/com/xkrs/model/qo/BankCardQo.java new file mode 100644 index 0000000..e8082d7 --- /dev/null +++ b/src/main/java/com/xkrs/model/qo/BankCardQo.java @@ -0,0 +1,34 @@ +package com.xkrs.model.qo; + + +/** + * @Author: XinYi Song + * @Date: 2021/12/14 9:25 + */ +public class BankCardQo { + /** + * 银行卡号 + */ + private String bankCardNumber; + + /** + * 开户行 + */ + private String accountBank; + + public String getBankCardNumber() { + return bankCardNumber; + } + + public void setBankCardNumber(String bankCardNumber) { + this.bankCardNumber = bankCardNumber; + } + + public String getAccountBank() { + return accountBank; + } + + public void setAccountBank(String accountBank) { + this.accountBank = accountBank; + } +} diff --git a/src/main/java/com/xkrs/model/qo/BusinessQo.java b/src/main/java/com/xkrs/model/qo/BusinessQo.java new file mode 100644 index 0000000..7aed88d --- /dev/null +++ b/src/main/java/com/xkrs/model/qo/BusinessQo.java @@ -0,0 +1,147 @@ +package com.xkrs.model.qo; + +import com.xkrs.model.validation.BusinessQoInsert; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Pattern; + +/** + * @Author: XinYi Song + * @Date: 2021/12/14 9:11 + */ +public class BusinessQo { + /** + * 商户名称 + */ + @NotBlank(message = "{Business.businessName.null}",groups={BusinessQoInsert.class}) + private String businessName; + + /** + * 省 + */ + @NotBlank(message = "{Business.businessPro.null}",groups={BusinessQoInsert.class}) + private String businessPro; + + /** + * 市 + */ + @NotBlank(message = "{Business.businessCity.null}",groups={BusinessQoInsert.class}) + private String businessCity; + + /** + * 区 + */ + @NotBlank(message = "{Business.businessCountry.null}",groups={BusinessQoInsert.class}) + private String businessCountry; + + /** + * 详细地址 + */ + private String businessAddress; + + /** + * 商家电话 + */ + @Pattern(regexp = "^(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])\\d{8}$", message = "{Business.businessPhone.null}",groups={BusinessQoInsert.class}) + private String businessPhone; + + /** + * 商家折扣 + */ + @NotBlank(message = "{Business.businessDiscount.null}",groups={BusinessQoInsert.class}) + private Double businessDiscount; + + /** + * 团长识别码 + */ + private String headIdentifier; + + /** + * 商家图片 + */ + private String businessPhoto; + + /** + * 营业执照 + */ + private String businessLicense; + + public String getBusinessName() { + return businessName; + } + + public void setBusinessName(String businessName) { + this.businessName = businessName; + } + + public String getBusinessPro() { + return businessPro; + } + + public void setBusinessPro(String businessPro) { + this.businessPro = businessPro; + } + + public String getBusinessCity() { + return businessCity; + } + + public void setBusinessCity(String businessCity) { + this.businessCity = businessCity; + } + + public String getBusinessCountry() { + return businessCountry; + } + + public void setBusinessCountry(String businessCountry) { + this.businessCountry = businessCountry; + } + + public String getBusinessAddress() { + return businessAddress; + } + + public void setBusinessAddress(String businessAddress) { + this.businessAddress = businessAddress; + } + + public String getBusinessPhone() { + return businessPhone; + } + + public void setBusinessPhone(String businessPhone) { + this.businessPhone = businessPhone; + } + + public Double getBusinessDiscount() { + return businessDiscount; + } + + public void setBusinessDiscount(Double businessDiscount) { + this.businessDiscount = businessDiscount; + } + + public String getHeadIdentifier() { + return headIdentifier; + } + + public void setHeadIdentifier(String headIdentifier) { + this.headIdentifier = headIdentifier; + } + + public String getBusinessPhoto() { + return businessPhoto; + } + + public void setBusinessPhoto(String businessPhoto) { + this.businessPhoto = businessPhoto; + } + + public String getBusinessLicense() { + return businessLicense; + } + + public void setBusinessLicense(String businessLicense) { + this.businessLicense = businessLicense; + } +} diff --git a/src/main/java/com/xkrs/model/qo/FileDocumentQo.java b/src/main/java/com/xkrs/model/qo/FileDocumentQo.java new file mode 100644 index 0000000..35033e5 --- /dev/null +++ b/src/main/java/com/xkrs/model/qo/FileDocumentQo.java @@ -0,0 +1,106 @@ +package com.xkrs.model.qo; + +import com.xkrs.model.validation.FileDocumentQoInsert; +import com.xkrs.model.validation.FileDocumentQoUpdate; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; + +/** + * AssistantInvestigatorQo + * @author tajochen + */ +public class FileDocumentQo { + + @NotBlank(message = "{FileDocument.id.null}",groups={FileDocumentQoUpdate.class}) + private Integer id; + + @NotBlank(message = "{FileDocument.name.null}",groups = {FileDocumentQoInsert.class}) + @Size(max = 64, message = "{FileDocument.name.length.illegal}", groups={FileDocumentQoInsert.class, FileDocumentQoUpdate.class}) + private String name; + + @Min(value = 0, message = "{FileDocument.category.length.illegal}", groups={FileDocumentQoInsert.class, FileDocumentQoUpdate.class}) + private Integer category; + + @NotBlank(message = "{FileDocument.filePath.null}",groups = {FileDocumentQoInsert.class, FileDocumentQoUpdate.class}) + @Size(max = 192, message = "{FileDocument.filePath.length.illegal}",groups = {FileDocumentQoInsert.class, FileDocumentQoUpdate.class}) + private String filePath; + + @Size(max = 128, message = "{FileDocument.size.length.illegal}",groups = {FileDocumentQoInsert.class, FileDocumentQoUpdate.class}) + private String size; + + @NotBlank(message = "{FileDocument.md5.null}",groups = {FileDocumentQoInsert.class, FileDocumentQoUpdate.class}) + @Size(max = 192, message = "{FileDocument.md5.length.illegal}",groups = {FileDocumentQoInsert.class, FileDocumentQoUpdate.class}) + private String md5; + + @Size(max = 128, message = "{FileDocument.memo.length.illegal}",groups = {FileDocumentQoInsert.class, FileDocumentQoUpdate.class}) + private String memo; + + @Size(max = 128, message = "{FileDocument.checkingToken.length.illegal}",groups = {FileDocumentQoInsert.class, FileDocumentQoUpdate.class}) + private String checkingToken; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public Integer getCategory() { + return category; + } + + public void setCategory(Integer category) { + this.category = category; + } + + public String getFilePath() { + return filePath; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public String getSize() { + return size; + } + + public void setSize(String size) { + this.size = size; + } + + public String getMd5() { + return md5; + } + + public void setMd5(String md5) { + this.md5 = md5; + } + + public String getMemo() { + return memo; + } + + public void setMemo(String memo) { + this.memo = memo; + } + + public String getCheckingToken() { + return checkingToken; + } + + public void setCheckingToken(String checkingToken) { + this.checkingToken = checkingToken; + } +} diff --git a/src/main/java/com/xkrs/model/qo/SysUserQo.java b/src/main/java/com/xkrs/model/qo/SysUserQo.java new file mode 100644 index 0000000..e024abe --- /dev/null +++ b/src/main/java/com/xkrs/model/qo/SysUserQo.java @@ -0,0 +1,137 @@ +package com.xkrs.model.qo; + +import com.xkrs.model.validation.SysUserQoInsert; +import com.xkrs.model.validation.SysUserQoUpdate; +import org.hibernate.validator.constraints.Range; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Pattern; +import javax.validation.constraints.Size; + +/** + * SysUserQo + * @author tajochen + */ +public class SysUserQo { + + @NotNull( message = "{SysUser.id.blank}",groups={SysUserQoUpdate.class}) + private Integer id; + + @NotBlank(message = "{SysUser.userName.blank}",groups={SysUserQoInsert.class}) + @Size(min = 4,max = 16, message = "{SysUser.userName.length.illegal}",groups = {SysUserQoInsert.class, + SysUserQoUpdate.class}) + @Pattern(regexp = "^([A-Za-z0-9_]+)$",message = "{SysUser.userName.format.illegal}",groups = {SysUserQoInsert.class, + SysUserQoUpdate.class}) + private String userName; + + @Size(max = 32, message = "{SysUser.nickName.length.illegal}",groups = {SysUserQoInsert.class, + SysUserQoUpdate.class}) + private String nickName; + + @NotBlank(message = "{SysUser.password.blank}",groups = {SysUserQoInsert.class}) + @Size(min = 6,max = 16, message = "{SysUser.password.length.illegal}",groups = {SysUserQoInsert.class, + SysUserQoUpdate.class}) + @Pattern(regexp = "^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$",message = "{SysUser.password.format.illegal}", + groups = {SysUserQoInsert.class,SysUserQoUpdate.class}) + private String password; + + @Pattern(regexp = "^(13[0-9]|14[0-9]|15[0-9]|16[0-9]|17[0-9]|18[0-9]|19[0-9])\\d{8}$", + message = "{SysUser.telephone.format.illegal}",groups = {SysUserQoInsert.class,SysUserQoUpdate.class}) + private String telephone; + + @NotNull(message = "{SysUser.statusCode.illegal}",groups={SysUserQoUpdate.class}) + @Range(min=0,max=2,message = "{SysUser.statusCode.illegal}",groups = {SysUserQoInsert.class, SysUserQoUpdate.class}) + private Integer statusCode; + + @NotNull(message = "{SysUser.deleteFlag.null}",groups={SysUserQoUpdate.class}) + private Integer deleteFlag; + + private Integer roleId; + + private Integer authorityId; + + private String identity; + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + + public String getPassword() { + return password; + } + + public void setPassword(String password) { + this.password = password; + } + + + public String getTelephone() { + return telephone; + } + + public void setTelephone(String telephone) { + this.telephone = telephone; + } + + public Integer getStatusCode() { + return statusCode; + } + + public void setStatusCode(Integer statusCode) { + this.statusCode = statusCode; + } + + public Integer getDeleteFlag() { + return deleteFlag; + } + + public void setDeleteFlag(Integer deleteFlag) { + this.deleteFlag = deleteFlag; + } + + public Integer getRoleId() { + return roleId; + } + + public void setRoleId(Integer roleId) { + this.roleId = roleId; + } + + public Integer getAuthorityId() { + return authorityId; + } + + public void setAuthorityId(Integer authorityId) { + this.authorityId = authorityId; + } + + public String getIdentity() { + return identity; + } + + public void setIdentity(String identity) { + this.identity = identity; + } +} diff --git a/src/main/java/com/xkrs/model/qo/UserUpdate.java b/src/main/java/com/xkrs/model/qo/UserUpdate.java new file mode 100644 index 0000000..08f4ea4 --- /dev/null +++ b/src/main/java/com/xkrs/model/qo/UserUpdate.java @@ -0,0 +1,62 @@ +package com.xkrs.model.qo; + +import javax.persistence.Column; + +/** + * @Author: XinYi Song + * @Date: 2021/12/10 16:37 + */ +public class UserUpdate { + + /** + * 用户昵称 + */ + private String nickName; + + /** + * 省 + */ + private String province; + + /** + * 市 + */ + private String city; + + /** + * 区 + */ + private String county; + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getCounty() { + return county; + } + + public void setCounty(String county) { + this.county = county; + } +} diff --git a/src/main/java/com/xkrs/model/validation/BusinessQoInsert.java b/src/main/java/com/xkrs/model/validation/BusinessQoInsert.java new file mode 100644 index 0000000..30b98e7 --- /dev/null +++ b/src/main/java/com/xkrs/model/validation/BusinessQoInsert.java @@ -0,0 +1,8 @@ +package com.xkrs.model.validation; + +/** + * @Author: XinYi Song + * @Date: 2021/12/14 9:13 + */ +public interface BusinessQoInsert { +} diff --git a/src/main/java/com/xkrs/model/validation/FileDocumentQoInsert.java b/src/main/java/com/xkrs/model/validation/FileDocumentQoInsert.java new file mode 100644 index 0000000..ff52dbc --- /dev/null +++ b/src/main/java/com/xkrs/model/validation/FileDocumentQoInsert.java @@ -0,0 +1,8 @@ +package com.xkrs.model.validation; + +/** + * FileDocumentQoInsert + * @author tajochen + */ +public interface FileDocumentQoInsert { +} diff --git a/src/main/java/com/xkrs/model/validation/FileDocumentQoUpdate.java b/src/main/java/com/xkrs/model/validation/FileDocumentQoUpdate.java new file mode 100644 index 0000000..9edaabc --- /dev/null +++ b/src/main/java/com/xkrs/model/validation/FileDocumentQoUpdate.java @@ -0,0 +1,8 @@ +package com.xkrs.model.validation; + +/** + * FileDocumentQoUpdate + * @author tajochen + */ +public interface FileDocumentQoUpdate { +} diff --git a/src/main/java/com/xkrs/model/validation/SysUserQoInsert.java b/src/main/java/com/xkrs/model/validation/SysUserQoInsert.java new file mode 100644 index 0000000..b7ce804 --- /dev/null +++ b/src/main/java/com/xkrs/model/validation/SysUserQoInsert.java @@ -0,0 +1,8 @@ +package com.xkrs.model.validation; + +/** + * SysUserQoInsert + * @author tajochen + */ +public interface SysUserQoInsert { +} diff --git a/src/main/java/com/xkrs/model/validation/SysUserQoUpdate.java b/src/main/java/com/xkrs/model/validation/SysUserQoUpdate.java new file mode 100644 index 0000000..2c1d87d --- /dev/null +++ b/src/main/java/com/xkrs/model/validation/SysUserQoUpdate.java @@ -0,0 +1,8 @@ +package com.xkrs.model.validation; + +/** + * SysUserQoUpdate + * @author tajochen + */ +public interface SysUserQoUpdate { +} diff --git a/src/main/java/com/xkrs/model/vo/FileServerResultVo.java b/src/main/java/com/xkrs/model/vo/FileServerResultVo.java new file mode 100644 index 0000000..77fb534 --- /dev/null +++ b/src/main/java/com/xkrs/model/vo/FileServerResultVo.java @@ -0,0 +1,67 @@ +package com.xkrs.model.vo; + +import java.io.Serializable; + +/** + * FileServerResultVo 文件服务器查询结果 + * @author tajochen + */ +public class FileServerResultVo implements Serializable { + + /** + * 状态信息 + */ + String status; + + /** + * 提示信息 + */ + String message; + + /** + * 数据 + */ + T data; + + public FileServerResultVo() { + } + + public FileServerResultVo(String status, String msg, T data) { + this.status = status; + this.message = msg; + this.data = data; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + public T getData() { + return data; + } + + public void setData(T data) { + this.data = data; + } + + @Override + public String toString() { + return "FileServerResultVo{" + + "status='" + status + '\'' + + ", message='" + message + '\'' + + ", data=" + data + + '}'; + } +} diff --git a/src/main/java/com/xkrs/model/vo/SysUserVo.java b/src/main/java/com/xkrs/model/vo/SysUserVo.java new file mode 100644 index 0000000..90a4856 --- /dev/null +++ b/src/main/java/com/xkrs/model/vo/SysUserVo.java @@ -0,0 +1,198 @@ +package com.xkrs.model.vo; + +import javax.persistence.Column; +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * SysUserVo + * @Author tajochen + */ +public class SysUserVo implements Serializable { + private Integer id; + + private String userName; + + private String nickName; + + private String telephone; + + private LocalDateTime addTime; + + private LocalDateTime lastEntryTime; + + private String lastEntryIp; + + /** + * 用户头像 + */ + private String avatar; + + /** + * 省 + */ + @Column(columnDefinition = "varchar(32)") + private String province; + + /** + * 市 + */ + @Column(columnDefinition = "varchar(32)") + private String city; + + /** + * 区 + */ + @Column(columnDefinition = "varchar(32)") + private String county; + + /** + * 识别码,身份id + */ + private String identifier; + + /** + * 用户身份 + */ + private String identity; + + public SysUserVo(Integer id, String userName, String nickName, String telephone, LocalDateTime addTime, LocalDateTime lastEntryTime, String lastEntryIp, String avatar, String province, String city, String county, String identifier, String identity) { + this.id = id; + this.userName = userName; + this.nickName = nickName; + this.telephone = telephone; + this.addTime = addTime; + this.lastEntryTime = lastEntryTime; + this.lastEntryIp = lastEntryIp; + this.avatar = avatar; + this.province = province; + this.city = city; + this.county = county; + this.identifier = identifier; + this.identity = identity; + } + + public Integer getId() { + return id; + } + + public void setId(Integer id) { + this.id = id; + } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } + + public String getNickName() { + return nickName; + } + + public void setNickName(String nickName) { + this.nickName = nickName; + } + + public String getTelephone() { + return telephone; + } + + public void setTelephone(String telephone) { + this.telephone = telephone; + } + + public LocalDateTime getAddTime() { + return addTime; + } + + public void setAddTime(LocalDateTime addTime) { + this.addTime = addTime; + } + + public LocalDateTime getLastEntryTime() { + return lastEntryTime; + } + + public void setLastEntryTime(LocalDateTime lastEntryTime) { + this.lastEntryTime = lastEntryTime; + } + + public String getLastEntryIp() { + return lastEntryIp; + } + + public void setLastEntryIp(String lastEntryIp) { + this.lastEntryIp = lastEntryIp; + } + + public String getAvatar() { + return avatar; + } + + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + public String getProvince() { + return province; + } + + public void setProvince(String province) { + this.province = province; + } + + public String getCity() { + return city; + } + + public void setCity(String city) { + this.city = city; + } + + public String getCounty() { + return county; + } + + public void setCounty(String county) { + this.county = county; + } + + public String getIdentifier() { + return identifier; + } + + public void setIdentifier(String identifier) { + this.identifier = identifier; + } + + public String getIdentity() { + return identity; + } + + public void setIdentity(String identity) { + this.identity = identity; + } + + @Override + public String toString() { + return "SysUserVo{" + + "id=" + id + + ", userName='" + userName + '\'' + + ", nickName='" + nickName + '\'' + + ", telephone='" + telephone + '\'' + + ", addTime=" + addTime + + ", lastEntryTime=" + lastEntryTime + + ", lastEntryIp='" + lastEntryIp + '\'' + + ", avatar='" + avatar + '\'' + + ", province='" + province + '\'' + + ", city='" + city + '\'' + + ", county='" + county + '\'' + + ", identifier='" + identifier + '\'' + + ", identity='" + identity + '\'' + + '}'; + } +} + diff --git a/src/main/java/com/xkrs/qiniu/config/QiNiuYunConfig.java b/src/main/java/com/xkrs/qiniu/config/QiNiuYunConfig.java new file mode 100644 index 0000000..995ea6b --- /dev/null +++ b/src/main/java/com/xkrs/qiniu/config/QiNiuYunConfig.java @@ -0,0 +1,64 @@ +package com.xkrs.qiniu.config; + +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Configuration; + +/** + * @Author: XinYi Song + * @Date: 2021/12/14 16:39 + */ +@Configuration +public class QiNiuYunConfig { + /** + * 七牛域名domain + */ + @Value("${qiniu.domain}") + private String url; + /** + * 七牛ACCESS_KEY + */ + @Value("${qiniu.accessKey}") + private String AccessKey; + /** + * 七牛SECRET_KEY + */ + @Value("${qiniu.secretKey}") + private String SecretKey; + /** + * 七牛空间名 + */ + @Value("${qiniu.bucket}") + private String BucketName; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getAccessKey() { + return AccessKey; + } + + public void setAccessKey(String accessKey) { + AccessKey = accessKey; + } + + public String getSecretKey() { + return SecretKey; + } + + public void setSecretKey(String secretKey) { + SecretKey = secretKey; + } + + public String getBucketName() { + return BucketName; + } + + public void setBucketName(String bucketName) { + BucketName = bucketName; + } +} diff --git a/src/main/java/com/xkrs/qiniu/controller/UploadFileController.java b/src/main/java/com/xkrs/qiniu/controller/UploadFileController.java new file mode 100644 index 0000000..33f77ba --- /dev/null +++ b/src/main/java/com/xkrs/qiniu/controller/UploadFileController.java @@ -0,0 +1,38 @@ +package com.xkrs.qiniu.controller; + +import com.xkrs.common.encapsulation.PromptMessageEnum; +import com.xkrs.qiniu.service.UploadImageService; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; + +import java.util.Locale; + +import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; + +/** + * @Author: XinYi Song + * @Date: 2021/12/15 15:01 + */ +@RestController +public class UploadFileController { + + @Resource + private UploadImageService uploadImageService; + + /** + * 将图片上传到七牛云 + * @param files + * @return + */ + @PostMapping("/qiNiuUploadFile") + public String uploadFile(@RequestParam("files") MultipartFile files){ + Locale locale = LocaleContextHolder.getLocale(); + String uploadQiNiuImg = uploadImageService.uploadQiNiuImg(files); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,uploadQiNiuImg,locale); + } +} diff --git a/src/main/java/com/xkrs/qiniu/service/UploadImageService.java b/src/main/java/com/xkrs/qiniu/service/UploadImageService.java new file mode 100644 index 0000000..ebbe71b --- /dev/null +++ b/src/main/java/com/xkrs/qiniu/service/UploadImageService.java @@ -0,0 +1,32 @@ +package com.xkrs.qiniu.service; + +import org.springframework.web.multipart.MultipartFile; + +/** + * @Author: XinYi Song + * @Date: 2021/12/14 16:52 + */ +public interface UploadImageService { + + /** + * 上传文件 + * @param file + * @return + */ + String uploadQiNiuImg(MultipartFile file); + + /** + * 获取私有空间文件 + * @param fileKey + * @return + */ + String getPrivateFile(String fileKey); + + /** + * 根据空间名、文件名删除文件 + * @param bucketName + * @param fileKey + * @return + */ + boolean removeFile(String bucketName, String fileKey); +} diff --git a/src/main/java/com/xkrs/qiniu/service/impl/UploadImageServiceImpl.java b/src/main/java/com/xkrs/qiniu/service/impl/UploadImageServiceImpl.java new file mode 100644 index 0000000..353cfb2 --- /dev/null +++ b/src/main/java/com/xkrs/qiniu/service/impl/UploadImageServiceImpl.java @@ -0,0 +1,122 @@ +package com.xkrs.qiniu.service.impl; + +import com.google.gson.Gson; +import com.qiniu.common.QiniuException; +import com.qiniu.common.Zone; +import com.qiniu.http.Response; +import com.qiniu.storage.BucketManager; +import com.qiniu.storage.Configuration; +import com.qiniu.storage.UploadManager; +import com.qiniu.storage.model.DefaultPutRet; +import com.qiniu.util.Auth; +import com.xkrs.qiniu.config.QiNiuYunConfig; +import com.xkrs.qiniu.service.UploadImageService; +import com.xkrs.qiniu.util.StringUtil; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; +import java.io.FileInputStream; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; + +/** + * @Author: XinYi Song + * @Date: 2021/12/14 16:53 + */ +@Service +public class UploadImageServiceImpl implements UploadImageService { + + private QiNiuYunConfig qiNiuYunConfig; + + // 七牛文件上传管理器 + private UploadManager uploadManager; + //上传的token + private String token; + // 七牛认证管理 + private Auth auth; + + private BucketManager bucketManager; + + public UploadImageServiceImpl(QiNiuYunConfig qiNiuYunConfig) { + this.qiNiuYunConfig = qiNiuYunConfig; + init(); + } + + private void init() { + // 构造一个带指定Zone对象的配置类, 注意这里的Zone.zone0需要根据主机选择 + uploadManager = new UploadManager(new Configuration(Zone.zone2())); + auth = Auth.create(qiNiuYunConfig.getAccessKey(), qiNiuYunConfig.getSecretKey()); + // 根据命名空间生成的上传token + bucketManager = new BucketManager(auth, new Configuration(Zone.zone2())); + token = auth.uploadToken(qiNiuYunConfig.getBucketName()); + } + + /** + * 上传文件 + * @param file + * @return + */ + @Override + public String uploadQiNiuImg(MultipartFile file) { + try { + // 获取文件的名称 + String fileName = file.getOriginalFilename(); + if(fileName != null){ + // 使用工具类根据上传文件生成唯一图片名称 + String imgName = StringUtil.getRandomImgName(fileName); + + FileInputStream inputStream = (FileInputStream) file.getInputStream(); + // 上传图片文件 + Response res = uploadManager.put(inputStream, imgName, token, null, null); + if (!res.isOK()) { + throw new RuntimeException("上传七牛出错:" + res.toString()); + } + // 解析上传成功的结果 + DefaultPutRet putRet = new Gson().fromJson(res.bodyString(), DefaultPutRet.class); + + // 直接返回外链地址 + return getPrivateFile(imgName); + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * 获取私有空间文件 + * + * @param fileKey + * @return + */ + @Override + public String getPrivateFile(String fileKey) { + String encodedFileName = null; + String finalUrl = null; + try { + encodedFileName = URLEncoder.encode(fileKey, "utf-8").replace("+", "%20"); + String publicUrl = String.format("%s/%s", this.qiNiuYunConfig.getUrl(), encodedFileName); + // 1小时,可以自定义链接过期时间 + long expireInSeconds = 3600; + finalUrl = auth.privateDownloadUrl(publicUrl, expireInSeconds); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + return finalUrl; + } + + /** + * 根据空间名、文件名删除文件 + * @param bucketName + * @param fileKey + * @return + */ + @Override + public boolean removeFile(String bucketName, String fileKey) { + try { + bucketManager.delete(bucketName, fileKey); + } catch (QiniuException e) { + e.printStackTrace(); + } + return true; + } +} diff --git a/src/main/java/com/xkrs/qiniu/util/StringUtil.java b/src/main/java/com/xkrs/qiniu/util/StringUtil.java new file mode 100644 index 0000000..bb57a3f --- /dev/null +++ b/src/main/java/com/xkrs/qiniu/util/StringUtil.java @@ -0,0 +1,30 @@ +package com.xkrs.qiniu.util; + +import java.util.UUID; + +/** + * @Author: XinYi Song + * @Date: 2021/12/14 16:43 + */ +public class StringUtil { + + /** + * @Description: 生成唯一图片名称 + * @Param: fileName + * @return: 云服务器fileName + */ + public static String getRandomImgName(String fileName) { + int index = fileName.lastIndexOf("."); + if ((fileName == null || fileName.isEmpty()) || index == -1){ + throw new IllegalArgumentException(); + } + // 获取文件后缀 + String suffix = fileName.substring(index); + // 生成UUID + String uuid = UUID.randomUUID().toString().replaceAll("-", ""); + // 生成上传至云服务器的路径 + // String path = "news/crush/"+ DateUtil.today() + "-" + uuid + suffix; + String path = uuid + suffix; + return path; + } +} diff --git a/src/main/java/com/xkrs/service/FileDocumentService.java b/src/main/java/com/xkrs/service/FileDocumentService.java new file mode 100644 index 0000000..2d79789 --- /dev/null +++ b/src/main/java/com/xkrs/service/FileDocumentService.java @@ -0,0 +1,45 @@ +package com.xkrs.service; + +import com.xkrs.model.entity.FileDocumentEntity; +import com.xkrs.model.qo.FileDocumentQo; + +import java.util.Optional; + +/** + * 文档管理接口 + * @author tajochen + */ +public interface FileDocumentService { + + /** + * 文档列表 + * @return + */ + Iterable getAllFile(); + + /** + * 获取指定id记录 + * @param id + * @return + */ + Optional getById(Integer id); + + /** + * 新增文档记录 + * @param fileDocumentQo + * @param userName + */ + void add(FileDocumentQo fileDocumentQo, String userName); + + /** + * 删除文档记录 + * @param id + */ + void delete(Integer id); + + /** + * 修改文档记录 + * @param fileDocumentEntity + */ + void update(FileDocumentEntity fileDocumentEntity); +} diff --git a/src/main/java/com/xkrs/service/FileServerService.java b/src/main/java/com/xkrs/service/FileServerService.java new file mode 100644 index 0000000..ee32796 --- /dev/null +++ b/src/main/java/com/xkrs/service/FileServerService.java @@ -0,0 +1,53 @@ +package com.xkrs.service; + +import com.xkrs.model.vo.FileServerResultVo; + +/** + * 文件服务器接口 + * @author tajochen + */ +public interface FileServerService { + + /** + * 获取文件统计信息 + * @return + */ + FileServerResultVo getFileStat(); + + /** + * 删除文件 + * @param md5 信息摘要 + * @param path 路径 + * @return + */ + FileServerResultVo deleteFile(String md5, String path); + + /** + * 获取文件信息 + * @param md5 信息摘要 + * @param path 路径 + * @return + */ + FileServerResultVo getFileInfo(String md5, String path); + + /** + * 获取文件列表 + * @param dir 目录名 + * @return + */ + FileServerResultVo getFileList(String dir); + + /** + * 修复统计信息 + * @param date 要修复的日期,格式如:20190725 + * @return + */ + FileServerResultVo getFileRepairStat(String date); + + /** + * 同步失败修复 + * @param force 是否强行修复(0|1) + * @return + */ + FileServerResultVo getFileRepair(String force); +} diff --git a/src/main/java/com/xkrs/service/MerchantSettlementService.java b/src/main/java/com/xkrs/service/MerchantSettlementService.java new file mode 100644 index 0000000..b264771 --- /dev/null +++ b/src/main/java/com/xkrs/service/MerchantSettlementService.java @@ -0,0 +1,50 @@ +package com.xkrs.service; + +import com.xkrs.model.qo.BankCardQo; +import com.xkrs.model.qo.BusinessQo; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.List; + +/** + * @Author: XinYi Song + * @Date: 2021/12/14 9:51 + * 商家模块 + */ +public interface MerchantSettlementService { + + /** + * 商家入驻 + * @param businessQo + * @param businessPhoto + * @param businessLicense + * @param bankCardQos + * @param businessId + * @return + * @throws IOException + */ + String merchantSettlement(BusinessQo businessQo, MultipartFile businessPhoto, MultipartFile businessLicense, List bankCardQos) throws IOException; + + /** + * 通过状态查询商家入驻信息 + * @param type + * @return + */ + String findAllByBusinessType(String type); + + /** + * 根据省市区查询审核通过的商家的信息 + * @param countyName + * @param keepType + * @return + */ + String findAllByCountyName(String countyName, String keepType); + + /** + * 根据商家用户id查询商家入驻信息 + * @param businessId + * @return + */ + String findBusinessById(Integer businessId); +} diff --git a/src/main/java/com/xkrs/service/SysAuthorityService.java b/src/main/java/com/xkrs/service/SysAuthorityService.java new file mode 100644 index 0000000..101c3ec --- /dev/null +++ b/src/main/java/com/xkrs/service/SysAuthorityService.java @@ -0,0 +1,19 @@ +package com.xkrs.service; + +import com.xkrs.model.entity.SysAuthorityEntity; + +import java.util.List; + +/** + * 系统权限服务接口 + * @author tajochen + */ +public interface SysAuthorityService { + + /** + * 获取权限实体列表根据用户名 + * @param userName + * @return + */ + List getSysAuthorityListByUserName(String userName); +} diff --git a/src/main/java/com/xkrs/service/SysRoleService.java b/src/main/java/com/xkrs/service/SysRoleService.java new file mode 100644 index 0000000..b3149eb --- /dev/null +++ b/src/main/java/com/xkrs/service/SysRoleService.java @@ -0,0 +1,19 @@ +package com.xkrs.service; + +import com.xkrs.model.entity.SysRoleEntity; + +import java.util.List; + +/** + * 系统角色服务接口 + * @author tajochen + */ +public interface SysRoleService { + + /** + * 获取角色实体列表根据用户名 + * @param userName + * @return + */ + List getSysRoleListByUserName(String userName); +} diff --git a/src/main/java/com/xkrs/service/SysUserService.java b/src/main/java/com/xkrs/service/SysUserService.java new file mode 100644 index 0000000..2b9ce3b --- /dev/null +++ b/src/main/java/com/xkrs/service/SysUserService.java @@ -0,0 +1,108 @@ +package com.xkrs.service; + +import com.xkrs.model.entity.SysUserEntity; +import com.xkrs.model.qo.SysUserQo; +import com.xkrs.model.qo.UserUpdate; +import com.xkrs.model.vo.SysUserVo; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; + +/** + * 系统用户服务接口 + * @author tajochen + */ +public interface SysUserService { + + /** + * 检查用户名 + * @param userName + * @return + */ + boolean checkUserName(String userName); + + /** + * 获取所有用户 + * @return + */ + //Iterable getAllSysUser(); + + /** + * 保存用户 + * @param sysUserQo + */ + void addUser(SysUserQo sysUserQo); + + /** + * 获取系统用户实体根据用户名 + * @param userName + * @return + */ + SysUserEntity getSysUserByUserName(String userName); + + /** + * 获取用户信息 + * @param userName + * @return + */ + SysUserVo selectUserByUserName(String userName); + + /** + * 用户登录更新 + * @param userName + * @param ipAddress + * @return + */ + int updateSysUserLogin(String userName, String ipAddress); + + /** + * 系统用户更新 + * @param sysUserQo + * @return + */ + int updateSysUser(SysUserQo sysUserQo); + + /** + * 软删除系统用户 + * @param id + * @return + */ + int softDeleteGeneralUser(Integer id); + + /** + * 用户绑定手机号 + * @param userId + * @param phone + * @return + */ + String bindPhone(Integer userId, String phone); + + /** + * 手机号登录 + * @param phone + * @param verificationCode + * @return + */ + String loginByPhone(String phone, String verificationCode); + + /** + * 用户完善个人信息 + * @param files + * @param userUpdate + * @param userId + * @return + */ + String updateUserByUserId(MultipartFile files, UserUpdate userUpdate, Integer userId) throws IOException; + + /** + * 启用 + * @param userId + */ + void updateEnable(Integer userId); + + /** + * 禁用 + * @param userId + */ + void updateDisable(Integer userId); +} diff --git a/src/main/java/com/xkrs/service/impl/FileDocumentServiceImpl.java b/src/main/java/com/xkrs/service/impl/FileDocumentServiceImpl.java new file mode 100644 index 0000000..bb2f0f6 --- /dev/null +++ b/src/main/java/com/xkrs/service/impl/FileDocumentServiceImpl.java @@ -0,0 +1,99 @@ +package com.xkrs.service.impl; + +import com.xkrs.dao.FileDocumentDao; +import com.xkrs.model.entity.FileDocumentEntity; +import com.xkrs.model.qo.FileDocumentQo; +import com.xkrs.service.FileDocumentService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cache.annotation.CacheConfig; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.util.Optional; + +import static com.xkrs.utils.DateTimeUtil.getNowTime; + +/** + * 文档管理接口 + * @author tajochen + */ +@Service +@CacheConfig(cacheNames = "FileDocumentServiceCache") +public class FileDocumentServiceImpl implements FileDocumentService { + + Logger logger = LoggerFactory.getLogger(FileDocumentServiceImpl.class); + + @Resource + private FileDocumentDao fileDocumentDao; + + /** + * 文档列表 + * @return + */ + @Cacheable(keyGenerator = "keyGenerator",unless="#result == null") + @Override + public Iterable getAllFile() { + Iterable list = fileDocumentDao.findAll(); + return list; + } + + /** + * 获取指定id记录 + * @param id + * @return + */ + @Cacheable(keyGenerator = "keyGenerator",unless="#result == null") + @Override + public Optional getById(Integer id) { + Optional obj = fileDocumentDao.findById(id); + return obj; + } + + /** + * 新增文档记录 + * @param fileDocumentQo + * @param userName + */ + @Transactional(rollbackFor=Exception.class) + @Override + @CacheEvict(value = "FileDocumentServiceCache",allEntries = true) + public void add(FileDocumentQo fileDocumentQo, String userName) { + FileDocumentEntity fileDocumentEntity = new FileDocumentEntity(); + fileDocumentEntity.setName(fileDocumentQo.getName()); + fileDocumentEntity.setFilePath(fileDocumentQo.getFilePath()); + fileDocumentEntity.setAddUserName(userName); + fileDocumentEntity.setCategory(fileDocumentQo.getCategory()); + fileDocumentEntity.setMemo(fileDocumentQo.getMemo()); + fileDocumentEntity.setMd5(fileDocumentQo.getMd5()); + fileDocumentEntity.setSize(fileDocumentQo.getSize()); + // 设置系统时间 + fileDocumentEntity.setAddTime(getNowTime()); + fileDocumentDao.save(fileDocumentEntity); + } + + /** + * 删除文档记录 + * @param id + */ + @Transactional(rollbackFor=Exception.class) + @Override + @CacheEvict(value = "FileDocumentServiceCache",allEntries = true) + public void delete(Integer id) { + fileDocumentDao.deleteById(id); + } + + /** + * 修改文档记录 + * @param fileDocumentEntity + */ + @Transactional(rollbackFor=Exception.class) + @Override + @CacheEvict(value = "FileDocumentServiceCache",allEntries = true) + public void update(FileDocumentEntity fileDocumentEntity) { + fileDocumentDao.save(fileDocumentEntity); + } +} diff --git a/src/main/java/com/xkrs/service/impl/FileServerServiceImpl.java b/src/main/java/com/xkrs/service/impl/FileServerServiceImpl.java new file mode 100644 index 0000000..fe3a899 --- /dev/null +++ b/src/main/java/com/xkrs/service/impl/FileServerServiceImpl.java @@ -0,0 +1,121 @@ +package com.xkrs.service.impl; + +import com.xkrs.model.vo.FileServerResultVo; +import com.xkrs.service.FileServerService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Service; + +import java.util.HashMap; +import java.util.Map; + +import static com.xkrs.utils.RequestUtil.postFileManage; + +/** + * 文件服务器接口 + * @author tajochen + */ +@Service +public class FileServerServiceImpl implements FileServerService { + + Logger logger = LoggerFactory.getLogger(FileServerServiceImpl.class); + + @Value("${my.FileServerAdminAdress}") + private String fileServerAdminAdress; + + /** + * 获取文件统计信息 + * @return + */ + @Override + public FileServerResultVo getFileStat(){ + String requestUrl = fileServerAdminAdress + "/group1/stat"; + Map map = new HashMap(16); + FileServerResultVo fileServerResultVo = postFileManage(requestUrl,map); + return fileServerResultVo; + } + + /** + * 删除文件 + * @param md5 信息摘要 + * @param path 路径 + * @return + */ + @Override + public FileServerResultVo deleteFile(String md5,String path){ + String requestUrl = fileServerAdminAdress + "/group1/delete"; + Map map = new HashMap(16); + if(md5 != null && !md5.isEmpty()){ + map.put("md5",md5); + } + if(path != null && !path.isEmpty()){ + map.put("path",path); + } + FileServerResultVo fileServerResultVo = postFileManage(requestUrl,map); + return fileServerResultVo; + } + + /** + * 获取文件信息 + * @param md5 信息摘要 + * @param path 路径 + * @return + */ + @Override + public FileServerResultVo getFileInfo(String md5,String path){ + String requestUrl = fileServerAdminAdress + "/group1/get_file_info"; + Map map = new HashMap(16); + if(md5 != null && !md5.isEmpty()){ + map.put("md5",md5); + } + if(path != null && !path.isEmpty()){ + map.put("path",path); + } + FileServerResultVo fileServerResultVo = postFileManage(requestUrl,map); + return fileServerResultVo; + } + + /** + * 获取文件列表 + * @param dir 目录名 + * @return + */ + @Override + public FileServerResultVo getFileList(String dir){ + String requestUrl = fileServerAdminAdress + "/group1/list_dir"; + Map map = new HashMap(16); + map.put("dir",dir); + FileServerResultVo fileServerResultVo = postFileManage(requestUrl,map); + return fileServerResultVo; + } + + /** + * 修复统计信息 + * @param date 要修复的日期,格式如:20190725 + * @return + */ + @Override + public FileServerResultVo getFileRepairStat(String date){ + String requestUrl = fileServerAdminAdress + "/group1/repair_stat"; + Map map = new HashMap(16); + map.put("date",date); + FileServerResultVo fileServerResultVo = postFileManage(requestUrl,map); + return fileServerResultVo; + } + + /** + * 同步失败修复 + * @param force 是否强行修复(0|1) + * @return + */ + @Override + public FileServerResultVo getFileRepair(String force){ + String requestUrl = fileServerAdminAdress + "/group1/repair"; + Map map = new HashMap(16); + map.put("force",force); + FileServerResultVo fileServerResultVo = postFileManage(requestUrl,map); + return fileServerResultVo; + } + +} diff --git a/src/main/java/com/xkrs/service/impl/MerchantSettlementServiceImpl.java b/src/main/java/com/xkrs/service/impl/MerchantSettlementServiceImpl.java new file mode 100644 index 0000000..83c3348 --- /dev/null +++ b/src/main/java/com/xkrs/service/impl/MerchantSettlementServiceImpl.java @@ -0,0 +1,141 @@ +package com.xkrs.service.impl; + +import com.xkrs.common.encapsulation.PromptMessageEnum; +import com.xkrs.dao.BankCardDao; +import com.xkrs.dao.BusinessDao; +import com.xkrs.model.entity.BankCardEntity; +import com.xkrs.model.entity.BusinessEntity; +import com.xkrs.model.qo.BankCardQo; +import com.xkrs.model.qo.BusinessQo; +import com.xkrs.service.MerchantSettlementService; +import com.xkrs.utils.DateTimeUtil; +import com.xkrs.utils.PhotoUtil; +import com.xkrs.utils.VerifyBankCardUtil; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.stereotype.Service; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.IOException; +import java.time.LocalDateTime; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; + +/** + * @Author: XinYi Song + * @Date: 2021/12/14 9:52 + * 商家模块 + */ +@Service +public class MerchantSettlementServiceImpl implements MerchantSettlementService { + + @Resource + private BusinessDao businessDao; + + @Resource + private BankCardDao bankCardDao; + + /** + * 商家入驻 + * @param businessQo + * @param businessPhoto + * @param businessLicense + * @param bankCardQos + * @param + * @return + */ + @Override + public String merchantSettlement(BusinessQo businessQo, MultipartFile businessPhoto, MultipartFile businessLicense, List bankCardQos) throws IOException { + Locale locale = LocaleContextHolder.getLocale(); + BusinessEntity byBusinessName = businessDao.findByBusinessName(businessQo.getBusinessName()); + if(byBusinessName != null){ + return outputEncapsulationObject(PromptMessageEnum.FILE_EXISTS,"您已入驻,请勿重复入驻或提交!",locale); + } + BusinessEntity byBusinessPhone = businessDao.findByBusinessPhone(businessQo.getBusinessPhone()); + if(byBusinessPhone != null){ + return outputEncapsulationObject(PromptMessageEnum.FILE_EXISTS,"您已入驻,请勿重复入驻或提交!",locale); + } + if(businessPhoto == null){ + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"商家图片不能为空!",locale); + } + if(businessLicense == null){ + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"营业执照不能为空!",locale); + } + // 上传商家图片 + //String busPhoto = PhotoUtil.memoryPhoto(businessPhoto); + // 上传商家营业执照 + //String photo = PhotoUtil.memoryPhoto(businessLicense); + for(BankCardQo bankCardQo : bankCardQos){ + Map stringObjectMap = VerifyBankCardUtil.checkBankCar(bankCardQo.getBankCardNumber()); + if(!((Boolean) stringObjectMap.get("card")) || "findNotName".equals(stringObjectMap.get("cardName").toString())){ + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"银行卡信息有误,请检查重新填写!",locale); + } + BankCardEntity bankCardEntity = new BankCardEntity(); + bankCardEntity.setBankCardNumber(bankCardQo.getBankCardNumber()); + bankCardEntity.setAccountBank(bankCardQo.getAccountBank()); + bankCardEntity.setBankName(stringObjectMap.get("cardName").toString()); +// bankCardEntity.setBusinessId(businessId); + bankCardEntity.setBusinessPhone(businessQo.getBusinessPhone()); + bankCardDao.save(bankCardEntity); + } + BusinessEntity businessEntity = new BusinessEntity(); + businessEntity.setBusinessName(businessQo.getBusinessName()); + businessEntity.setBusinessPro(businessQo.getBusinessPro()); + businessEntity.setBusinessCity(businessQo.getBusinessCity()); + businessEntity.setBusinessCountry(businessQo.getBusinessCountry()); + businessEntity.setBusinessAddress(businessQo.getBusinessAddress()); + businessEntity.setBusinessPhone(businessQo.getBusinessPhone()); + businessEntity.setBusinessPhoto(businessQo.getBusinessPhoto()); + businessEntity.setBusinessLicense(businessQo.getBusinessLicense()); + businessEntity.setBusinessDiscount(businessQo.getBusinessDiscount()); + businessEntity.setHeadIdentifier(businessQo.getHeadIdentifier()); + businessEntity.setBusinessType("0"); + businessEntity.setSettleInTime(DateTimeUtil.dateTimeToString(LocalDateTime.now())); + businessDao.save(businessEntity); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"入驻成功!",locale); + } + + /** + * 通过状态查询商家入驻的信息 + * @param type + * @return + */ + @Override + public String findAllByBusinessType(String type) { + Locale locale = LocaleContextHolder.getLocale(); + List allByBusinessType = businessDao.findAllByBusinessType(type); + if(allByBusinessType == null || allByBusinessType.size() == 0){ + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"暂时没有您所需要的商家的信息!",locale); + } + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,allByBusinessType,locale); + } + + /** + * 根据省市区查询审核通过的商家的信息 + * @param countyName + * @param keepType + * @return + */ + @Override + public String findAllByCountyName(String countyName, String keepType) { + return null; + } + + /** + * 根据商家用户id查询入驻信息 + * @param businessId + * @return + */ + @Override + public String findBusinessById(Integer businessId) { + Locale locale = LocaleContextHolder.getLocale(); + BusinessEntity byBusinessId = businessDao.findByBusinessId(businessId); + if(byBusinessId == null){ + return outputEncapsulationObject(PromptMessageEnum.DATA_NONE,"你还未入驻,请先入驻!",locale); + } + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,byBusinessId,locale); + } +} diff --git a/src/main/java/com/xkrs/service/impl/SysAuthorityServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysAuthorityServiceImpl.java new file mode 100644 index 0000000..f63df29 --- /dev/null +++ b/src/main/java/com/xkrs/service/impl/SysAuthorityServiceImpl.java @@ -0,0 +1,29 @@ +package com.xkrs.service.impl; + +import com.xkrs.dao.SysAuthorityDao; +import com.xkrs.model.entity.SysAuthorityEntity; +import com.xkrs.service.SysAuthorityService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 系统权限服务实现 + * @author tajochen + */ +@Service +public class SysAuthorityServiceImpl implements SysAuthorityService { + + Logger logger = LoggerFactory.getLogger(SysAuthorityServiceImpl.class); + + @Resource + private SysAuthorityDao sysAuthorityDao; + + @Override + public List getSysAuthorityListByUserName(String userName) { + return sysAuthorityDao.selectByUserName(userName); + } +} diff --git a/src/main/java/com/xkrs/service/impl/SysRoleServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysRoleServiceImpl.java new file mode 100644 index 0000000..4cb3bd2 --- /dev/null +++ b/src/main/java/com/xkrs/service/impl/SysRoleServiceImpl.java @@ -0,0 +1,29 @@ +package com.xkrs.service.impl; + +import com.xkrs.dao.SysRoleDao; +import com.xkrs.model.entity.SysRoleEntity; +import com.xkrs.service.SysRoleService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * 系统角色服务实现 + * @author tajochen + */ +@Service +public class SysRoleServiceImpl implements SysRoleService { + + Logger logger = LoggerFactory.getLogger(SysRoleServiceImpl.class); + + @Resource + private SysRoleDao sysRoleDao; + + @Override + public List getSysRoleListByUserName(String userName) { + return sysRoleDao.selectByUserName(userName); + } +} diff --git a/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java new file mode 100644 index 0000000..5912e6b --- /dev/null +++ b/src/main/java/com/xkrs/service/impl/SysUserServiceImpl.java @@ -0,0 +1,272 @@ +package com.xkrs.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.xkrs.common.config.RedisUtil; +import com.xkrs.common.encapsulation.PromptMessageEnum; +import com.xkrs.dao.RelRoleAuthorityDao; +import com.xkrs.dao.RelUserRoleDao; +import com.xkrs.dao.SysRoleDao; +import com.xkrs.dao.SysUserDao; +import com.xkrs.model.entity.RelRoleAuthorityEntity; +import com.xkrs.model.entity.RelUserRoleEntity; +import com.xkrs.model.entity.SysRoleEntity; +import com.xkrs.model.entity.SysUserEntity; +import com.xkrs.model.qo.SysUserQo; +import com.xkrs.model.qo.UserUpdate; +import com.xkrs.model.vo.SysUserVo; +import com.xkrs.service.SysUserService; +import com.xkrs.utils.PhotoUtil; +import com.xkrs.utils.RequestUtil; +import org.apache.kafka.common.requests.RequestUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.context.i18n.LocaleContextHolder; +import org.springframework.security.crypto.keygen.KeyGenerators; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.IOException; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; + +import static com.xkrs.common.encapsulation.OutputEncapsulation.outputEncapsulationObject; +import static com.xkrs.utils.DateTimeUtil.getNowTime; +import static com.xkrs.utils.EncryptDecryptUtil.encry256; + +/** + * 系统用户服务实现 + * @author tajochen + */ +@Service +public class SysUserServiceImpl implements SysUserService { + + Logger logger = LoggerFactory.getLogger(SysUserServiceImpl.class); + + @Resource + private SysUserDao sysUserDao; + + @Resource + private SysRoleDao sysRoleDao; + + @Resource + private RelUserRoleDao relUserRoleDao; + + @Resource + private RelRoleAuthorityDao relRoleAuthorityDao; + + @Resource + private RedisUtil redisUtil; + + /** + * 检查用户名是否存在 + * @param userName + * @return + */ + @Override + public boolean checkUserName(String userName) { + int num = sysUserDao.checkUserName(userName); + return (num == 0); + }; + + /** + * 新增用户 + * @param sysUserQo + */ + @Transactional(rollbackFor=Exception.class) + @Override + public void addUser(SysUserQo sysUserQo) { + String salt = KeyGenerators.string().generateKey(); + SysUserEntity sysUserEntity = new SysUserEntity(); + sysUserEntity.setUserName(sysUserQo.getUserName()); + sysUserEntity.setSalt(salt); + sysUserEntity.setPassword(encry256(sysUserQo.getPassword() + salt)); +// sysUserEntity.setTelephone(sysUserQo.getTelephone()); + sysUserEntity.setActiveFlag(0); + sysUserEntity.setStatusCode(0); + sysUserEntity.setAddTime(getNowTime()); + sysUserEntity.setDeleteFlag(0); + int i = (int)(Math.random()*9+1)*100000; + sysUserEntity.setIdentifier(String.valueOf(i)); + sysUserEntity.setIdentity(sysUserQo.getIdentity()); + + sysUserDao.save(sysUserEntity); + + RelUserRoleEntity relUserRoleEntity = new RelUserRoleEntity(); + relUserRoleEntity.setUserId(sysUserEntity.getId().longValue()); + relUserRoleEntity.setRoleId(sysUserQo.getRoleId()); + + RelRoleAuthorityEntity relRoleAuthorityEntity = new RelRoleAuthorityEntity(); + relRoleAuthorityEntity.setRoleId(sysUserQo.getRoleId()); + relRoleAuthorityEntity.setAuthorityId(sysUserQo.getAuthorityId()); + relUserRoleDao.save(relUserRoleEntity); + + relRoleAuthorityDao.save(relRoleAuthorityEntity); + + //sysRoleDao.insertRelUserRole(sysUserEntity.getUserName(),"role_general_user"); + } + + /** + * 查询所有用户Vo + * @return + */ + /*@Transactional(rollbackFor=Exception.class) + @Override + public Iterable getAllSysUser() { + Iterable ls = sysUserDao.selectAllSysUser(); + return ls; + }*/ + + @Transactional(rollbackFor=Exception.class) + @Override + public SysUserEntity getSysUserByUserName(String userName) { + return sysUserDao.selectByUserName(userName); + } + + /** + * 获取用户信息 + * @param userName + * @return + */ + @Transactional(rollbackFor=Exception.class) + @Override + public SysUserVo selectUserByUserName(String userName) { + return sysUserDao.selectUserByUserName(userName); + } + + @Transactional(rollbackFor=Exception.class) + @Override + public int updateSysUserLogin(String userName,String ipAddress) { + return sysUserDao.updateSysUserLogin(userName,ipAddress); + } + + /** + * 更新用户 + * @param sysUserQo + * @return + */ + @Transactional(rollbackFor=Exception.class) + @Override + public int updateSysUser(SysUserQo sysUserQo) { + SysUserEntity sysUserEntity = new SysUserEntity(); + sysUserEntity.setNickName(sysUserQo.getNickName()); + sysUserDao.save(sysUserEntity); + return 1; + } + + /** + * 软删除普通用户 + * @param id + * @return + */ + @Transactional(rollbackFor=Exception.class) + @Override + public int softDeleteGeneralUser(Integer id) { + String adminRole = "role_administor"; + String sysRole ="role_system_manager"; + + List list = sysRoleDao.selectByUserId(id); + if(list.size()>0){ + SysRoleEntity sysRoleEntity = list.get(1); + if(sysRole.equals(sysRoleEntity.getRoleName())||adminRole.equals(sysRoleEntity.getRoleName())){ + sysUserDao.softDeleteGeneralUserById(id); + return 0; + } + } + return 1; + } + + /** + * 用户绑定手机号 + * @param userId + * @param phone + * @return + */ + @Transactional(rollbackFor=Exception.class) + @Override + public String bindPhone(Integer userId, String phone) { + Locale locale = LocaleContextHolder.getLocale(); + SysUserEntity byTelephone = sysUserDao.findByTelephone(phone); + if(byTelephone != null){ + return outputEncapsulationObject(PromptMessageEnum.FILE_EXISTS,"该手机号已用于该平台的绑定!",locale); + } + sysUserDao.updatePhoneByUserId(userId,phone); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"绑定成功!!",locale); + } + + /** + * 手机号登录 + * @param phone + * @param verificationCode + * @return + */ + @Override + public String loginByPhone(String phone, String verificationCode) { + Locale locale = LocaleContextHolder.getLocale(); + SysUserEntity byTelephone = sysUserDao.findByTelephone(phone); + if(byTelephone == null){ + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"您还未绑定手机号!不能使用手机号登录!",locale); + } + String o = (String) redisUtil.get(phone); + if("".equals(o) || o == null){ + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"请先发送验证码!",locale); + } + if(!redisUtil.get(phone).equals(verificationCode)){ + return outputEncapsulationObject(PromptMessageEnum.DATA_WRONG,"验证码错误,请重新输入!",locale); + } + String url = "http://localhost:6809/api/login"; + Map map = new HashMap(3); + map.put("userName",byTelephone.getUserName()); + map.put("password",byTelephone.getPassword()); + String userLogin = RequestUtil.doGet(url, map); + JSONObject jsonObject = JSON.parseObject(userLogin); + JSONObject data = (JSONObject) jsonObject.get("data"); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,data,locale); + } + + /** + * 用户完善个人信息 + * @param files + * @param userUpdate + * @param userId + * @return + */ + @Transactional(rollbackFor=Exception.class) + @Override + public String updateUserByUserId(MultipartFile files, UserUpdate userUpdate, Integer userId) throws IOException { + Locale locale = LocaleContextHolder.getLocale(); + if(files == null){ + String uploadAvatar = ""; + sysUserDao.updateUserByUserId(userId,userUpdate.getNickName(),uploadAvatar,userUpdate.getProvince(),userUpdate.getCity(),userUpdate.getCounty()); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"提交成功!",locale); + } + String memoryPhoto = PhotoUtil.memoryPhoto(files); + sysUserDao.updateUserByUserId(userId,userUpdate.getNickName(),memoryPhoto,userUpdate.getProvince(),userUpdate.getCity(),userUpdate.getCounty()); + return outputEncapsulationObject(PromptMessageEnum.SUCCESS,"提交成功!",locale); + } + + /** + * 启用 + * @param userId + */ + @Transactional(rollbackFor=Exception.class) + @Override + public void updateEnable(Integer userId) { + sysUserDao.updateEnable(userId); + } + + /** + * 禁用 + * @param userId + */ + @Transactional(rollbackFor=Exception.class) + @Override + public void updateDisable(Integer userId) { + sysUserDao.updateDisable(userId); + } + +} diff --git a/src/main/java/com/xkrs/utils/AddressUtils.java b/src/main/java/com/xkrs/utils/AddressUtils.java new file mode 100644 index 0000000..1ec5bf4 --- /dev/null +++ b/src/main/java/com/xkrs/utils/AddressUtils.java @@ -0,0 +1,293 @@ +package com.xkrs.utils; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.http.HttpEntity; +import org.apache.http.HttpStatus; +import org.apache.http.client.ClientProtocolException; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.charset.StandardCharsets; +import java.util.HashMap; +import java.util.Map; + +/** + * 根据经纬度获取地址:省 市 区 位置名称 + * @author XinYi Song + */ +public class AddressUtils { + + /*public static String getLatAndLng(String lat, String lng) { + String key = "O7QBZ-ZYDKI-EMKGN-53UHG-5XSJF-AAFBP"; + try { + String hsUrl = "https://apis.map.qq.com/ws/geocoder/v1/?location=" + lat + "," + lng + "&key=" + key + "&get_poi=1"; + + URL url; + + url = new URL(hsUrl); + HttpsURLConnection con = (HttpsURLConnection) url.openConnection(); + // 提交模式 + con.setRequestMethod("GET"); + X509TrustManager xtm = new X509TrustManager() { + @Override + public X509Certificate[] getAcceptedIssuers() { + // TODO Auto-generated method stub + return null; + } + + @Override + public void checkServerTrusted(X509Certificate[] arg0, String arg1) + throws CertificateException { + // TODO Auto-generated method stub + } + + @Override + public void checkClientTrusted(X509Certificate[] arg0, String arg1) + throws CertificateException { + // TODO Auto-generated method stub + } + }; + + TrustManager[] tm = {xtm}; + + SSLContext ctx = SSLContext.getInstance("TLS"); + ctx.init(null, tm, null); + + con.setSSLSocketFactory(ctx.getSocketFactory()); + con.setHostnameVerifier(new HostnameVerifier() { + @Override + public boolean verify(String arg0, SSLSession arg1) { + return true; + } + }); + + + InputStream inStream = con.getInputStream(); + ByteArrayOutputStream outStream = new ByteArrayOutputStream(); + byte[] buffer = new byte[1024]; + int len = 0; + while ((len = inStream.read(buffer)) != -1) { + outStream.write(buffer, 0, len); + } + //网页的二进制数据 + byte[] b = outStream.toByteArray(); + outStream.close(); + inStream.close(); + String rtn = new String(b, "utf-8"); + if (StringUtils.isNotBlank(rtn)) { + JSONObject object = JSONObject.fromObject(rtn); + if (object != null) { + if (object.has("status") && object.getInt("status") == 0) { + JSONObject result = JSONObject.fromObject(object.get("result")); + if (result != null) { + JSONObject addressComponent = JSONObject.fromObject(result.get("address_component")); + if (addressComponent != null) { + String province = (String) addressComponent.get("province"); + String city = (String) addressComponent.get("city"); + String district = (String) addressComponent.get("district"); + String street = (String) addressComponent.get("street"); + String street_number = (String) addressComponent.get("street_number"); + String address = province + city + district + street + street_number; + return address; + } + } + } + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + }*/ + + private static final Logger log = LoggerFactory.getLogger(AddressUtils.class); + private static final String USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " + + "AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36"; + + /** + * 获取指定经纬度的地理位置 + * @param latitude 纬度 + * @param longitude 经度 + * @return + */ + public static String getLocal(String latitude, String longitude) { + String ok = "ok"; + String msg = "msg"; + String info = getAdd(latitude, longitude); + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = null; + try { + node = mapper.readTree(info); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + assert node != null; + String province = null; + String city = null; + String county = null; + String road = null; + String address = null; + if (ok.equals(node.path(msg).asText())) { + province = node.path("result").path("addressComponent").path("province").asText(); + city = node.path("result").path("addressComponent").path("city").asText(); + county = node.path("result").path("addressComponent").path("county").asText(); + road = node.path("result").path("addressComponent").path("road").asText(); + address = node.path("result").path("addressComponent").path("address").asText(); + } + String fireAddress = province + city + county + road + address; + return fireAddress; + } + /** + * 根据经纬度获取位置信息 + * @param latitude 纬度 + * @param longitude 经度 + * @return + */ + public static String getAdd(String latitude, String longitude) { + // 读取成功标志 + boolean isSuccess = false; + // 重复次数 + int count = 10; + ObjectMapper mapper = new ObjectMapper(); + Map paramMap = new HashMap<>(3); + paramMap.put("lon", longitude); + paramMap.put("lat", latitude); + paramMap.put("ver", "1"); + String paramStr = null; + try { + paramStr = mapper.writeValueAsString(paramMap); + } catch (JsonProcessingException e) { + log.error("转json失败,{}", (Object) e.getStackTrace()); + } + String url = String.format("http://api.tianditu.gov.cn/geocoder?type=geocode&tk=5a1d34815475f88e6d8802da6be832ae&postStr=%s", + paramStr); + // 创建http对象 + RequestConfig defaultRequestConfig = RequestConfig.custom() + .setSocketTimeout(60000).setConnectTimeout(60000) + .setConnectionRequestTimeout(60000) + .build(); + CloseableHttpClient client = HttpClients.custom() + .setDefaultRequestConfig(defaultRequestConfig).build(); + + // 创建并设置URI + URIBuilder uri = null; + // 创建Get请求 + HttpGet get = null; + + try { + URL url1 = new URL(url); + URI uri1 = new URI(url1.getProtocol(), url1.getHost(), url1.getPath(), url1.getQuery(), null); + uri = new URIBuilder(uri1); + get = new HttpGet(uri.build()); + // 设置请求头 + setGet(get); + } catch (URISyntaxException | MalformedURLException e) { + log.info("错误{}", (Object) e.getStackTrace()); + } + //发送请求 + HttpEntity entity = null; + InputStream is = null; + BufferedReader br = null; + // 创建响应对象 + CloseableHttpResponse response = null; + String line; + String sLine = null; + + String json = null; + while (!isSuccess && count > 0) { + try { + response = client.execute(get); + // 获取请求结果 + if (response.getStatusLine().getStatusCode() != HttpStatus.SC_OK) { + log.info("实时定位数据未请求成功"); + count--; + //close(is, br, response, client); + continue; + } + entity = response.getEntity(); + is = entity.getContent(); + br = new BufferedReader( + new InputStreamReader(is, StandardCharsets.UTF_8) + ); + StringBuilder sb = new StringBuilder(); + while ((line = br.readLine()) != null) { + sb.append(line); + } + sLine = sb.toString(); + sLine = sLine.substring(sLine.indexOf("{")); + //使用ObjectMapper对象对 User对象进行转换 + try { + json = mapper.writeValueAsString(sLine); + } catch (JsonProcessingException e) { + log.info("json字符串转化异常{}", (Object) e.getStackTrace()); + } + isSuccess = true; + + } catch (ClientProtocolException e) { + log.info("请求超时等问题:{}", (Object) e.getStackTrace()); + } catch (IOException e) { + log.info("I/O问题:{}", (Object) e.getStackTrace()); + } finally { + close(is, br, response, client); + } + } + return sLine; + } + + private static void close(InputStream is, BufferedReader br, CloseableHttpResponse response, CloseableHttpClient client){ + try { + if (null != is){ + is.close(); + } + if (null != br){ + br.close(); + } + if (null != response){ + response.close(); + } + if (null != client){ + client.close(); + } + } catch (IOException e) { + log.info("IO错误{}", (Object) e.getStackTrace()); + } + } + + private static HttpGet setGet(HttpGet get) { + get.setHeader("Accept" + , "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); + get.setHeader("Accept-Encoding" + , "gzip, deflate"); + get.setHeader("Accept-Language" + , "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7,zh-TW;q=0.6"); + get.setHeader("Connection" + , "keep-alive"); + get.setHeader("Cache-Control" + , "no-cache"); + get.setHeader("Upgrade-Insecure-Requests" + , "1"); + get.setHeader("User-Agent", USER_AGENT); + return get; + } + + public static void main(String[] args) { + String latAndLng = getLocal("36.89", "115.90"); + System.out.println(latAndLng); + } +} diff --git a/src/main/java/com/xkrs/utils/AliYunSmsUtils.java b/src/main/java/com/xkrs/utils/AliYunSmsUtils.java new file mode 100644 index 0000000..7d91942 --- /dev/null +++ b/src/main/java/com/xkrs/utils/AliYunSmsUtils.java @@ -0,0 +1,67 @@ +package com.xkrs.utils; + +import com.aliyuncs.DefaultAcsClient; +import com.aliyuncs.IAcsClient; +import com.aliyuncs.dysmsapi.model.v20170525.SendSmsRequest; +import com.aliyuncs.dysmsapi.model.v20170525.SendSmsResponse; +import com.aliyuncs.exceptions.ClientException; +import com.aliyuncs.profile.DefaultProfile; +import com.aliyuncs.profile.IClientProfile; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * @author Xin + */ +public class AliYunSmsUtils { + public static Logger log = LoggerFactory.getLogger(AliYunSmsUtils.class); + /** + * 产品名称:云通信短信API产品,开发者无需替换 + */ + static final String product = "Dysmsapi"; + /** + * 产品域名,开发者无需替换 + */ + static final String domain = "dysmsapi.aliyuncs.com"; + /** + * TODO 此处需要替换成开发者自己的AK(在阿里云访问控制台寻找) + * TODO 修改成自己的 + */ + static final String accessKeyId = "LTAI5tMSjLfu8Xu2w6WeguFF"; + /** + * TODO 修改成自己的 + */ + static final String accessKeySecret = "hvqM5zpi72hvX4VXM71wq6AE0XYtDI"; + + public static SendSmsResponse sendSms(String telephone, String code) throws ClientException { + //可自助调整超时时间 + System.setProperty("sun.net.client.defaultConnectTimeout", "10000"); + System.setProperty("sun.net.client.defaultReadTimeout", "10000"); + //初始化acsClient,暂不支持region化 + IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret); + DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain); + IAcsClient acsClient = new DefaultAcsClient(profile); + //组装请求对象-具体描述见控制台-文档部分内容 + SendSmsRequest request = new SendSmsRequest(); + //必填:待发送手机号 + request.setPhoneNumbers(telephone); + //必填:短信签名-可在短信控制台中找到 + request.setSignName("青岛星科瑞升"); + //必填:短信模板-可在短信控制台中找到 + request.setTemplateCode("SMS_221082764"); + //可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为 + //如果为发送验证码 无需修改 + request.setTemplateParam("{\"code\":\"" + code + "\"}"); + //选填-上行短信扩展码(无特殊需求用户请忽略此字段) + //request.setSmsUpExtendCode("90997"); + //可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者 + //hint 此处可能会抛出异常,注意catch + SendSmsResponse sendSmsResponse = acsClient.getAcsResponse(request); + if(sendSmsResponse.getCode()!= null && sendSmsResponse.getCode().equals("OK")){ + log.info("------------>短信发送成功!"); + }else { + log.info("------------>短信发送失败!"); + } + return sendSmsResponse; + } +} diff --git a/src/main/java/com/xkrs/utils/BeanUtils.java b/src/main/java/com/xkrs/utils/BeanUtils.java new file mode 100644 index 0000000..67c5ba2 --- /dev/null +++ b/src/main/java/com/xkrs/utils/BeanUtils.java @@ -0,0 +1,73 @@ +package com.xkrs.utils; + +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; +import java.util.function.Supplier; + +/** + * @author xkrs + */ +public class BeanUtils { + + /** + * 缓存BeanCopier 对象 提升性能 + */ + private static final ConcurrentHashMap BEAN_COPIER_MAP = new ConcurrentHashMap<>(); + + + /** + * Bean属性复制工具方法。 + * @param sources 原始集合 + * @param supplier: 目标类::new(eg: UserVO::new) + */ + public static List cgLibCopyList(List sources, Supplier supplier) { + List list = new ArrayList<>(sources.size()); + org.springframework.cglib.beans.BeanCopier beanCopier = null; + for (S source : sources) { + T t = supplier.get(); + if (beanCopier == null) { + beanCopier = getBeanCopier(source.getClass(), t.getClass()); + } + beanCopier.copy(source, t, null); + list.add(t); + } + return list; + } + + /** + * Bean属性复制工具方法。 + * @param source 目标对象 + * @param supplier: 目标类::new(eg: UserVO::new) + */ + public static T cgLibCopyBean(Object source, Supplier supplier) { + T t = supplier.get(); + getBeanCopier(source.getClass(), t.getClass()).copy(source, t, null); + return t; + } + + + /** + * 获取BeanCopier对象 如果缓存中有从缓存中获取 如果没有则新创建对象并加入缓存 + * @param sourceClass + * @param targetClass + * @return + */ + private static org.springframework.cglib.beans.BeanCopier getBeanCopier(Class sourceClass, Class targetClass) { + String key = getKey(sourceClass.getName(), targetClass.getName()); + org.springframework.cglib.beans.BeanCopier beanCopier; + beanCopier = BEAN_COPIER_MAP.get(key); + if (beanCopier == null) { + beanCopier = org.springframework.cglib.beans.BeanCopier.create(sourceClass, targetClass, false); + BEAN_COPIER_MAP.put(key, beanCopier); + } + return beanCopier; + } + + /** + * 生成缓存key + */ + private static String getKey(String sourceClassName, String targetClassName) { + return sourceClassName + targetClassName; + } +} diff --git a/src/main/java/com/xkrs/utils/CommonConstant.java b/src/main/java/com/xkrs/utils/CommonConstant.java new file mode 100644 index 0000000..19933c7 --- /dev/null +++ b/src/main/java/com/xkrs/utils/CommonConstant.java @@ -0,0 +1,177 @@ +package com.xkrs.utils; + +/** + * @author XinYi Song + */ +public interface CommonConstant { + + /** + * 正常状态 + */ + public static final String STATUS_NORMAL = "0"; + + /** + * 禁用状态 + */ + public static final String STATUS_DISABLE = "1"; + + /** + * 删除标志 + */ + public static final String DEL_FLAG_1 = "1"; + + /** + * 未删除 + */ + public static final String DEL_FLAG_0 = "0"; + + /** + * 系统日志类型: 登录 + */ + public static final int LOG_TYPE_1 = 1; + + /** + * 系统日志类型: 操作 + */ + public static final int LOG_TYPE_2 = 2; + + /** + * 操作日志类型: 查询 + */ + public static final int OPERATE_TYPE_1 = 1; + + /** + * 操作日志类型: 添加 + */ + public static final int OPERATE_TYPE_2 = 2; + + /** + * 操作日志类型: 更新 + */ + public static final int OPERATE_TYPE_3 = 3; + + /** + * 操作日志类型: 删除 + */ + public static final int OPERATE_TYPE_4 = 4; + + /** + * 操作日志类型: 倒入 + */ + public static final int OPERATE_TYPE_5 = 5; + + /** + * 操作日志类型: 导出 + */ + public static final int OPERATE_TYPE_6 = 6; + + + /** {@code 500 Server Error} (HTTP/1.0 - RFC 1945) */ + public static final Integer SC_INTERNAL_SERVER_ERROR_500 = 500; + public static final Integer SC_INTERNAL_SERVER_ERROR_501 = 501; + public static final Integer SC_INTERNAL_SERVER_ERROR_502 = 502; + /** {@code 200 OK} (HTTP/1.0 - RFC 1945) */ + public static final Integer SC_OK_200 = 200; + public static final Integer SC_OK_201 = 201; + public static final Integer SC_OK_202 = 202; + + public static final Integer SC_OK_300 = 300; + public static final Integer SC_OK_301 = 301; + /**访问权限认证未通过 510*/ + public static final Integer SC_JEECG_NO_AUTHZ=510; + + /** 登录用户Shiro权限缓存KEY前缀 */ + public static String PREFIX_USER_SHIRO_CACHE = "shiro:cache:org.jeecg.modules.shiro.authc.ShiroRealm.authorizationCache:"; + /** 登录用户Token令牌缓存KEY前缀 */ + public static final String PREFIX_USER_TOKEN = "prefix_user_token_"; + /** Token缓存时间:3600秒即一小时 */ + public static final int TOKEN_EXPIRE_TIME = 3600; + + + /** + * 0:一级菜单 + */ + public static final Integer MENU_TYPE_0 = 0; + /** + * 1:子菜单 + */ + public static final Integer MENU_TYPE_1 = 1; + /** + * 2:按钮权限 + */ + public static final Integer MENU_TYPE_2 = 2; + + /**通告对象类型(USER:指定用户,ALL:全体用户)*/ + public static final String MSG_TYPE_UESR = "USER"; + public static final String MSG_TYPE_ALL = "ALL"; + + /**发布状态(0未发布,1已发布,2已撤销)*/ + public static final String NO_SEND = "0"; + public static final String HAS_SEND = "1"; + public static final String HAS_CANCLE = "2"; + + /**阅读状态(0未读,1已读)*/ + public static final String HAS_READ_FLAG = "1"; + public static final String NO_READ_FLAG = "0"; + + /**优先级(L低,M中,H高)*/ + public static final String PRIORITY_L = "L"; + public static final String PRIORITY_M = "M"; + public static final String PRIORITY_H = "H"; + + /** + * 短信模板方式 0 .登录模板、1.注册模板、2.忘记密码模板 + * 3 信息变更 + */ + public static final String SMS_TPL_TYPE_0 = "0"; + public static final String SMS_TPL_TYPE_1 = "1"; + public static final String SMS_TPL_TYPE_2 = "2"; + public static final String SMS_TPL_TYPE_3 = "3"; + /** + * 状态(0无效1有效) + */ + public static final String STATUS_0 = "0"; + public static final String STATUS_1 = "1"; + + /** + * 同步工作流引擎1同步0不同步 + */ + public static final Integer ACT_SYNC_1 = 1; + public static final Integer ACT_SYNC_0 = 0; + + /** + * 消息类型1:通知公告2:系统消息 + */ + public static final String MSG_CATEGORY_1 = "1"; + public static final String MSG_CATEGORY_2 = "2"; + + /** + * 是否配置菜单的数据权限 1是0否 + */ + public static final Integer RULE_FLAG_0 = 0; + public static final Integer RULE_FLAG_1 = 1; + + /** + * 是否用户已被冻结 1正常(解冻) 2冻结 + */ + public static final String USER_UNFREEZE = "1"; + public static final String USER_FREEZE = "2"; + + /** + * 文件上传类型(本地:local,Minio:minio,阿里云:alioss) + */ + public static final String UPLOAD_TYPE_LOCAL = "local"; + public static final String UPLOAD_TYPE_MINIO = "minio"; + public static final String UPLOAD_TYPE_OSS = "alioss"; + + + /** + * 收入明细 (1:收入 2:支出) + */ + public static final Integer USER_IDENTITY_1 = 1; + public static final Integer USER_IDENTITY_2 = 2; + + + + +} diff --git a/src/main/java/com/xkrs/utils/CopyPropertiesUtil.java b/src/main/java/com/xkrs/utils/CopyPropertiesUtil.java new file mode 100644 index 0000000..03155f8 --- /dev/null +++ b/src/main/java/com/xkrs/utils/CopyPropertiesUtil.java @@ -0,0 +1,54 @@ +package com.xkrs.utils; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; + +/** + * 复制源对象的属性值 + * @Author tajochen + */ +public class CopyPropertiesUtil { + + /** + * 复制源对象和目标对象的属性值 + * @param source 源对象 + * @param target 目标对象 + * @throws SecurityException + * @throws IllegalArgumentException + */ + public static void copy(Object source, Object target) { + //得到对象的Class + Class sourceClass = source.getClass(); + Class targetClass = target.getClass(); + //得到Class对象的所有属性 + Field[] sourceFields = sourceClass.getDeclaredFields(); + Field[] targetFields = targetClass.getDeclaredFields(); + + for(Field sourceField : sourceFields){ + //属性名 + String name = sourceField.getName(); + //属性类型 + Class type = sourceField.getType(); + String methodName = name.substring(0, 1).toUpperCase() + name.substring(1); + try{ + //得到属性对应get方法 + Method getMethod = sourceClass.getMethod("get" + methodName); + //执行源对象的get方法得到属性值 + Object value = getMethod.invoke(source); + //目标对象的属性名 + for(Field targetField : targetFields){ + String targetName = targetField.getName(); + if(targetName.equals(name)){ + //属性对应的set方法 + Method setMethod = targetClass.getMethod("set" + methodName, type); + //执行目标对象的set方法 + setMethod.invoke(target, value); + } + } + } + catch (Exception e){ + e.printStackTrace(); + } + } + } +} diff --git a/src/main/java/com/xkrs/utils/DateTimeUtil.java b/src/main/java/com/xkrs/utils/DateTimeUtil.java new file mode 100644 index 0000000..f8e2e56 --- /dev/null +++ b/src/main/java/com/xkrs/utils/DateTimeUtil.java @@ -0,0 +1,231 @@ +package com.xkrs.utils; + +import java.time.Instant; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.ZoneOffset; +import java.time.format.DateTimeFormatter; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 日期时间工具 + * @author tajochen + */ +public class DateTimeUtil { + + private final static String COMMON_PATTERN_DATETIME = "yyyy-MM-dd HH:mm:ss"; + private final static String COMMON_PATTERN_DATE = "yyyy-MM-dd"; + private final static DateTimeFormatter COMMON_FORMATTER_DATETIME = DateTimeFormatter.ofPattern(COMMON_PATTERN_DATETIME); + private final static DateTimeFormatter COMMON_FORMATTER_DATE = DateTimeFormatter.ofPattern(COMMON_PATTERN_DATE); + private final static ZoneOffset DEFAULT_ZONE_OFFSET = ZoneOffset.of("+8"); + + /** + * 字符串转LocalDate + * @param date + * @return + */ + public static LocalDate stringToDate(String date) { + assert date != null; + return LocalDate.parse(date, COMMON_FORMATTER_DATE); + } + + /** + * LocalDate转字符串 + * @param date + * @return + */ + public static String dateToString(LocalDate date) { + assert date != null; + return COMMON_FORMATTER_DATE.format(date); + } + + /** + * LocalDateTime转字符串 + * @param dateTime + * @return + */ + public static String dateTimeToString(LocalDateTime dateTime) { + assert dateTime != null; + return COMMON_FORMATTER_DATETIME.format(dateTime); + } + + /** + * 字符串转LocalDateTime + * @param dateStr + * @return + */ + public static LocalDateTime stringToDateTime(String dateStr) { + assert dateStr != null; + return LocalDateTime.parse(dateStr, COMMON_FORMATTER_DATETIME); + } + + /** + * 字符串转Instant时间戳 + * @param str + * @return + */ + public static Instant stringToInstant(String str) { + assert str != null; + return stringToDateTime(str).toInstant(DEFAULT_ZONE_OFFSET); + } + + /** + * LocalDateTime转字符串(格式化) + * @param dateTime + * @param formatter + * @return + */ + public static String dateToStringFormatter(LocalDateTime dateTime, DateTimeFormatter formatter) { + assert dateTime != null; + return formatter.format(dateTime); + } + + /** + * 字符串转LocalDateTime(格式化) + * @param dateStr + * @param formatter + * @return + */ + public static LocalDateTime stringToDateTimeFormatter(String dateStr, DateTimeFormatter formatter) { + assert dateStr != null; + return LocalDateTime.parse(dateStr, formatter); + } + + /** + * 字符串转 local date + * @param dateStr + * @return + */ + public static LocalDate stringToDateFormatter(String dateStr){ + LocalDate date = LocalDate.parse(dateStr, COMMON_FORMATTER_DATE); + return date; + } + + + /** + * 日期转时间戳 + * @param dateTime + * @return + */ + public static long dateToTimeMillis(LocalDateTime dateTime) { + assert dateTime != null; + return dateTime.toInstant(DEFAULT_ZONE_OFFSET).toEpochMilli(); + } + + /** + * 时间戳转日期 + * @param timeMillis + * @return + */ + public static LocalDateTime timeMillisToDate(long timeMillis) { + Instant instant = Instant.ofEpochMilli(timeMillis); + return LocalDateTime.ofInstant(instant, DEFAULT_ZONE_OFFSET); + } + + /** + * 时间戳转时间 + * @param timeMillis + * @return + */ + public static LocalDateTime timeMillisToTime(long timeMillis) { + LocalDateTime localDateTime = LocalDateTime.ofEpochSecond(timeMillis, 0, ZoneOffset.ofHours(8)); + return localDateTime; + } + + /** + * 时间戳转时间再转字符串 + * @param timeMillis + * @return + */ + public static String timeMillisToString(long timeMillis){ + LocalDateTime localDateTime = LocalDateTime.ofEpochSecond(timeMillis, 0, ZoneOffset.ofHours(8)); + return COMMON_FORMATTER_DATETIME.format(localDateTime); + } + + /** + * 获取当前时间 hh:mm:ss:nnn + * @return + */ + public static LocalDateTime getNowTime() { + LocalDateTime now = LocalDateTime.now(); + return now; + } + + /** + * 获取当前日期 yyyy-MM-dd + * @return + */ + public static LocalDate getToday() { + LocalDate now = LocalDate.now(); + return now; + } + + /** + * 获取当前 Instant 时间戳 + * @return + */ + public static Instant getInstant() { + Instant timeStamp = Instant.now(); + return timeStamp; + } + + /** + * 获取当前时间 yyyy-MM-ss hh:mm:ss + * @return + */ + public static String getNowTimeStr(){ + return COMMON_FORMATTER_DATETIME.format(getNowTime()); + } + + /** + * 判断日期格式是否合法 "yyyy-MM-dd" + * @param strDate + * @return + */ + public static boolean isValidDate(String strDate) { + final int minLen = 10; + if(strDate == null || strDate.length() < minLen) { + return false; + } + //正则表达式校验日期格式 yyyy-MM-dd + String eL = "(([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))-02-29)(([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))-02-29)"; + Pattern pat = Pattern.compile(eL); + Matcher matcher = pat.matcher(strDate); + return matcher.matches(); + } + + /** + * 判断时间格式 格式必须为 "YYYY-MM-DD HH:mm:ss" + * @param sDateTime + * @return + */ + public static boolean isValidDateTime(String sDateTime) { + final int minLen = 19; + if ((sDateTime == null) || (sDateTime.length() < minLen)) { + return false; + } + String eL = "(((01[0-9]{2}|0[2-9][0-9]{2}|[1-9][0-9]{3})-(0?[13578]|1[02])-" + + "(0?[1-9]|[12]\\\\d|3[01]))|((01[0-9]{2}|0[2-9][0-9]{2}|[1-9][0-9]{3})-" + + "(0?[13456789]|1[012])-(0?[1-9]|[12]\\\\d|30))|((01[0-9]{2}|0[2-9][0-9]{2}|[1-9][0-9]{3})-0?2-" + + "(0?[1-9]|1\\\\d|2[0-8]))|(((1[6-9]|[2-9]\\\\d)(0[48]|[2468][048]|[13579][26])|((04|08|12|16|[2468][048]|" + + "[3579][26])00))-0?2-29)) (20|21|22|23|[0-1]?\\\\d):[0-5]?\\\\d:[0-5]?\\\\d"; + Pattern pat = Pattern.compile(eL); + Matcher matcher = pat.matcher(sDateTime); + return matcher.matches(); + } + + public static void main(String[] args) { + LocalDate now = LocalDate.now(); + LocalDate localDate = now.plusDays(1); + String s = dateToString(localDate); + LocalDate localDate1 = stringToDate(s); + System.out.println(localDate1); + } + +} diff --git a/src/main/java/com/xkrs/utils/EncryptDecryptUtil.java b/src/main/java/com/xkrs/utils/EncryptDecryptUtil.java new file mode 100644 index 0000000..7ef363e --- /dev/null +++ b/src/main/java/com/xkrs/utils/EncryptDecryptUtil.java @@ -0,0 +1,66 @@ +package com.xkrs.utils; + +import java.security.MessageDigest; +import java.security.NoSuchAlgorithmException; + +/** + * SHA加密解密工具 + * @author tajochen + */ +public class EncryptDecryptUtil { + + /** + * SHA-256加密 + * @param strText + * @return + */ + public static String encry256(final String strText){ + return encrySha(strText,"SHA-256"); + } + + /** + * SHA-512加密 + * @param strText + * @return + */ + public static String encry512(final String strText){ + return encrySha(strText,"SHA-512"); + } + + /** + * 基础SHA加密 + * @param strText + * @param strType + * @return + */ + private static String encrySha(final String strText, final String strType){ + // 返回值 + String strResult=null; + // 是否是有效的字符串 + if (strText != null && strText.length()>0){ + // 加密开始,创建加密对象,并传入加密类型 + try { + MessageDigest messageDigest = MessageDigest.getInstance(strType); + // 传入加密的字符串 + messageDigest.update(strText.getBytes()); + // 得到bytes类型结果 + byte[] byteBuffer = messageDigest.digest(); + StringBuilder strHexString = new StringBuilder(); + for (byte b : byteBuffer) { + String hex = Integer.toHexString(0xff & b); + if (hex.length() == 1) { + strHexString.append('0'); + } + strHexString.append(hex); + } + // 得到返回的结果 + strResult = strHexString.toString(); + } + catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + } + return strResult; + } +} + diff --git a/src/main/java/com/xkrs/utils/EntityManagerUtil.java b/src/main/java/com/xkrs/utils/EntityManagerUtil.java new file mode 100644 index 0000000..ac1ede1 --- /dev/null +++ b/src/main/java/com/xkrs/utils/EntityManagerUtil.java @@ -0,0 +1,36 @@ +package com.xkrs.utils; + +import java.lang.reflect.Constructor; +import java.util.ArrayList; +import java.util.List; + +/** + * @author XinYi Song + */ +public class EntityManagerUtil { + /** + * 把List转换成List + */ + public static List objectToBean(List objList, Class clz) throws Exception{ + if (objList==null || objList.size()==0) { + return null; + } + + Class[] cz = null; + Constructor[] cons = clz.getConstructors(); + for (Constructor ct : cons) { + Class[] clazz = ct.getParameterTypes(); + if (objList.get(0).length == clazz.length) { + cz = clazz; + break; + } + } + + List list = new ArrayList(); + for (Object[] obj : objList) { + Constructor cr = clz.getConstructor(cz); + list.add(cr.newInstance(obj)); + } + return list; + } +} diff --git a/src/main/java/com/xkrs/utils/ExcelImportUtil.java b/src/main/java/com/xkrs/utils/ExcelImportUtil.java new file mode 100644 index 0000000..8788901 --- /dev/null +++ b/src/main/java/com/xkrs/utils/ExcelImportUtil.java @@ -0,0 +1,193 @@ +package com.xkrs.utils; + +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.ss.usermodel.*; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.springframework.web.multipart.MultipartFile; + +import java.io.InputStream; +import java.text.DecimalFormat; +import java.text.SimpleDateFormat; +import java.util.*; + +/** + * @author ZHY + * @date 2020/6/17 15:56 + */ +public class ExcelImportUtil { + private Workbook wb; + private Sheet sheet; + private Row row; + + String xls = ".xls"; + String xlsx = ".xlsx"; + + /** + * 读取Excel + * + * @author ZHY + */ + public ExcelImportUtil(MultipartFile file) throws Exception { + String filename = file.getOriginalFilename(); + String ext = filename.substring(filename.lastIndexOf(".")); + InputStream is = file.getInputStream(); + if (xls.equals(ext)) { + wb = new HSSFWorkbook(is); + } else if (xlsx.equals(ext)) { + wb = new XSSFWorkbook(is); + } else { + wb = null; + } + } + + /** + * 读取Excel表格表头的内容输出 + * + */ + public List> readExcelTitleOut() { + List> list = new ArrayList>(); + if (wb != null) { + sheet = wb.getSheetAt(0); + row = sheet.getRow(0); + // 标题总列数 + int colNum = row.getPhysicalNumberOfCells(); + + System.out.println("colNum:" + colNum); + + Map map = new LinkedHashMap(); + + for (int i = 0; i < colNum; i++) { + String stringCellValue = row.getCell(i).getStringCellValue(); + map.put(stringCellValue, null); + } + list.add(map); + return list; + } + return list; + } + + /** + * 读取Excel表格表头 + * + */ + public String[] readExcelTitle() { + String[] title = {}; + if (wb != null) { + sheet = wb.getSheetAt(0); + row = sheet.getRow(0); + // 标题总列数 + int colNum = row.getPhysicalNumberOfCells(); + + System.out.println("colNum:" + colNum); + + title = new String[colNum]; + + for (int i = 0; i < colNum; i++) { + Cell cell = row.getCell(i); + title[i] = cell.getStringCellValue().replaceAll("\\s+", ""); + } + } + return title; + } + + /** + * 读取Excel表格的某一个数值 + * @return + */ + public Map readExcelSomeTitle(){ + Map map = new LinkedHashMap<>(); + if (wb != null) { + sheet = wb.getSheetAt(0); + String title = parseExcel(sheet.getRow(2).getCell(1)); + String remark = parseExcel(sheet.getRow(3).getCell(1)); + map.put("date",title); + map.put("remark",remark); + } + return map; + } + + /** + * 读取Excel数据内容 + * + */ + public List> readExcelContent() { + List> list = new ArrayList<>(); + if (wb != null) { + //获取sheet表 + sheet = wb.getSheetAt(0); + // 得到总行数 + int rowNum = sheet.getLastRowNum(); + //获取表头的标题 + String[] readExcelTitle = readExcelTitle(); + // 正文内容应该从第二行开始,第一行为表头的标题 + for (int i = 1; i <= rowNum; i++) { + row = sheet.getRow(i); + if (row == null) { + continue; + } + Map map = new LinkedHashMap<>(); + for (int j = 0; j < readExcelTitle.length; j++) { + //获取每一列的数据值 + String str = parseExcel(row.getCell(j)); + //判断对应行的列值是否为空 + if (str != null || "".equals(str)) { + //表头的标题为键值,列值为值 + map.put(readExcelTitle[j], str); + } + } + //判段添加的对象是否为空 + if (!map.isEmpty()){ + list.add(map); + } + } + } + return list; + } + + /** + * + * 根据Cell类型设置数据 + * + */ + int ss = 20; + int xx = 58; + private String parseExcel(Cell cell) { + String result = ""; + if (cell != null) { + SimpleDateFormat sdf = null; + switch (cell.getCellType()) { + // 数字类型 + case NUMERIC: + // 处理日期格式、时间格式 + if (DateUtil.isCellDateFormatted(cell)) { + if (cell.getCellStyle().getDataFormat() == ss) { + sdf = new SimpleDateFormat("HH:mm"); + } else {// 日期 + sdf = new SimpleDateFormat("yyyy-MM-dd"); + } + String dateFormat = sdf.format(cell.getDateCellValue()); + result = dateFormat; + } else if (cell.getCellStyle().getDataFormat() == xx) { + // 处理自定义日期格式:m月d日(通过判断单元格的格式id解决,id的值是58) + sdf = new SimpleDateFormat("yyyy-MM-dd"); + double value = cell.getNumericCellValue(); + Date date = DateUtil.getJavaDate(value); + result = sdf.format(date); + } else { + double value = cell.getNumericCellValue(); + DecimalFormat format = new DecimalFormat("#.###########"); + String strVal = format.format(value); + result = strVal; + } + break; + // String类型 + case STRING: + result = cell.getRichStringCellValue().toString(); + break; + default: + break; + } + } + return result; + } +} diff --git a/src/main/java/com/xkrs/utils/FileFastDfs.java b/src/main/java/com/xkrs/utils/FileFastDfs.java new file mode 100644 index 0000000..2ec28d9 --- /dev/null +++ b/src/main/java/com/xkrs/utils/FileFastDfs.java @@ -0,0 +1,477 @@ +package com.xkrs.utils; + +import cn.hutool.core.io.resource.InputStreamResource; +import cn.hutool.core.thread.ThreadUtil; +import cn.hutool.core.util.StrUtil; +import cn.hutool.http.HttpUtil; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import io.tus.java.client.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.stereotype.Component; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.*; +import java.net.URL; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.Base64; +import java.util.HashMap; +import java.util.Objects; + +/** + * @author dong + * @date 2020/12/31 + */ +@Component +public class FileFastDfs { + + @Value("${dfs.ip}") + public String ip; + @Value("${dfs.port}") + public String port; + +// @Value("${dfs.upload}") +// public String upload; +// +// @Value("${dfs.delete}") +// public String delete; + + @Resource + private KafkaTemplate kafkaTemplate; + private static final Logger log = LoggerFactory.getLogger(FileFastDfs.class); + private static final String STATUS = "status"; + private static final String UPLOAD_BIG_PATH = "http://192.168.2.166:2001/group1/big/upload"; + private static final String UPLOAD_PATH = "http://192.168.2.166:2001/group1/upload"; + + /** + * 文件上传到dfs服务器 + * @param file + * @param dir + * @return + */ + public String uploadFile(MultipartFile file, String dir) { + File file1 = null; + InputStreamResource isr = null; + try { + file1 = multipartFileToFile(file); + isr=new InputStreamResource(file.getInputStream(), + file.getOriginalFilename()); + } catch (IOException e) { + log.info("IO错误{}", (Object) e.getStackTrace()); + } catch (Exception e) { + e.printStackTrace(); + } + //文件地址 + //声明参数集合 + HashMap paramMap = new HashMap<>(7); + //文件 + paramMap.put("file", isr); + //输出 + paramMap.put("output", "json"); + //自定义路径 + paramMap.put("path", dir); + //场景 文件分类 + if (null == file1) { + return null; + } + String name = file1.getName(); + System.err.println("file:" + file1.getName()); + paramMap.put("scene", name.substring(name.lastIndexOf(".") + 1)); + paramMap.put("fileName", System.currentTimeMillis() + "" + + Objects.requireNonNull(file.getOriginalFilename()) + .substring(file.getOriginalFilename().lastIndexOf("."))); + System.err.println(paramMap); + // + String result = HttpUtil.post("http://" + ip + ":" + port + "/group1/upload", paramMap); + System.err.println(result); + + // 拿出状态码,判断上传状态 + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = null; + try { + node = mapper.readTree(result); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + final String fail = "fail"; + if (null != node) { + if (fail.equals(node.path(STATUS).asText())) { + return null; + } + } + return result; + } + + /** + * @description: 文件上传到dfs服务器 + * @params [file:File 文件, dir 文件存放路径] + * @author: wd + * @time: 2020/3/31 2020/3/31 + */ + public String uploadFile(File file, String dir) { + //文件地址 + //声明参数集合 + HashMap paramMap = new HashMap<>(7); + //文件 + paramMap.put("file", file); + //输出 + paramMap.put("output", "json"); + //自定义路径 + paramMap.put("path", dir); + //场景 +// System.err.println(file.getName()); + + // paramMap.put("fileName", System.currentTimeMillis() + "" + file.getName().substring(file.getName().lastIndexOf("."))); + paramMap.put("fileName", file.getName()); + System.err.println(paramMap); + //上传 + String result = HttpUtil.post("http://" + ip + ":" + port + "/group1/upload", paramMap); + System.err.println(result); + // 拿出状态码,判断上传状态 + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = null; + try { + node = mapper.readTree(result); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + final String status = "status"; + final String statusFail = "fail"; + if (null != node) { + if (statusFail.equals(node.path(status).asText())) { + return null; + } + } + return result; + } + + /** + * @description: 文件上传到dfs服务器 + * @params [file:File 文件, dir 文件存放路径] + * @author: wd + * @time: 2020/3/31 2020/3/31 + */ + public String uploadFile(File file, String dir, String fileType) { + //文件地址 + //声明参数集合 + HashMap paramMap = new HashMap<>(7); + //文件 + paramMap.put("file", file); + //输出 + paramMap.put("output", "json"); + //自定义路径 + paramMap.put("path", dir); + //场景 + System.err.println(file.getName()); + + // paramMap.put("fileName", System.currentTimeMillis() + "" + file.getName().substring(file.getName().lastIndexOf("."))); + paramMap.put("fileName", file.getName()); + paramMap.put("scene", fileType); + System.err.println(paramMap); + //上传 + String result = HttpUtil.post("http://" + ip + ":" + port + "/group1/upload", paramMap); + System.err.println(result); + // 拿出状态码,判断上传状态 + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = null; + try { + node = mapper.readTree(result); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + final String status = "status"; + final String statusFail = "fail"; + if (null != node) { + if (statusFail.equals(node.path(status).asText())) { + return null; + } + } + return result; + } + + public String uploadBigFile(File file, String dir, String fileType) { + // 下面这个一定要注意,如果不设置为true,将会直接返回301 + System.setProperty("http.strictPostRedirect", Boolean.toString(true)); + TusClient tusClient = new TusClient(); + try { + tusClient.setUploadCreationURL(new URL(UPLOAD_BIG_PATH)); + +// tusClient.enableResuming(new TusRedisUrlStrore()); + tusClient.enableResuming(new TusURLMemoryStore()); + + final TusUpload upload = new TusUpload(file); + System.out.println("start upload......"); + TusExecutor executor = new TusExecutor() { + @Override + protected void makeAttempt() throws ProtocolException, IOException { + TusUploader uploader = tusClient.resumeOrCreateUpload(upload); + uploader.setChunkSize(1024 * 1024); + + long start = System.currentTimeMillis(); + do { + long totalBytes = upload.getSize(); + long bytesUploaded = uploader.getOffset(); + double progress = (double) bytesUploaded / totalBytes * 100; + + System.out.printf("Upload at %06.2f%%.\n", progress); + } while (uploader.uploadChunk() > -1); + + uploader.finish(); + + String uploadUrl = uploader.getUploadURL().toString(); + System.out.println("Upload finished."); + System.out.format("Upload available at: %s\n", uploadUrl); + + long end = System.currentTimeMillis(); + + System.out.println((end - start) + "ms"); + // 使用hutool进行秒传置换url + String fileId = StrUtil.subAfter(uploadUrl, UPLOAD_BIG_PATH + "/", true); + System.out.println("fileId: " + fileId); + String url = StrUtil.format("{}?md5={}&output=json", UPLOAD_PATH, fileId); + System.out.println("url: " + url); + // 上传大文件的时候(1.xG)需要sleep一下,要不然会有问题 + ThreadUtil.sleep(5000); + String result = HttpUtil.get(url); + } + }; + executor.makeAttempts(); + } catch (IOException | ProtocolException e) { + e.printStackTrace(); + } + return null; + } + + /** + * @description: 文件base64流获取 + * @params [fileName : 文件路径] + * @return: java.lang.String + * @author: chqf + * @time: 2020/3/31 2020/3/31 + */ + public String getBase64(String fileName) { + if (fileName == null || "".equals(fileName)) { + return null; + } + InputStream fis = null; + URL url = null; + try { + url = new URL("http://" + ip + ":" + port + "/" + URLEncoder.encode(fileName, StandardCharsets.UTF_8)); + System.err.println(url); + fis = url.openStream(); + } catch (IOException e) { + log.info("IO错误{}", (Object) e.getStackTrace()); + } + final ByteArrayOutputStream data = new ByteArrayOutputStream(); + String imgStr = ""; + try { + if (fis == null) { + return null; + } + int len = -1; + byte[] buf = new byte[2048]; + while (-1 != (len = fis.read(buf, 0, buf.length))) { + data.write(buf, 0, len); + } + Base64.Encoder encoder = Base64.getEncoder(); + imgStr = encoder.encodeToString(data.toByteArray()); + } catch (IOException e) { + log.info("IO错误{}", (Object) e.getStackTrace()); + }finally { + try { + if (null != fis) { + fis.close(); + } + data.close(); + } catch (IOException e) { + log.info("IO错误{}", (Object) e.getStackTrace()); + } + } + + return "data:image/jpeg;base64," + imgStr; + } + + /** + * @description: 文件格式转换multipartFil 转为 File 格式 + * @params [file] + * @return: java.io.File + * @author: dong + * @time: 2020/3/31 2020/3/31 + */ + public File multipartFileToFile(MultipartFile file) throws Exception { + + File toFile = null; + if ("".equals(file) || file.getSize() <= 0) { + file = null; + } else { + InputStream ins; + ins = file.getInputStream(); + toFile = new File(Objects.requireNonNull(file.getOriginalFilename())); + inputStreamToFile(ins, toFile); + ins.close(); + } + return toFile; + } + + private static void inputStreamToFile(InputStream ins, File file) { + OutputStream os = null; + try { + os = new FileOutputStream(file); + int bytesRead = 0; + byte[] buffer = new byte[8192]; + while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) { + os.write(buffer, 0, bytesRead); + } + } catch (IOException e) { + log.info("IO错误{}", (Object) e.getStackTrace()); + }finally { + try { + if (null != os) { + os.close(); + } + if (null != ins) { + ins.close(); + } + } catch (IOException e) { + log.info("IO错误{}", (Object) e.getStackTrace()); + } + } + } + + /** + * @description: 文件base64流获取 + * @params [fileName : 文件路径] + * @return: java.lang.String + * @author: dong + * @time: 2020/3/31 2020/3/31 + */ + public Boolean getFile(String fileName, HttpServletResponse response) { + if (fileName == null || "".equals(fileName)) { + return null; + } + InputStream fis = null; + URL url = null; + try { + url = new URL("http://" + ip + ":" + port + "/" + URLEncoder.encode(fileName, StandardCharsets.UTF_8)); + System.err.println(url); + fis = url.openStream(); + response.reset(); + response.setContentType("bin"); + response.addHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\""); + } catch (IOException e) { + log.info("IO错误{}", (Object) e.getStackTrace()); + } + // + byte[] b = new byte[256]; + int len; + try { + assert fis != null; + while ((len = fis.read(b)) > 0){ + response.getOutputStream().write(b, 0, len); + } + } catch (IOException e) { + log.info("IO错误{}", (Object) e.getStackTrace()); + }finally { + try { + if (null != fis) { + fis.close(); + } + } catch (IOException e) { + log.info("IO错误{}", (Object) e.getStackTrace()); + } + } + return true; + } + + /** + * 删除文件 path + * @param filePath 文件路径 上传返回的path + * @return + */ + public Boolean deleteFileByPath(String filePath) { + if (filePath == null || "".equals(filePath)) { + return false; + } + HashMap paramMap = new HashMap<>(1); + // 参数 + paramMap.put("path", filePath); + + String result = HttpUtil.post("http://" + ip + ":" + port + "/group1/delete", paramMap); + System.out.println(result); + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = null; + try { + node = mapper.readTree(result); + } catch (JsonProcessingException e) { + + e.printStackTrace(); + } + + final String statusOk = "ok"; + + if (null == node) { + log.error("返回结果为空"); + return false; + } + if (!statusOk.equals(node.path(STATUS).asText())) { + log.error("未删除成功"); + return false; + } + return true; + } + + /** + * 删除文件 path + * @param md5 上传返回的md5 + * @return + */ + public Boolean deleteFileByMd5(String md5) { + if (md5 == null || "".equals(md5)) { + return false; + } + HashMap paramMap = new HashMap<>(1); + // 参数 + paramMap.put("md5", md5); + + String result = HttpUtil.post("http://" + ip + ":" + port + "/group1/delete", paramMap); + + ObjectMapper mapper = new ObjectMapper(); + JsonNode node = null; + try { + node = mapper.readTree(result); + } catch (JsonProcessingException e) { + + e.printStackTrace(); + } + final String status = "status"; + final String statusOk = "ok"; + + if (null == node) { + log.error("返回结果为空"); + return false; + } + if (!statusOk.equals(node.path(status).asText())) { + log.error("未删除成功"); + return false; + } + return true; + } + + + + + + public static void main(String[] args) { + File file = new File("C:\\Users\\dong\\Desktop\\遥感影像\\遥感影像\\GF1\\GF1_PMS1_E116.8_N36.6_20190528_L1A0004026837-MSS1_ORTHO_MS.tif"); + FileFastDfs fileFastDfs = new FileFastDfs(); + } +} + + diff --git a/src/main/java/com/xkrs/utils/FileUtil.java b/src/main/java/com/xkrs/utils/FileUtil.java new file mode 100644 index 0000000..6a2d201 --- /dev/null +++ b/src/main/java/com/xkrs/utils/FileUtil.java @@ -0,0 +1,250 @@ +package com.xkrs.utils; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static com.xkrs.utils.DateTimeUtil.getNowTimeStr; + +public class FileUtil { + private static final Logger log = LoggerFactory.getLogger(FileUtil.class); + + /** + * 判断目录是否存在, 不存在创建 + * @param path 路径,目录最后带 File.separator + * @return + */ + public static boolean isFileExit(String path){ + path = path.replace("/",File.separator); + File file = new File(path); + if (file.exists()) { + log.info("文件已存在"); + return true; + } + if(path.endsWith(File.separator)) { + log.info("创建单个文件" + path + "失败,目标不能是目录!"); + return false; + } + if(!file.getParentFile().exists()) { + log.info("目标文件所在路径不存在,准备创建。。。"); + if (file.getParentFile().mkdirs()) { + if (file.mkdir()) { + log.info("创建目录文件成功!"); + } + } + } else { + log.info("目标文件所在路径存在"); + if (file.mkdir()) { + log.info("创建目录文件成功!"); + } + } + return true; + } + + /** + * 获取目录下的所有文件 + * @param filePath 目录 + * @return + * @throws Exception + */ + public static List showListFile(String filePath) { + File dir = new File(filePath); + List list = new ArrayList<>(); + // 查找参数文件是否存在,只检查第一个入参 + if(!dir.exists()) { + log.error("找不到文件"); + } + // 如果是目录那么进行递归调用 + if(dir.isDirectory()) { + // 获取目录下的所有文件 + File[] f = dir.listFiles(); + // 进行递归调用,最后总会返回一个list + assert f != null; + for (File file : f) { + list.addAll(showListFile(file.getPath())); + } + }else { + // 不是目录直接添加进去,判断是否为xml文件 + list.add(dir.getPath()); + } + return list; + } + + /** + * 移动文件到目标目录 + * @param path 文件路径 + * @return + */ + /*public static FileEntity mvFile(String path){ + String savePath = "D:" + File.separator + "dms" + File.separator + "data" ; + + File file = new File(path); + if (!file.isFile()) { + log.info("{}不是文件。",path); + return null; + } + // 从文件名获取到入库信息 暂时不知道 + String[] infos = path.split("/"); + String fileNameUnHandler = infos[infos.length - 1]; + String[] fileNameUnHandlerSplitWithPoint = fileNameUnHandler.split("."); + String fileName = fileNameUnHandlerSplitWithPoint[0]; + String scene = fileNameUnHandlerSplitWithPoint[1]; + String[] fileNames = fileNameUnHandler.split("_"); + long length = file.length(); + String filePath = File.separator + scene + File.separator + fileName; +// savePath = savePath + File.separator + dir + File.separator + fileName; + if (isFileExit(savePath + File.separator + scene)) { + if (file.renameTo(new File(filePath))) { + log.info("移动文件{}到{}目录",file.getName(), savePath + filePath); + } else { + log.info("文件{}移动失败",file.getName()); + return null; + } + } + return null; + }*/ + + /** + * 读取txt文件内容 + * @param file + * @return + */ + public static String txt2String(File file){ + StringBuilder result = new StringBuilder(); + try{ + //构造一个BufferedReader类来读取文件 + BufferedReader br = new BufferedReader(new FileReader(file)); + String s = null; + //使用readLine方法,一次读一行 + while((s = br.readLine())!=null){ + result.append(System.lineSeparator()).append(s); + } + br.close(); + }catch(Exception e){ + e.printStackTrace(); + } + return result.toString(); + } + + /** + * 确定上传文件路径遥感数据 栅格 + * @param file 文件 + * @return + */ + public static String fileRsSaveType(File file) { + String name = file.getName(); + String suffix = name.substring(name.indexOf(".")); + // 判断是否为栅格数据 + if (!suffix.contains("tif")) { + return null; + } + // GF1_PMS1_E116.8_N36.6_20190528_L1A0004026837-MSS1_ORTHO_MS.tif + String[] s = name.split("_"); + // 卫星种类 + String satelliteType = s[0]; + // 传感器种类 + String sensorType = s[1]; + // 中心点经度 + String lat = s[2]; + // 中心点纬度 + String lon = s[3]; + // 时间 + String time = s[4]; + String year = time.substring(0, 4); + String month = time.substring(4, 6); + String day = time.substring(6); + // 产品号 + String product = s[5]; + String productLevel = product.substring(0, 3); + String productCode = product.substring(3); + // 种类 + String type = s[6]; + // 文件路径 + String filePath = "/" + satelliteType + "/" + sensorType + "/" + productLevel + "/" + year + "/" + month + "/" + + day + "/" + productCode + "/"; + + return filePath; + } + + /** + * 矢量数据路径 + * C:\Users\dong\Desktop\2018年山东省矢量数据\2018年山东省矢量数据\2018年动态\分县动态\山东.gdb\sa.gdb + * @param file + * @return + */ + public static String fileShpSavePath(File file) { + if (file.exists()) { + if (file.isFile()) { + String path = file.getPath(); + String[] dirNames = path.split("\\\\"); + StringBuffer sb = new StringBuffer(); + int length = dirNames.length; + final int minLength = 5; + if (length >= minLength) { + for (int i = 5; i > 1; i--) { + sb.append("/").append(dirNames[length - i]); + } + return sb.toString(); + } + } + } + return null; + } + + public static Map getUploadInfo(String info) { + final String statusFail = "fail"; + final String status = "status"; + ObjectMapper mapper = new ObjectMapper(); + JsonNode resultNode = null; + Map map = new HashMap<>(); + try { + resultNode = mapper.readTree(info); + } catch (JsonProcessingException e) { + e.printStackTrace(); + } + if (!statusFail.equals(resultNode.path(status).asText())) { + String path = resultNode.path("path").asText(); + String fileName = path.substring(path.lastIndexOf("/") + 1); + map.put("md5", resultNode.path("md5").asText()); + map.put("mtime", getNowTimeStr()); + map.put("path", path); + map.put("scene", resultNode.path("scene").asText()); + map.put("size", resultNode.path("size").asText()); + map.put("url", resultNode.path("url").asText()); + map.put("fileName", fileName); + } + return map; + } + + public static boolean checkFileSize(Long len, int size, String unit) { + double fileSize = 0; + if ("B".equals(unit.toUpperCase())) { + fileSize = (double) len; + } else if ("K".equals(unit.toUpperCase())) { + fileSize = (double) len / 1024; + } else if ("M".equals(unit.toUpperCase())) { + fileSize = (double) len / 1048576; + } else if ("G".equals(unit.toUpperCase())) { + fileSize = (double) len / 1073741824; + } + if (fileSize > size) { + return false; + } + return true; + } + + public static void main(String[] args) { + String s = "C:/Users/dong/Desktop/2018年山东省矢量数据/2018年山东省矢量数据/2018年动态/分县动态/山东.gdb/a0000000a.gdbindexes"; + fileShpSavePath(new File(s)); + } +} diff --git a/src/main/java/com/xkrs/utils/HashUtil.java b/src/main/java/com/xkrs/utils/HashUtil.java new file mode 100644 index 0000000..2aa3a99 --- /dev/null +++ b/src/main/java/com/xkrs/utils/HashUtil.java @@ -0,0 +1,40 @@ +package com.xkrs.utils; + +import java.security.MessageDigest; + +/** + * md5加密解密工具 + * @author tajochen + */ +public class HashUtil { + + /** + * MD5加密 + * + * @param password + * @return + */ + public static String md5Encode(String password) { + MessageDigest md5 = null; + try { + md5 = MessageDigest.getInstance("MD5"); + } catch (Exception e) { + throw new RuntimeException(e); + } + char[] charArray = password.toCharArray(); + byte[] byteArray = new byte[charArray.length]; + for (int i = 0; i < charArray.length; i++){ + byteArray[i] = (byte) charArray[i]; + } + byte[] md5Bytes = md5.digest(byteArray); + StringBuilder hexValue = new StringBuilder(); + for (byte md5Byte : md5Bytes) { + int val = ((int) md5Byte) & 0xff; + if (val < 16) { + hexValue.append("0"); + } + hexValue.append(Integer.toHexString(val)); + } + return hexValue.toString(); + } +} diff --git a/src/main/java/com/xkrs/utils/IpUtil.java b/src/main/java/com/xkrs/utils/IpUtil.java new file mode 100644 index 0000000..ae88933 --- /dev/null +++ b/src/main/java/com/xkrs/utils/IpUtil.java @@ -0,0 +1,42 @@ +package com.xkrs.utils; + +import javax.servlet.http.HttpServletRequest; + +/** + * IP地址处理工具 + * @author tajochen + */ +public class IpUtil { + + public static String getIpAddr(HttpServletRequest request) { + String ip = request.getHeader("x-forwarded-for"); + final String unkonwMsg = "unknown"; + final char splitChar = ','; + if (ip != null && ip.length() != 0 && !unkonwMsg.equalsIgnoreCase(ip)) { + // 多次反向代理后会有多个ip值,第一个ip才是真实ip + if( ip.indexOf(splitChar)!=-1 ){ + ip = ip.split(",")[0]; + } + } + if (ip == null || ip.length() == 0 || unkonwMsg.equalsIgnoreCase(ip)) { + ip = request.getHeader("Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || unkonwMsg.equalsIgnoreCase(ip)) { + ip = request.getHeader("WL-Proxy-Client-IP"); + } + if (ip == null || ip.length() == 0 || unkonwMsg.equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_CLIENT_IP"); + } + if (ip == null || ip.length() == 0 || unkonwMsg.equalsIgnoreCase(ip)) { + ip = request.getHeader("HTTP_X_FORWARDED_FOR"); + } + if (ip == null || ip.length() == 0 || unkonwMsg.equalsIgnoreCase(ip)) { + ip = request.getHeader("X-Real-IP"); + } + if (ip == null || ip.length() == 0 || unkonwMsg.equalsIgnoreCase(ip)) { + ip = request.getRemoteAddr(); + } + System.out.println("获取客户端ip: " + ip); + return ip; + } +} diff --git a/src/main/java/com/xkrs/utils/NumberUtil.java b/src/main/java/com/xkrs/utils/NumberUtil.java new file mode 100644 index 0000000..2ead0c3 --- /dev/null +++ b/src/main/java/com/xkrs/utils/NumberUtil.java @@ -0,0 +1,21 @@ +package com.xkrs.utils; + +/** + * 数字工具 + * @author tajochen + */ +public class NumberUtil { + + public static boolean isStrNumeric(String str) { + if(str==null||str.length()==0){ + return false; + } + for (int i = 0; i < str.length(); i++) { + System.out.println(str.charAt(i)); + if (!Character.isDigit(str.charAt(i))) { + return false; + } + } + return true; + } +} diff --git a/src/main/java/com/xkrs/utils/ObjectToBeanUtils.java b/src/main/java/com/xkrs/utils/ObjectToBeanUtils.java new file mode 100644 index 0000000..1caf481 --- /dev/null +++ b/src/main/java/com/xkrs/utils/ObjectToBeanUtils.java @@ -0,0 +1,152 @@ +package com.xkrs.utils; + + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.lang.reflect.Constructor; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author XinYi Song + */ +public class ObjectToBeanUtils { + + public static Logger log = LoggerFactory.getLogger(ObjectToBeanUtils.class); + + /** + * 把List转换成List + */ + public static List objectToBean(List objList, Class clz) throws Exception{ + if (objList==null || objList.size()==0) { + return null; + } + + Class[] cz = null; + Constructor[] cons = clz.getConstructors(); + for (Constructor ct : cons) { + Class[] clazz = ct.getParameterTypes(); + if (objList.get(0).length == clazz.length) { + cz = clazz; + break; + } + } + + List list = new ArrayList(); + for (Object[] obj : objList) { + Constructor cr = clz.getConstructor(cz); + list.add(cr.newInstance(obj)); + } + return list; + } + + + + + + + public static List objectToBeans(List objList, Class clz) throws Exception{ + if (objList==null || objList.size()==0) { + return null; + } + + int length = objList.get(0).length; + log.info("*************>"+length); + + Class[] cz = null; + Constructor[] cons = clz.getConstructors(); + for (Constructor ct : cons) { + Class[] clazz = ct.getParameterTypes(); + if (objList.get(0).length == clazz.length) { + cz = clazz; + break; + } + } + + List list = new ArrayList(); + log.info("---------->"+objList.get(0)); + Constructor cr = clz.getConstructor(cz); + T newInstance = cr.newInstance((Object) objList.get(0)); + list.add(newInstance); + return list; + } + + + public static List castEntity(List list, Class clazz, Object model) { + List returnList = new ArrayList(); + if (list.isEmpty()) { + return returnList; + } + //获取每个数组集合的元素个数 + Object[] co = list.get(0); + + //获取当前实体类的属性名、属性值、属性类别 + List attributeInfoList = getFiledsInfo(model); + //创建属性类别数组 + Class[] c2 = new Class[attributeInfoList.size()]; + //如果数组集合元素个数与实体类属性个数不一致则发生错误 + if (attributeInfoList.size() != co.length) { + return returnList; + } + //确定构造方法 + for (int i = 0; i < attributeInfoList.size(); i++) { + c2[i] = (Class) attributeInfoList.get(i).get("type"); + } + try { + for (Object[] o : list) { + Constructor constructor = clazz.getConstructor(c2); + returnList.add(constructor.newInstance(o)); + } + } catch (Exception ex) { + log.info("实体数据转化为实体类发生异常:异常信息:{}", ex.getMessage()); + return returnList; + } + return returnList; + } + + /** + * 根据属性名获取属性值 + * + * @param fieldName 属性名 + * @param modle 实体类 + * @return 属性值 + */ + private static Object getFieldValueByName(String fieldName, Object modle) { + try { + String firstLetter = fieldName.substring(0, 1).toUpperCase(); + String getter = "get" + firstLetter + fieldName.substring(1); + Method method = modle.getClass().getMethod(getter, new Class[]{}); + Object value = method.invoke(modle, new Object[]{}); + return value; + } catch (Exception e) { + return null; + } + } + + /** + * 获取属性类型(type),属性名(name),属性值(value)的map组成的list + * + * @param model 实体类 + * @return list集合 + */ + private static List getFiledsInfo(Object model) { + Field[] fields = model.getClass().getDeclaredFields(); + List list = new ArrayList(fields.length); + Map infoMap = null; + for (int i = 0; i < fields.length; i++) { + infoMap = new HashMap(3); + infoMap.put("type", fields[i].getType()); + infoMap.put("name", fields[i].getName()); + infoMap.put("value", getFieldValueByName(fields[i].getName(), model)); + list.add(infoMap); + } + return list; + } + + +} diff --git a/src/main/java/com/xkrs/utils/OpenGeoUtil.java b/src/main/java/com/xkrs/utils/OpenGeoUtil.java new file mode 100644 index 0000000..cc1b03a --- /dev/null +++ b/src/main/java/com/xkrs/utils/OpenGeoUtil.java @@ -0,0 +1,37 @@ +package com.xkrs.utils; + +import org.geolatte.geom.Geometry; +import org.geolatte.geom.Point; +import org.geolatte.geom.codec.Wkt; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 开源Gis工具集 + * @author tajochen + */ +public class OpenGeoUtil { + + Logger logger = LoggerFactory.getLogger(OpenGeoUtil.class); + + /** + * wkt文本转为点数据 + * @param wkt + * @return + */ + public static Point wktStrToPoint(String wkt) { + Point point = (Point) Wkt.fromWkt(wkt); + return point; + } + + /** + * wkt文本转geometry + * @param wkt + * @return + */ + public static Geometry wktStrToGeom(String wkt) { + Geometry geom = Wkt.fromWkt(wkt); + return geom; + } + +} diff --git a/src/main/java/com/xkrs/utils/PhotoUtil.java b/src/main/java/com/xkrs/utils/PhotoUtil.java new file mode 100644 index 0000000..486801f --- /dev/null +++ b/src/main/java/com/xkrs/utils/PhotoUtil.java @@ -0,0 +1,190 @@ +package com.xkrs.utils; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.UUID; + +/** + * @author XinYi Song + */ +public class PhotoUtil { + + public static Logger log = LoggerFactory.getLogger(PhotoUtil.class); + + /** + * 上传单张图片 + * @param imgFile + * @return + * @throws IOException + */ + public static String memoryPhoto(MultipartFile imgFile) throws IOException { + //String uploadPath = "http://139.199.98.175:2088/wfTaskImage/"; +// String uploadPath = "http://192.168.2.139"; + String uploadPath = "/"; + //获取原始文件名 + String originalFilename = imgFile.getOriginalFilename(); + if (originalFilename != null && !"".equals(originalFilename)) { + //找到 . 的位置 + int index = originalFilename.lastIndexOf("."); + //根据 . 的位置进行分割,拿到文件后缀名 + String suffix = originalFilename.substring(index); + //uuid生成新的文件名 + String newName = UUID.randomUUID().toString() + suffix; + + //将图片保存到本地/usr/etc/images/Folder + File file = new File("E:/img/"); + if (!file.exists()) { + file.mkdirs(); + } + String path = "E:/img/" + newName; + String uploadsImage = uploadPath + newName; + //实现上传 + imgFile.transferTo(new File(path)); + + + return uploadsImage; + } + return null; + } + + /** + * 以文件形式,批量上传图片 + * @param files + * @return + * @throws IOException + */ + /*public static List uploadImage(MultipartFile[] files, String fireCode) throws IOException { + //String uploadPath = "http://139.199.98.175:2099/forestTaskImage/"; + String uploadPath = "http://118.24.27.47:2088/"; + String newName = ""; + String oldName = ""; + List fireTaskPhotos = new ArrayList<>(); + for(MultipartFile file : files){ + //获取file图片名称 + oldName = file.getOriginalFilename(); + //找到 . 的位置 + int index = oldName.lastIndexOf("."); + //根据 . 的位置进行分割,拿到文件后缀名 + String suffix = oldName.substring(index); + //uuid生成新的文件名 + newName = UUID.randomUUID().toString() + suffix; + //将图片保存到本地/usr/etc/images/Folder + File file1 = new File("/home/sxy/server/fire_point/firePointImage/"); + //File file1 = new File("E:/file/work/image/"); + if (!file1.exists()) { + file1.mkdirs(); + } + String path = "/home/sxy/server/fire_point/firePointImage/" + newName; + //String path = "E:/file/work/image/" + newName; + String uploadPaths = "/firePointImage/" + newName; + //实现上传 + file.transferTo(new File(path)); + FireTaskPhoto fireTaskPhoto = new FireTaskPhoto(); + fireTaskPhoto.setPhotoFireCode(fireCode); + fireTaskPhoto.setTaskPhoto(uploadPaths); + + fireTaskPhotos.add(fireTaskPhoto); + } + return fireTaskPhotos; + }*/ + + + + /** + * 删除本地或服务器储存的图片 + * @param path + * @return + */ + public static String delFile(String path){ + String resultInfo = null; + int lastIndexOf = path.lastIndexOf("/"); + String imgPath = path.substring(lastIndexOf + 1,path.length()); + System.out.println(imgPath); + imgPath = "/usr/local/etc/images/" + imgPath; +// img_path = "/usr/etc/images/Folder/" + img_path; + File file = new File(imgPath); + if(file.exists()){ + if(file.delete()){ + resultInfo = "删除成功!"; + }else { + resultInfo = "删除失败!"; + } + }else { + resultInfo = "文件不存在"; + } + return resultInfo; + } + + /** + * 通过图片路径解析 ,上传保存 + * @param listImgSrc + * @return + */ + public static List downloadImage(List listImgSrc) { + try { + List list = new ArrayList(); + //开始时间 + Date beginDate = new Date(); + for (String url : listImgSrc) { + //开始时间 + Date beginDate2 = new Date(); + String imageName = url.substring(url.lastIndexOf("/") + 1, url.length()); + URL uri = new URL(url); + InputStream in = uri.openStream(); + //String pathUpload = "E:/img/" + imageName; + String pathUpload = "/home/web/wf-fire-service/wfimage/" + imageName; + FileOutputStream fo = new FileOutputStream(new File(pathUpload)); + byte[] buf = new byte[1024]; + int length = 0; + log.info("-------开始下载:" + url); + while ((length = in.read(buf, 0, buf.length)) != -1) { + fo.write(buf, 0, length); + } + in.close(); + fo.close(); + list.add(imageName); + log.info(imageName + "------下载完成"); + //结束时间 + Date overDate2 = new Date(); + double time = overDate2.getTime() - beginDate2.getTime(); + log.info("-----耗时:" + time / 1000 + "s"); + } + Date overDate = new Date(); + double time = overDate.getTime() - beginDate.getTime(); + log.info("======总耗时:" + time / 1000 + "s"); + return list; + } catch (Exception e) { + log.info("++++++下载失败"); + } + return null; + } + + /** + * 删除本地文件夹图片 + * @param url + */ + public static void deleteImage(String url){ + File file=new File(url); + //判断file是否是文件目录 若是返回TRUE + if (file.isDirectory()){ + //name存储file文件夹中的文件名 + String[] name =file.list(); + for (int i=0; i selectFirePointByMonthCounty(String proName, String countyCode,String startTime,String endTime) { + Specification specification = new Specification() { + @Override + public Predicate toPredicate(Root root, CriteriaQuery criteriaQuery, CriteriaBuilder criteriaBuilder) { + List list = new ArrayList<>(); + if(countyCode != null && !"".equals(countyCode)){ + list.add(criteriaBuilder.like(root.get("countyCode").as(String.class), countyCode)); + } + if(startTime != null && !"".equals(startTime)){ + list.add(criteriaBuilder.greaterThanOrEqualTo(root.get("satelliteTime").as(String.class), startTime)); + } + if(endTime != null && !"".equals(endTime)){ + list.add(criteriaBuilder.lessThanOrEqualTo(root.get("satelliteTime").as(String.class), endTime)); + } + if(proName.equals("山东省")){ + list.add(criteriaBuilder.notEqual(root.get("landType").as(String.class), "耕地")); + } + Predicate[] predicates = new Predicate[list.size()]; + return criteriaBuilder.and(list.toArray(predicates)); + } + }; + return firePointDao.findAll(specification); + }*/ + + +} \ No newline at end of file diff --git a/src/main/java/com/xkrs/utils/RandomUtil.java b/src/main/java/com/xkrs/utils/RandomUtil.java new file mode 100644 index 0000000..c546877 --- /dev/null +++ b/src/main/java/com/xkrs/utils/RandomUtil.java @@ -0,0 +1,71 @@ +package com.xkrs.utils; + +import java.util.Random; +import java.util.UUID; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 随机字符串产生工具 + * @author tajochen + */ +public class RandomUtil { + /** + * 获取随机字母数字组合 + * @param length + * 字符串长度 + * @return + */ + public static String getRandomCharAndNumr(Integer length) { + String str = ""; + StringBuilder strBuffer = new StringBuilder(); + Random random = new Random(); + for (int i = 0; i < length; i++) { + boolean b = random.nextBoolean(); + // 字符串 + if (b) { + //取得65大写字母还是97小写字母 + int choice = random.nextBoolean() ? 65 : 97; + strBuffer.append((char) (choice + random.nextInt(26))); + } else { + // 数字 + strBuffer.append(random.nextInt(10)); + } + } + str = strBuffer.toString(); + return str; + } + + /** + * 验证随机字母数字组合是否纯数字与纯字母 + * @param str + * @return true 是 , false 否 + */ + public static boolean isRandomUsable(String str) { + // String regExp = + // "^[A-Za-z]+(([0-9]+[A-Za-z0-9]+)|([A-Za-z0-9]+[0-9]+))|[0-9]+(([A-Za-z]+[A-Za-z0-9]+)|([A-Za-z0-9]+[A-Za-z]+))$"; + String regExp = "^([0-9]+)|([A-Za-z]+)$"; + Pattern pat = Pattern.compile(regExp); + Matcher mat = pat.matcher(str); + return mat.matches(); + } + + /** + * 生成UUID + * @return + */ + public static String getUuid32(){ + String uuid = UUID.randomUUID().toString().replace("-", "").toLowerCase(); + return uuid; +//  return UUID.randomUUID().toString().replace("-", "").toLowerCase(); + } + + /** + * 随机生成六位数 + * @return + */ + public static int returnCode() { + Random rand = new Random(); + return rand.nextInt(899999) + 100000; + } +} diff --git a/src/main/java/com/xkrs/utils/RequestUtil.java b/src/main/java/com/xkrs/utils/RequestUtil.java new file mode 100644 index 0000000..86ef7e2 --- /dev/null +++ b/src/main/java/com/xkrs/utils/RequestUtil.java @@ -0,0 +1,304 @@ +package com.xkrs.utils; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.xkrs.model.vo.FileServerResultVo; +import org.apache.http.Consts; +import org.apache.http.HttpEntity; +import org.apache.http.NameValuePair; +import org.apache.http.client.entity.UrlEncodedFormEntity; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpGet; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.client.utils.URIBuilder; +import org.apache.http.entity.ContentType; +import org.apache.http.entity.mime.HttpMultipartMode; +import org.apache.http.entity.mime.MultipartEntityBuilder; +import org.apache.http.entity.mime.content.StringBody; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.message.BasicNameValuePair; +import org.apache.http.util.EntityUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Component; + +import java.io.File; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.util.*; + +/** + * 上传工具 + * @author tajochen + **/ +public class RequestUtil { + + /** + * 发送管理命令到文件服务器 + * @param url + * @param map + * @return + */ + public static FileServerResultVo postFileManage(String url, Map map){ + Logger log = LoggerFactory.getLogger(RequestUtil.class); + String body = ""; + // 创建httpclient对象 + CloseableHttpClient client = HttpClients.createDefault(); + // 创建post方式请求对象 + HttpPost httpPost = new HttpPost(url); + // 装填参数 + List nvps = new ArrayList(); + if(map!=null){ + for (Map.Entry entry : map.entrySet()) { + nvps.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); + } + } + try { + // 设置参数到请求对象中 + httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8")); + // 设置header报文头信息 + httpPost.setHeader("Content-type", "application/x-www-form-urlencoded"); + httpPost.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0"); + httpPost.setHeader("Accept", "application"); + httpPost.setHeader("Accept-Encoding", "gzip, deflate"); + // 执行请求操作,并拿到结果(同步阻塞) + CloseableHttpResponse response = client.execute(httpPost); + // 获取结果实体 + HttpEntity entity = response.getEntity(); + if (entity != null) { + // 按指定编码转换结果实体为String类型 + body = EntityUtils.toString(entity, "UTF-8"); + } + EntityUtils.consume(entity); + // 释放链接 + response.close(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + client.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + FileServerResultVo fileServerResultVo = new FileServerResultVo(); + ObjectMapper mapper = new ObjectMapper(); + try { + fileServerResultVo = mapper.readValue(body, FileServerResultVo.class); + } catch (JsonProcessingException e) { + e.printStackTrace(); + log.warn(e.toString()); + + } + return fileServerResultVo; + } + + /** + * 模拟 get请求 + * @param url 链接 + * @param map 参数列表 + */ + public static void getStandard(String url, Map map) { + // 1.拿到一个httpclient的对象 + CloseableHttpClient httpClient = HttpClients.createDefault(); + // 2.设置请求方式和请求信息 + HttpPost httpPost = new HttpPost(url); + //2.1 提交header头信息 + httpPost.addHeader("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"); + //2.1 提交请求体 + ArrayList parameters = new ArrayList(); + // 装填参数 + if(map!=null){ + for (Map.Entry entry : map.entrySet()) { + parameters.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); + } + } + + try { + httpPost.setEntity(new UrlEncodedFormEntity(parameters)); + } catch (UnsupportedEncodingException e) { + e.printStackTrace(); + } + + // 3.执行请求 + CloseableHttpResponse response = null; + try { + response = httpClient.execute(httpPost); + } catch (IOException e) { + e.printStackTrace(); + } + // 4.获取返回值 + String html = null; + try { + assert response != null; + html = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8); + } catch (IOException e) { + e.printStackTrace(); + } + // 5.打印 + System.out.println(html); + } + + /** + * 模拟get请求(加请求头) + * @param url + * @param param + * @return + */ + public static String doGet(String url, Map param) { + + String result = null; + CloseableHttpClient httpclient = HttpClients.createDefault(); + CloseableHttpResponse response = null; + try { + URIBuilder builder = new URIBuilder(url); + if (param != null) { + for (String key : param.keySet()) { + builder.addParameter(key, param.get(key)); + } + } + URI uri = builder.build(); + HttpGet httpGet = new HttpGet(uri); + httpGet.addHeader("user-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36"); + response = httpclient.execute(httpGet); + if (response.getStatusLine().getStatusCode() == 200) { + result = EntityUtils.toString(response.getEntity(), "UTF-8"); + } + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if (response != null) { + response.close(); + } + httpclient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return result; + } + + /** + * 模拟Post请求 application/x-www-form-urlencoded + * @param url 资源地址 + * @param map 参数列表 + * @return + */ + public static String postStandard(String url, Map map) { + String body = ""; + // 创建httpclient对象 + CloseableHttpClient client = HttpClients.createDefault(); + // 创建post方式请求对象 + HttpPost httpPost = new HttpPost(url); + // 装填参数 + List nvps = new ArrayList(); + if(map!=null){ + for (Map.Entry entry : map.entrySet()) { + nvps.add(new BasicNameValuePair(entry.getKey(), entry.getValue())); + } + } + try { + // 设置参数到请求对象中 + httpPost.setEntity(new UrlEncodedFormEntity(nvps, "UTF-8")); + // 设置header报文头信息 + httpPost.setHeader("Content-type", "application/x-www-form-urlencoded"); + httpPost.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:67.0) Gecko/20100101 Firefox/67.0"); + httpPost.setHeader("Accept", "application"); + httpPost.setHeader("Accept-Encoding", "gzip, deflate"); + // 执行请求操作,并拿到结果(同步阻塞) + CloseableHttpResponse response = client.execute(httpPost); + // 获取结果实体 + HttpEntity entity = response.getEntity(); + if (entity != null) { + // 按指定编码转换结果实体为String类型 + body = EntityUtils.toString(entity, "UTF-8"); + } + EntityUtils.consume(entity); + // 释放链接 + response.close(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + client.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + return body; + } + + /** + * 模拟Post请求 multipart/form-data + * @param postFile + * @param postUrl + * @param postParam + * @return + */ + public static Map postFile(File postFile,String postUrl,Map postParam) { + + Logger log = LoggerFactory.getLogger(RequestUtil.class); + Map resultMap = new HashMap(16); + CloseableHttpClient httpClient = HttpClients.createDefault(); + try{ + // 把一个普通参数和文件上传给下面这个地址 + HttpPost httpPost = new HttpPost(postUrl); + + // 设置传输参数 + MultipartEntityBuilder multipartEntity = MultipartEntityBuilder.create(); + // 解决乱码问题 + multipartEntity.setMode(HttpMultipartMode.BROWSER_COMPATIBLE); + multipartEntity.setCharset(StandardCharsets.UTF_8); + + // 设置文件参数 ,获取文件名postFile.getName() + // 把文件转换成流对象FileBody + multipartEntity.addBinaryBody("file",postFile, ContentType.create("multipart/form-data", Consts.UTF_8),postFile.getName()); + // 设计文件以外的参数 + Set keySet = postParam.keySet(); + for (String key : keySet) { + // 相当于 + multipartEntity.addPart(key, new StringBody(postParam.get(key), ContentType.create("multipart/form-data", Consts.UTF_8))); + } + HttpEntity reqEntity = multipartEntity.build(); + httpPost.setEntity(reqEntity); + // 设置header报文头信息 + httpPost.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:79.0) Gecko/20100101 Firefox/79.0"); + httpPost.setHeader("Accept","text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"); + httpPost.setHeader("Accept-Encoding","gzip, deflate"); + + // 发起请求,返回请求的响应 + CloseableHttpResponse response = httpClient.execute(httpPost); + try { + resultMap.put("statusCode", response.getStatusLine().getStatusCode()); + // 获取响应对象 + HttpEntity resEntity = response.getEntity(); + if (resEntity != null) { + // 打印响应内容 + resultMap.put("data", EntityUtils.toString(resEntity, StandardCharsets.UTF_8)); + resultMap.put("message", EntityUtils.toString(resEntity, StandardCharsets.UTF_8)); + resultMap.put("status", EntityUtils.toString(resEntity, StandardCharsets.UTF_8)); + } + // 销毁 + EntityUtils.consume(resEntity); + } catch (Exception e) { + e.printStackTrace(); + } finally { + response.close(); + } + } catch (IOException e1) { + e1.printStackTrace(); + } finally{ + try { + httpClient.close(); + } catch (IOException e) { + e.printStackTrace(); + } + } + log.info("上传结果:" + resultMap); + return resultMap; + } +} diff --git a/src/main/java/com/xkrs/utils/SnowFlakeUtil.java b/src/main/java/com/xkrs/utils/SnowFlakeUtil.java new file mode 100644 index 0000000..a5ba62d --- /dev/null +++ b/src/main/java/com/xkrs/utils/SnowFlakeUtil.java @@ -0,0 +1,124 @@ +package com.xkrs.utils; + +/** + * 基于Twitter开源的分布式ID生成算法snowflake + * @author tajochen + **/ +public class SnowFlakeUtil { + + /** + * 起始时间戳 + * 2018-01-01 00:00:00 + */ + private final static long START_STMP = 1514736000L; + /** + * 序列在id中占用的位数 + */ + private final static long SEQUENCE_BIT = 12L; + /** + * 机器标识占用的位数 + */ + private final static long MACHINE_BIT = 5L; + /** + * 数据中心占用的位数 + */ + private final static long DATACENTER_BIT = 5L; + /** + * 每一部分的最大值 + */ + private final static long MAX_DATACENTER_NUM = -1L ^ (-1L << DATACENTER_BIT); + private final static long MAX_MACHINE_NUM = -1L ^ (-1L << MACHINE_BIT); + private final static long MAX_SEQUENCE = -1L ^ (-1L << SEQUENCE_BIT); + + /** + * 每一部分向左的位移 + */ + private final static long MACHINE_LEFT = SEQUENCE_BIT; + private final static long DATACENTER_LEFT = SEQUENCE_BIT + MACHINE_BIT; + private final static long TIMESTMP_LEFT = DATACENTER_LEFT + DATACENTER_BIT; + + /** + * 数据中心 + */ + private long datacenterId; + /** + * 机器标识 + */ + private long machineId; + /** + * 序列号 + */ + private long sequence = 0L; + /** + * 上一次时间戳 + */ + private long lastStmp = -1L; + + public SnowFlakeUtil(long datacenterId, long machineId) { + if (datacenterId > MAX_DATACENTER_NUM || datacenterId < 0) { + throw new IllegalArgumentException("data center id can't be greater than MAX_DATACENTER_NUM or less than 0"); + } + if (machineId > MAX_MACHINE_NUM || machineId < 0) { + throw new IllegalArgumentException("machine id can't be greater than MAX_MACHINE_NUM or less than 0"); + } + this.datacenterId = datacenterId; + this.machineId = machineId; + } + + /** + * 产生下一个ID + * @return + */ + public synchronized long nextId() { + long currStmp = getNewstmp(); + if (currStmp < lastStmp) { + throw new RuntimeException("Clock moved backwards. Refusing to generate id"); + } + + if (currStmp == lastStmp) { + //相同毫秒内,序列号自增 + sequence = (sequence + 1) & MAX_SEQUENCE; + //同一毫秒的序列数已经达到最大 + if (sequence == 0L) { + currStmp = getNextMill(); + } + } else { + //不同毫秒内,序列号置为0 + sequence = 0L; + } + + lastStmp = currStmp; + //时间戳部分 + return (currStmp - START_STMP) << TIMESTMP_LEFT + //数据中心部分 + | datacenterId << DATACENTER_LEFT + //机器标识部分 + | machineId << MACHINE_LEFT + //序列号部分 + | sequence; + } + + private long getNextMill() { + long mill = getNewstmp(); + while (mill <= lastStmp) { + mill = getNewstmp(); + } + return mill; + } + + private long getNewstmp() { + return System.currentTimeMillis(); + } + + public static void main(String[] args) { + SnowFlakeUtil snowFlake = new SnowFlakeUtil(5, 5); + //测试次数 + int testTimes = 10000; + long start = System.currentTimeMillis(); + for (int i = 0; i < testTimes; i++) { + System.out.println(snowFlake.nextId()); + } + + System.out.println(System.currentTimeMillis() - start); + } +} diff --git a/src/main/java/com/xkrs/utils/VerifyBankCardUtil.java b/src/main/java/com/xkrs/utils/VerifyBankCardUtil.java new file mode 100644 index 0000000..f676e46 --- /dev/null +++ b/src/main/java/com/xkrs/utils/VerifyBankCardUtil.java @@ -0,0 +1,592 @@ +package com.xkrs.utils; + +import java.util.HashMap; +import java.util.Map; + +/** + * @Author: XinYi Song + * @Date: 2021/12/13 15:37 + */ +public class VerifyBankCardUtil { + + /** + * 校验银行卡卡号 + * + * @param cardId + * 银行卡号 + * @return 银行卡号符合校验规则,false 银行卡号不符合校验规则 + */ + public static boolean checkBankCard(String cardId) { + + if (cardId == null || cardId.length() < 16 || cardId.length() > 19) { + return false; + } + + char bit = getBankCardCheckCode(cardId + .substring(0, cardId.length() - 1)); + if (bit == 'N') { + return false; + } + return cardId.charAt(cardId.length() - 1) == bit; + } + + /** + * 从不含校验位的银行卡卡号采用 Luhm 校验算法获得校验位 + * + * @param nonCheckCodeCardId + * 不包含最后一位的银行卡号 + * @return 银行卡号校验位 + */ + private static char getBankCardCheckCode(String nonCheckCodeCardId) { + if (nonCheckCodeCardId == null + || nonCheckCodeCardId.trim().length() == 0 + || !nonCheckCodeCardId.matches("\\d+")) { + // 如果传的不是数据返回N + return 'N'; + } + char[] chs = nonCheckCodeCardId.trim().toCharArray(); + int luhnSum = 0; + for (int i = chs.length - 1, j = 0; i >= 0; i--, j++) { + int k = chs[i] - '0'; + if (j % 2 == 0) { + k *= 2; + k = k / 10 + k % 10; + } + luhnSum += k; + } + return (luhnSum % 10 == 0) ? '0' : (char) ((10 - luhnSum % 10) + '0'); + } + + /** + * 传入卡号 得到银行名称 + * + * @param cardId + * @return + */ + public static String getNameOfBank(String cardId) { + int bin = 0, index = 0; + + if (cardId == null || cardId.length() < 16 || cardId.length() > 19) { + return "银行卡号错误"; + } + // 6位Bin号 + String cardBin = cardId.substring(0, 6); + + if (!isNumeric(cardBin)) { + return "银行卡号前六位不是数字"; + } + + bin = Integer.valueOf(cardBin); + index = binarySearch(bankBin, bin); + if (index == -1 || index > bankName.length) { + return "findNotName"; + } + return bankName[index]; + + } + + // 查找方法 + private static int binarySearch(int[] srcArray, int des) { + int low = 0; + int high = srcArray.length; + while (low < high) { + + if (des == srcArray[low]) { + return low; + } + low++; + } + return -1; + } + + // 检验数字 + public static boolean isNumeric(String str) { + if (str == null) { + return false; + } + int sz = str.length(); + for (int i = 0; i < sz; i++) { + if (!Character.isDigit(str.charAt(i))) { + return false; + } + } + return true; + } + + + /** + * BIN号 + * 银行卡是由”发卡行标识代码 + 自定义 + 校验码 “等部分组成的 + * 银联标准卡与以往发行的银行卡最直接的区别就是其卡号前6位数字的不同。 + * 银行卡卡号的前6位是用来表示发卡银行或机构的,称为“发卡行识别码”(Bank Identification Number,缩写为“BIN”)。 + * 银联标准卡是由国内各家商业银行(含邮储、信用社)共同发行、符合银联业务规范和技术标准、卡正面右下角带有“银联”标识(目前,新发行的银联标准卡一定带有国际化的银联新标识,新发的非银联标准卡使用旧的联网通用银联标识)、 + * 卡号前6位为622126至622925之一的银行卡,是中国银行卡产业共有的民族品牌。 + */ + private final static int[] bankBin = { 102033, 103000, 185720, 303781, + 356827, 356828, 356833, 356835, 356837, 356838, 356839, 356840, + 356885, 356886, 356887, 356888, 356889, 356890, 370246, 370247, + 370248, 370249, 400360, 400937, 400938, 400939, 400940, 400941, + 400942, 402658, 402673, 402791, 403361, 403391, 404117, 404157, + 404171, 404172, 404173, 404174, 404738, 404739, 405512, 405512, + 406252, 406254, 406365, 407405, 409665, 409666, 409667, 409668, + 409669, 409670, 409671, 409672, 410062, 412962, 412963, 415599, + 421317, 421349, 421393, 421437, 421865, 421869, 421870, 421871, + 422160, 422161, 424106, 424107, 424108, 424109, 424110, 424111, + 424902, 425862, 427010, 427018, 427019, 427020, 427028, 427029, + 427038, 427039, 427062, 427064, 427571, 428911, 431502, 431502, + 433666, 433670, 433680, 434061, 434062, 435744, 435745, 436718, + 436728, 436738, 436742, 436745, 436748, 436768, 438088, 438125, + 438126, 438588, 438589, 438600, 439188, 439225, 439227, 442729, + 442730, 451289, 451291, 451804, 451804, 451810, 451810, 453242, + 456351, 456418, 458060, 458060, 458071, 458071, 458123, 458124, + 468203, 472067, 472068, 479228, 479229, 481699, 486466, 486493, + 486494, 486497, 487013, 489592, 489734, 489735, 489736, 491020, + 491020, 491031, 491032, 491040, 493427, 493878, 498451, 504923, + 510529, 512315, 512316, 512411, 512412, 512425, 512431, 512466, + 512695, 512732, 514906, 514957, 514958, 517636, 518212, 518364, + 518378, 518379, 518474, 518475, 518476, 518710, 518718, 519412, + 519498, 520082, 520108, 520131, 520152, 520169, 520194, 520382, + 521899, 522153, 523036, 524011, 524047, 524070, 524091, 524094, + 524864, 524865, 525498, 525745, 525746, 526410, 526855, 527414, + 528020, 528931, 528948, 530970, 530980, 530980, 530990, 532420, + 532430, 532450, 532458, 535910, 535910, 535918, 537830, 540297, + 540838, 541068, 541709, 543159, 544033, 545619, 545623, 545947, + 547628, 547648, 547766, 547766, 548259, 548844, 552245, 552288, + 552534, 552587, 552599, 552742, 552794, 552801, 552853, 553131, + 553242, 556610, 556617, 558360, 558730, 558808, 558809, 558868, + 558868, 558894, 558895, 558916, 566666, 584016, 601100, 601101, + 601121, 601122, 601123, 601124, 601125, 601126, 601127, 601128, + 601131, 601136, 601137, 601138, 601140, 601142, 601143, 601144, + 601145, 601146, 601147, 601148, 601149, 601174, 601177, 601178, + 601179, 601186, 601187, 601188, 601189, 601382, 601382, 601428, + 601428, 601428, 601428, 602907, 602907, 602969, 602969, 603128, + 603128, 603367, 603367, 603445, 603445, 603506, 603506, 603601, + 603601, 603601, 603601, 603601, 603601, 603602, 603602, 603694, + 603694, 603708, 603708, 621021, 621201, 621977, 621977, 622126, + 622126, 622127, 622127, 622127, 622127, 622128, 622128, 622129, + 622129, 622131, 622131, 622132, 622132, 622133, 622133, 622134, + 622134, 622135, 622135, 622136, 622136, 622137, 622137, 622138, + 622138, 622139, 622139, 622140, 622140, 622141, 622141, 622143, + 622143, 622146, 622146, 622147, 622147, 622148, 622148, 622149, + 622149, 622150, 622150, 622151, 622151, 622152, 622152, 622153, + 622153, 622154, 622154, 622155, 622155, 622156, 622156, 622165, + 622165, 622166, 622166, 622168, 622168, 622169, 622169, 622178, + 622178, 622179, 622179, 622184, 622184, 622188, 622188, 622199, + 622199, 622200, 622200, 622202, 622202, 622203, 622203, 622208, + 622208, 622210, 622210, 622211, 622211, 622212, 622212, 622213, + 622213, 622214, 622214, 622215, 622215, 622220, 622220, 622225, + 622225, 622230, 622230, 622235, 622235, 622240, 622240, 622245, + 622245, 622250, 622250, 622251, 622251, 622252, 622252, 622253, + 622253, 622254, 622254, 622258, 622258, 622259, 622259, 622260, + 622260, 622261, 622261, 622280, 622280, 622291, 622291, 622292, + 622292, 622301, 622301, 622302, 622302, 622303, 622303, 622305, + 622305, 622307, 622307, 622308, 622308, 622310, 622310, 622311, + 622311, 622312, 622312, 622316, 622316, 622318, 622318, 622319, + 622319, 622321, 622321, 622322, 622322, 622323, 622323, 622324, + 622324, 622325, 622325, 622327, 622327, 622328, 622328, 622329, + 622329, 622331, 622331, 622332, 622332, 622333, 622333, 622335, + 622335, 622336, 622336, 622337, 622337, 622338, 622338, 622339, + 622339, 622340, 622340, 622341, 622341, 622342, 622342, 622343, + 622343, 622345, 622345, 622346, 622346, 622347, 622347, 622348, + 622348, 622349, 622349, 622350, 622350, 622351, 622351, 622352, + 622352, 622353, 622353, 622355, 622355, 622358, 622358, 622359, + 622359, 622360, 622360, 622361, 622361, 622362, 622362, 622363, + 622363, 622365, 622365, 622366, 622366, 622367, 622367, 622368, + 622368, 622369, 622369, 622370, 622370, 622371, 622371, 622373, + 622373, 622375, 622375, 622376, 622376, 622377, 622377, 622378, + 622378, 622379, 622379, 622382, 622382, 622383, 622383, 622384, + 622384, 622385, 622385, 622386, 622386, 622387, 622387, 622388, + 622388, 622389, 622389, 622391, 622391, 622392, 622392, 622393, + 622393, 622394, 622394, 622395, 622395, 622396, 622396, 622397, + 622397, 622398, 622399, 622399, 622400, 622400, 622406, 622406, + 622407, 622407, 622411, 622411, 622412, 622412, 622413, 622413, + 622415, 622415, 622418, 622418, 622420, 622420, 622421, 622421, + 622422, 622422, 622423, 622423, 622425, 622425, 622426, 622426, + 622427, 622427, 622428, 622428, 622429, 622429, 622432, 622432, + 622434, 622434, 622435, 622435, 622436, 622436, 622439, 622439, + 622440, 622440, 622441, 622441, 622442, 622442, 622443, 622443, + 622447, 622447, 622448, 622448, 622449, 622449, 622450, 622450, + 622451, 622451, 622452, 622452, 622453, 622453, 622456, 622456, + 622459, 622459, 622462, 622462, 622463, 622463, 622466, 622466, + 622467, 622467, 622468, 622468, 622470, 622470, 622471, 622471, + 622472, 622472, 622476, 622476, 622477, 622477, 622478, 622478, + 622481, 622481, 622485, 622485, 622486, 622486, 622487, 622487, + 622487, 622487, 622488, 622488, 622489, 622489, 622490, 622490, + 622490, 622490, 622491, 622491, 622491, 622491, 622492, 622492, + 622492, 622492, 622493, 622493, 622495, 622495, 622496, 622496, + 622498, 622498, 622499, 622499, 622500, 622500, 622506, 622506, + 622509, 622509, 622510, 622510, 622516, 622516, 622517, 622517, + 622518, 622518, 622519, 622519, 622521, 622521, 622522, 622522, + 622523, 622523, 622525, 622525, 622526, 622526, 622538, 622538, + 622546, 622546, 622547, 622547, 622548, 622548, 622549, 622549, + 622550, 622550, 622561, 622561, 622562, 622562, 622563, 622563, + 622575, 622575, 622576, 622576, 622577, 622577, 622578, 622578, + 622579, 622579, 622580, 622580, 622581, 622581, 622582, 622582, + 622588, 622588, 622598, 622598, 622600, 622600, 622601, 622601, + 622602, 622602, 622603, 622603, 622615, 622615, 622617, 622617, + 622619, 622619, 622622, 622622, 622630, 622630, 622631, 622631, + 622632, 622632, 622633, 622633, 622650, 622650, 622655, 622655, + 622658, 622658, 622660, 622660, 622678, 622678, 622679, 622679, + 622680, 622680, 622681, 622681, 622682, 622682, 622684, 622684, + 622688, 622688, 622689, 622689, 622690, 622690, 622691, 622691, + 622692, 622692, 622696, 622696, 622698, 622698, 622700, 622700, + 622725, 622725, 622728, 622728, 622750, 622750, 622751, 622751, + 622752, 622752, 622753, 622753, 622754, 622755, 622755, 622756, + 622756, 622757, 622757, 622758, 622758, 622759, 622759, 622760, + 622760, 622761, 622761, 622762, 622762, 622763, 622763, 622770, + 622770, 622777, 622777, 622821, 622821, 622822, 622822, 622823, + 622823, 622824, 622824, 622825, 622825, 622826, 622826, 622827, + 622836, 622836, 622837, 622837, 622840, 622840, 622841, 622842, + 622843, 622844, 622844, 622845, 622845, 622846, 622846, 622847, + 622847, 622848, 622848, 622849, 622855, 622855, 622856, 622856, + 622857, 622857, 622858, 622858, 622859, 622859, 622860, 622860, + 622861, 622861, 622864, 622864, 622865, 622865, 622866, 622866, + 622867, 622867, 622869, 622869, 622870, 622870, 622871, 622871, + 622877, 622877, 622878, 622878, 622879, 622879, 622880, 622880, + 622881, 622881, 622882, 622882, 622884, 622884, 622885, 622885, + 622886, 622886, 622891, 622891, 622892, 622892, 622893, 622893, + 622895, 622895, 622897, 622897, 622898, 622898, 622900, 622900, + 622901, 622901, 622908, 622908, 622909, 622909, 622940, 622982, + 628218, 628288, 628366, 628368, 650600, 650600, 650700, 650700, + 650800, 650800, 650900, 650900, 682900, 682900, 683970, 683970, + 685800, 685800, 685800, 685800, 685800, 685800, 690755, 690755, + 690755, 690755, 694301, 694301, 695800, 695800, 843010, 843010, + 843360, 843360, 843420, 843420, 843610, 843610, 843730, 843730, + 843800, 843800, 843850, 843850, 843900, 843900, 870000, 870000, + 870100, 870100, 870300, 870300, 870400, 870400, 870500, 870500, + 888000, 888000, 940056, 955880, 955881, 955882, 955888, 984301, + 998800 }; + + /** + * 发卡行.卡种名称 + */ + private static final String[] bankName = { "广东发展银行.广发理财通", "农业银行.金穗借记卡", + "昆明农联社.金碧卡", "中国光大银行.阳光爱心卡", "上海银行.双币种申卡贷记卡个人金卡", + "上海银行.双币种申卡贷记卡个人普卡", "中国银行.中银JCB卡金卡", "中国银行.中银JCB卡普卡", + "中国光大银行.阳光商旅信用卡", "中国光大银行.阳光商旅信用卡", "中国光大银行.阳光商旅信用卡", + "中国光大银行.阳光商旅信用卡", "招商银行.招商银行银行信用卡", "招商银行.招商银行银行信用卡", + "招商银行.招商银行银行信用卡", "招商银行.招商银行银行信用卡", "招商银行.招商银行银行信用卡", + "招商银行.招商银行银行信用卡", "工商银行.牡丹运通卡金卡", "工商银行.牡丹运通卡普通卡", + "中国工商银行.牡丹运通卡金卡", "中国工商银行.牡丹运通卡金卡", "中信实业银行.中信贷记卡", + "中国银行.长城国际卡(美元卡)-商务普卡", "中国银行.长城国际卡(美元卡)-商务金卡", + "中国银行.长城国际卡(港币卡)-商务普卡", "中国银行.长城国际卡(港币卡)-商务金卡", + "中国银行.长城国际卡(美元卡)-个人普卡", "中国银行.长城国际卡(美元卡)-个人金卡", "招商银行.两地一卡通", + "上海银行.申卡贷记卡", "工商银行.国际借记卡", "农业银行.金穗贷记卡", "中信实业银行.中信贷记卡", + "农业银行.金穗贷记卡", "中信实业银行.中信贷记卡", "中信实业银行.中信贷记卡", "中信实业银行.中信贷记卡", + "中信实业银行.中信贷记卡", "中信实业银行.中信贷记卡", "上海浦东发展银行.上海浦东发展银行信用卡VISA普通卡", + "上海浦东发展银行.上海浦东发展银行信用卡VISA金卡", "交通银行.太平洋互连卡", "交通银行.太平洋互连卡", + "中国光大银行.阳光信用卡", "中国光大银行.阳光信用卡", "广东发展银行.广发VISA信用卡", "民生银行.民生贷记卡", + "中国银行.中银威士信用卡员工普卡", "中国银行.中银威士信用卡个人普卡", "中国银行.中银威士信用卡员工金卡", + "中国银行.中银威士信用卡个人金卡", "中国银行.中银威士信用卡员工白金卡", "中国银行.中银威士信用卡个人白金卡", + "中国银行.中银威士信用卡商务白金卡", "中国银行.长城公务卡", "招商银行银行.招商银行银行国际卡", + "深圳发展银行.发展借记卡", "深圳发展银行.发展借记卡", "民生银行.民生借记卡", "北京银行.京卡双币种国际借记卡", + "建设银行.乐当家银卡VISA", "民生银行.民生国际卡", "中信实业银行.中信国际借记卡", "民生银行.民生国际卡", + "民生银行.民生贷记卡", "民生银行.民生贷记卡", "民生银行.民生贷记卡", "北京银行.京卡贵宾金卡", + "北京银行.京卡贵宾白金卡", "中国银行.长城人民币信用卡-个人金卡", "中国银行.长城人民币信用卡-员工金卡", + "中国银行.长城人民币信用卡-个人普卡", "中国银行.长城人民币信用卡-员工普卡", "中国银行.长城人民币信用卡-单位普卡", + "中国银行.长城人民币信用卡-单位金卡", "中国银行.长城国际卡(美元卡)-白金卡", "中国光大银行.阳光商旅信用卡", + "工商银行.牡丹VISA信用卡", "工商银行.牡丹VISA信用卡", "工商银行.牡丹VISA信用卡", + "工商银行.牡丹VISA信用卡", "工商银行.国际借记卡", "工商银行.牡丹VISA信用卡", "工商银行.国际借记卡", + "工商银行.牡丹VISA信用卡", "工商银行.牡丹VISA信用卡", "工商银行.牡丹VISA信用卡", + "中国民生银行.民生国际借记卡", "广东发展银行.广发信用卡", "华夏.华夏卡", "华夏.华夏卡", + "中信实业银行.中信贷记卡", "中信实业银行.中信借记卡", "中信实业银行.中信借记卡", "建设银行.乐当家金卡VISA", + "建设银行.乐当家白金卡VISA", "深圳发展银行.沃尔玛百分卡", "深圳发展银行.沃尔玛百分卡", + "建设银行.龙卡贷记卡公司卡金卡VISA", "建设银行.龙卡普通卡VISA", "建设银行.龙卡贷记卡公司卡普通卡VISA", + "建设银行.龙卡储蓄卡", "建设银行.龙卡国际普通卡VISA", "建设银行.龙卡国际金卡VISA", + "广东发展银行.广发信用卡", "中国银行.中银奥运信用卡个人卡", "工商银行.牡丹VISA信用卡", + "中国工商银行.牡丹VISA白金卡", "兴业银行.兴业智能卡", "兴业银行.兴业智能卡", "上海银行.上海申卡IC", + "招商银行.招商银行银行信用卡", "招商银行.VISA信用卡", "招商银行.VISA商务信用卡", + "中信实业银行.中信国际借记卡", "中信实业银行.中信国际借记卡", "兴业银行.VISA信用卡", + "中国银行.长城国际卡(欧元卡)-个人金卡", "工商银行.牡丹贷记卡", "工商银行.牡丹贷记卡", "工商银行.牡丹贷记卡", + "工商银行.牡丹贷记卡", "建设银行.VISA准贷记卡", "中国银行.长城电子借记卡", + "上海浦东发展银行.浦发银行VISA年青卡", "工商银行.牡丹信用卡", "工商银行.牡丹信用卡", "工商银行.牡丹贷记卡", + "工商银行.牡丹贷记卡", "交通银行.太平洋双币贷记卡VISA", "交通银行.太平洋双币贷记卡VISA", + "招商银行.招商银行银行国际卡", "民生银行.民生国际卡", "民生银行.民生国际卡", "招商银行.招商银行银行信用卡", + "招商银行.招商银行银行信用卡", "中国光大银行.阳光白金信用卡", "上海银行.申卡贷记卡", "兴业银行.VISA商务普卡", + "兴业银行.VISA商务金卡", "中国光大银行.阳光商旅信用卡", "广东发展银行.广发VISA信用卡", + "中国建设银行.VISA白金/钻石信用卡", "中国工商银行.牡丹欧元卡", "中国工商银行.牡丹欧元卡", + "中国工商银行.牡丹欧元卡", "农业银行.金穗信用卡", "农业银行.金穗信用卡", "建设银行.VISA准贷记金卡", + "广东发展银行.广发信用卡", "交通银行.太平洋信用卡", "广东发展银行.广发信用卡", + "中国银行.长城国际卡(港币卡)-个人金卡", "上海浦东发展银行.上海浦东发展银行信用卡VISA白金卡", + "常州商业银行.月季卡", "工商银行.牡丹万事达国际借记卡", "中国银行.中银万事达信用卡员工普卡", + "中国银行.中银万事达信用卡个人普卡", "中国银行.中银万事达信用卡员工金卡", "中国银行.中银万事达信用卡个人金卡", + "招商银行.招商银行银行国际卡", "宁波市商业银行.汇通国际卡", "民生银行.民生贷记卡", + "中国银行.长城国际卡(英镑卡)-个人普卡", "中国银行.长城国际卡(英镑卡)-个人金卡", "中信实业银行.中信贷记卡", + "中国银行.中银万事达信用卡员工白金卡", "中国银行.中银万事达信用卡个人白金卡", "民生银行.民生贷记卡", + "中信实业银行.中信贷记卡", "广东发展银行.广发信用卡", "中国银行.长城人民币信用卡-个人金卡", + "中国银行.长城人民币信用卡-员工金卡", "中国银行.长城人民币信用卡-专用卡普卡", "中国银行.长城人民币信用卡-员工普卡", + "中国银行.长城人民币信用卡-个人普卡", "招商银行.MASTER信用卡", "招商银行.MASTER信用金卡", + "农业银行.金穗贷记卡", "上海银行.双币种申卡贷记卡普通卡", "农业银行.金穗贷记卡", "中信实业银行.中信贷记卡", + "上海银行.双币种申卡贷记卡金卡", "广东发展银行.广发万事达信用卡", "交通银行.太平洋双币贷记卡MasterCard", + "宁波市商业银行.汇通国际卡", "广东发展银行.广发万事达信用卡", "交通银行.太平洋双币贷记卡MasterCard", + "中国银行.长城国际卡(欧元卡)-个人普卡", "兴业银行.万事达信用卡", "招商银行.招商银行银行国际卡", + "工商银行.牡丹万事达白金卡", "兴业银行.万事达信用卡", "中国工商银行.牡丹海航信用卡个人金卡", + "建设银行.乐当家金卡MASTER", "中国银行.长城信用卡", "中国银行.长城信用卡", + "中国工商银行.牡丹海航信用卡个人普卡", "中国银行.长城信用卡", "中国银行.长城信用卡", + "建设银行.乐当家银卡MASTER", "深圳市商业银行.深圳市商业银行信用卡", "兴业银行.加菲猫信用卡", + "深圳市商业银行.深圳市商业银行信用卡", "广东发展银行.广发万事达信用卡", "民生银行.民生贷记卡", + "工商银行.牡丹万事达信用卡", "工商银行.牡丹信用卡", "工商银行.牡丹信用卡", "工商银行.牡丹万事达信用卡", + "建设银行.MASTER准贷记卡", "建设银行.龙卡普通卡MASTER", "建设银行.龙卡国际普通卡MASTER", + "建设银行.龙卡国际金卡MASTER", "农业银行.金穗信用卡", "农业银行.金穗信用卡", "农业银行.金穗信用卡", + "交通银行.太平洋信用卡", "中国银行.长城国际卡(港币卡)-个人普卡", "中国银行.长城国际卡(美元卡)-个人普卡", + "中国银行.长城国际卡(美元卡)-个人金卡", "广东发展银行.广发信用卡", "中国光大银行.第十八届世界足球锦标赛纪念卡", + "建设银行.MASTER准贷记金卡", "招商银行.万事达信用卡", "招商银行.万事达信用卡", "招商银行.万事达信用卡", + "中国银行.长城国际卡(美元卡)-商务普卡", "中国银行.长城国际卡(港币卡)-商务普卡", + "中国银行.长城人民币信用卡-单位普卡", "中国银行.长城万事达信用卡单位普卡", "工商银行.国际借记卡", + "广东发展银行.广发信用卡", "建设银行.乐当家白金卡MASTER", "民生银行.民生贷记卡", + "招商银行.招商银行银行信用卡", "招商银行.招商银行银行信用卡", "农业银行.金穗贷记卡", "中国银行.长城公务卡", + "广东发展银行.广发万事达信用卡", "建设银行.龙卡贷记卡公司卡普通卡MASTER", + "交通银行.太平洋双币贷记卡MasterCard", "中国银行.长城公务卡", "建设银行.龙卡信用卡", + "民生银行.民生贷记卡", "中信实业银行.中信MASTERCARD人民币+美金双币贷记卡", "工商银行.牡丹万事达信用卡", + "农业银行.金穗贷记卡", "中国银行.长城国际卡(港币卡)-商务金卡", "中国银行.长城国际卡(美元卡)-商务金卡", + "中国银行.长城人民币信用卡-单位金卡", "中国银行.中银万事达信用卡单位金卡", "广东发展银行.广发万事达信用卡", + "建设银行.龙卡贷记卡公司卡金卡MASTER", "中信实业银行.中信MASTERCARD人民币+美金双币贷记卡", + "沈阳市商业银行.玫瑰卡", "深圳农联社.信通卡", "D.F.S.I(备注1).发现卡", "D.F.S.I.发现卡", + "D.F.S.I.发现卡", "D.F.S.I.发现卡", "D.F.S.I.发现卡", "D.F.S.I.发现卡", + "D.F.S.I.发现卡", "D.F.S.I.发现卡", "D.F.S.I.发现卡", "D.F.S.I.发现卡", + "D.F.S.I.发现卡", "D.F.S.I.发现卡", "D.F.S.I.发现卡", "D.F.S.I.发现卡", + "D.F.S.I.发现卡", "D.F.S.I.发现卡", "D.F.S.I.发现卡", "D.F.S.I.发现卡", + "D.F.S.I.发现卡", "D.F.S.I.发现卡", "D.F.S.I.发现卡", "D.F.S.I.发现卡", + "D.F.S.I.发现卡", "D.F.S.I.发现卡", "D.F.S.I.发现卡", "D.F.S.I.发现卡", + "D.F.S.I.发现卡", "D.F.S.I.发现卡", "D.F.S.I.发现卡", "D.F.S.I.发现卡", + "D.F.S.I.发现卡", "中国银行.长城电子借记卡", "中国银行.长城电子借记卡", "交通银行.太平洋万事顺卡", + "交通银行.太平洋万事顺卡", "交通银行.太平洋万事顺卡", "交通银行.太平洋万事顺卡", "深圳商业银行.万事顺卡", + "深圳商业银行.万事顺卡", "北京银行.京卡", "北京银行.京卡", "南京市商业银行.梅花卡", "南京市商业银行.梅花卡", + "杭州商业银行.西湖卡", "杭州商业银行.西湖卡", "广州市商业银行.羊城借记卡", "广州市商业银行.羊城借记卡", + "苏州市商业银行.姑苏卡", "苏州市商业银行.姑苏卡", "徽商银行合肥分行.黄山卡", "徽商银行合肥分行.黄山卡", + "徽商银行合肥分行.黄山卡", "徽商银行合肥分行.黄山卡", "徽商银行合肥分行.黄山卡", "徽商银行合肥分行.黄山卡", + "绍兴商业银行.兰花卡", "绍兴商业银行.兰花卡", "常熟农村商业银行.粒金卡", "常熟农村商业银行.粒金卡", + "大连商业银行.北方明珠卡", "大连商业银行.北方明珠卡", "河北省农村信用社.信通卡", "韩亚银行.", + "温州商业银行.金鹿卡", "温州商业银行.金鹿卡", "阜新市商业银行.金通卡", "阜新市商业银行.金通卡", + "福建省农村信用社联合社.万通", "厦门市农村信用合作社.万通卡", "福建省农村信用社联合社.万通", + "厦门市农村信用合作社.万通卡", "深圳农信社.信通卡", "深圳农信社.信通卡", "深圳市农村信用合作社联合社.信通商务卡", + "深圳市农村信用合作社联合社.信通商务卡", "淮安市商业银行.九州借记卡", "淮安市商业银行.九州借记卡", + "嘉兴市商业银行.南湖借记卡", "嘉兴市商业银行.南湖借记卡", "贵阳市商业银行.甲秀银联借记卡", + "贵阳市商业银行.甲秀银联借记卡", "重庆市商业银行.长江卡", "重庆市商业银行.长江卡", "成都商业银行.锦程卡", + "成都商业银行.锦程卡", "西安市商业银行.福瑞卡", "西安市商业银行.福瑞卡", "徽商银行芜湖分行.黄山卡", + "徽商银行芜湖分行.黄山卡", "北京农联社.信通卡", "北京农联社.信通卡", "兰州市商业银行.敦煌国际卡", + "兰州市商业银行.敦煌国际卡", "廊坊市商业银行.银星卡", "廊坊市商业银行.银星卡", "泰隆城市信用社.泰隆卡", + "泰隆城市信用社.泰隆卡", "乌鲁木齐市商业银行.雪莲借记卡", "乌鲁木齐市商业银行.雪莲借记卡", "青岛商行.金桥卡", + "青岛商行.金桥卡", "呼市商业银行.百灵卡", "呼市商业银行.百灵卡", "上海银行.人民币申卡贷记卡金卡", + "上海银行.人民币申卡贷记卡金卡", "上海银行.人民币申卡贷记卡普通卡", "上海银行.人民币申卡贷记卡普通卡", + "国家邮政局.绿卡银联标准卡", "国家邮政局.绿卡银联标准卡", "国家邮政局.绿卡银联标准卡", "国家邮政局.绿卡银联标准卡", + "成都市商业银行.锦程卡金卡", "成都市商业银行.锦程卡金卡", "成都市商业银行.锦程卡定活一卡通金卡", + "成都市商业银行.锦程卡定活一卡通金卡", "成都市商业银行.锦程卡定活一卡通", "成都市商业银行.锦程卡定活一卡通", + "深圳市商业银行.深圳市商业银行信用卡", "深圳市商业银行.深圳市商业银行信用卡", "深圳市商业银行.深圳市商业银行信用卡", + "深圳市商业银行.深圳市商业银行信用卡", "包头市商业银行.包头市商业银行借记卡", "包头市商业银行.包头市商业银行借记卡", + "中国建设银行.龙卡人民币信用卡", "中国建设银行.龙卡人民币信用卡", "中国建设银行.龙卡人民币信用金卡", + "中国建设银行.龙卡人民币信用金卡", "湖南省农村信用社联合社.福祥借记卡", "湖南省农村信用社联合社.福祥借记卡", + "吉林市商业银行.信用卡", "吉林市商业银行.信用卡", "吉林市商业银行.信用卡", "吉林市商业银行.信用卡", + "福建省农村信用社联合社.万通", "福建省农村信用社联合社.万通", "国家邮政局.绿卡银联标准卡", + "国家邮政局.绿卡银联标准卡", "国家邮政局.绿卡银联标准卡", "国家邮政局.绿卡银联标准卡", "中国工商银行.灵通卡", + "中国工商银行.灵通卡", "中国工商银行.E时代卡", "中国工商银行.E时代卡", "中国工商银行.E时代卡", + "中国工商银行.E时代卡", "中国工商银行.理财金卡", "中国工商银行.理财金卡", "中国工商银行.准贷记卡", + "中国工商银行.准贷记卡", "中国工商银行.准贷记卡", "中国工商银行.准贷记卡", "中国工商银行.准贷记卡", + "中国工商银行.准贷记卡", "中国工商银行.准贷记卡", "中国工商银行.准贷记卡", "中国工商银行.准贷记卡", + "中国工商银行.准贷记卡", "中国工商银行.准贷记卡", "中国工商银行.准贷记卡", "中国工商银行.准贷记卡", + "中国工商银行.准贷记卡", "中国工商银行.准贷记卡", "中国工商银行.准贷记卡", "中国工商银行.贷记卡", + "中国工商银行.贷记卡", "中国工商银行.贷记卡", "中国工商银行.贷记卡", "中国工商银行.贷记卡", + "中国工商银行.贷记卡", "中国工商银行.贷记卡", "中国工商银行.贷记卡", + "交通银行股份有限公司太平洋双币信用卡中心.太平洋人民币贷记卡", "交行太平洋卡中心.太平洋人民币贷记卡", + "交通银行股份有限公司太平洋双币信用卡中心.太平洋人民币贷记卡", "交行太平洋卡中心.太平洋人民币贷记卡", + "交通银行股份有限公司太平洋双币信用卡中心.太平洋人民币贷记卡", "交行太平洋卡中心.太平洋人民币贷记卡", + "交通银行股份有限公司太平洋双币信用卡中心.太平洋人民币贷记卡", "交行太平洋卡中心.太平洋人民币贷记卡", + "交通银行.太平洋人民币准贷记卡", "交通银行.太平洋人民币准贷记卡", "交通银行.太平洋人民币借记卡", + "交通银行.太平洋人民币借记卡", "交通银行.太平洋人民币借记卡", "交通银行.太平洋人民币借记卡", + "交通银行.太平洋人民币借记卡", "交通银行.太平洋人民币借记卡", "交通银行.太平洋人民币借记卡", + "交通银行.太平洋人民币借记卡", "建设银行.622280银联储蓄卡", "建设银行.622280银联储蓄卡", + "柳州市商业银行.龙城卡", "柳州市商业银行.龙城卡", "柳州市商业银行.龙城卡", "柳州市商业银行.龙城卡", + "湖州市商业银行.百合卡", "湖州市商业银行.百合卡", "佛山市禅城区农村信用联社.信通卡", + "佛山市禅城区农村信用联社.信通卡", "南京市商业银行.梅花贷记卡", "南京市商业银行.梅花贷记卡", + "南京市商业银行.梅花借记卡", "南京市商业银行.梅花借记卡", "九江市商业银行.庐山卡", "九江市商业银行.庐山卡", + "昆明商业银行.春城卡", "昆明商业银行.春城卡", "西宁市商业银行.三江银行卡", "西宁市商业银行.三江银行卡", + "淄博市商业银行.金达借记卡", "淄博市商业银行.金达借记卡", "徐州市郊农村信用合作联社.信通卡", + "徐州市郊农村信用合作联社.信通卡", "宁波市商业银行.汇通卡", "宁波市商业银行.汇通卡", "宁波市商业银行.汇通卡", + "宁波市商业银行.汇通卡", "山东农村信用联合社.信通卡", "山东农村信用联合社.信通卡", "台州市商业银行.大唐贷记卡", + "台州市商业银行.大唐贷记卡", "顺德农信社.恒通卡", "顺德农信社.恒通卡", "常熟农村商业银行.粒金借记卡", + "常熟农村商业银行.粒金借记卡", "江苏农信.圆鼎卡", "江苏农信.圆鼎卡", "武汉市商业银行.九通卡", + "武汉市商业银行.九通卡", "徽商银行马鞍山分行.黄山卡", "徽商银行马鞍山分行.黄山卡", "东莞农村信用合作社.信通卡", + "东莞农村信用合作社.信通卡", "天津市农村信用社.信通借记卡", "天津市农村信用社.信通借记卡", "天津市商业银行.津卡", + "天津市商业银行.津卡", "张家港市农村商业银行.一卡通", "张家港市农村商业银行.一卡通", "东莞市商业银行.万顺通卡", + "东莞市商业银行.万顺通卡", "南宁市商业银行.桂花卡", "南宁市商业银行.桂花卡", "包头市商业银行.雄鹰卡", + "包头市商业银行.雄鹰卡", "连云港市商业银行.金猴神通借记卡", "连云港市商业银行.金猴神通借记卡", + "焦作市商业银行.月季借记卡", "焦作市商业银行.月季借记卡", "鄞州农村合作银行.蜜蜂借记卡", + "鄞州农村合作银行.蜜蜂借记卡", "徽商银行淮北分行.黄山卡", "徽商银行淮北分行.黄山卡", "江阴农村商业银行.合作借记卡", + "江阴农村商业银行.合作借记卡", "攀枝花市商业银行.攀枝花卡", "攀枝花市商业银行.攀枝花卡", + "佛山市三水区农村信用合作社.信通卡", "佛山市三水区农村信用合作社.信通卡", "成都农信社.天府借记卡", + "成都农信社.天府借记卡", "中国银行.人民币信用卡金卡", "中国银行.人民币信用卡金卡", "中国银行.人民币信用卡普通卡", + "中国银行.人民币信用卡普通卡", "中国银行.中银卡", "中国银行.中银卡", "南洋商业银行.人民币信用卡金卡", + "南洋商业银行.人民币信用卡金卡", "南洋商业银行.人民币信用卡普通卡", "南洋商业银行.人民币信用卡普通卡", + "南洋商业银行.中银卡", "南洋商业银行.中银卡", "集友银行.人民币信用卡金卡", "集友银行.人民币信用卡金卡", + "集友银行.人民币信用卡普通卡", "集友银行.人民币信用卡普通卡", "集友银行.中银卡", "集友银行.中银卡", + "沧州农信社.信通卡", "沧州农信社.信通卡", "临沂市商业银行.沂蒙卡", "临沂市商业银行.沂蒙卡", + "香港上海汇丰银行有限公司.人民币卡", "香港上海汇丰银行有限公司.人民币卡", "香港上海汇丰银行有限公司.人民币金卡", + "香港上海汇丰银行有限公司.人民币金卡", "中山市农村信用合作社.信通卡", "中山市农村信用合作社.信通卡", + "珠海市商业银行.万事顺卡", "珠海市商业银行.万事顺卡", "东亚银行有限公司.电子网络人民币卡", + "东亚银行有限公司.电子网络人民币卡", "徽商银行安庆分行.黄山卡", "徽商银行安庆分行.黄山卡", + "绵阳市商业银行.科技城卡", "绵阳市商业银行.科技城卡", "长沙市商业银行.芙蓉卡", "长沙市商业银行.芙蓉卡", + "昆明市农村信用联社.金碧一卡通", "昆明市农村信用联社.金碧一卡通", "泉州市商业银行.海峡银联卡", + "泉州市商业银行.海峡银联卡", "花旗银行有限公司.花旗人民币信用卡", "花旗银行有限公司.花旗人民币信用卡", + "大新银行有限公司.大新人民币信用卡普通卡", "大新银行有限公司.大新人民币信用卡普通卡", "大新银行有限公司.人民币借记卡", + "大新银行有限公司.人民币借记卡", "恒生银行有限公司.恒生人民币信用卡", "恒生银行有限公司.恒生人民币信用卡", + "恒生银行有限公司.恒生人民币金卡", "恒生银行有限公司.恒生人民币金卡", "恒生银行有限公司.恒生人民币白金卡", + "恒生银行有限公司.恒生人民币白金卡", "济南市商业银行.齐鲁卡", "济南市商业银行.齐鲁卡", "美国银行.人民币卡", + "美国银行.人民币卡", "大连市商业银行.大连市商业银行贷记卡", "大连市商业银行.大连市商业银行贷记卡", + "恒丰银行.九州借记卡", "恒丰银行.九州借记卡", "大连市商业银行.大连市商业银行贷记卡", + "大连市商业银行.大连市商业银行贷记卡", "上海商业银行.人民币信用卡", "上海商业银行.人民币信用卡", + "永隆银行有限公司.永隆人民币信用卡", "永隆银行有限公司.永隆人民币信用卡", "福州市商业银行.榕城卡", + "福州市商业银行.榕城卡", "宁波鄞州农村合作银行.蜜蜂贷记卡", "宁波鄞州农村合作银行.蜜蜂贷记卡", + "潍坊商业银行.鸢都卡", "潍坊商业银行.鸢都卡", "泸州市商业银行.酒城卡", "泸州市商业银行.酒城卡", + "厦门市商业银行.银鹭借记卡", "厦门市商业银行.银鹭借记卡", "镇江市商业银行.金山灵通卡", "镇江市商业银行.金山灵通卡", + "大同市商业银行.云冈卡", "大同市商业银行.云冈卡", "宜昌市商业银行.三峡卡", "宜昌市商业银行.三峡卡", + "宜昌市商业银行.信用卡", "宜昌市商业银行.信用卡", "葫芦岛市商业银行.一通卡", "辽阳市商业银行.新兴卡", + "辽阳市商业银行.新兴卡", "营口市商业银行.辽河一卡通", "营口市商业银行.辽河一卡通", + "香港上海汇丰银行有限公司.ATM Card", "香港上海汇丰银行有限公司.ATM Card", + "香港上海汇丰银行有限公司.ATM Card", "香港上海汇丰银行有限公司.ATM Card", "威海市商业银行.通达卡", + "威海市商业银行.通达卡", "湖北农信社.信通卡", "湖北农信社.信通卡", "鞍山市商业银行.千山卡", + "鞍山市商业银行.千山卡", "丹东商行.银杏卡", "丹东商行.银杏卡", "南通市商业银行.金桥卡", + "南通市商业银行.金桥卡", "洛阳市商业银行.都市一卡通", "洛阳市商业银行.都市一卡通", "郑州商业银行.世纪一卡通", + "郑州商业银行.世纪一卡通", "扬州市商业银行.绿扬卡", "扬州市商业银行.绿扬卡", "永隆银行有限公司.永隆人民币信用卡", + "永隆银行有限公司.永隆人民币信用卡", "哈尔滨市商业银行.丁香借记卡", "哈尔滨市商业银行.丁香借记卡", + "天津市商业银行.津卡贷记卡", "天津市商业银行.津卡贷记卡", "台州市商业银行.大唐卡", "台州市商业银行.大唐卡", + "银川市商业银行.如意卡", "银川市商业银行.如意卡", "银川市商业银行.如意借记卡", "银川市商业银行.如意借记卡", + "大西洋银行股份有限公司.澳门币卡", "大西洋银行股份有限公司.澳门币卡", "澳门国际银行.人民币卡", + "澳门国际银行.人民币卡", "澳门国际银行.港币卡", "澳门国际银行.港币卡", "澳门国际银行.澳门币卡", + "澳门国际银行.澳门币卡", "广州农村信用合作社联合社.麒麟储蓄卡", "广州农村信用合作社.麒麟储蓄卡", + "吉林市商业银行.雾凇卡", "吉林市商业银行.雾凇卡", "三门峡市城市信用社.天鹅卡", "三门峡市城市信用社.天鹅卡", + "抚顺市商业银行.绿叶卡", "抚顺市商业银行.绿叶卡", "昆山农村信用合作社联合社.江通卡", + "昆山农村信用合作社联合社.江通卡", "常州商业银行.月季卡", "常州商业银行.月季卡", "湛江市商业银行.南珠卡", + "湛江市商业银行.南珠卡", "金华市商业银行.双龙借记卡", "金华市商业银行.双龙借记卡", "金华市商业银行.双龙贷记卡", + "金华市商业银行.双龙贷记卡", "大新银行有限公司.大新人民币信用卡金卡", "大新银行有限公司.大新人民币信用卡金卡", + "江苏农信社.圆鼎卡", "江苏农信社.圆鼎卡", "中信嘉华银行有限公司.人民币信用卡金卡", + "中信嘉华银行有限公司.人民币信用卡金卡", "中信嘉华银行有限公司.人民币信用卡普通卡", + "中信嘉华银行有限公司.人民币信用卡普通卡", "中信嘉华银行有限公司.人民币借记卡", "中信嘉华银行有限公司.人民币借记卡", + "常熟市农村商业银行.粒金贷记卡", "常熟市农村商业银行.粒金贷记卡", "廖创兴银行有限公司.港币借记卡", + "廖创兴银行有限公司.港币借记卡", "沈阳市商业银行.玫瑰卡", "沈阳市商业银行.玫瑰卡", "广州市商业银行.羊城借记卡", + "广州市商业银行.羊城借记卡", "上海银行.申卡", "上海银行.申卡", "江门市新会农信社.信通卡", + "江门市新会农信社.信通卡", "东亚银行有限公司.人民币信用卡", "东亚银行有限公司.人民币信用卡", + "东亚银行有限公司.人民币信用卡金卡", "东亚银行有限公司.人民币信用卡金卡", "乌鲁木齐市商业银行.雪莲贷记卡", + "乌鲁木齐市商业银行.雪莲贷记卡", "高要市农村信用联社.信通卡", "高要市农村信用联社.信通卡", + "上海市农村信用合作社联合社.如意卡", "上海市农村信用合作社联社.如意卡", "江阴市农村商业银行.合作贷记卡", + "江阴市农村商业银行.合作贷记卡", "无锡市商业银行.太湖金保卡", "无锡市商业银行.太湖金保卡", "绍兴市商业银行.兰花卡", + "绍兴市商业银行.兰花卡", "星展银行.银联人民币银行卡", "星展银行.银联人民币银行卡", "星展银行.银联人民币银行卡", + "星展银行.银联人民币银行卡", "吴江农村商业银行.垂虹卡", "吴江农村商业银行.垂虹卡", "大新银行有限公司.借记卡", + "大新银行有限公司.借记卡", "星展银行.银联人民币银行卡", "星展银行.银联人民币银行卡", "星展银行.银联人民币银行卡", + "星展银行.银联人民币银行卡", "星展银行.银联银行卡", "星展银行.银联港币银行卡", "星展银行.银联港币银行卡", + "星展银行.银联银行卡", "星展银行.银联银行卡", "星展银行.银联港币银行卡", "星展银行.银联港币银行卡", + "星展银行.银联银行卡", "AEON信贷财务.AEON JUSCO银联卡", "AEON信贷财务.AEON JUSCO银联卡", + "Travelex.Travelex港币卡", "Travelex.Travelex港币卡", + "Travelex.Travelex美元卡", "Travelex.Travelex美元卡", "石家庄市商业银行.如意借记卡", + "石家庄市商业银行.如意借记卡", "石家庄市商业银行.如意借记卡", "石家庄市商业银行.如意借记卡", + "上海浦东发展银行.东方卡", "上海浦东发展银行.东方卡", "陕西省农村信用社联合社.陕西信合富泰卡", + "陕西省农村信用社联合社.陕西信合富泰卡", "高要市农村信用合作社联合社.信通白金卡", "高要市农村信用合作社联社.信通白金卡", + "高要市农村信用合作社联合社.信通金卡", "高要市农村信用合作社联社.信通金卡", "上海浦东发展银行.东方-轻松理财卡白金卡", + "上海浦东发展银行.东方-轻松理财卡白金卡", "上海浦东发展银行.东方-轻松理财卡普卡", + "上海浦东发展银行.东方-轻松理财卡普卡", "上海浦东发展银行.东方-轻松理财卡钻石卡", + "上海浦东发展银行.东方-轻松理财卡钻石卡", "上海浦东发展银行.东方-新标准准贷记卡", + "上海浦东发展银行.东方-新标准准贷记卡", "上海浦东发展银行.东方卡", "上海浦东发展银行.东方卡", + "上海浦东发展银行.东方卡", "上海浦东发展银行.东方卡", "上海浦东发展银行.东方卡", "上海浦东发展银行.东方卡", + "深圳发展银行.人民币信用卡金卡", "深圳发展银行.人民币信用卡金卡", "深圳发展银行.人民币信用卡普卡", + "深圳发展银行.人民币信用卡普卡", "深圳发展银行.发展卡", "深圳发展银行.发展卡", "大丰银行有限公司.人民币借记卡", + "大丰银行有限公司.人民币借记卡", "大丰银行有限公司.港币借记卡", "大丰银行有限公司.港币借记卡", + "大丰银行有限公司.澳门币借记卡", "大丰银行有限公司.澳门币借记卡", + "哈萨克斯坦国民储蓄银行.Halykbank Classic", "哈萨克斯坦国民储蓄银行.Halykbank Classic", + "哈萨克斯坦国民储蓄银行.Halykbank Golden", "哈萨克斯坦国民储蓄银行.Halykbank Golden", + "德阳市商业银行.锦程卡定活一卡通白金卡", "德阳市商业银行.锦程卡定活一卡通白金卡", "德阳市商业银行.锦程卡定活一卡通金卡", + "德阳市商业银行.锦程卡定活一卡通金卡", "德阳市商业银行.锦程卡定活一卡通", "德阳市商业银行.锦程卡定活一卡通", + "招商银行.招商银行信用卡", "招商银行银行.招商银行银行信用卡", "招商银行.招商银行信用卡", + "招商银行银行.招商银行银行信用卡", "招商银行.招商银行信用卡", "招商银行银行.招商银行银行信用卡", + "招商银行.招商银行信用卡", "招商银行银行.招商银行银行信用卡", "招商银行.招商银行信用卡", + "招商银行银行.招商银行银行信用卡", "招商银行.一卡通", "招商银行银行.一卡通", "招商银行.招商银行信用卡", + "招商银行银行.招商银行银行信用卡", "招商银行.招商银行信用卡", "招商银行银行.招商银行银行信用卡", "招商银行.一卡通", + "招商银行银行.一卡通", "招商银行.公司卡", "招商银行银行.公司卡", "民生银行.民生信用卡", "民生银行.民生信用卡", + "民生银行.民生信用卡", "民生银行.民生信用卡", "中国民生银行.民生银联白金信用卡", "中国民生银行.民生银联白金信用卡", + "中国民生银行.民生银联商务信用卡", "中国民生银行.民生银联商务信用卡", "民生银行.民生借记卡", "民生银行.民生借记卡", + "中国民生银行.民生借记卡", "中国民生银行.民生借记卡", "中国民生银行.民生借记卡", "中国民生银行.民生借记卡", + "中国民生银行.民生借记卡", "中国民生银行.民生借记卡", "华夏银行.华夏卡", "华夏银行.华夏卡", + "华夏银行.华夏至尊金卡", "华夏银行.华夏至尊金卡", "华夏银行.华夏丽人卡", "华夏银行.华夏丽人卡", + "华夏银行.华夏万通卡", "华夏银行.华夏万通卡", "中国光大银行.炎黄卡普卡", "中国光大银行.炎黄卡普卡", + "中国光大银行.炎黄卡白金卡", "中国光大银行.炎黄卡白金卡", "中国光大银行.炎黄卡金卡", "中国光大银行.炎黄卡金卡", + "光大银行.阳光卡", "光大银行.阳光卡", "中信实业银行信用卡中心.中信银联标准贷记卡", + "中信实业银行信用卡中心.中信银联标准贷记卡", "中信实业银行信用卡中心.中信银联标准贷记卡", + "中信实业银行信用卡中心.中信银联标准贷记卡", "中信实业银行信用卡中心.中信银联标准贷记卡", + "中信实业银行信用卡中心.中信银联标准贷记卡", "江西省农村信用社联合社.百福卡", "江西省农村信用社联合社.百福卡", + "江西省农村信用社联合社.百福卡", "江西省农村信用社联合社.百福卡", "渤海银行.渤海银行公司借记卡", + "渤海银行.渤海银行公司借记卡", "中信实业银行信用卡中心.中信银联标准贷记卡", "中信实业银行信用卡中心.中信银联标准贷记卡", + "中信实业银行信用卡中心.中信银联标准贷记卡", "中信实业银行信用卡中心.中信银联标准贷记卡", "中信实业银行.中信借记卡", + "中信实业银行.中信借记卡", "中信实业银行.中信借记卡", "中信实业银行.中信借记卡", "中信实业银行.中信贵宾卡", + "中信实业银行.中信贵宾卡", "中信银行.中信理财宝金卡", "中信银行.中信理财宝金卡", "中信银行.中信理财宝白金卡", + "中信银行.中信理财宝白金卡", "建设银行.龙卡储蓄卡", "中国建设银行.龙卡储蓄卡", "中国建设银行.龙卡准贷记卡", + "中国建设银行.龙卡准贷记卡", "中国建设银行.龙卡准贷记卡金卡", "中国建设银行.龙卡准贷记卡金卡", + "中国银行澳门分行.人民币信用卡", "中国银行澳门分行.人民币信用卡", "中国银行澳门分行.人民币信用卡", + "中国银行澳门分行.人民币信用卡", "中国银行.长城人民币信用卡", "中国银行.长城人民币信用卡-个人普卡", + "中国银行.长城人民币信用卡", "中国银行.长城人民币信用卡-个人金卡", "中国银行.长城人民币信用卡-专用卡普卡", + "中国银行.长城人民币信用卡", "中国银行.长城人民币信用卡-员工金卡", "中国银行.长城人民币信用卡", + "中国银行.长城人民币信用卡-员工金卡", "中国银行.长城人民币信用卡", "中国银行.长城人民币信用卡-员工金卡", + "中国银行.长城人民币信用卡", "中国银行.长城人民币信用卡-单位普卡", "中国银行.长城信用卡", + "中国银行.长城人民币信用卡-单位金卡", "中国银行.银联单币贷记卡", "中国银行.银联单币贷记卡", "中国银行.长城信用卡", + "中国银行.长城信用卡", "中国银行.长城信用卡", "中国银行.长城信用卡", "中国银行.长城信用卡", + "中国银行.长城信用卡", "中国银行澳门分行.中银卡", "中国银行澳门分行.中银卡", "曲靖市商业银行.珠江源卡", + "曲靖市商业银行.珠江源卡", "农业银行.金穗校园卡", "农业银行.金穗校园卡", "农业银行.金穗星座卡", + "农业银行.金穗星座卡", "农业银行.金穗社保卡", "农业银行.金穗社保卡", "农业银行.金穗旅游卡", + "农业银行.金穗旅游卡", "农业银行.金穗青年卡", "农业银行.金穗青年卡", "农业银行.复合介质金穗通宝卡", + "农业银行.复合介质金穗通宝卡", "农业银行.金穗海通卡", "农业银行.金穗贷记卡", "农业银行.金穗贷记卡", + "农业银行.金穗贷记卡", "农业银行.金穗贷记卡", "农业银行.金穗通宝卡(暂未使用)", "农业银行.金穗通宝卡", + "农业银行.金穗惠农卡", "农业银行.金穗通宝卡(暂未使用)", "农业银行.金穗通宝贵宾卡(银)", + "农业银行.金穗通宝卡(暂未使用)", "农业银行.金穗通宝卡", "农业银行.金穗通宝贵宾卡(金)", "农业银行.金穗通宝卡", + "农业银行.金穗通宝贵宾卡(白金)", "中国农业银行.金穗通宝卡", "农业银行.金穗通宝卡(单位卡)", + "农业银行.金穗通宝卡", "农业银行.金穗通宝卡(个人普卡)", "农业银行.金穗通宝卡", "农业银行.金穗通宝贵宾卡(钻石)", + "江苏东吴农村商业银行.新苏卡", "江苏东吴农村商业银行.新苏卡", "桂林市商业银行.漓江卡", "桂林市商业银行.漓江卡", + "日照市商业银行.黄海卡", "日照市商业银行.黄海卡", "浙江省农村信用社联合社.丰收卡", "浙江省农村信用社联社.丰收卡", + "珠海农村信用合作社联社.信通卡", "珠海农村信用合作联社.信通卡", "大庆市商业银行.玉兔卡", "大庆市商业银行.玉兔卡", + "澳门永亨银行股份有限公司.人民币卡", "澳门永亨银行股份有限公司.人民币卡", "莱芜市商业银行.金凤卡", + "莱芜市商业银行.金凤卡", "长春市商业银行.君子兰一卡通", "长春市商业银行.君子兰一卡通", "徐州市商业银行.彭城借记卡", + "徐州市商业银行.彭城借记卡", "重庆市农村信用社联合社.信合平安卡", "重庆市农村信用社联合社.信合平安卡", + "太仓农村商业银行.郑和卡", "太仓农村商业银行.郑和卡", "靖江市长江城市信用社.长江卡", "靖江市长江城市信用社.长江卡", + "永亨银行.永亨尊贵理财卡", "永亨银行.永亨尊贵理财卡", "徽商银行.黄山卡", "徽商银行.黄山卡", + "杭州市商业银行.西湖卡", "杭州市商业银行.西湖卡", "徽商银行.黄山卡", "徽商银行.黄山卡", + "柳州市商业银行.龙城卡", "柳州市商业银行.龙城卡", "柳州市商业银行.龙城卡", "柳州市商业银行.龙城卡", + "尧都区农村信用合作社联社.天河卡", "尧都区农村信用合作社联社.天河卡", "渤海银行.渤海银行借记卡", + "渤海银行.渤海银行借记卡", "重庆市农村信用社联合社.信合希望卡", "重庆市农村信用社联合社.信合希望卡", + "烟台市商业银行.金通卡", "烟台市商业银行.金通卡", "武进农村商业银行.阳湖卡", "武进农村商业银行.阳湖卡", + "上海银行.申卡借记卡", "上海银行.申卡借记卡", "贵州省农村信用社联合社.信合卡", "贵州省农村信用社联合社.信合卡", + "江苏锡州农村商业银行.金阿福", "江苏锡州农村商业银行.金阿福", "中外合资.南充市商业银行.熊猫团团卡", + "中外合资.南充市商业银行.熊猫团团卡", "长沙市商业银行.芙蓉贷记卡", "长沙市商业银行.芙蓉贷记卡", + "长沙市商业银行.芙蓉贷记卡", "长沙市商业银行.芙蓉贷记卡", "兴业银行.银联信用卡", "兴业银行.银联信用卡", + "兴业银行.兴业自然人生理财卡", "兴业银行.兴业自然人生理财卡", "兴业银行.万能卡", "兴业银行.万能卡", + "石嘴山城市信用社.麒麟卡", "张家口市商业银行.好运卡", "交通银行.太平洋卡", "中国工商银行.公务卡", + "中国建设银行.公务卡", "大庆市商业银行.公务卡", "Discover Financial Services,Inc.发现卡", + ".发现卡", "Discover Financial Services,Inc.发现卡", ".发现卡", + "Discover Financial Services,Inc.发现卡", ".发现卡", + "Discover Financial Services,Inc.发现卡", ".发现卡", "上海银行.上海明珠卡", + "上海银行.上海明珠卡", "泉州市商业银行.海峡储蓄卡", "泉州市商业银行.海峡储蓄卡", "广东发展银行.广发信用卡", + "广东发展银行.广发VISA信用卡", "广东发展银行.广发理财通", "广东发展银行.广发VISA信用卡", + "广东发展银行.广发理财通", "广东发展银行.广发信用卡", "招商.招行一卡通", "招商.招行一卡通", + "招商银行.招商银行银行一卡通", "招商银行.招商银行银行一卡通", "长沙市商业银行.芙蓉卡", "长沙市商业银行.芙蓉卡", + "南通商业银行.金桥卡", "南通商业银行.金桥卡", "浦东发展银行.东方卡", "浦东发展银行.东方卡", + "浦东发展银行.东方卡", "浦东发展银行.东方卡", "浦东发展银行.东方卡", "浦东发展银行.东方卡", + "浦东发展银行.东方卡", "浦东发展银行.东方卡", "浦东发展银行.东方卡", "浦东发展银行.东方卡", + "浦东发展银行.东方卡", "浦东发展银行.东方卡", "浦东发展银行.东方卡", "浦东发展银行.东方卡", + "浦东发展银行.东方卡", "浦东发展银行.东方卡", "浦东发展银行.东方卡", "浦东发展银行.东方卡", + "浦东发展银行.东方卡", "浦东发展银行.东方卡", "浦东发展银行.东方卡", "浦东发展银行.东方卡", + "浦东发展银行.东方卡", "浦东发展银行.东方卡", "浦东发展银行.东方卡", "浦东发展银行.东方卡", + "贵阳市商业银行.甲秀卡", "贵阳市商业银行.甲秀卡", "郑州市商业银行.世纪一卡通", "工商银行.牡丹银联灵通卡-个人普卡", + "工商银行.牡丹银联灵通卡-个人普卡", "工商银行.牡丹银联灵通卡-个人金卡", "工商银行.牡丹银联理财金卡", + "上海浦东发展银行.东方卡", "深圳发展银行.发展卡" }; + + public static Map checkBankCar(String cardId){ + Map map = new HashMap(3); + boolean checkBankCard = checkBankCard(cardId); + map.put("card",checkBankCard); + String nameOfBank = getNameOfBank(cardId); + map.put("cardName",nameOfBank); + return map; + } + + public static void main(String[] args) { + + String cards = "1035481552887309119"; + Map stringObjectMap = checkBankCar(cards); + System.out.println(stringObjectMap); + } +} diff --git a/src/main/resources/application.properties b/src/main/resources/application.properties new file mode 100644 index 0000000..25b3cd9 --- /dev/null +++ b/src/main/resources/application.properties @@ -0,0 +1,102 @@ +server.port = 6809 + +## 数据源配置 +#spring.datasource.url = jdbc:postgresql://118.24.27.47:5432/fire_point +#spring.datasource.userName = fire_manage +#spring.datasource.password = fire456 +#spring.datasource.driverClassName = org.postgresql.Driver + +spring.datasource.url = jdbc:postgresql://localhost:5432/shopping +spring.datasource.userName = postgres +spring.datasource.password = 123456 +spring.datasource.driverClassName = org.postgresql.Driver + +server.tomcat.uri-encoding=UTF-8 + +# 关闭spring data 的redis仓库 +spring.data.redis.repositories.enabled = false + +# jackson 配置 +spring.jackson.serialization.write-date-keys-as-timestamps=false + +## Hikari连接池设置 +spring.datasource.hikari.auto-commit = true +spring.datasource.hikari.maximum-pool-size = 100 +spring.datasource.hikari.idle-timeout = 10000 +spring.datasource.hikari.minimum-idle = 5 +spring.datasource.hikari.validation-timeout = 3000 + +## Spring Data JPA 配置 +spring.jpa.database = POSTGRESQL +spring.jpa.database-platform = org.hibernate.dialect.PostgreSQLDialect +spring.jpa.show-sql = true +# 指定 ddl mode (none, validate, create, create-drop, update) +spring.jpa.hibernate.ddl-auto = update +# 命名策略 +spring.jpa.hibernate.naming-strategy = org.hibernate.cfg.ImprovedNamingStrategy +#spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.PostgreSQL95Dialect +#spring.jpa.properties.hibernate.dialect = org.hibernate.spatial.dialect.postgis.PostgisDialect +spring.jpa.properties.hibernate.temp.use_jdbc_metadata_defaults = false + +spring.jpa.properties.hibernate.jdbc.batch_size=500 +spring.jpa.properties.hibernate.jdbc.batch_versioned_data=true +spring.jpa.properties.hibernate.order_inserts=true +spring.jpa.properties.hibernate.order_updates =true + +## Redis配置 12 +spring.cache.type = redis +spring.redis.database = 12 +spring.redis.host = localhost +spring.redis.port = 6379 +spring.redis.password=sdust2020 +spring.redis.timeout = 10000 +spring.redis.lettuce.pool.max-active = 100 +spring.redis.lettuce.pool.max-wait = 10000 +spring.redis.lettuce.pool.max-idle = 100 +spring.redis.lettuce.pool.min-idle = 1 +spring.redis.lettuce.shutdown-timeout = 0 + +## Devtools配置 +spring.devtools.livereload.enabled = true + +## 多国语言配置 +spring.messages.basename = i18n/messages +spring.messages.encoding = UTF-8 + +# 上传文件配置 +spring.servlet.multipart.enabled=true +# 最大文件大小 +spring.servlet.multipart.max-file-size = 100MB +# 最大请求大小 +spring.servlet.multipart.max-request-size = 100MB + +spring.main.allow-bean-definition-overriding = true + +# Geoserver服务器地址 +my.GeoserverAdress = http://139.199.98.175:9080/geoserver/ + +# 文件服务器地址 +my.FileServerAdress = http://139.199.98.175:4096/ +my.FileServerAdminAdress = http://127.0.0.1:4096/ + +dfs.ip = 192.168.2.9 +dfs.port = 4096 + +## 自定义用户最大登录错误尝试次数 +my.MaxLoginErrorCount = 5 + +## 自定义用户登录错误间隔时间(分钟) +my.LoginErrorIntervalTime = 60 + + +#公共密钥 +qiniu.accessKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +# 私钥 +qiniu.secretKey=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX +# 空间名 +qiniu.bucket=XXXXXXX + +qiniu.zone=XXXXXXX +# 外链默认域名 +qiniu.domain=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX + diff --git a/src/main/resources/i18n/messages.properties b/src/main/resources/i18n/messages.properties new file mode 100644 index 0000000..8cfedc5 --- /dev/null +++ b/src/main/resources/i18n/messages.properties @@ -0,0 +1,162 @@ +sys.message.success = 成功 +sys.message.null = 暂时还没有数据 +sys.message.exit = 已存在相关内容,请勿重复操作 +sys.message.user.not_logged_in = 用户未登录 +sys.message.user.login_error = 用户登陆失败 +sys.message.user.account_forbidden = 用户已被禁止 +sys.message.user.account_not_activated = 用户未激活 +sys.message.user.overtime = 用户登录超时 +sys.message.user.no_permission = 用户权限不足 +sys.message.user.already_logged = 用户已经登录 +sys.message.param.null = 参数为空 +sys.message.param.illegal = 参数非法 +sys.message.data.none = 数据为空 +sys.message.data.wrong = 数据错误 +sys.message.process.fail = 处理失败 +sys.message.process.overtime = 处理超时 +sys.message.system.inner_error = 系统内部错误 +sys.message.system.abnormal = 系统异常 +sys.message.system.busy = 系统正忙,请稍后 +sys.message.system.maintain = 系统维护中 +sys.message.database.error = 数据库错误 +sys.message.file.exists = 文件已存在 +sys.message.file.write.error = 文件写入失败 +sys.message.file.read.error = 文件读取失败 + +SysUser.id.blank = 用户id不能为空 +SysUser.userName.blank = 用户名不能为空 +SysUser.userName.length.illegal = 用户名长度不合法 +SysUser.userName.format.illegal = 用户名格式不合法 +SysUser.nickName.length.illegal = 用户昵称长度不合法 +SysUser.userCode.length.illegal = 用户编码长度不合法 +SysUser.userCode.format.illegal = 用户编码含有非法字符 +SysUser.password.blank = 用户密码不能为空 +SysUser.password.length.illegal = 用户密码长度不合法 +SysUser.password.format.illegal = 用户密码格式不合法 +SysUser.sex.num.null = 用户性别数字不能为空 +SysUser.sex.num.illegal = 用户性别数字不合法 +SysUser.telephone.format.illegal = 用户手机号码不合法 +SysUser.email.length.illegal = 用户邮箱长度不合法 +SysUser.email.format.illegal = 用户邮箱格式不合法 +SysUser.admCode.illegal = 用户行政区划代码不合法 +SysUser.address.length.illegal = 用户详细地址长度不合法 +SysUser.birthday.format.illegal = 用户出生日期必须是 yyyy-MM-dd +SysUser.personalSignature.length.illegal = 用户个性签名长度非法 +SysUser.portraitId.illegal = 用户头像id非法 +SysUser.statusCode.null = 用户当前状态编码为空 +SysUser.statusCode.illegal = 用户当前状态编码非法 +SysUser.deleteFlag.null = 用户删除标记不能是空 + +TrajectoryRecord.id.null = id 不能为空 +TrajectoryRecord.startTimeTs.null = startTimeTs 不能为空 + +SatelliteFirePoint.id.null = id 不能为空 +SatelliteFirePoint.fireCode.null = fireCode 不能为空 +SatelliteFirePoint.fireCode.length.illegal = fireCode 长度过长 +SatelliteFirePoint.countyCode.null = countyCode 不能为空 +SatelliteFirePoint.countyCode.length.illegal = countyCode 长度过长 +SatelliteFirePoint.countyName.null = countyName 不能为空 +SatelliteFirePoint.countyName.length.illegal = countyName 长度过长 +SatelliteFirePoint.satelliteType.null = satelliteType 不能为空 +SatelliteFirePoint.fireStatus.null = fireStatus 不能为空 +SatelliteFirePoint.verifyStatus.null = verifyStatus 不能为空 +SatelliteFirePoint.satelliteTimeTs.null = satelliteTimeTs 不能为空 + +PictureFirePoint.id.null = id 不能为空 +PictureFirePoint.fireCode.null = fireCode 不能为空 +PictureFirePoint.fireCode.length.illegal = fireCode 长度过长 +PictureFirePoint.pictureName.length.illegal = pictureName 长度过长 +PictureFirePoint.picturePath.null = picturePath 不能为空 +PictureFirePoint.picturePath.length.illegal = picturePath 长度过长 +PictureFirePoint.memo.length.illegal = memo 长度过长 +PictureFirePoint.size.length.illegal = size 长度过长 +PictureFirePoint.md5.null = md5 不能为空 +PictureFirePoint.md5.length.illegal = md5 长度过长 +PictureFirePoint.shootTimeTs.null = shootTimeTs 不能为空 + +PersonInvestigator.id.null = id 不能为空 +PersonInvestigator.name.null = name 不能为空 +PersonInvestigator.name.length.illegal = name 长度过长 +PersonInvestigator.code.length.illegal = code 长度过长 +PersonInvestigator.telephone.null = telephone 不能为空 +PersonInvestigator.telephone.format.illegal = telephone 格式非法 +PersonInvestigator.sex.null = sex 不能为空 +PersonInvestigator.sex.format.illegal = sex 格式非法 +PersonInvestigator.idCard.length.illegal = idCard 长度过长 +PersonInvestigator.memo.length.illegal = memo 长度过长 +PersonInvestigator.linkUserName.null = linkUserName 不能为空 +PersonInvestigator.linkUserName.format.illegal = linkUserName 格式非法 +PersonInvestigator.password.null = password 不能为空 +PersonInvestigator.password.format.illegal = password 格式非法 +InvestigateFirePoint.verifyTimeTs.null = verifyTimeTs 不能为空 + +InvestigateFirePoint.id.null = id 不能为空 +InvestigateFirePoint.fireCode.null = fireCode 不能为空 +InvestigateFirePoint.fireCode.length.illegal = fireCode 长度过长 +InvestigateFirePoint.countyCode.null = countyCode 不能为空 +InvestigateFirePoint.countyCode.length.illegal = countyCode 长度过长 +InvestigateFirePoint.countyName.null = countyName 不能为空 +InvestigateFirePoint.countyName.length.illegal = countyName 长度过长 +InvestigateFirePoint.address.null = address 不能为空 +InvestigateFirePoint.fireArea.null = fireArea 不能为空 +InvestigateFirePoint.verifyType.null = verifyType 不能为空 +InvestigateFirePoint.satelliteType.null = satelliteType 不能为空 +InvestigateFirePoint.satelliteType.length.illegal = satelliteType 长度过长 + +FileDocument.id.null = id 不能为空 +FileDocument.name.null = name 不能为空 +FileDocument.name.length.illegal = name 长度过长 +FileDocument.category.length.illegal = category 长度过长 +FileDocument.filePath.null = filePath 不能为空 +FileDocument.filePath.length.illegal = filePath 长度过长 +FileDocument.size.length.illegal = size 长度过长 +FileDocument.md5.null = md5 不能为空 +FileDocument.md5.length.illegal = md5 长度过长 +FileDocument.memo.length.illegal = memo 长度过长 +FileDocument.checkingToken.length.illegal = checkingToken 长度过长 + +AppFile.id.null = id 不能为空 +AppFile.name.null = name 不能为空 +AppFile.name.length.illegal = name 长度过长 +AppFile.appPath.null = appPath 不能为空 +AppFile.appPath.length.illegal = appPath 长度过长 +AppFile.versionNumber.null = versionNumber 不能为空 +AppFile.versionNumber.length.illegal = versionNumber 长度过长 +AppFile.versionNumber.format.illegal = versionNumber 格式不合法 +AppFile.size.null = size 不能为空 +AppFile.size.length.illegal = size 长度过长 +AppFile.md5.null = md5 不能为空 +AppFile.md5.length.illegal = md5 长度过长 +AppFile.memo.length.illegal = memo 长度过长 + +RealFirePoint.id.null = id 不能为空 +RealFirePoint.fireCode.null = fireCode 不能为空 +RealFirePoint.fireCode.length.illegal = fireCode 不合法 +RealFirePoint.countyCode.null = countyCode 不能为空 +RealFirePoint.countyCode.length.illegal = countyCode 不合法 +RealFirePoint.countyName.null = countyName 不能为空 +RealFirePoint.countyName.length.illegal = countyName 不合法 +RealFirePoint.address.null = address 不能为空 +RealFirePoint.address.length.illegal = address 不合法 +RealFirePoint.fireArea.null = fireArea 不能为空 +RealFirePoint.verifyTimeTs.null = verifyTimeTs 不能为空 +RealFirePoint.verifyType.null = verifyType 不能为空 + +InvestigationTeam.id.null = id 不能为空 +InvestigationTeam.teamName.null = teamName 不能为空 +InvestigationTeam.teamName.length.illegal = teamName 长度过长 +InvestigationTeam.memo.length.illegal = memo 长度过长 +InvestigationTeam.userName.null = userName 不能为空 +InvestigationTeam.userName.length.illegal = userName 长度过长 +InvestigationTeam.userRealName.null = userRealName 不能为空 +InvestigationTeam.userRealName.length.illegal = userRealName 长度过长 + +RelTeamInvestigator.id.null = id 不能为空 +RelTeamInvestigator.teamCode.null = teamCode 不能为空 +RelTeamInvestigator.teamCode.length.illegal = teamCode 长度过长 +RelTeamInvestigator.userName.null = userName 不能为空 +RelTeamInvestigator.userName.length.illegal = userName 长度过长 +RelTeamInvestigator.teamDeputy.null = teamDeputy 不能为空 +RelTeamInvestigator.memo.length.illegal = memo 长度过长 +RelTeamInvestigator.userRealName.null = userRealName 不能为空 +RelTeamInvestigator.userRealName.length.illegal = userRealName 长度过长 diff --git a/src/main/resources/i18n/messages_en_US.properties b/src/main/resources/i18n/messages_en_US.properties new file mode 100644 index 0000000..9b23e85 --- /dev/null +++ b/src/main/resources/i18n/messages_en_US.properties @@ -0,0 +1,162 @@ +sys.message.success = success +sys.message.null = null +sys.message.exit = data already exists +sys.message.user.not_logged_in = user not logged in +sys.message.user.login_error = user login failed +sys.message.user.account_forbidden = this account is forbidden +sys.message.user.account_not_activated = this account not activated +sys.message.user.overtime = user login timeout +sys.message.user.no_permission = user permission denied +sys.message.user.already_logged = user already logged +sys.message.param.null = parameter is null +sys.message.param.illegal = parameter is illegal +sys.message.data.none = data is none +sys.message.data.wrong = data is wrong +sys.message.process.fail = process fail +sys.message.process.overtime = process overtime +sys.message.system.inner_error = system inner error +sys.message.system.abnormal = system abnormal +sys.message.system.busy = system is busy +sys.message.system.maintain = system maintenance +sys.message.database.error = database error +sys.message.file.exists = file exists +sys.message.file.write.error = file write error +sys.message.file.read.error = file read error + +SysUser.id.blank = user id can't be blank +SysUser.userName.blank = user name can't be blank +SysUser.userName.length.illegal = user name length illegal +SysUser.userName.format.illegal = user name format illegal +SysUser.nickName.length.illegal = user nickname length illegal +SysUser.userCode.length.illegal = user code length illegal +SysUser.userCode.format.illegal = user code cantains illegal character +SysUser.password.blank = user password can't be blank +SysUser.password.length.illegal = user password length illegal +SysUser.password.format.illegal = user password format illegal +SysUser.sex.num.null = user sex num can't be blank +SysUser.sex.num.illegal = user sex num illegal +SysUser.telephone.format.illegal = user telephone format illegal +SysUser.email.length.illegal = user email length illegal +SysUser.email.format.illegal = user email format illegal +SysUser.admCode.illegal = user administrative area code illegal +SysUser.address.length.illegal = user address length illegal +SysUser.birthday.format.illegal = user birthday must be yyyy-MM-dd +SysUser.personalSignature.length.illegal = user personal signature length illegal +SysUser.portraitId.illegal = user portrait id illegal +SysUser.statusCode.null = user current status code can't be blank +SysUser.statusCode.illegal = user current status code illegal +SysUser.deleteFlag.null = user delete flag can't be null + +TrajectoryRecord.id.null = id can't be null +TrajectoryRecord.startTimeTs.null = startTimeTs can't be null + +SatelliteFirePoint.id.null = id can't be blank +SatelliteFirePoint.fireCode.null = fireCode can't be blank +SatelliteFirePoint.fireCode.length.illegal = fireCode length illegal +SatelliteFirePoint.countyCode.null = countyCode can't be blank +SatelliteFirePoint.countyCode.length.illegal = countyCode length illegal +SatelliteFirePoint.countyName.null = countyName can't be blank +SatelliteFirePoint.countyName.length.illegal = countyName length illegal +SatelliteFirePoint.satelliteType.null = satelliteType can't be blank +SatelliteFirePoint.fireStatus.null = fireStatus can't be blank +SatelliteFirePoint.verifyStatus.null = verifyStatus can't be blank +SatelliteFirePoint.satelliteTimeTs.null = satelliteTimeTs can't be blank + +PictureFirePoint.id.null = id can't be blank +PictureFirePoint.fireCode.null = fireCode can't be blank +PictureFirePoint.fireCode.length.illegal = fireCode length illegal +PictureFirePoint.pictureName.length.illegal = pictureName length illegal +PictureFirePoint.picturePath.null = picturePath can't be blank +PictureFirePoint.picturePath.length.illegal = picturePath length illegal +PictureFirePoint.memo.length.illegal = memo length illegal +PictureFirePoint.size.length.illegal = size length illegal +PictureFirePoint.md5.null = md5 can't be blank +PictureFirePoint.md5.length.illegal = md5 length illegal +PictureFirePoint.shootTimeTs.null = shootTimeTs can't be blank + +PersonInvestigator.id.null = id can't be blank +PersonInvestigator.name.null = name can't be blank +PersonInvestigator.name.length.illegal = name length illegal +PersonInvestigator.code.length.illegal = code length illegal +PersonInvestigator.telephone.null = telephone can't be blank +PersonInvestigator.telephone.format.illegal = telephone format illegal +PersonInvestigator.sex.null = sex format can't be blank +PersonInvestigator.sex.format.illegal = sex format illegal +PersonInvestigator.idCard.length.illegal = idCard length illegal +PersonInvestigator.memo.length.illegal = memo length illegal +PersonInvestigator.linkUserName.null = linkUserName can't be blank +PersonInvestigator.linkUserName.format.illegal = linkUserName format illegal +PersonInvestigator.password.null = password can't be blank +PersonInvestigator.password.format.illegal = password format +InvestigateFirePoint.verifyTimeTs.null = verifyTimeTs can't be blank + +InvestigateFirePoint.id.null = id can't be blank +InvestigateFirePoint.fireCode.null = fireCode can't be blank +InvestigateFirePoint.fireCode.length.illegal = fireCode length illegal +InvestigateFirePoint.countyCode.null = countyCode can't be blank +InvestigateFirePoint.countyCode.length.illegal = countyCode length illegal +InvestigateFirePoint.countyName.null = countyName can't be blank +InvestigateFirePoint.countyName.length.illegal = countyName length illegal +InvestigateFirePoint.address.null = address can't be blank +InvestigateFirePoint.fireArea.null = fireArea can't be blank +InvestigateFirePoint.verifyType.null = verifyType can't be blank +InvestigateFirePoint.satelliteType.null = satelliteType can't be blank +InvestigateFirePoint.satelliteType.length.illegal = satelliteType length illegal + +FileDocument.id.null = id can't be blank +FileDocument.name.null = name can't be blank +FileDocument.name.length.illegal = name length illegal +FileDocument.category.length.illegal = category length illegal +FileDocument.filePath.null = filePath can't be blank +FileDocument.filePath.length.illegal = filePath length illegal +FileDocument.size.length.illegal = size length illegal +FileDocument.md5.null = md5 can't be blank +FileDocument.md5.length.illegal = md5 length illegal +FileDocument.memo.length.illegal = memo length illegal +FileDocument.checkingToken.length.illegal = checkingToken length illegal + +AppFile.id.null = id can't be blank +AppFile.name.null = name can't be blank +AppFile.name.length.illegal = name length illegal +AppFile.appPath.null = appPath can't be blank +AppFile.appPath.length.illegal = appPath length illegal +AppFile.versionNumber.null = versionNumber can't be blank +AppFile.versionNumber.length.illegal = versionNumber length illegal +AppFile.versionNumber.format.illegal = versionNumber illegal +AppFile.size.null = size can't be blank +AppFile.size.length.illegal = size length illegal +AppFile.md5.null = md5 can't be blank +AppFile.md5.length.illegal = md5 length illegal +AppFile.memo.length.illegal = memo length illegal + +RealFirePoint.id.null = id can't be blank +RealFirePoint.fireCode.null = fireCode can't be blank +RealFirePoint.fireCode.length.illegal = fireCode illegal +RealFirePoint.countyCode.null = countyCode can't be blank +RealFirePoint.countyCode.length.illegal = countyCode +RealFirePoint.countyName.null = countyName can't be blank +RealFirePoint.countyName.length.illegal = countyName illegal +RealFirePoint.address.null = address can't be blank +RealFirePoint.address.length.illegal = address illegal +RealFirePoint.fireArea.null = fireArea can't be blank +RealFirePoint.verifyTimeTs.null = verifyTimeTs can't be blank +RealFirePoint.verifyType.null = verifyType can't be blank + +InvestigationTeam.id.null = id can't be blank +InvestigationTeam.teamName.null = teamName can't be blank +InvestigationTeam.teamName.length.illegal = teamName length illegal +InvestigationTeam.memo.length.illegal = memo length illegal +InvestigationTeam.userName.null = userName can't be blank +InvestigationTeam.userName.length.illegal = userName length illegal +InvestigationTeam.userRealName.null = userRealName can't be blank +InvestigationTeam.userRealName.length.illegal = userRealName length illegal + +RelTeamInvestigator.id.null = id can't be blank +RelTeamInvestigator.teamCode.null = teamCode can't be blank +RelTeamInvestigator.teamCode.length.illegal = teamCode length illegal +RelTeamInvestigator.userName.null = userName can't be blank +RelTeamInvestigator.userName.length.illegal = userName length illegal +RelTeamInvestigator.teamDeputy.null = teamDeputy can't be blank +RelTeamInvestigator.memo.length.illegal = memo length illegal +RelTeamInvestigator.userRealName.null = userRealName can't be blank +RelTeamInvestigator.userRealName.length.illegal = userRealName length illegal diff --git a/src/main/resources/i18n/messages_zh_CN.properties b/src/main/resources/i18n/messages_zh_CN.properties new file mode 100644 index 0000000..8cfedc5 --- /dev/null +++ b/src/main/resources/i18n/messages_zh_CN.properties @@ -0,0 +1,162 @@ +sys.message.success = 成功 +sys.message.null = 暂时还没有数据 +sys.message.exit = 已存在相关内容,请勿重复操作 +sys.message.user.not_logged_in = 用户未登录 +sys.message.user.login_error = 用户登陆失败 +sys.message.user.account_forbidden = 用户已被禁止 +sys.message.user.account_not_activated = 用户未激活 +sys.message.user.overtime = 用户登录超时 +sys.message.user.no_permission = 用户权限不足 +sys.message.user.already_logged = 用户已经登录 +sys.message.param.null = 参数为空 +sys.message.param.illegal = 参数非法 +sys.message.data.none = 数据为空 +sys.message.data.wrong = 数据错误 +sys.message.process.fail = 处理失败 +sys.message.process.overtime = 处理超时 +sys.message.system.inner_error = 系统内部错误 +sys.message.system.abnormal = 系统异常 +sys.message.system.busy = 系统正忙,请稍后 +sys.message.system.maintain = 系统维护中 +sys.message.database.error = 数据库错误 +sys.message.file.exists = 文件已存在 +sys.message.file.write.error = 文件写入失败 +sys.message.file.read.error = 文件读取失败 + +SysUser.id.blank = 用户id不能为空 +SysUser.userName.blank = 用户名不能为空 +SysUser.userName.length.illegal = 用户名长度不合法 +SysUser.userName.format.illegal = 用户名格式不合法 +SysUser.nickName.length.illegal = 用户昵称长度不合法 +SysUser.userCode.length.illegal = 用户编码长度不合法 +SysUser.userCode.format.illegal = 用户编码含有非法字符 +SysUser.password.blank = 用户密码不能为空 +SysUser.password.length.illegal = 用户密码长度不合法 +SysUser.password.format.illegal = 用户密码格式不合法 +SysUser.sex.num.null = 用户性别数字不能为空 +SysUser.sex.num.illegal = 用户性别数字不合法 +SysUser.telephone.format.illegal = 用户手机号码不合法 +SysUser.email.length.illegal = 用户邮箱长度不合法 +SysUser.email.format.illegal = 用户邮箱格式不合法 +SysUser.admCode.illegal = 用户行政区划代码不合法 +SysUser.address.length.illegal = 用户详细地址长度不合法 +SysUser.birthday.format.illegal = 用户出生日期必须是 yyyy-MM-dd +SysUser.personalSignature.length.illegal = 用户个性签名长度非法 +SysUser.portraitId.illegal = 用户头像id非法 +SysUser.statusCode.null = 用户当前状态编码为空 +SysUser.statusCode.illegal = 用户当前状态编码非法 +SysUser.deleteFlag.null = 用户删除标记不能是空 + +TrajectoryRecord.id.null = id 不能为空 +TrajectoryRecord.startTimeTs.null = startTimeTs 不能为空 + +SatelliteFirePoint.id.null = id 不能为空 +SatelliteFirePoint.fireCode.null = fireCode 不能为空 +SatelliteFirePoint.fireCode.length.illegal = fireCode 长度过长 +SatelliteFirePoint.countyCode.null = countyCode 不能为空 +SatelliteFirePoint.countyCode.length.illegal = countyCode 长度过长 +SatelliteFirePoint.countyName.null = countyName 不能为空 +SatelliteFirePoint.countyName.length.illegal = countyName 长度过长 +SatelliteFirePoint.satelliteType.null = satelliteType 不能为空 +SatelliteFirePoint.fireStatus.null = fireStatus 不能为空 +SatelliteFirePoint.verifyStatus.null = verifyStatus 不能为空 +SatelliteFirePoint.satelliteTimeTs.null = satelliteTimeTs 不能为空 + +PictureFirePoint.id.null = id 不能为空 +PictureFirePoint.fireCode.null = fireCode 不能为空 +PictureFirePoint.fireCode.length.illegal = fireCode 长度过长 +PictureFirePoint.pictureName.length.illegal = pictureName 长度过长 +PictureFirePoint.picturePath.null = picturePath 不能为空 +PictureFirePoint.picturePath.length.illegal = picturePath 长度过长 +PictureFirePoint.memo.length.illegal = memo 长度过长 +PictureFirePoint.size.length.illegal = size 长度过长 +PictureFirePoint.md5.null = md5 不能为空 +PictureFirePoint.md5.length.illegal = md5 长度过长 +PictureFirePoint.shootTimeTs.null = shootTimeTs 不能为空 + +PersonInvestigator.id.null = id 不能为空 +PersonInvestigator.name.null = name 不能为空 +PersonInvestigator.name.length.illegal = name 长度过长 +PersonInvestigator.code.length.illegal = code 长度过长 +PersonInvestigator.telephone.null = telephone 不能为空 +PersonInvestigator.telephone.format.illegal = telephone 格式非法 +PersonInvestigator.sex.null = sex 不能为空 +PersonInvestigator.sex.format.illegal = sex 格式非法 +PersonInvestigator.idCard.length.illegal = idCard 长度过长 +PersonInvestigator.memo.length.illegal = memo 长度过长 +PersonInvestigator.linkUserName.null = linkUserName 不能为空 +PersonInvestigator.linkUserName.format.illegal = linkUserName 格式非法 +PersonInvestigator.password.null = password 不能为空 +PersonInvestigator.password.format.illegal = password 格式非法 +InvestigateFirePoint.verifyTimeTs.null = verifyTimeTs 不能为空 + +InvestigateFirePoint.id.null = id 不能为空 +InvestigateFirePoint.fireCode.null = fireCode 不能为空 +InvestigateFirePoint.fireCode.length.illegal = fireCode 长度过长 +InvestigateFirePoint.countyCode.null = countyCode 不能为空 +InvestigateFirePoint.countyCode.length.illegal = countyCode 长度过长 +InvestigateFirePoint.countyName.null = countyName 不能为空 +InvestigateFirePoint.countyName.length.illegal = countyName 长度过长 +InvestigateFirePoint.address.null = address 不能为空 +InvestigateFirePoint.fireArea.null = fireArea 不能为空 +InvestigateFirePoint.verifyType.null = verifyType 不能为空 +InvestigateFirePoint.satelliteType.null = satelliteType 不能为空 +InvestigateFirePoint.satelliteType.length.illegal = satelliteType 长度过长 + +FileDocument.id.null = id 不能为空 +FileDocument.name.null = name 不能为空 +FileDocument.name.length.illegal = name 长度过长 +FileDocument.category.length.illegal = category 长度过长 +FileDocument.filePath.null = filePath 不能为空 +FileDocument.filePath.length.illegal = filePath 长度过长 +FileDocument.size.length.illegal = size 长度过长 +FileDocument.md5.null = md5 不能为空 +FileDocument.md5.length.illegal = md5 长度过长 +FileDocument.memo.length.illegal = memo 长度过长 +FileDocument.checkingToken.length.illegal = checkingToken 长度过长 + +AppFile.id.null = id 不能为空 +AppFile.name.null = name 不能为空 +AppFile.name.length.illegal = name 长度过长 +AppFile.appPath.null = appPath 不能为空 +AppFile.appPath.length.illegal = appPath 长度过长 +AppFile.versionNumber.null = versionNumber 不能为空 +AppFile.versionNumber.length.illegal = versionNumber 长度过长 +AppFile.versionNumber.format.illegal = versionNumber 格式不合法 +AppFile.size.null = size 不能为空 +AppFile.size.length.illegal = size 长度过长 +AppFile.md5.null = md5 不能为空 +AppFile.md5.length.illegal = md5 长度过长 +AppFile.memo.length.illegal = memo 长度过长 + +RealFirePoint.id.null = id 不能为空 +RealFirePoint.fireCode.null = fireCode 不能为空 +RealFirePoint.fireCode.length.illegal = fireCode 不合法 +RealFirePoint.countyCode.null = countyCode 不能为空 +RealFirePoint.countyCode.length.illegal = countyCode 不合法 +RealFirePoint.countyName.null = countyName 不能为空 +RealFirePoint.countyName.length.illegal = countyName 不合法 +RealFirePoint.address.null = address 不能为空 +RealFirePoint.address.length.illegal = address 不合法 +RealFirePoint.fireArea.null = fireArea 不能为空 +RealFirePoint.verifyTimeTs.null = verifyTimeTs 不能为空 +RealFirePoint.verifyType.null = verifyType 不能为空 + +InvestigationTeam.id.null = id 不能为空 +InvestigationTeam.teamName.null = teamName 不能为空 +InvestigationTeam.teamName.length.illegal = teamName 长度过长 +InvestigationTeam.memo.length.illegal = memo 长度过长 +InvestigationTeam.userName.null = userName 不能为空 +InvestigationTeam.userName.length.illegal = userName 长度过长 +InvestigationTeam.userRealName.null = userRealName 不能为空 +InvestigationTeam.userRealName.length.illegal = userRealName 长度过长 + +RelTeamInvestigator.id.null = id 不能为空 +RelTeamInvestigator.teamCode.null = teamCode 不能为空 +RelTeamInvestigator.teamCode.length.illegal = teamCode 长度过长 +RelTeamInvestigator.userName.null = userName 不能为空 +RelTeamInvestigator.userName.length.illegal = userName 长度过长 +RelTeamInvestigator.teamDeputy.null = teamDeputy 不能为空 +RelTeamInvestigator.memo.length.illegal = memo 长度过长 +RelTeamInvestigator.userRealName.null = userRealName 不能为空 +RelTeamInvestigator.userRealName.length.illegal = userRealName 长度过长 diff --git a/src/main/resources/log4j2.xml b/src/main/resources/log4j2.xml new file mode 100644 index 0000000..2216be2 --- /dev/null +++ b/src/main/resources/log4j2.xml @@ -0,0 +1,100 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file