flowerpig 10 months ago
parent
commit
bcd4b5e530
56 changed files with 4525 additions and 4526 deletions
  1. 8 8
      .gitignore
  2. 2 2
      META-INF/MANIFEST.MF
  3. 28 28
      build.gradle
  4. 27 27
      build.sh
  5. BIN
      gradle/wrapper/gradle-wrapper.jar
  6. 1 2
      gradle/wrapper/gradle-wrapper.properties
  7. 3 3
      gradlew
  8. 84 84
      gradlew.bat
  9. 2 2
      settings.gradle
  10. 15 15
      src/main/java/com/ljsd/Test.java
  11. 42 42
      src/main/java/com/ljsd/controller/ExcelController.java
  12. 97 97
      src/main/java/com/ljsd/controller/GetNoticeController.java
  13. 260 260
      src/main/java/com/ljsd/controller/GetServerListController.java
  14. 284 284
      src/main/java/com/ljsd/controller/GetUserController.java
  15. 100 100
      src/main/java/com/ljsd/controller/GetUserHwController.java
  16. 25 25
      src/main/java/com/ljsd/controller/IndexController.java
  17. 31 31
      src/main/java/com/ljsd/controller/PublishNoticeController.java
  18. 65 65
      src/main/java/com/ljsd/controller/RegistController.java
  19. 15 15
      src/main/java/com/ljsd/controller/RoutePublishNoticeController.java
  20. 63 63
      src/main/java/com/ljsd/controller/ServerListController.java
  21. 56 56
      src/main/java/com/ljsd/controller/TestController.java
  22. 104 104
      src/main/java/com/ljsd/controller/UserLoginController.java
  23. 97 97
      src/main/java/com/ljsd/controller/UserRegisterController.java
  24. 116 116
      src/main/java/com/ljsd/controller/UserRegisterIDCardController.java
  25. 56 56
      src/main/java/com/ljsd/listener/WebContextListener.java
  26. 71 71
      src/main/java/com/ljsd/plat/AbstractMHTPlat.java
  27. 31 31
      src/main/java/com/ljsd/plat/MHTGPPlat.java
  28. 32 32
      src/main/java/com/ljsd/plat/MHTHyTestPlat.java
  29. 32 32
      src/main/java/com/ljsd/plat/MHTIOSPlat.java
  30. 17 17
      src/main/java/com/ljsd/plat/PlatProcess.java
  31. 74 74
      src/main/java/com/ljsd/pojo/NoticeInfo.java
  32. 36 36
      src/main/java/com/ljsd/pojo/ResMsg.java
  33. 72 72
      src/main/java/com/ljsd/pojo/UserRecentLoginInfo.java
  34. 24 24
      src/main/java/com/ljsd/pojo/UserServerInfo.java
  35. 302 302
      src/main/java/com/ljsd/redis/RedisApp.java
  36. 18 18
      src/main/java/com/ljsd/redis/RedisKey.java
  37. 423 423
      src/main/java/com/ljsd/redis/RedisUtil.java
  38. 79 79
      src/main/java/com/ljsd/util/BaseGlobal.java
  39. 162 162
      src/main/java/com/ljsd/util/ClassLoaderHelper.java
  40. 52 52
      src/main/java/com/ljsd/util/EncryptUtils.java
  41. 325 325
      src/main/java/com/ljsd/util/ExcelUtils.java
  42. 45 45
      src/main/java/com/ljsd/util/HttpUtils.java
  43. 211 211
      src/main/java/com/ljsd/util/IdCard.java
  44. 11 11
      src/main/java/com/ljsd/util/KTSDKConstans.java
  45. 37 37
      src/main/java/com/ljsd/util/MD5Util.java
  46. 37 37
      src/main/java/com/ljsd/util/MHTSDKConstans.java
  47. 130 130
      src/main/java/com/ljsd/util/MyMongoDBPool.java
  48. 40 40
      src/main/java/com/ljsd/util/NetUtil.java
  49. 201 201
      src/main/java/com/ljsd/util/StringUtils.java
  50. 76 76
      src/main/java/com/ljsd/util/TimeUtil.java
  51. 42 42
      src/main/resources/application.properties
  52. 49 49
      src/main/resources/logback.xml
  53. 149 149
      src/main/webapp/WEB-INF/web.xml
  54. 65 65
      src/main/webapp/index.jsp
  55. 57 57
      src/main/webapp/list.jsp
  56. 44 44
      src/main/webapp/updateNotice.jsp

+ 8 - 8
.gitignore

@@ -1,8 +1,8 @@
-*.iml
-.idea
-.gradle
-build
-out
-
-
-
+*.iml
+.idea
+.gradle
+build
+out
+
+
+

+ 2 - 2
META-INF/MANIFEST.MF

@@ -1,2 +1,2 @@
-Manifest-Version: 1.0
-
+Manifest-Version: 1.0
+

+ 28 - 28
build.gradle

@@ -1,28 +1,28 @@
-group 'loginserver'
-version '1.0-SNAPSHOT'
-
-apply plugin: 'java'
-apply plugin: 'war'
-
-sourceCompatibility = 1.8
-
-repositories {
-    mavenLocal()
-    mavenCentral()
-}
-
-dependencies {
-    testCompile group: 'junit', name: 'junit', version: '4.11'
-    compile("javax.servlet:servlet-api:2.5")
-    compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.2.2'
-    compile("ch.qos.logback:logback-core:1.1.11")
-    compile("ch.qos.logback:logback-classic:1.1.11")
-    compile("org.apache.poi:poi-ooxml:3.12")
-    compile group: 'redis.clients', name: 'jedis', version: '2.9.0'
-    compile group: 'com.alibaba', name: 'fastjson', version: '1.2.47'
-    compile group: 'jcifs', name: 'jcifs', version: '1.3.17'
-    compile group: 'com.google.code.gson', name: 'gson', version: '2.2.4'
-    // https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
-    compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.6'
-
-}
+group 'loginserver'
+version '1.0-SNAPSHOT'
+
+apply plugin: 'java'
+apply plugin: 'war'
+
+sourceCompatibility = 1.8
+
+repositories {
+    mavenLocal()
+    mavenCentral()
+}
+
+dependencies {
+    testCompile group: 'junit', name: 'junit', version: '4.11'
+    compile("javax.servlet:servlet-api:2.5")
+    compile group: 'org.mongodb', name: 'mongo-java-driver', version: '3.2.2'
+    compile("ch.qos.logback:logback-core:1.1.11")
+    compile("ch.qos.logback:logback-classic:1.1.11")
+    compile("org.apache.poi:poi-ooxml:3.12")
+    compile group: 'redis.clients', name: 'jedis', version: '2.9.0'
+    compile group: 'com.alibaba', name: 'fastjson', version: '1.2.47'
+    compile group: 'jcifs', name: 'jcifs', version: '1.3.17'
+    compile group: 'com.google.code.gson', name: 'gson', version: '2.2.4'
+    // https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient
+    compile group: 'org.apache.httpcomponents', name: 'httpclient', version: '4.5.6'
+
+}

+ 27 - 27
build.sh

@@ -1,27 +1,27 @@
-#!/bin/bash
-
-#########################################################################
-# File Name: build.sh
-# Created on: 2019-08-15 11:56:54
-# Author: Wu Kang
-# Last Modified: 2019-08-15 13:47:44
-# Description: 
-#########################################################################
-ip=$1
-usage(){
-        echo -e "\033[32mUsage: $0 {ip} \033[0m"
-        exit 7;
-}
-
-if [ ! $ip ];then
-        usage
-fi
-git pull
-./gradlew clean 
-./gradlew build 
-./gradlew jar
-
-if [ ! -z ${ip} ];then
-  # scp build/libs/loginserver-1.0-SNAPSHOT.war  ${ip}:/usr/local/apache-tomcat-7.0.79/webapps/jl_loginserver.war
-  scp build/libs/tk.war  ${ip}:/home/tomcat/apache-tomcat-7.0.79/webapps/tk.war
-fi
+#!/bin/bash
+
+#########################################################################
+# File Name: build.sh
+# Created on: 2019-08-15 11:56:54
+# Author: Wu Kang
+# Last Modified: 2019-08-15 13:47:44
+# Description: 
+#########################################################################
+ip=$1
+usage(){
+        echo -e "\033[32mUsage: $0 {ip} \033[0m"
+        exit 7;
+}
+
+if [ ! $ip ];then
+        usage
+fi
+git pull
+./gradlew clean 
+./gradlew build 
+./gradlew jar
+
+if [ ! -z ${ip} ];then
+  # scp build/libs/loginserver-1.0-SNAPSHOT.war  ${ip}:/usr/local/apache-tomcat-7.0.79/webapps/jl_loginserver.war
+  scp build/libs/tk.war  ${ip}:/home/tomcat/apache-tomcat-7.0.79/webapps/tk.war
+fi

BIN
gradle/wrapper/gradle-wrapper.jar


+ 1 - 2
gradle/wrapper/gradle-wrapper.properties

@@ -1,6 +1,5 @@
-#Tue Jan 29 11:36:14 CST 2019
 distributionBase=GRADLE_USER_HOME
 distributionPath=wrapper/dists
 zipStoreBase=GRADLE_USER_HOME
 zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-rc-2-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-4.5-bin.zip

+ 3 - 3
gradlew

@@ -33,11 +33,11 @@ DEFAULT_JVM_OPTS=""
 # Use the maximum available, or set MAX_FD != -1 to use that value.
 MAX_FD="maximum"
 
-warn ( ) {
+warn () {
     echo "$*"
 }
 
-die ( ) {
+die () {
     echo
     echo "$*"
     echo
@@ -155,7 +155,7 @@ if $cygwin ; then
 fi
 
 # Escape application args
-save ( ) {
+save () {
     for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
     echo " "
 }

+ 84 - 84
gradlew.bat

@@ -1,84 +1,84 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem  Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windows variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem  Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if  not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega

+ 2 - 2
settings.gradle

@@ -1,2 +1,2 @@
-rootProject.name = 'loginserver'
-
+rootProject.name = 'loginserver'
+

+ 15 - 15
src/main/java/com/ljsd/Test.java

@@ -1,15 +1,15 @@
-package com.ljsd;
-
-import com.ljsd.util.StringUtils;
-
-class Untitled {
-    public static void main(String[] args) {
-
-
-
-        //System.out.println("42212619890917755X".length());
-
-        System.out.println(StringUtils.check("42212619890917755X"));
-
-    }
-}
+package com.ljsd;
+
+import com.ljsd.util.StringUtils;
+
+class Untitled {
+    public static void main(String[] args) {
+
+
+
+        //System.out.println("42212619890917755X".length());
+
+        System.out.println(StringUtils.check("42212619890917755X"));
+
+    }
+}

+ 42 - 42
src/main/java/com/ljsd/controller/ExcelController.java

@@ -1,42 +1,42 @@
-package com.ljsd.controller;
-
-
-import com.ljsd.util.ExcelUtils;
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBObject;
-
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-public class ExcelController extends HttpServlet {
-
-    public ExcelController() {
-        super();
-    }
-
-    public void destroy() {
-        super.destroy();
-    }
-
-
-    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
-        response.setCharacterEncoding("UTF-8");
-        response.setContentType("application/json; charset=utf-8");
-        PrintWriter out = response.getWriter();
-        ExcelUtils.readExcelData();
-        DBObject resp = new BasicDBObject();
-        resp.put("state", 0);
-        resp.put("msg", "success");
-        out.print(resp.toString());
-        out.flush();
-        out.close();
-    }
-
-    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
-        this.doGet(request, response);
-    }
-
-}
+package com.ljsd.controller;
+
+
+import com.ljsd.util.ExcelUtils;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class ExcelController extends HttpServlet {
+
+    public ExcelController() {
+        super();
+    }
+
+    public void destroy() {
+        super.destroy();
+    }
+
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        response.setCharacterEncoding("UTF-8");
+        response.setContentType("application/json; charset=utf-8");
+        PrintWriter out = response.getWriter();
+        ExcelUtils.readExcelData();
+        DBObject resp = new BasicDBObject();
+        resp.put("state", 0);
+        resp.put("msg", "success");
+        out.print(resp.toString());
+        out.flush();
+        out.close();
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        this.doGet(request, response);
+    }
+
+}

+ 97 - 97
src/main/java/com/ljsd/controller/GetNoticeController.java

@@ -1,97 +1,97 @@
-package com.ljsd.controller;
-
-import com.google.gson.Gson;
-import com.ljsd.pojo.NoticeInfo;
-import com.ljsd.pojo.ResMsg;
-import com.ljsd.util.BaseGlobal;
-import com.mongodb.DBObject;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.*;
-
-
-/**
- * 常驻 中 高优先级  同等优先级按最新发布的
- */
-public class GetNoticeController extends HttpServlet {
-    private static Gson gson = new Gson();
-    private final static String _NOTICE_INFO = "notice_info";
-
-    @Override
-    protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
-        req.setCharacterEncoding("UTF-8");
-        response.setCharacterEncoding("UTF-8");
-        response.setContentType("application/json; charset=utf-8");
-        ResMsg resMsg = new ResMsg();
-        resMsg.setCode(1);
-        try (PrintWriter out = response.getWriter();) {
-            Comparator<NoticeInfo> comparator = (o1, o2) -> {
-                if (o1.getStartTime() < o2.getStartTime()) {
-                    return -1;
-                } else if (o1.getStartTime() == o2.getStartTime()) {
-                    return 0;
-                } else {
-                    return 1;
-                }
-            };
-            TreeSet<NoticeInfo> highLevelList = new TreeSet(comparator);
-            TreeSet<NoticeInfo> mediumLevelList = new TreeSet(comparator);
-            TreeSet<NoticeInfo> normalList = new TreeSet(comparator);
-            long localtime = System.currentTimeMillis();
-            NoticeInfo res = new NoticeInfo();
-            res.setTitle(new String("公告".getBytes("gbk"), "utf-8"));
-            res.setContent(new String("暂无公告...".getBytes("gbk"), "utf-8"));
-            List<DBObject> allDBObject = BaseGlobal.getInstance().mongoDBPool.findAll(_NOTICE_INFO);
-            for (DBObject db : allDBObject) {
-                NoticeInfo noticeInfo = dbToNoticeInfo(db);
-                if (noticeInfo == null) {
-                    break;
-                }
-                //0:常驻;1:优先级中;2:优先级高
-                switch(noticeInfo.getLeve()){
-                    case 0 :
-                        normalList.add(noticeInfo);
-                        break;
-                    case 1 :
-                        mediumLevelList.add(noticeInfo);
-                        break;
-                    case 2 :
-                        highLevelList.add(noticeInfo);
-                        break;
-                }
-            }
-            if(highLevelList.size() > 0){
-                res = highLevelList.last();
-            } else if(mediumLevelList.size() > 0){
-                res = mediumLevelList.last();
-            } else {
-                res = normalList.last();
-            }
-            Map<String, String> parms = new HashMap<>();
-            parms.put("title", res.getTitle());
-            parms.put("content", res.getContent());
-            resMsg.setParms(parms);
-            out.print(gson.toJson(resMsg));
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    //转成NoticeInfo类型
-    public NoticeInfo dbToNoticeInfo(DBObject db) {
-        NoticeInfo noticeInfo = new NoticeInfo();
-        if(db == null){
-            return null;
-        }
-        noticeInfo.setTitle(db.get("title").toString());
-        noticeInfo.setContent(db.get("content").toString());
-        noticeInfo.setLeve(Integer.parseInt(db.get("grade").toString()));
-        noticeInfo.setStartTime(Long.parseLong(db.get("publish_time").toString()));
-        return noticeInfo;
-    }
-}
+package com.ljsd.controller;
+
+import com.google.gson.Gson;
+import com.ljsd.pojo.NoticeInfo;
+import com.ljsd.pojo.ResMsg;
+import com.ljsd.util.BaseGlobal;
+import com.mongodb.DBObject;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.*;
+
+
+/**
+ * 常驻 中 高优先级  同等优先级按最新发布的
+ */
+public class GetNoticeController extends HttpServlet {
+    private static Gson gson = new Gson();
+    private final static String _NOTICE_INFO = "notice_info";
+
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
+        req.setCharacterEncoding("UTF-8");
+        response.setCharacterEncoding("UTF-8");
+        response.setContentType("application/json; charset=utf-8");
+        ResMsg resMsg = new ResMsg();
+        resMsg.setCode(1);
+        try (PrintWriter out = response.getWriter();) {
+            Comparator<NoticeInfo> comparator = (o1, o2) -> {
+                if (o1.getStartTime() < o2.getStartTime()) {
+                    return -1;
+                } else if (o1.getStartTime() == o2.getStartTime()) {
+                    return 0;
+                } else {
+                    return 1;
+                }
+            };
+            TreeSet<NoticeInfo> highLevelList = new TreeSet(comparator);
+            TreeSet<NoticeInfo> mediumLevelList = new TreeSet(comparator);
+            TreeSet<NoticeInfo> normalList = new TreeSet(comparator);
+            long localtime = System.currentTimeMillis();
+            NoticeInfo res = new NoticeInfo();
+            res.setTitle(new String("公告".getBytes("gbk"), "utf-8"));
+            res.setContent(new String("暂无公告...".getBytes("gbk"), "utf-8"));
+            List<DBObject> allDBObject = BaseGlobal.getInstance().mongoDBPool.findAll(_NOTICE_INFO);
+            for (DBObject db : allDBObject) {
+                NoticeInfo noticeInfo = dbToNoticeInfo(db);
+                if (noticeInfo == null) {
+                    break;
+                }
+                //0:常驻;1:优先级中;2:优先级高
+                switch(noticeInfo.getLeve()){
+                    case 0 :
+                        normalList.add(noticeInfo);
+                        break;
+                    case 1 :
+                        mediumLevelList.add(noticeInfo);
+                        break;
+                    case 2 :
+                        highLevelList.add(noticeInfo);
+                        break;
+                }
+            }
+            if(highLevelList.size() > 0){
+                res = highLevelList.last();
+            } else if(mediumLevelList.size() > 0){
+                res = mediumLevelList.last();
+            } else {
+                res = normalList.last();
+            }
+            Map<String, String> parms = new HashMap<>();
+            parms.put("title", res.getTitle());
+            parms.put("content", res.getContent());
+            resMsg.setParms(parms);
+            out.print(gson.toJson(resMsg));
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    //转成NoticeInfo类型
+    public NoticeInfo dbToNoticeInfo(DBObject db) {
+        NoticeInfo noticeInfo = new NoticeInfo();
+        if(db == null){
+            return null;
+        }
+        noticeInfo.setTitle(db.get("title").toString());
+        noticeInfo.setContent(db.get("content").toString());
+        noticeInfo.setLeve(Integer.parseInt(db.get("grade").toString()));
+        noticeInfo.setStartTime(Long.parseLong(db.get("publish_time").toString()));
+        return noticeInfo;
+    }
+}

+ 260 - 260
src/main/java/com/ljsd/controller/GetServerListController.java

@@ -1,260 +1,260 @@
-package com.ljsd.controller;
-
-import com.ljsd.pojo.UserRecentLoginInfo;
-import com.ljsd.redis.RedisKey;
-import com.ljsd.util.BaseGlobal;
-import com.ljsd.util.NetUtil;
-import com.ljsd.util.StringUtils;
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBObject;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-public class GetServerListController extends HttpServlet {
-    private final static String _COLLECTION_NAME = "server_info";
-    //白名单
-    private final static String _WHITE_LIST = "white_user_list";
-    //黑名单
-    private final static String _BLACK_LIST = "black_user_list";
-    private final static String _IP_LIST = "white_ip_list";
-    private static ConcurrentHashMap<String, DBObject> serverInfosCache = new ConcurrentHashMap<>();
-    private static volatile DBObject whiteListCache = new BasicDBObject();
-    private static volatile String recommend = "";//推荐列表
-    private static volatile long lastRefreshTime = 0;
-
-    public GetServerListController() {
-        super();
-    }
-
-    public void destroy() {
-        super.destroy();
-    }
-
-    // 服务器状态 0:不可见  -1 准备状态 1:维护 2:流畅 3拥挤 4爆满 5状态根据在线人数改变
-    public void doGet(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-        response.setCharacterEncoding("UTF-8");
-        response.setContentType("application/json; charset=utf-8");
-        PrintWriter out = response.getWriter();
-        try {
-            String openId = request.getParameter("openId");                 //登录账号
-            String channel = request.getParameter("channel");               //pc
-            String sub_channel = request.getParameter("sub_channel");       //1
-            String server_version = String.valueOf(request.getParameter("server_version")); //1
-            String plat = request.getParameter("plat");                     //android
-            //判断非空
-            if (StringUtils.checkIsEmpty(openId) || StringUtils.checkIsEmpty(channel) ||
-                    StringUtils.checkIsEmpty(sub_channel) || StringUtils.checkIsEmpty(plat) || StringUtils.checkIsEmpty(server_version)) {
-                response.sendError(400, "parm is wrong");
-                return;
-            }
-
-            DBObject req = new BasicDBObject();
-            req.put("channel", channel);
-            req.put("sub_channel", sub_channel);
-            req.put("plat", plat);
-            //req.put("server_version", server_version);
-            //req.put("server_version", Integer.valueOf(server_version));
-
-            List<DBObject> serverList = new ArrayList<>();
-            long local = System.currentTimeMillis();
-            //     if ((local - lastRefreshTime) > 10 * 1000 || serverInfosCache.isEmpty()) {
-            serverInfosCache.clear();
-            lastRefreshTime = local;
-            recommend = "";
-
-            DBObject whiteListDBObject = new BasicDBObject();
-            whiteListDBObject.put("openId", openId);
-            List<DBObject> whiteList = BaseGlobal.getInstance().mongoDBPool.find(_WHITE_LIST, whiteListDBObject);
-            List<DBObject> blackList = BaseGlobal.getInstance().mongoDBPool.find(_BLACK_LIST, whiteListDBObject);
-
-            String userip = NetUtil.getIpAddr(request);
-            DBObject whiteIPListDBObject = new BasicDBObject();
-            whiteIPListDBObject.put("ip", userip);
-            List<DBObject> ipList = BaseGlobal.getInstance().mongoDBPool.find(_BLACK_LIST, whiteIPListDBObject);
-
-            List<DBObject> serverInfoList = BaseGlobal.getInstance().mongoDBPool.find(_COLLECTION_NAME, req);
-            SortedSet<String> newServerList = new TreeSet<>();
-            String maxNumServerId = "";
-            int maxNum = 0;
-            int shenheNum = 0; //记录 审核服数量
-            for (DBObject serverInfo : serverInfoList) {
-                String server_version1 = serverInfo.get("server_version").toString();
-                if(server_version.equals(server_version1)) {
-                    shenheNum += 1;
-                }
-            }
-
-            for (DBObject serverInfo : serverInfoList) {
-                int state = Integer.parseInt(serverInfo.get("state").toString());
-                //opentime
-                long time = Long.parseLong(serverInfo.get("open_time").toString());
-                //state
-                String server_id = serverInfo.get("server_id").toString();
-                //server_version
-                String server_version2 = serverInfo.get("server_version").toString();
-                int num = getOnlineNum(server_id);
-                if (whiteList != null && whiteList.size() > 0 && (state == -1 || state == 1 || state == 0)) {
-                    state = 2;
-                } else if (ipList != null && ipList.size() > 0 && (state == -1 || state == 1 || state == 0)) {
-                    state = 2;
-                } else if (blackList != null && blackList.size() > 0) {
-                    state = 1;
-                } else {
-                    if (state == 5) {
-                        state = getState(server_id, num);
-                    }
-                }
-
-                if (state == 0) {
-                    continue;
-                }
-                if (state == -1) {
-                    continue;
-                }
-                if (System.currentTimeMillis() < time && whiteList.size() == 0) {
-                    continue;
-                }
-                if (state == 2 && maxNum < num) {
-                    maxNum = num;
-                    maxNumServerId = server_id;
-                }
-
-                //判断版本号,0=普通服,!=0 审核服
-                if(!server_version2.equals("0")){   //审核服
-                    if(!server_version.equals(server_version2)) {
-                        continue;
-                    }
-                }else {
-                    //shenheNum >=1 表示是审核服
-                    if(shenheNum >= 1){
-                        continue;
-                    }
-                }
-
-                //new
-                int isnew = 0;
-                if (serverInfo.containsField("is_new"))
-                    isnew = Integer.parseInt(serverInfo.get("is_new").toString());
-                if (isnew == 1) {
-                    newServerList.add(server_id);
-                }
-                int banreg = 0;
-                if (serverInfo.containsField("is_banreg"))
-                    banreg = Integer.parseInt(serverInfo.get("is_banreg").toString());
-//                if (banreg == 1) {
-//                    newServerList.add(server_id);
-//                }
-                DBObject res = new BasicDBObject();
-                res.put("name", serverInfo.get("name"));
-                res.put("server_id", server_id);
-                res.put("state", state);
-                res.put("open_time", serverInfo.get("open_time"));
-                res.put("isnew", isnew);
-                res.put("isbanreg", banreg);
-                Object ip = serverInfo.get("ip");
-                Object port = serverInfo.get("port");
-                if (state == 1) { // 服务器状态为维护的话不传给前端ip端口
-                    ip = "";
-                    port = "";
-                }
-                res.put("ip", ip);
-                res.put("port", port);
-                serverList.add(res);
-                serverInfosCache.put(serverInfo.get("server_id").toString(), res);
-            }
-
-            //推荐服务器 新服中选择id小的 否者流畅中选择人数最多的
-            if (newServerList.size() != 0) {
-                recommend = newServerList.first();
-            } else {
-                recommend = maxNumServerId;
-            }
-
-
-            //   } else {
-            //      serverList.addAll(serverInfosCache.values());
-            //  }
-
-            //获取我的服务器列表
-            Map<String, UserRecentLoginInfo> userServerInfoMap = BaseGlobal.getInstance().redisApp.hgetAll(RedisKey.USER_SERVER_INFO, openId, UserRecentLoginInfo.class, -1, false);
-            DBObject myLastServer = null;
-            List<DBObject> myServerList = new ArrayList<>();
-            long time = 0;
-            for (Map.Entry<String, UserRecentLoginInfo> entry : userServerInfoMap.entrySet()) {
-                if (!serverInfosCache.keySet().contains(entry.getKey())) {
-                    //服务器已清除
-                    continue;
-                }
-                myServerList.add(getDBObject(entry.getKey(), entry.getValue()));
-                if (entry.getValue().getLoginTime() > time) {
-                    time = entry.getValue().getLoginTime();
-                    myLastServer = getDBObject(entry.getKey(), entry.getValue());
-                }
-            }
-
-
-            DBObject resp = new BasicDBObject();
-            resp.put("serverList", serverList);
-            resp.put("myServerList", myServerList);
-            if (null != myLastServer)
-                resp.put("lastServer", myLastServer);
-            if (recommend != null && !recommend.equals("")) {
-                resp.put("recommend", recommend);
-            }
-            out.print(resp.toString());
-        } catch (Exception e) {
-            e.printStackTrace();
-        } finally {
-            out.flush();
-            out.close();
-        }
-
-    }
-
-    private DBObject getDBObject(String serverId, UserRecentLoginInfo userRecentLoginInfo) {
-        DBObject res = new BasicDBObject();
-        res.put("serverid", serverId);
-        res.put("name", userRecentLoginInfo.getName());
-        res.put("level", userRecentLoginInfo.getLevel());
-        res.put("head", userRecentLoginInfo.getHead());
-        res.put("headfream", userRecentLoginInfo.getHeadFream());
-        return res;
-    }
-
-
-    public void doPost(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-        this.doGet(request, response);
-    }
-
-    private int getState(String server_id, int num) throws Exception {
-        int state = 2;
-        Map<String, String> globalCfgMap = BaseGlobal.getInstance().redisApp.hgetAll(RedisKey.GLOBAL_SYS_PRO, "", String.class, -1, false);
-        int crowdnum = Integer.valueOf(globalCfgMap.getOrDefault("crowdnum", "0"));
-        int highnum = Integer.valueOf(globalCfgMap.getOrDefault("highnum", "0"));
-        if (crowdnum != 0 && highnum != 0) {
-            if (num >= crowdnum) {
-                state = 3;
-                if (num >= highnum)
-                    state = 4;
-            }
-        }
-        return state;
-    }
-
-    private int getOnlineNum(String server_id) throws Exception {
-        Integer num = BaseGlobal.getInstance().redisApp.get("ONLINE_NUM", server_id, Integer.class, -1);
-        if (num == null) {
-            num = 0;
-        }
-        return num;
-    }
-}
+package com.ljsd.controller;
+
+import com.ljsd.pojo.UserRecentLoginInfo;
+import com.ljsd.redis.RedisKey;
+import com.ljsd.util.BaseGlobal;
+import com.ljsd.util.NetUtil;
+import com.ljsd.util.StringUtils;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+
+public class GetServerListController extends HttpServlet {
+    private final static String _COLLECTION_NAME = "server_info";
+    //白名单
+    private final static String _WHITE_LIST = "white_user_list";
+    //黑名单
+    private final static String _BLACK_LIST = "black_user_list";
+    private final static String _IP_LIST = "white_ip_list";
+    private static ConcurrentHashMap<String, DBObject> serverInfosCache = new ConcurrentHashMap<>();
+    private static volatile DBObject whiteListCache = new BasicDBObject();
+    private static volatile String recommend = "";//推荐列表
+    private static volatile long lastRefreshTime = 0;
+
+    public GetServerListController() {
+        super();
+    }
+
+    public void destroy() {
+        super.destroy();
+    }
+
+    // 服务器状态 0:不可见  -1 准备状态 1:维护 2:流畅 3拥挤 4爆满 5状态根据在线人数改变
+    public void doGet(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {
+        response.setCharacterEncoding("UTF-8");
+        response.setContentType("application/json; charset=utf-8");
+        PrintWriter out = response.getWriter();
+        try {
+            String openId = request.getParameter("openId");                 //登录账号
+            String channel = request.getParameter("channel");               //pc
+            String sub_channel = request.getParameter("sub_channel");       //1
+            String server_version = String.valueOf(request.getParameter("server_version")); //1
+            String plat = request.getParameter("plat");                     //android
+            //判断非空
+            if (StringUtils.checkIsEmpty(openId) || StringUtils.checkIsEmpty(channel) ||
+                    StringUtils.checkIsEmpty(sub_channel) || StringUtils.checkIsEmpty(plat) || StringUtils.checkIsEmpty(server_version)) {
+                response.sendError(400, "parm is wrong");
+                return;
+            }
+
+            DBObject req = new BasicDBObject();
+            req.put("channel", channel);
+            req.put("sub_channel", sub_channel);
+            req.put("plat", plat);
+            //req.put("server_version", server_version);
+            //req.put("server_version", Integer.valueOf(server_version));
+
+            List<DBObject> serverList = new ArrayList<>();
+            long local = System.currentTimeMillis();
+            //     if ((local - lastRefreshTime) > 10 * 1000 || serverInfosCache.isEmpty()) {
+            serverInfosCache.clear();
+            lastRefreshTime = local;
+            recommend = "";
+
+            DBObject whiteListDBObject = new BasicDBObject();
+            whiteListDBObject.put("openId", openId);
+            List<DBObject> whiteList = BaseGlobal.getInstance().mongoDBPool.find(_WHITE_LIST, whiteListDBObject);
+            List<DBObject> blackList = BaseGlobal.getInstance().mongoDBPool.find(_BLACK_LIST, whiteListDBObject);
+
+            String userip = NetUtil.getIpAddr(request);
+            DBObject whiteIPListDBObject = new BasicDBObject();
+            whiteIPListDBObject.put("ip", userip);
+            List<DBObject> ipList = BaseGlobal.getInstance().mongoDBPool.find(_BLACK_LIST, whiteIPListDBObject);
+
+            List<DBObject> serverInfoList = BaseGlobal.getInstance().mongoDBPool.find(_COLLECTION_NAME, req);
+            SortedSet<String> newServerList = new TreeSet<>();
+            String maxNumServerId = "";
+            int maxNum = 0;
+            int shenheNum = 0; //记录 审核服数量
+            for (DBObject serverInfo : serverInfoList) {
+                String server_version1 = serverInfo.get("server_version").toString();
+                if(server_version.equals(server_version1)) {
+                    shenheNum += 1;
+                }
+            }
+
+            for (DBObject serverInfo : serverInfoList) {
+                int state = Integer.parseInt(serverInfo.get("state").toString());
+                //opentime
+                long time = Long.parseLong(serverInfo.get("open_time").toString());
+                //state
+                String server_id = serverInfo.get("server_id").toString();
+                //server_version
+                String server_version2 = serverInfo.get("server_version").toString();
+                int num = getOnlineNum(server_id);
+                if (whiteList != null && whiteList.size() > 0 && (state == -1 || state == 1 || state == 0)) {
+                    state = 2;
+                } else if (ipList != null && ipList.size() > 0 && (state == -1 || state == 1 || state == 0)) {
+                    state = 2;
+                } else if (blackList != null && blackList.size() > 0) {
+                    state = 1;
+                } else {
+                    if (state == 5) {
+                        state = getState(server_id, num);
+                    }
+                }
+
+                if (state == 0) {
+                    continue;
+                }
+                if (state == -1) {
+                    continue;
+                }
+                if (System.currentTimeMillis() < time && whiteList.size() == 0) {
+                    continue;
+                }
+                if (state == 2 && maxNum < num) {
+                    maxNum = num;
+                    maxNumServerId = server_id;
+                }
+
+                //判断版本号,0=普通服,!=0 审核服
+                if(!server_version2.equals("0")){   //审核服
+                    if(!server_version.equals(server_version2)) {
+                        continue;
+                    }
+                }else {
+                    //shenheNum >=1 表示是审核服
+                    if(shenheNum >= 1){
+                        continue;
+                    }
+                }
+
+                //new
+                int isnew = 0;
+                if (serverInfo.containsField("is_new"))
+                    isnew = Integer.parseInt(serverInfo.get("is_new").toString());
+                if (isnew == 1) {
+                    newServerList.add(server_id);
+                }
+                int banreg = 0;
+                if (serverInfo.containsField("is_banreg"))
+                    banreg = Integer.parseInt(serverInfo.get("is_banreg").toString());
+//                if (banreg == 1) {
+//                    newServerList.add(server_id);
+//                }
+                DBObject res = new BasicDBObject();
+                res.put("name", serverInfo.get("name"));
+                res.put("server_id", server_id);
+                res.put("state", state);
+                res.put("open_time", serverInfo.get("open_time"));
+                res.put("isnew", isnew);
+                res.put("isbanreg", banreg);
+                Object ip = serverInfo.get("ip");
+                Object port = serverInfo.get("port");
+                if (state == 1) { // 服务器状态为维护的话不传给前端ip端口
+                    ip = "";
+                    port = "";
+                }
+                res.put("ip", ip);
+                res.put("port", port);
+                serverList.add(res);
+                serverInfosCache.put(serverInfo.get("server_id").toString(), res);
+            }
+
+            //推荐服务器 新服中选择id小的 否者流畅中选择人数最多的
+            if (newServerList.size() != 0) {
+                recommend = newServerList.first();
+            } else {
+                recommend = maxNumServerId;
+            }
+
+
+            //   } else {
+            //      serverList.addAll(serverInfosCache.values());
+            //  }
+
+            //获取我的服务器列表
+            Map<String, UserRecentLoginInfo> userServerInfoMap = BaseGlobal.getInstance().redisApp.hgetAll(RedisKey.USER_SERVER_INFO, openId, UserRecentLoginInfo.class, -1, false);
+            DBObject myLastServer = null;
+            List<DBObject> myServerList = new ArrayList<>();
+            long time = 0;
+            for (Map.Entry<String, UserRecentLoginInfo> entry : userServerInfoMap.entrySet()) {
+                if (!serverInfosCache.keySet().contains(entry.getKey())) {
+                    //服务器已清除
+                    continue;
+                }
+                myServerList.add(getDBObject(entry.getKey(), entry.getValue()));
+                if (entry.getValue().getLoginTime() > time) {
+                    time = entry.getValue().getLoginTime();
+                    myLastServer = getDBObject(entry.getKey(), entry.getValue());
+                }
+            }
+
+
+            DBObject resp = new BasicDBObject();
+            resp.put("serverList", serverList);
+            resp.put("myServerList", myServerList);
+            if (null != myLastServer)
+                resp.put("lastServer", myLastServer);
+            if (recommend != null && !recommend.equals("")) {
+                resp.put("recommend", recommend);
+            }
+            out.print(resp.toString());
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            out.flush();
+            out.close();
+        }
+
+    }
+
+    private DBObject getDBObject(String serverId, UserRecentLoginInfo userRecentLoginInfo) {
+        DBObject res = new BasicDBObject();
+        res.put("serverid", serverId);
+        res.put("name", userRecentLoginInfo.getName());
+        res.put("level", userRecentLoginInfo.getLevel());
+        res.put("head", userRecentLoginInfo.getHead());
+        res.put("headfream", userRecentLoginInfo.getHeadFream());
+        return res;
+    }
+
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {
+        this.doGet(request, response);
+    }
+
+    private int getState(String server_id, int num) throws Exception {
+        int state = 2;
+        Map<String, String> globalCfgMap = BaseGlobal.getInstance().redisApp.hgetAll(RedisKey.GLOBAL_SYS_PRO, "", String.class, -1, false);
+        int crowdnum = Integer.valueOf(globalCfgMap.getOrDefault("crowdnum", "0"));
+        int highnum = Integer.valueOf(globalCfgMap.getOrDefault("highnum", "0"));
+        if (crowdnum != 0 && highnum != 0) {
+            if (num >= crowdnum) {
+                state = 3;
+                if (num >= highnum)
+                    state = 4;
+            }
+        }
+        return state;
+    }
+
+    private int getOnlineNum(String server_id) throws Exception {
+        Integer num = BaseGlobal.getInstance().redisApp.get("ONLINE_NUM", server_id, Integer.class, -1);
+        if (num == null) {
+            num = 0;
+        }
+        return num;
+    }
+}

+ 284 - 284
src/main/java/com/ljsd/controller/GetUserController.java

@@ -1,284 +1,284 @@
-package com.ljsd.controller;
-
-import com.alibaba.fastjson.JSONObject;
-import com.ljsd.redis.RedisKey;
-import com.ljsd.util.*;
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-public class GetUserController extends HttpServlet {
-    private final static String _COLLECTION_NAME = "user_info";
-    private static final Logger LOGGER = LoggerFactory.getLogger(GetUserController.class);
-    public static int isTestLan=0;
-
-    public static void initLanState(){
-        Properties properties = BaseGlobal.getInstance().properties;
-        isTestLan = Integer.parseInt(properties.getProperty("isTestLan"));
-    }
-
-    public GetUserController() {
-        super();
-    }
-
-    public void destroy() {
-        super.destroy();
-    }
-
-
-    /**
-     * openId 账号id
-     * version
-     * serverId
-     * token
-     * platform android、ios  3 跳过验证
-     * admin
-     * gid pid
-     *
-     *
-     *---verty--
-     *  openid 和token校验
-     *
-     * ---return--
-     *
-     * uid(openid + serverid + platid)
-
-     *
-     */
-    public void doGet(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-        String openId = request.getParameter("openId");
-        if (openId == null || openId.isEmpty()) {
-            response.sendError(400, "openId is empety");
-            return;
-        }
-        String version = request.getParameter("version");
-        if (version == null)  {
-            version="未知版本号";
-        }
-        LOGGER.info("the opendId = {},isTestLan={},version{}",openId,isTestLan,version);
-        String serverId = request.getParameter("serverId");
-        if (serverId == null || serverId.isEmpty()) {
-            response.sendError(400, "serverId is empety");
-            return;
-        }
-        String token = request.getParameter("token");
-        if (token == null || serverId.isEmpty()) {
-            response.sendError(400, "token is empety");
-            return;
-        }
-        String platform = request.getParameter("platform"); //平台类型
-        if (platform == null || platform.isEmpty()) {
-            response.sendError(400, "platform is empety");
-            return;
-        }
-        String admin = request.getParameter("admin"); //平台类型
-
-        String gid = request.getParameter("gid"); //gid
-        String pid = request.getParameter("pid"); //pid
-
-        /*if (StringUtils.checkIsEmpty(admin)) {
-            response.sendError(400, "platform is empety");
-            return;
-        }*/
-        LOGGER.info("the opendId = {},token={},platform={}",openId,token,platform);
-        try {
-            boolean vertify = vertify(response, request, admin, platform, pid, openId, token);
-            if(!vertify){
-                return;
-            }
-            response.setCharacterEncoding("UTF-8");
-            response.setContentType("application/json; charset=utf-8");
-            DBObject dbObject = new BasicDBObject();
-            dbObject.put("openId", openId);
-            dbObject.put("serverId", serverId);
-            dbObject.put("platform", platform);
-
-
-
-            int uid = 0;
-            List<DBObject> userInfos = BaseGlobal.getInstance().mongoDBPool.find(_COLLECTION_NAME, dbObject);
-            DBObject res = new BasicDBObject();
-            if (userInfos.size() == 0) {
-                uid = BaseGlobal.getInstance().mongoDBPool.inc("uid") + 10000000;
-                dbObject.put("uid", uid);
-                dbObject.put("_id", uid);
-                userInfos.add(dbObject);
-                if (gid != null && !gid.isEmpty()) {
-                    dbObject.put("gid", gid);
-                }
-                if (pid != null && !pid.isEmpty()) {
-                    dbObject.put("pid", pid);
-                }
-                BaseGlobal.getInstance().mongoDBPool.save(_COLLECTION_NAME, dbObject);
-
-                //记录日志,为了数据后台
-                logRegister(openId,uid,serverId);
-
-            }
-            Random random = new Random();
-            int utoken = Math.abs(random.nextInt());
-            uid = (int) userInfos.get(0).get("uid");
-            res.put("uid", uid);
-            res.put("token", utoken);
-            BaseGlobal.getInstance().redisApp.set(RedisKey.TOKEN, String.valueOf(uid), utoken, -1, false);
-            BaseGlobal.getInstance().redisApp.set(RedisKey.PIDGIDTEMP, String.valueOf(uid), pid+"#"+gid, -1, false);
-            //记录日志,为了数据后台
-            logLogin(openId,uid,serverId);
-
-
-            PrintWriter out = response.getWriter();
-            out.print(res);
-            out.flush();
-            out.close();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-    //注册 用户id,角色id,serverid,时间 放到一个表里
-    private void logRegister(String openId,int uid,String serverId){
-        Date date = new Date();
-        long loginTime = date.getTime();
-        DBObject doc = new BasicDBObject();
-        DBObject doc1 = new BasicDBObject();
-        //doc.put("_id",);
-        doc1.put("openId",openId);
-        doc1.put("uid",uid);
-        doc1.put("serverId",serverId);
-        doc1.put("registerTime",loginTime);
-        doc.put("register",doc1);
-        BaseGlobal.getInstance().mongoDBPool.save("logRegister", doc);
-    }
-    //登录 用户id,角色id,serverid,时间 按天放到一个表里
-    private void logLogin(String openId,int uid,String serverId){
-        //DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
-        Date date = new Date();
-        //long loginTime = Long.parseLong(dateFormat.format(date));
-        long loginTime = date.getTime();
-        DBObject doc = new BasicDBObject();
-        DBObject doc1 = new BasicDBObject();
-        //doc.put("_id",);
-        doc1.put("openId",openId);
-        doc1.put("uid",uid);
-        doc1.put("serverId",serverId);
-        doc1.put("loginTime",loginTime);
-        doc.put("loginTime",doc1);
-        BaseGlobal.getInstance().mongoDBPool.save("logLogin", doc);
-    }
-
-
-
-
-    public boolean vertify(HttpServletResponse response,HttpServletRequest request,String admin,String platform,String pid,String openId,String token){
-                    try {
-                        if(!KTSDKConstans.appsecret.equals(admin)) {
-                            if (isTestLan == 1) { //test
-                    boolean result = loginVerfifyByTestLan(openId, token);
-                    if (!result) {
-                        //response.sendError(400, "verify fail");
-
-                        PrintWriter out = response.getWriter();
-                        out.print("fail");//认证失败
-                        out.flush();
-                        out.close();
-
-                        LOGGER.error("test verify fail");
-                        return false;
-                    }
-                } else if (!"3".equals(platform)) {//正式 切不是pc
-                    String sub_channel = request.getParameter("sub_channel");
-                    boolean result = false;
-                    if (sub_channel != null && !sub_channel.equals("")) {
-                        if (sub_channel.equals("1000")) {
-                            result = loginVerfify(pid, openId, token, MHTSDKConstans.rhappid);
-                        } else {
-                            result = loginVerfify(pid, openId, token, MHTSDKConstans.rhappidOnline);
-                        }
-                    }
-                    if (!result) {
-                        response.sendError(400, "verify fail");
-                        LOGGER.error("verify fail");
-                        return false;
-                    }
-                }
-            }else {
-                boolean result = loginVerfifyByTestLan(openId, token);
-                if (!result) {
-                    //response.sendError(400, "verify fail");
-                    PrintWriter out = response.getWriter();
-                    out.print("fail");//认证失败
-                    out.flush();
-                    out.close();
-                    LOGGER.error("test verify fail");
-                    return false;
-                }
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-        return true;
-    }
-
-    public void doPost(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-        this.doGet(request, response);
-    }
-
-
-    public static boolean loginVerfify(String channelName,String openId,String token,String appId){
-        try{
-            String loginUrl = MHTSDKConstans.loginVerify;
-            Map<String, String> params = new HashMap<String, String>();
-            params.put("userToken", token);
-            params.put("appId", appId);
-            params.put("channelName", channelName);
-            params.put("uid", openId);
-            String loginResult = HttpUtils.doPost(loginUrl,params);
-            if(loginResult == null || loginResult.isEmpty()){
-                return false;
-            }
-            return parseLoginResult(loginResult);
-        }catch(Exception e){
-            return false;
-        }
-
-    }
-
-    public static boolean loginVerfifyByTestLan(String openId,String token) throws Exception {
-        String tokenInRedis = BaseGlobal.getInstance().redisApp.get(RedisKey.LOGIN_TOKEN, openId, String.class, -1);
-        LOGGER.info("tokenInRedis={}",tokenInRedis);
-        return token.equals(tokenInRedis);
-    }
-
-
-    private static boolean parseLoginResult(String orderResult){
-        try {
-            JSONObject jsonObject = JSONObject.parseObject(orderResult);
-            int state = jsonObject.getIntValue("code");
-            if(state != 200){
-                String content = jsonObject.getString("message");
-                LOGGER.info("parseLoginResult content={}",content);
-                return false;
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return true;
-    }
-
-    public static void main(String[] args) {
-//        boolean mht = loginVerfify("MHT", "2318137", "be385683efe228aadac0c8b5822a6fba");
-    }
-
-}
+package com.ljsd.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ljsd.redis.RedisKey;
+import com.ljsd.util.*;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+public class GetUserController extends HttpServlet {
+    private final static String _COLLECTION_NAME = "user_info";
+    private static final Logger LOGGER = LoggerFactory.getLogger(GetUserController.class);
+    public static int isTestLan=0;
+
+    public static void initLanState(){
+        Properties properties = BaseGlobal.getInstance().properties;
+        isTestLan = Integer.parseInt(properties.getProperty("isTestLan"));
+    }
+
+    public GetUserController() {
+        super();
+    }
+
+    public void destroy() {
+        super.destroy();
+    }
+
+
+    /**
+     * openId 账号id
+     * version
+     * serverId
+     * token
+     * platform android、ios  3 跳过验证
+     * admin
+     * gid pid
+     *
+     *
+     *---verty--
+     *  openid 和token校验
+     *
+     * ---return--
+     *
+     * uid(openid + serverid + platid)
+
+     *
+     */
+    public void doGet(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {
+        String openId = request.getParameter("openId");
+        if (openId == null || openId.isEmpty()) {
+            response.sendError(400, "openId is empety");
+            return;
+        }
+        String version = request.getParameter("version");
+        if (version == null)  {
+            version="未知版本号";
+        }
+        LOGGER.info("the opendId = {},isTestLan={},version{}",openId,isTestLan,version);
+        String serverId = request.getParameter("serverId");
+        if (serverId == null || serverId.isEmpty()) {
+            response.sendError(400, "serverId is empety");
+            return;
+        }
+        String token = request.getParameter("token");
+        if (token == null || serverId.isEmpty()) {
+            response.sendError(400, "token is empety");
+            return;
+        }
+        String platform = request.getParameter("platform"); //平台类型
+        if (platform == null || platform.isEmpty()) {
+            response.sendError(400, "platform is empety");
+            return;
+        }
+        String admin = request.getParameter("admin"); //平台类型
+
+        String gid = request.getParameter("gid"); //gid
+        String pid = request.getParameter("pid"); //pid
+
+        /*if (StringUtils.checkIsEmpty(admin)) {
+            response.sendError(400, "platform is empety");
+            return;
+        }*/
+        LOGGER.info("the opendId = {},token={},platform={}",openId,token,platform);
+        try {
+            boolean vertify = vertify(response, request, admin, platform, pid, openId, token);
+            if(!vertify){
+                return;
+            }
+            response.setCharacterEncoding("UTF-8");
+            response.setContentType("application/json; charset=utf-8");
+            DBObject dbObject = new BasicDBObject();
+            dbObject.put("openId", openId);
+            dbObject.put("serverId", serverId);
+            dbObject.put("platform", platform);
+
+
+
+            int uid = 0;
+            List<DBObject> userInfos = BaseGlobal.getInstance().mongoDBPool.find(_COLLECTION_NAME, dbObject);
+            DBObject res = new BasicDBObject();
+            if (userInfos.size() == 0) {
+                uid = BaseGlobal.getInstance().mongoDBPool.inc("uid") + 10000000;
+                dbObject.put("uid", uid);
+                dbObject.put("_id", uid);
+                userInfos.add(dbObject);
+                if (gid != null && !gid.isEmpty()) {
+                    dbObject.put("gid", gid);
+                }
+                if (pid != null && !pid.isEmpty()) {
+                    dbObject.put("pid", pid);
+                }
+                BaseGlobal.getInstance().mongoDBPool.save(_COLLECTION_NAME, dbObject);
+
+                //记录日志,为了数据后台
+                logRegister(openId,uid,serverId);
+
+            }
+            Random random = new Random();
+            int utoken = Math.abs(random.nextInt());
+            uid = (int) userInfos.get(0).get("uid");
+            res.put("uid", uid);
+            res.put("token", utoken);
+            BaseGlobal.getInstance().redisApp.set(RedisKey.TOKEN, String.valueOf(uid), utoken, -1, false);
+            BaseGlobal.getInstance().redisApp.set(RedisKey.PIDGIDTEMP, String.valueOf(uid), pid+"#"+gid, -1, false);
+            //记录日志,为了数据后台
+            logLogin(openId,uid,serverId);
+
+
+            PrintWriter out = response.getWriter();
+            out.print(res);
+            out.flush();
+            out.close();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+    //注册 用户id,角色id,serverid,时间 放到一个表里
+    private void logRegister(String openId,int uid,String serverId){
+        Date date = new Date();
+        long loginTime = date.getTime();
+        DBObject doc = new BasicDBObject();
+        DBObject doc1 = new BasicDBObject();
+        //doc.put("_id",);
+        doc1.put("openId",openId);
+        doc1.put("uid",uid);
+        doc1.put("serverId",serverId);
+        doc1.put("registerTime",loginTime);
+        doc.put("register",doc1);
+        BaseGlobal.getInstance().mongoDBPool.save("logRegister", doc);
+    }
+    //登录 用户id,角色id,serverid,时间 按天放到一个表里
+    private void logLogin(String openId,int uid,String serverId){
+        //DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
+        Date date = new Date();
+        //long loginTime = Long.parseLong(dateFormat.format(date));
+        long loginTime = date.getTime();
+        DBObject doc = new BasicDBObject();
+        DBObject doc1 = new BasicDBObject();
+        //doc.put("_id",);
+        doc1.put("openId",openId);
+        doc1.put("uid",uid);
+        doc1.put("serverId",serverId);
+        doc1.put("loginTime",loginTime);
+        doc.put("loginTime",doc1);
+        BaseGlobal.getInstance().mongoDBPool.save("logLogin", doc);
+    }
+
+
+
+
+    public boolean vertify(HttpServletResponse response,HttpServletRequest request,String admin,String platform,String pid,String openId,String token){
+                    try {
+                        if(!KTSDKConstans.appsecret.equals(admin)) {
+                            if (isTestLan == 1) { //test
+                    boolean result = loginVerfifyByTestLan(openId, token);
+                    if (!result) {
+                        //response.sendError(400, "verify fail");
+
+                        PrintWriter out = response.getWriter();
+                        out.print("fail");//认证失败
+                        out.flush();
+                        out.close();
+
+                        LOGGER.error("test verify fail");
+                        return false;
+                    }
+                } else if (!"3".equals(platform)) {//正式 切不是pc
+                    String sub_channel = request.getParameter("sub_channel");
+                    boolean result = false;
+                    if (sub_channel != null && !sub_channel.equals("")) {
+                        if (sub_channel.equals("1000")) {
+                            result = loginVerfify(pid, openId, token, MHTSDKConstans.rhappid);
+                        } else {
+                            result = loginVerfify(pid, openId, token, MHTSDKConstans.rhappidOnline);
+                        }
+                    }
+                    if (!result) {
+                        response.sendError(400, "verify fail");
+                        LOGGER.error("verify fail");
+                        return false;
+                    }
+                }
+            }else {
+                boolean result = loginVerfifyByTestLan(openId, token);
+                if (!result) {
+                    //response.sendError(400, "verify fail");
+                    PrintWriter out = response.getWriter();
+                    out.print("fail");//认证失败
+                    out.flush();
+                    out.close();
+                    LOGGER.error("test verify fail");
+                    return false;
+                }
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return true;
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {
+        this.doGet(request, response);
+    }
+
+
+    public static boolean loginVerfify(String channelName,String openId,String token,String appId){
+        try{
+            String loginUrl = MHTSDKConstans.loginVerify;
+            Map<String, String> params = new HashMap<String, String>();
+            params.put("userToken", token);
+            params.put("appId", appId);
+            params.put("channelName", channelName);
+            params.put("uid", openId);
+            String loginResult = HttpUtils.doPost(loginUrl,params);
+            if(loginResult == null || loginResult.isEmpty()){
+                return false;
+            }
+            return parseLoginResult(loginResult);
+        }catch(Exception e){
+            return false;
+        }
+
+    }
+
+    public static boolean loginVerfifyByTestLan(String openId,String token) throws Exception {
+        String tokenInRedis = BaseGlobal.getInstance().redisApp.get(RedisKey.LOGIN_TOKEN, openId, String.class, -1);
+        LOGGER.info("tokenInRedis={}",tokenInRedis);
+        return token.equals(tokenInRedis);
+    }
+
+
+    private static boolean parseLoginResult(String orderResult){
+        try {
+            JSONObject jsonObject = JSONObject.parseObject(orderResult);
+            int state = jsonObject.getIntValue("code");
+            if(state != 200){
+                String content = jsonObject.getString("message");
+                LOGGER.info("parseLoginResult content={}",content);
+                return false;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return true;
+    }
+
+    public static void main(String[] args) {
+//        boolean mht = loginVerfify("MHT", "2318137", "be385683efe228aadac0c8b5822a6fba");
+    }
+
+}

+ 100 - 100
src/main/java/com/ljsd/controller/GetUserHwController.java

@@ -1,100 +1,100 @@
-package com.ljsd.controller;
-
-import com.alibaba.fastjson.JSONObject;
-import com.ljsd.plat.MHTHyTestPlat;
-import com.ljsd.plat.PlatProcess;
-import com.ljsd.redis.RedisKey;
-import com.ljsd.util.BaseGlobal;
-import com.ljsd.util.HttpUtils;
-import com.ljsd.util.KTSDKConstans;
-import com.ljsd.util.MHTSDKConstans;
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBObject;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.*;
-
-public class GetUserHwController extends GetUserController {
-    private final static String _COLLECTION_NAME = "user_info";
-    private static final Logger LOGGER = LoggerFactory.getLogger(GetUserHwController.class);
-    public static int isTestLan=0;
-
-    public static void initLanState(){
-        Properties properties = BaseGlobal.getInstance().properties;
-        isTestLan = Integer.parseInt(properties.getProperty("isTestLan"));
-    }
-
-    public GetUserHwController() {
-        super();
-    }
-
-    public void destroy() {
-        super.destroy();
-    }
-
-
-    @Override
-    public boolean vertify(HttpServletResponse response, HttpServletRequest request, String admin, String platform, String pid, String openId, String token) {
-        try {
-            if(!KTSDKConstans.appsecret.equals(admin)) {
-                if (isTestLan == 1) { //test
-                    boolean result = loginVerfifyByTestLan(openId, token);
-                    if (!result) {
-                        response.sendError(400, "verify fail");
-                        LOGGER.error("test verify fail");
-                        return false;
-                    }
-                } else if (!"3".equals(platform)) {//正式 切不是pc
-                    boolean result = false;
-                    if(platform.equals("1")){
-                        String sub_channel = request.getParameter("sub_channel");
-                        if (sub_channel != null && !sub_channel.equals("")) {
-                            PlatProcess hwios;
-                            if (sub_channel.equals("1000")) {
-                                hwios = BaseGlobal.getInstance().getHandlers("HWTEST");
-                            } else {
-                                 hwios = BaseGlobal.getInstance().getHandlers("HWGP");
-                            }
-                            result = hwios.loginVerfify(pid, openId, token);
-                        }
-
-                    }else if(platform.equals("2")){
-                        PlatProcess hwios = BaseGlobal.getInstance().getHandlers("HWIOS");
-                        result = hwios.loginVerfify(pid, openId, token);
-                    }
-
-                    if (!result) {
-                        response.sendError(400, "verify fail");
-                        LOGGER.error("verify fail");
-                        return false;
-                    }
-                }
-            }
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-        return true;
-    }
-
-
-    public void doPost(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-        this.doGet(request, response);
-    }
-
-
-
-
-    public static void main(String[] args) {
-        boolean mht = new MHTHyTestPlat().loginVerfify("MHT", "31179", "1f9dc916200a4483b7ab391ae90d7451");
-        System.out.println("mht = " + mht);
-    }
-
-}
+package com.ljsd.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ljsd.plat.MHTHyTestPlat;
+import com.ljsd.plat.PlatProcess;
+import com.ljsd.redis.RedisKey;
+import com.ljsd.util.BaseGlobal;
+import com.ljsd.util.HttpUtils;
+import com.ljsd.util.KTSDKConstans;
+import com.ljsd.util.MHTSDKConstans;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.*;
+
+public class GetUserHwController extends GetUserController {
+    private final static String _COLLECTION_NAME = "user_info";
+    private static final Logger LOGGER = LoggerFactory.getLogger(GetUserHwController.class);
+    public static int isTestLan=0;
+
+    public static void initLanState(){
+        Properties properties = BaseGlobal.getInstance().properties;
+        isTestLan = Integer.parseInt(properties.getProperty("isTestLan"));
+    }
+
+    public GetUserHwController() {
+        super();
+    }
+
+    public void destroy() {
+        super.destroy();
+    }
+
+
+    @Override
+    public boolean vertify(HttpServletResponse response, HttpServletRequest request, String admin, String platform, String pid, String openId, String token) {
+        try {
+            if(!KTSDKConstans.appsecret.equals(admin)) {
+                if (isTestLan == 1) { //test
+                    boolean result = loginVerfifyByTestLan(openId, token);
+                    if (!result) {
+                        response.sendError(400, "verify fail");
+                        LOGGER.error("test verify fail");
+                        return false;
+                    }
+                } else if (!"3".equals(platform)) {//正式 切不是pc
+                    boolean result = false;
+                    if(platform.equals("1")){
+                        String sub_channel = request.getParameter("sub_channel");
+                        if (sub_channel != null && !sub_channel.equals("")) {
+                            PlatProcess hwios;
+                            if (sub_channel.equals("1000")) {
+                                hwios = BaseGlobal.getInstance().getHandlers("HWTEST");
+                            } else {
+                                 hwios = BaseGlobal.getInstance().getHandlers("HWGP");
+                            }
+                            result = hwios.loginVerfify(pid, openId, token);
+                        }
+
+                    }else if(platform.equals("2")){
+                        PlatProcess hwios = BaseGlobal.getInstance().getHandlers("HWIOS");
+                        result = hwios.loginVerfify(pid, openId, token);
+                    }
+
+                    if (!result) {
+                        response.sendError(400, "verify fail");
+                        LOGGER.error("verify fail");
+                        return false;
+                    }
+                }
+            }
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return true;
+    }
+
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {
+        this.doGet(request, response);
+    }
+
+
+
+
+    public static void main(String[] args) {
+        boolean mht = new MHTHyTestPlat().loginVerfify("MHT", "31179", "1f9dc916200a4483b7ab391ae90d7451");
+        System.out.println("mht = " + mht);
+    }
+
+}

+ 25 - 25
src/main/java/com/ljsd/controller/IndexController.java

@@ -1,25 +1,25 @@
-package com.ljsd.controller;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-public class IndexController extends HttpServlet {
-    public IndexController() {
-        super();
-    }
-
-    public void destroy() {
-        super.destroy();
-    }
-
-
-    public void doGet(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-
-        response.sendRedirect("/index.jsp");
-
-    }
-}
+package com.ljsd.controller;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class IndexController extends HttpServlet {
+    public IndexController() {
+        super();
+    }
+
+    public void destroy() {
+        super.destroy();
+    }
+
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {
+
+        response.sendRedirect("/index.jsp");
+
+    }
+}

+ 31 - 31
src/main/java/com/ljsd/controller/PublishNoticeController.java

@@ -1,31 +1,31 @@
-package com.ljsd.controller;
-
-import com.ljsd.util.BaseGlobal;
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBObject;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-public class PublishNoticeController extends HttpServlet {
-    @Override
-    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        request.setCharacterEncoding("UTF-8");
-        String content = request.getParameter("content");
-        String title = request.getParameter("title");
-        DBObject doc = new BasicDBObject();
-        doc.put("_id", "1");
-        doc.put("content", content);
-        doc.put("title", title);
-        BaseGlobal.getInstance().mongoDBPool.save("notice_info", doc);
-        response.setContentType("text/html");
-        PrintWriter out = response.getWriter();
-        out.println("add suc");
-        out.flush();
-        out.close();
-    }
-}
+package com.ljsd.controller;
+
+import com.ljsd.util.BaseGlobal;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class PublishNoticeController extends HttpServlet {
+    @Override
+    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        request.setCharacterEncoding("UTF-8");
+        String content = request.getParameter("content");
+        String title = request.getParameter("title");
+        DBObject doc = new BasicDBObject();
+        doc.put("_id", "1");
+        doc.put("content", content);
+        doc.put("title", title);
+        BaseGlobal.getInstance().mongoDBPool.save("notice_info", doc);
+        response.setContentType("text/html");
+        PrintWriter out = response.getWriter();
+        out.println("add suc");
+        out.flush();
+        out.close();
+    }
+}

+ 65 - 65
src/main/java/com/ljsd/controller/RegistController.java

@@ -1,65 +1,65 @@
-package com.ljsd.controller;
-
-import com.ljsd.util.BaseGlobal;
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBObject;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-public class RegistController extends HttpServlet {
-    public RegistController() {
-        super();
-    }
-
-    public void destroy() {
-        super.destroy();
-    }
-
-
-    public void doGet(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-        this.doPost(request, response);
-    }
-
-    public void doPost(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-        int serverId = BaseGlobal.getInstance().mongoDBPool.inc("server_id");
-        request.setCharacterEncoding("utf-8");
-        String name = request.getParameter("name");
-        String ip = request.getParameter("ip");
-        String port = request.getParameter("port");
-        String server_id = request.getParameter("server_id");
-        String channel = request.getParameter("channel");
-        String sub_channel = request.getParameter("sub_channel");
-        String plat = request.getParameter("plat");
-        String state = request.getParameter("state");
-        String open_time = request.getParameter("open_time");
-        String token = request.getParameter("token");
-        String isnew = request.getParameter("isnew");
-        DBObject doc = new BasicDBObject();
-        doc.put("_id", serverId);
-        doc.put("name", name);
-        doc.put("ip", ip);
-        doc.put("port", port);
-        doc.put("server_id", server_id);
-        doc.put("channel", channel);
-        doc.put("sub_channel", sub_channel);
-        doc.put("plat", plat);
-        doc.put("state", state);
-        doc.put("open_time", open_time);
-        doc.put("isnew", isnew);
-        doc.put("server_version", 1);
-        BaseGlobal.getInstance().mongoDBPool.save("server_info", doc);
-        response.setContentType("text/html");
-        PrintWriter out = response.getWriter();
-        out.println("add suc");
-        out.flush();
-        out.close();
-
-    }
-}
+package com.ljsd.controller;
+
+import com.ljsd.util.BaseGlobal;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class RegistController extends HttpServlet {
+    public RegistController() {
+        super();
+    }
+
+    public void destroy() {
+        super.destroy();
+    }
+
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {
+        this.doPost(request, response);
+    }
+
+    public void doPost(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {
+        int serverId = BaseGlobal.getInstance().mongoDBPool.inc("server_id");
+        request.setCharacterEncoding("utf-8");
+        String name = request.getParameter("name");
+        String ip = request.getParameter("ip");
+        String port = request.getParameter("port");
+        String server_id = request.getParameter("server_id");
+        String channel = request.getParameter("channel");
+        String sub_channel = request.getParameter("sub_channel");
+        String plat = request.getParameter("plat");
+        String state = request.getParameter("state");
+        String open_time = request.getParameter("open_time");
+        String token = request.getParameter("token");
+        String isnew = request.getParameter("isnew");
+        DBObject doc = new BasicDBObject();
+        doc.put("_id", serverId);
+        doc.put("name", name);
+        doc.put("ip", ip);
+        doc.put("port", port);
+        doc.put("server_id", server_id);
+        doc.put("channel", channel);
+        doc.put("sub_channel", sub_channel);
+        doc.put("plat", plat);
+        doc.put("state", state);
+        doc.put("open_time", open_time);
+        doc.put("isnew", isnew);
+        doc.put("server_version", 1);
+        BaseGlobal.getInstance().mongoDBPool.save("server_info", doc);
+        response.setContentType("text/html");
+        PrintWriter out = response.getWriter();
+        out.println("add suc");
+        out.flush();
+        out.close();
+
+    }
+}

+ 15 - 15
src/main/java/com/ljsd/controller/RoutePublishNoticeController.java

@@ -1,15 +1,15 @@
-package com.ljsd.controller;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-
-public class RoutePublishNoticeController extends HttpServlet {
-
-    @Override
-    protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
-        response.sendRedirect("updateNotice.jsp");
-    }
-}
+package com.ljsd.controller;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+
+public class RoutePublishNoticeController extends HttpServlet {
+
+    @Override
+    protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException {
+        response.sendRedirect("updateNotice.jsp");
+    }
+}

+ 63 - 63
src/main/java/com/ljsd/controller/ServerListController.java

@@ -1,63 +1,63 @@
-
-package com.ljsd.controller;
-
-import com.ljsd.util.BaseGlobal;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-
-public class ServerListController extends HttpServlet{
-    private String  message;
-    private final static String _COLLECTION_NAME = "server_info";
-    public void init() throws ServletException
-    {
-        // 执行必需的初始化
-        try {
-            String serverInfoList = BaseGlobal.getInstance().mongoDBPool.findList("server_info");
-            //message = serverInfoList.toString();
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-
-
-
-//        message = "Hello World";
-    }
-    public void doGet(HttpServletRequest request,
-                       HttpServletResponse response)
-            throws ServletException, IOException {
-        // 设置响应内容类型
-        //   response.setContentType("text/html");
-        response.setCharacterEncoding("UTF-8");
-        response.setContentType("text/html; charset=utf-8");
-
-        // 实际的逻辑是在这里
-        PrintWriter out = response.getWriter();
-        String title = "戒灵服务器列表";
-        String docType =
-                "<!doctype html public \"-//w3c//dtd html 4.0 " +
-                        "transitional//en\">\n";
-        out.println(docType +
-                "<html>\n" +
-                "<head><meta charset=\"utf-8\"><title>" + title + "</title></head>\n" +
-                "<body bgcolor=\"#f0f0f0\">\n" +
-                "<h1 align=\"center\">" + title + "</h1>\n" +
-                        message +
-                "<table width=\"100%\" border=\"1\" align=\"center\">\n" +
-                "<tr bgcolor=\"#949494\">\n" +
-                "<th>ID</th><th>服务器名</th><th>ip</th><th>port</th><th>server_id</th><th>渠道</th><th>子渠道</th><th>plat</th><th>状态</th><th>开服时间</th>\n"+
-                "</tr>\n");
-        //out.println("<h1>" + "戒灵服务器列表:" + "</h1>");
-        //out.println("<h3>" + message + "</h3>");
-
-    }
-
-    public void destroy()
-    {
-        // 什么也不做
-    }
-}
+
+package com.ljsd.controller;
+
+import com.ljsd.util.BaseGlobal;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+public class ServerListController extends HttpServlet{
+    private String  message;
+    private final static String _COLLECTION_NAME = "server_info";
+    public void init() throws ServletException
+    {
+        // 执行必需的初始化
+        try {
+            String serverInfoList = BaseGlobal.getInstance().mongoDBPool.findList("server_info");
+            //message = serverInfoList.toString();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+
+
+//        message = "Hello World";
+    }
+    public void doGet(HttpServletRequest request,
+                       HttpServletResponse response)
+            throws ServletException, IOException {
+        // 设置响应内容类型
+        //   response.setContentType("text/html");
+        response.setCharacterEncoding("UTF-8");
+        response.setContentType("text/html; charset=utf-8");
+
+        // 实际的逻辑是在这里
+        PrintWriter out = response.getWriter();
+        String title = "戒灵服务器列表";
+        String docType =
+                "<!doctype html public \"-//w3c//dtd html 4.0 " +
+                        "transitional//en\">\n";
+        out.println(docType +
+                "<html>\n" +
+                "<head><meta charset=\"utf-8\"><title>" + title + "</title></head>\n" +
+                "<body bgcolor=\"#f0f0f0\">\n" +
+                "<h1 align=\"center\">" + title + "</h1>\n" +
+                        message +
+                "<table width=\"100%\" border=\"1\" align=\"center\">\n" +
+                "<tr bgcolor=\"#949494\">\n" +
+                "<th>ID</th><th>服务器名</th><th>ip</th><th>port</th><th>server_id</th><th>渠道</th><th>子渠道</th><th>plat</th><th>状态</th><th>开服时间</th>\n"+
+                "</tr>\n");
+        //out.println("<h1>" + "戒灵服务器列表:" + "</h1>");
+        //out.println("<h3>" + message + "</h3>");
+
+    }
+
+    public void destroy()
+    {
+        // 什么也不做
+    }
+}

+ 56 - 56
src/main/java/com/ljsd/controller/TestController.java

@@ -1,57 +1,57 @@
-package com.ljsd.controller;
-
-import com.google.gson.Gson;
-import com.ljsd.pojo.ResMsg;
-import com.ljsd.util.BaseGlobal;
-import com.ljsd.util.MD5Util;
-import com.ljsd.util.StringUtils;
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBObject;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Random;
-
-public class TestController extends HttpServlet {
-
-    private static final String _COLLECTION_NAME = "user_register_info";
-    private static Gson gson = new Gson();
-
-    public void doGet(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-        this.doPost(request, response);
-    }
-
-    @Override
-    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-
-        try ( PrintWriter out = response.getWriter();){
-
-
-            DBObject one = BaseGlobal.getInstance().mongoDBPool.findOne(_COLLECTION_NAME, "s1");
-
-
-            String idstr = "111111111111111";
-            BasicDBObject searchQuery = new BasicDBObject();
-            searchQuery.put("openId",one.get("openId"));
-            BasicDBObject dbobj = new BasicDBObject();
-            dbobj.put("idstr", idstr);
-            BasicDBObject update = new BasicDBObject().append("$set", new BasicDBObject().append("idstr", idstr));
-            BaseGlobal.getInstance().mongoDBPool.updateValue(_COLLECTION_NAME,searchQuery, update);
-            //BaseGlobal.getInstance().mongoDBPool.getCollection(_COLLECTION_NAME).findAndModify(searchQuery, dbobj);
-            //BaseGlobal.getInstance().mongoDBPool.getCollection(_COLLECTION_NAME).findAndModify(searchQuery, update);
-
-
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-
-
-    }
-
-
+package com.ljsd.controller;
+
+import com.google.gson.Gson;
+import com.ljsd.pojo.ResMsg;
+import com.ljsd.util.BaseGlobal;
+import com.ljsd.util.MD5Util;
+import com.ljsd.util.StringUtils;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Random;
+
+public class TestController extends HttpServlet {
+
+    private static final String _COLLECTION_NAME = "user_register_info";
+    private static Gson gson = new Gson();
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {
+        this.doPost(request, response);
+    }
+
+    @Override
+    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+
+        try ( PrintWriter out = response.getWriter();){
+
+
+            DBObject one = BaseGlobal.getInstance().mongoDBPool.findOne(_COLLECTION_NAME, "s1");
+
+
+            String idstr = "111111111111111";
+            BasicDBObject searchQuery = new BasicDBObject();
+            searchQuery.put("openId",one.get("openId"));
+            BasicDBObject dbobj = new BasicDBObject();
+            dbobj.put("idstr", idstr);
+            BasicDBObject update = new BasicDBObject().append("$set", new BasicDBObject().append("idstr", idstr));
+            BaseGlobal.getInstance().mongoDBPool.updateValue(_COLLECTION_NAME,searchQuery, update);
+            //BaseGlobal.getInstance().mongoDBPool.getCollection(_COLLECTION_NAME).findAndModify(searchQuery, dbobj);
+            //BaseGlobal.getInstance().mongoDBPool.getCollection(_COLLECTION_NAME).findAndModify(searchQuery, update);
+
+
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+
+
+    }
+
+
 }

+ 104 - 104
src/main/java/com/ljsd/controller/UserLoginController.java

@@ -1,104 +1,104 @@
-package com.ljsd.controller;
-
-import com.google.gson.Gson;
-import com.ljsd.pojo.ResMsg;
-import com.ljsd.redis.RedisKey;
-import com.ljsd.redis.RedisUtil;
-import com.ljsd.util.BaseGlobal;
-import com.ljsd.util.IdCard;
-import com.ljsd.util.MD5Util;
-import com.ljsd.util.StringUtils;
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBObject;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.*;
-
-public class UserLoginController extends HttpServlet {
-    private static Gson gson = new Gson();
-    private static final String _COLLECTION_NAME = "user_register_info";
-
-    public void doGet(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-        this.doPost(request, response);
-    }
-    @Override
-    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        response.setCharacterEncoding("UTF-8");
-        response.setContentType("application/json; charset=utf-8");
-        String name = request.getParameter("userName");
-        String password = request.getParameter("password");
-        String sign = request.getParameter("sign");
-        String returnMsg = "success";
-        ResMsg resMsg = new ResMsg();
-        resMsg.setCode(1);
-        try (PrintWriter out = response.getWriter();){
-            if(StringUtils.checkIsEmpty(name) || StringUtils.checkIsEmpty(password) || StringUtils.checkIsEmpty(sign)){
-                resMsg.setMsg("参数不能为空");
-                out.print(gson.toJson(resMsg));
-                return;
-            }
-            String mySign = MD5Util.encrypByMd5(name + password + MD5Util.salt);
-            if(!mySign.equals(sign)){
-                resMsg.setMsg("签名错误");
-                out.print(gson.toJson(resMsg));
-                return;
-            }
-            DBObject one = BaseGlobal.getInstance().mongoDBPool.findOne(_COLLECTION_NAME, name);
-            if(one ==null){
-                resMsg.setMsg("该账号不存在");
-                out.print(gson.toJson(resMsg));
-                return;
-            }
-            Object passwordInDb = one.get("password");
-            if(!password.equals(passwordInDb)){
-                resMsg.setMsg("密码错误,请重试");
-                out.print(gson.toJson(resMsg));
-                return;
-            }
-            Map<String,String> parms = new HashMap<>();
-            String openId = one.get("openId").toString();
-            parms.put("openId",one.get("openId").toString());
-            int token = new Random().nextInt(1024) +10000;
-            parms.put("token",Integer.toString(token));
-            BaseGlobal.getInstance().redisApp.set(RedisKey.LOGIN_TOKEN,openId,token,-1, false);
-
-            int code = 0;
-            //开关防沉迷
-            Properties properties = BaseGlobal.getInstance().properties;
-            if(Boolean.parseBoolean(properties.getProperty("openAdultCheck"))){
-                int age = 0;//年龄
-                if(one.get("idstr")==null){
-                    //resMsg.setCode(2);//未进行身份验证
-                    code = 2;
-                }else{
-                    if(IdCard.isAdult((String) one.get("idstr"))){
-                        age = 19;
-                    }
-                    //resMsg.setCode(0);//正常
-                    code = 0;
-                }
-                resMsg.setMsg(String.valueOf(age)); //登录成功,返回年龄
-            }else{
-                resMsg.setMsg(returnMsg);
-            }
-
-
-
-            resMsg.setCode(code);//正常
-
-            resMsg.setParms(parms);
-            out.print(gson.toJson(resMsg));
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-    }
-
-}
+package com.ljsd.controller;
+
+import com.google.gson.Gson;
+import com.ljsd.pojo.ResMsg;
+import com.ljsd.redis.RedisKey;
+import com.ljsd.redis.RedisUtil;
+import com.ljsd.util.BaseGlobal;
+import com.ljsd.util.IdCard;
+import com.ljsd.util.MD5Util;
+import com.ljsd.util.StringUtils;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+public class UserLoginController extends HttpServlet {
+    private static Gson gson = new Gson();
+    private static final String _COLLECTION_NAME = "user_register_info";
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {
+        this.doPost(request, response);
+    }
+    @Override
+    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        response.setCharacterEncoding("UTF-8");
+        response.setContentType("application/json; charset=utf-8");
+        String name = request.getParameter("userName");
+        String password = request.getParameter("password");
+        String sign = request.getParameter("sign");
+        String returnMsg = "success";
+        ResMsg resMsg = new ResMsg();
+        resMsg.setCode(1);
+        try (PrintWriter out = response.getWriter();){
+            if(StringUtils.checkIsEmpty(name) || StringUtils.checkIsEmpty(password) || StringUtils.checkIsEmpty(sign)){
+                resMsg.setMsg("参数不能为空");
+                out.print(gson.toJson(resMsg));
+                return;
+            }
+            String mySign = MD5Util.encrypByMd5(name + password + MD5Util.salt);
+            if(!mySign.equals(sign)){
+                resMsg.setMsg("签名错误");
+                out.print(gson.toJson(resMsg));
+                return;
+            }
+            DBObject one = BaseGlobal.getInstance().mongoDBPool.findOne(_COLLECTION_NAME, name);
+            if(one ==null){
+                resMsg.setMsg("该账号不存在");
+                out.print(gson.toJson(resMsg));
+                return;
+            }
+            Object passwordInDb = one.get("password");
+            if(!password.equals(passwordInDb)){
+                resMsg.setMsg("密码错误,请重试");
+                out.print(gson.toJson(resMsg));
+                return;
+            }
+            Map<String,String> parms = new HashMap<>();
+            String openId = one.get("openId").toString();
+            parms.put("openId",one.get("openId").toString());
+            int token = new Random().nextInt(1024) +10000;
+            parms.put("token",Integer.toString(token));
+            BaseGlobal.getInstance().redisApp.set(RedisKey.LOGIN_TOKEN,openId,token,-1, false);
+
+            int code = 0;
+            //开关防沉迷
+            Properties properties = BaseGlobal.getInstance().properties;
+            if(Boolean.parseBoolean(properties.getProperty("openAdultCheck"))){
+                int age = 0;//年龄
+                if(one.get("idstr")==null){
+                    //resMsg.setCode(2);//未进行身份验证
+                    code = 2;
+                }else{
+                    if(IdCard.isAdult((String) one.get("idstr"))){
+                        age = 19;
+                    }
+                    //resMsg.setCode(0);//正常
+                    code = 0;
+                }
+                resMsg.setMsg(String.valueOf(age)); //登录成功,返回年龄
+            }else{
+                resMsg.setMsg(returnMsg);
+            }
+
+
+
+            resMsg.setCode(code);//正常
+
+            resMsg.setParms(parms);
+            out.print(gson.toJson(resMsg));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+    }
+
+}

+ 97 - 97
src/main/java/com/ljsd/controller/UserRegisterController.java

@@ -1,98 +1,98 @@
-package com.ljsd.controller;
-
-import com.google.gson.Gson;
-import com.ljsd.pojo.ResMsg;
-import com.ljsd.util.BaseGlobal;
-import com.ljsd.util.MD5Util;
-import com.ljsd.util.StringUtils;
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBObject;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Random;
-
-public class UserRegisterController extends HttpServlet {
-
-    private static final String _COLLECTION_NAME = "user_register_info";
-    private static Gson gson = new Gson();
-
-    public void doGet(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-        this.doPost(request, response);
-    }
-
-    @Override
-    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        response.setCharacterEncoding("UTF-8");
-        response.setContentType("application/json; charset=utf-8");
-        String name = request.getParameter("userName");
-        String password = request.getParameter("password");
-        String repeat = request.getParameter("repeat");
-        String sign = request.getParameter("sign");
-        String returnMsg = "success";
-        ResMsg resMsg = new ResMsg();
-        resMsg.setCode(1);
-        try ( PrintWriter out = response.getWriter();){
-            if(StringUtils.checkIsEmpty(name) || StringUtils.checkIsEmpty(password) || StringUtils.checkIsEmpty(repeat) || StringUtils.checkIsEmpty(sign) ){
-                returnMsg = "输入不可以为空";
-                resMsg.setMsg(returnMsg);
-                out.print(gson.toJson(resMsg));
-                return;
-            }
-            if(!password.equals(repeat)){
-                returnMsg = "两次密码输入不一致";
-                resMsg.setMsg(returnMsg);
-                out.print(gson.toJson(resMsg));
-                return;
-            }
-            if(!StringUtils.checkIsNumberOrChar(name)){
-                resMsg.setMsg("用户名只能是数字或英文符号");
-                out.print(gson.toJson(resMsg));
-                return;
-            }
-            if(name.length()<2 || name.length()>12){
-                resMsg.setMsg("用户名长度不符合");
-                out.print(gson.toJson(resMsg));
-                return;
-            }
-
-            String mySign = MD5Util.encrypByMd5(name + password + MD5Util.salt);
-            if(!mySign.equals(sign)){
-                resMsg.setMsg("签名错误");
-                out.print(gson.toJson(resMsg));
-                return;
-            }
-
-            DBObject one = BaseGlobal.getInstance().mongoDBPool.findOne(_COLLECTION_NAME, name);
-            if(one!=null){
-                resMsg.setMsg("该账号已被注册");
-                out.print(gson.toJson(resMsg));
-                return;
-            }
-
-            DBObject doc = new BasicDBObject();
-            doc.put("_id", name);
-            doc.put("password", password);
-            int random = new Random(1024).nextInt();
-            String openId = MD5Util.encrypByMd5(mySign + random);
-            doc.put("openId", openId);
-            BaseGlobal.getInstance().mongoDBPool.save(_COLLECTION_NAME, doc);
-            resMsg.setCode(0);
-            resMsg.setMsg(returnMsg);
-            out.print(gson.toJson(resMsg));
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-
-
-    }
-
+package com.ljsd.controller;
+
+import com.google.gson.Gson;
+import com.ljsd.pojo.ResMsg;
+import com.ljsd.util.BaseGlobal;
+import com.ljsd.util.MD5Util;
+import com.ljsd.util.StringUtils;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Random;
+
+public class UserRegisterController extends HttpServlet {
+
+    private static final String _COLLECTION_NAME = "user_register_info";
+    private static Gson gson = new Gson();
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {
+        this.doPost(request, response);
+    }
+
+    @Override
+    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        response.setCharacterEncoding("UTF-8");
+        response.setContentType("application/json; charset=utf-8");
+        String name = request.getParameter("userName");
+        String password = request.getParameter("password");
+        String repeat = request.getParameter("repeat");
+        String sign = request.getParameter("sign");
+        String returnMsg = "success";
+        ResMsg resMsg = new ResMsg();
+        resMsg.setCode(1);
+        try ( PrintWriter out = response.getWriter();){
+            if(StringUtils.checkIsEmpty(name) || StringUtils.checkIsEmpty(password) || StringUtils.checkIsEmpty(repeat) || StringUtils.checkIsEmpty(sign) ){
+                returnMsg = "输入不可以为空";
+                resMsg.setMsg(returnMsg);
+                out.print(gson.toJson(resMsg));
+                return;
+            }
+            if(!password.equals(repeat)){
+                returnMsg = "两次密码输入不一致";
+                resMsg.setMsg(returnMsg);
+                out.print(gson.toJson(resMsg));
+                return;
+            }
+            if(!StringUtils.checkIsNumberOrChar(name)){
+                resMsg.setMsg("用户名只能是数字或英文符号");
+                out.print(gson.toJson(resMsg));
+                return;
+            }
+            if(name.length()<2 || name.length()>12){
+                resMsg.setMsg("用户名长度不符合");
+                out.print(gson.toJson(resMsg));
+                return;
+            }
+
+            String mySign = MD5Util.encrypByMd5(name + password + MD5Util.salt);
+            if(!mySign.equals(sign)){
+                resMsg.setMsg("签名错误");
+                out.print(gson.toJson(resMsg));
+                return;
+            }
+
+            DBObject one = BaseGlobal.getInstance().mongoDBPool.findOne(_COLLECTION_NAME, name);
+            if(one!=null){
+                resMsg.setMsg("该账号已被注册");
+                out.print(gson.toJson(resMsg));
+                return;
+            }
+
+            DBObject doc = new BasicDBObject();
+            doc.put("_id", name);
+            doc.put("password", password);
+            int random = new Random(1024).nextInt();
+            String openId = MD5Util.encrypByMd5(mySign + random);
+            doc.put("openId", openId);
+            BaseGlobal.getInstance().mongoDBPool.save(_COLLECTION_NAME, doc);
+            resMsg.setCode(0);
+            resMsg.setMsg(returnMsg);
+            out.print(gson.toJson(resMsg));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+
+
+    }
+
 }

+ 116 - 116
src/main/java/com/ljsd/controller/UserRegisterIDCardController.java

@@ -1,117 +1,117 @@
-package com.ljsd.controller;
-
-import com.google.gson.Gson;
-import com.ljsd.pojo.ResMsg;
-import com.ljsd.util.BaseGlobal;
-import com.ljsd.util.IdCard;
-import com.ljsd.util.MD5Util;
-import com.ljsd.util.StringUtils;
-import com.mongodb.BasicDBObject;
-import com.mongodb.DBObject;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServlet;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Random;
-
-public class UserRegisterIDCardController extends HttpServlet {
-
-    private static final String _COLLECTION_NAME = "user_register_info";
-    private static Gson gson = new Gson();
-
-    public void doGet(HttpServletRequest request, HttpServletResponse response)
-            throws ServletException, IOException {
-        this.doPost(request, response);
-    }
-
-    @Override
-    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-        response.setCharacterEncoding("UTF-8");
-        response.setContentType("application/json; charset=utf-8");
-        String name = request.getParameter("userName");
-        String password = request.getParameter("password");
-        String idname = request.getParameter("idname");
-        //String s2 =  new String(idname .getBytes("iso8859-1"),"utf-8");
-        //String s2 =  new String(idname .getBytes("utf-8"),"utf-8");
-        String idstr = request.getParameter("idstr");
-
-        String sign = request.getParameter("sign");
-        String returnMsg = "success";
-        ResMsg resMsg = new ResMsg();
-        resMsg.setCode(1);
-        try ( PrintWriter out = response.getWriter();){
-            if(StringUtils.checkIsEmpty(name) || StringUtils.checkIsEmpty(password) || StringUtils.checkIsEmpty(sign) ){
-                returnMsg = "输入不可以为空";
-                resMsg.setMsg(returnMsg);
-                out.print(gson.toJson(resMsg));
-                return;
-            }
-
-
-
-            String mySign = MD5Util.encrypByMd5(name + password + MD5Util.salt);
-            if(!mySign.equals(sign)){
-                resMsg.setMsg("签名错误");
-                out.print(gson.toJson(resMsg));
-                return;
-            }
-
-            DBObject one = BaseGlobal.getInstance().mongoDBPool.findOne(_COLLECTION_NAME, name);
-            if(one==null){
-                resMsg.setMsg("该账号不存在");
-                out.print(gson.toJson(resMsg));
-                return;
-            }
-
-            if(!StringUtils.check(idstr)){
-                resMsg.setMsg("实名验证校验失败:");
-                out.print(gson.toJson(resMsg));
-                return;
-            }
-//            if(!StringUtils.checkName(s2)){
-//                //idea
-//                System.out.println("s2 = [" + s2 + "]"+"idname+ = [" + idname + "]");
-//                resMsg.setMsg("实名验证校验失败:");
-//                out.print(gson.toJson(resMsg));
-//                return;
-//            }
-
-            DBObject doc = new BasicDBObject();
-            doc.put("_id", name);
-            doc.put("password", password);
-            int random = new Random(1024).nextInt();
-            String openId = MD5Util.encrypByMd5(mySign + random);
-            doc.put("openId", openId);
-            doc.put("idstr", idstr);
-
-
-            BasicDBObject searchQuery = new BasicDBObject();
-            searchQuery.put("openId",one.get("openId"));
-            BasicDBObject update = new BasicDBObject().append("$set", new BasicDBObject().append("idstr", idstr));
-            BaseGlobal.getInstance().mongoDBPool.updateValue(_COLLECTION_NAME,searchQuery, update);
-
-            resMsg.setCode(0);
-
-
-            int age = 0;//年龄
-
-            if(IdCard.isAdult(idstr)){
-                age = 19;
-            }
-
-
-            resMsg.setMsg(String.valueOf(age)); //登录成功,返回年龄
-            //resMsg.setMsg(returnMsg);
-            out.print(gson.toJson(resMsg));
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-
-
-    }
-
-
+package com.ljsd.controller;
+
+import com.google.gson.Gson;
+import com.ljsd.pojo.ResMsg;
+import com.ljsd.util.BaseGlobal;
+import com.ljsd.util.IdCard;
+import com.ljsd.util.MD5Util;
+import com.ljsd.util.StringUtils;
+import com.mongodb.BasicDBObject;
+import com.mongodb.DBObject;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Random;
+
+public class UserRegisterIDCardController extends HttpServlet {
+
+    private static final String _COLLECTION_NAME = "user_register_info";
+    private static Gson gson = new Gson();
+
+    public void doGet(HttpServletRequest request, HttpServletResponse response)
+            throws ServletException, IOException {
+        this.doPost(request, response);
+    }
+
+    @Override
+    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        response.setCharacterEncoding("UTF-8");
+        response.setContentType("application/json; charset=utf-8");
+        String name = request.getParameter("userName");
+        String password = request.getParameter("password");
+        String idname = request.getParameter("idname");
+        //String s2 =  new String(idname .getBytes("iso8859-1"),"utf-8");
+        //String s2 =  new String(idname .getBytes("utf-8"),"utf-8");
+        String idstr = request.getParameter("idstr");
+
+        String sign = request.getParameter("sign");
+        String returnMsg = "success";
+        ResMsg resMsg = new ResMsg();
+        resMsg.setCode(1);
+        try ( PrintWriter out = response.getWriter();){
+            if(StringUtils.checkIsEmpty(name) || StringUtils.checkIsEmpty(password) || StringUtils.checkIsEmpty(sign) ){
+                returnMsg = "输入不可以为空";
+                resMsg.setMsg(returnMsg);
+                out.print(gson.toJson(resMsg));
+                return;
+            }
+
+
+
+            String mySign = MD5Util.encrypByMd5(name + password + MD5Util.salt);
+            if(!mySign.equals(sign)){
+                resMsg.setMsg("签名错误");
+                out.print(gson.toJson(resMsg));
+                return;
+            }
+
+            DBObject one = BaseGlobal.getInstance().mongoDBPool.findOne(_COLLECTION_NAME, name);
+            if(one==null){
+                resMsg.setMsg("该账号不存在");
+                out.print(gson.toJson(resMsg));
+                return;
+            }
+
+            if(!StringUtils.check(idstr)){
+                resMsg.setMsg("实名验证校验失败:");
+                out.print(gson.toJson(resMsg));
+                return;
+            }
+//            if(!StringUtils.checkName(s2)){
+//                //idea
+//                System.out.println("s2 = [" + s2 + "]"+"idname+ = [" + idname + "]");
+//                resMsg.setMsg("实名验证校验失败:");
+//                out.print(gson.toJson(resMsg));
+//                return;
+//            }
+
+            DBObject doc = new BasicDBObject();
+            doc.put("_id", name);
+            doc.put("password", password);
+            int random = new Random(1024).nextInt();
+            String openId = MD5Util.encrypByMd5(mySign + random);
+            doc.put("openId", openId);
+            doc.put("idstr", idstr);
+
+
+            BasicDBObject searchQuery = new BasicDBObject();
+            searchQuery.put("openId",one.get("openId"));
+            BasicDBObject update = new BasicDBObject().append("$set", new BasicDBObject().append("idstr", idstr));
+            BaseGlobal.getInstance().mongoDBPool.updateValue(_COLLECTION_NAME,searchQuery, update);
+
+            resMsg.setCode(0);
+
+
+            int age = 0;//年龄
+
+            if(IdCard.isAdult(idstr)){
+                age = 19;
+            }
+
+
+            resMsg.setMsg(String.valueOf(age)); //登录成功,返回年龄
+            //resMsg.setMsg(returnMsg);
+            out.print(gson.toJson(resMsg));
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+
+
+    }
+
+
 }

+ 56 - 56
src/main/java/com/ljsd/listener/WebContextListener.java

@@ -1,57 +1,57 @@
-package com.ljsd.listener;
-
-import com.ljsd.util.BaseGlobal;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import javax.servlet.ServletContextEvent;
-import javax.servlet.ServletContextListener;
-import java.io.FileInputStream;
-import java.io.InputStream;
-
-//创建的类名根据需要定义,但一定要实现ServletContextListener接口
-public class WebContextListener implements ServletContextListener {
-    private static final Logger LOGGER = LoggerFactory.getLogger(ServletContextListener.class);
-    private static String DEFAULT_CONFIG_PATH = "/application.properties";
-
-    @Override
-    public void contextInitialized(ServletContextEvent arg0) {
-        // TODO Auto-generated method stub
-        LOGGER.debug("dddddddddddddddddddddddddddddddd");
-        InputStream inputStream = null;
-        try {
-            String path=System.getProperty("catalina.home");
-            String osName = System.getProperty("os.name");
-            if (osName.matches("^(?i)Windows.*$")) {// Window 系统
-                path = DEFAULT_CONFIG_PATH;
-                inputStream = getClass().getResourceAsStream(path);
-            }else{
-               //path += "/config/jl_loginserver/application.properties";
-                //path += "/config/tk/application.properties";
-                path += "/config/x1/application.properties";
-                inputStream = new FileInputStream(path);
-            }
-            LOGGER.info("WebContextListener==>path={}",path);
-            if (inputStream != null) {
-                BaseGlobal.getInstance().properties.load(inputStream);
-            }
-            BaseGlobal.getInstance().init();
-        } catch (Exception ex) {
-            ex.printStackTrace();
-        } finally {
-            try {
-                if (inputStream != null) {
-                    inputStream.close();
-                }
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }
-    }
-
-    @Override
-    public void contextDestroyed(ServletContextEvent arg0) {
-        // TODO Auto-generated method stub
-
-    }
+package com.ljsd.listener;
+
+import com.ljsd.util.BaseGlobal;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+import java.io.FileInputStream;
+import java.io.InputStream;
+
+//创建的类名根据需要定义,但一定要实现ServletContextListener接口
+public class WebContextListener implements ServletContextListener {
+    private static final Logger LOGGER = LoggerFactory.getLogger(ServletContextListener.class);
+    private static String DEFAULT_CONFIG_PATH = "/application.properties";
+
+    @Override
+    public void contextInitialized(ServletContextEvent arg0) {
+        // TODO Auto-generated method stub
+        LOGGER.debug("dddddddddddddddddddddddddddddddd");
+        InputStream inputStream = null;
+        try {
+            String path=System.getProperty("catalina.home");
+            String osName = System.getProperty("os.name");
+            if (osName.matches("^(?i)Windows.*$")) {// Window 系统
+                path = DEFAULT_CONFIG_PATH;
+                inputStream = getClass().getResourceAsStream(path);
+            }else{
+               //path += "/config/jl_loginserver/application.properties";
+                //path += "/config/tk/application.properties";
+                path += "/config/x1/application.properties";
+                inputStream = new FileInputStream(path);
+            }
+            LOGGER.info("WebContextListener==>path={}",path);
+            if (inputStream != null) {
+                BaseGlobal.getInstance().properties.load(inputStream);
+            }
+            BaseGlobal.getInstance().init();
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        } finally {
+            try {
+                if (inputStream != null) {
+                    inputStream.close();
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    @Override
+    public void contextDestroyed(ServletContextEvent arg0) {
+        // TODO Auto-generated method stub
+
+    }
 }

+ 71 - 71
src/main/java/com/ljsd/plat/AbstractMHTPlat.java

@@ -1,71 +1,71 @@
-package com.ljsd.plat;
-
-import com.alibaba.fastjson.JSONObject;
-import com.ljsd.util.HttpUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Description:    des
- * Author:         zsx
- * CreateDate:     2020/8/10 16:35
- */
-public abstract class AbstractMHTPlat implements PlatProcess {
-    private static final Logger LOGGER = LoggerFactory.getLogger(AbstractMHTPlat.class);
-    String happid;
-    String appkey;
-    private String loginVertifyUrl;
-    public AbstractMHTPlat() {
-        init();
-        loginVertifyUrl = "http://interface.18183g.top/interface/user-login/checkLogin";
-    }
-
-
-    public String getVertifyUrl() {
-        return loginVertifyUrl;
-    }
-
-    @Override
-    public boolean loginVerfify(String channelName, String openId, String token) {
-        try{
-            String loginUrl =getVertifyUrl();
-            Map<String, String> params = new HashMap<String, String>();
-            params.put("sid", token);
-            params.put("appId", getAppkey());
-            params.put("channelId", "MHT");
-            String loginResult = HttpUtils.doPost(loginUrl,params);
-            if(loginResult == null || loginResult.isEmpty()){
-                return false;
-            }
-            return parseLoginResult(loginResult);
-        }catch(Exception e){
-            e.printStackTrace();
-            return false;
-        }
-    }
-
-    public String getAppkey() {
-        return appkey;
-    }
-
-
-    private static boolean parseLoginResult(String orderResult){
-        try {
-            JSONObject jsonObject = JSONObject.parseObject(orderResult);
-            int state = jsonObject.getIntValue("code");
-            if(state != 200){
-                String content = jsonObject.getString("message");
-                LOGGER.info("parseLoginResult content={}",content);
-                return false;
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-        return true;
-    }
-
-
-}
+package com.ljsd.plat;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ljsd.util.HttpUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Description:    des
+ * Author:         zsx
+ * CreateDate:     2020/8/10 16:35
+ */
+public abstract class AbstractMHTPlat implements PlatProcess {
+    private static final Logger LOGGER = LoggerFactory.getLogger(AbstractMHTPlat.class);
+    String happid;
+    String appkey;
+    private String loginVertifyUrl;
+    public AbstractMHTPlat() {
+        init();
+        loginVertifyUrl = "http://interface.18183g.top/interface/user-login/checkLogin";
+    }
+
+
+    public String getVertifyUrl() {
+        return loginVertifyUrl;
+    }
+
+    @Override
+    public boolean loginVerfify(String channelName, String openId, String token) {
+        try{
+            String loginUrl =getVertifyUrl();
+            Map<String, String> params = new HashMap<String, String>();
+            params.put("sid", token);
+            params.put("appId", getAppkey());
+            params.put("channelId", "MHT");
+            String loginResult = HttpUtils.doPost(loginUrl,params);
+            if(loginResult == null || loginResult.isEmpty()){
+                return false;
+            }
+            return parseLoginResult(loginResult);
+        }catch(Exception e){
+            e.printStackTrace();
+            return false;
+        }
+    }
+
+    public String getAppkey() {
+        return appkey;
+    }
+
+
+    private static boolean parseLoginResult(String orderResult){
+        try {
+            JSONObject jsonObject = JSONObject.parseObject(orderResult);
+            int state = jsonObject.getIntValue("code");
+            if(state != 200){
+                String content = jsonObject.getString("message");
+                LOGGER.info("parseLoginResult content={}",content);
+                return false;
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return true;
+    }
+
+
+}

+ 31 - 31
src/main/java/com/ljsd/plat/MHTGPPlat.java

@@ -1,31 +1,31 @@
-package com.ljsd.plat;
-
-import com.alibaba.fastjson.JSONObject;
-import com.ljsd.util.HttpUtils;
-import com.ljsd.util.MHTSDKConstans;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Description:    des
- * Author:         zsx
- * CreateDate:     2020/8/10 16:35
- */
-public class MHTGPPlat extends AbstractMHTPlat {
-    private static final Logger LOGGER = LoggerFactory.getLogger(MHTGPPlat.class);
-
-    @Override
-    public String getName() {
-        return "HWGP";
-    }
-
-    @Override
-    public void init() {
-        happid = "346450436349889";
-        appkey = "02c13b5e54da94aef0150db87b9862bb";
-    }
-
-}
+package com.ljsd.plat;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ljsd.util.HttpUtils;
+import com.ljsd.util.MHTSDKConstans;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Description:    des
+ * Author:         zsx
+ * CreateDate:     2020/8/10 16:35
+ */
+public class MHTGPPlat extends AbstractMHTPlat {
+    private static final Logger LOGGER = LoggerFactory.getLogger(MHTGPPlat.class);
+
+    @Override
+    public String getName() {
+        return "HWGP";
+    }
+
+    @Override
+    public void init() {
+        happid = "346450436349889";
+        appkey = "02c13b5e54da94aef0150db87b9862bb";
+    }
+
+}

+ 32 - 32
src/main/java/com/ljsd/plat/MHTHyTestPlat.java

@@ -1,32 +1,32 @@
-package com.ljsd.plat;
-
-import com.alibaba.fastjson.JSONObject;
-import com.ljsd.util.HttpUtils;
-import com.ljsd.util.MHTSDKConstans;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Description:    des
- * Author:         zsx
- * CreateDate:     2020/8/10 16:35
- */
-public class MHTHyTestPlat extends AbstractMHTPlat {
-    private static final Logger LOGGER = LoggerFactory.getLogger(MHTHyTestPlat.class);
-
-
-    @Override
-    public String getName() {
-        return "HWTEST";
-    }
-
-    @Override
-    public void init() {
-        happid = "3192205470869872";
-        appkey = "2c2ab86233c7266e9360b69506734b3f";
-    }
-
-}
+package com.ljsd.plat;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ljsd.util.HttpUtils;
+import com.ljsd.util.MHTSDKConstans;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Description:    des
+ * Author:         zsx
+ * CreateDate:     2020/8/10 16:35
+ */
+public class MHTHyTestPlat extends AbstractMHTPlat {
+    private static final Logger LOGGER = LoggerFactory.getLogger(MHTHyTestPlat.class);
+
+
+    @Override
+    public String getName() {
+        return "HWTEST";
+    }
+
+    @Override
+    public void init() {
+        happid = "3192205470869872";
+        appkey = "2c2ab86233c7266e9360b69506734b3f";
+    }
+
+}

+ 32 - 32
src/main/java/com/ljsd/plat/MHTIOSPlat.java

@@ -1,32 +1,32 @@
-package com.ljsd.plat;
-
-import com.alibaba.fastjson.JSONObject;
-import com.ljsd.util.HttpUtils;
-import com.ljsd.util.MHTSDKConstans;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Description:    des
- * Author:         zsx
- * CreateDate:     2020/8/10 16:35
- */
-public class MHTIOSPlat extends AbstractMHTPlat {
-    private static final Logger LOGGER = LoggerFactory.getLogger(MHTIOSPlat.class);
-
-
-    @Override
-    public String getName() {
-        return "HWIOS";
-    }
-
-    @Override
-    public void init() {
-        happid = "346450436349889";
-        appkey = "98ea7849bb70a99025dfc58b5f57762b";
-    }
-
-}
+package com.ljsd.plat;
+
+import com.alibaba.fastjson.JSONObject;
+import com.ljsd.util.HttpUtils;
+import com.ljsd.util.MHTSDKConstans;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Description:    des
+ * Author:         zsx
+ * CreateDate:     2020/8/10 16:35
+ */
+public class MHTIOSPlat extends AbstractMHTPlat {
+    private static final Logger LOGGER = LoggerFactory.getLogger(MHTIOSPlat.class);
+
+
+    @Override
+    public String getName() {
+        return "HWIOS";
+    }
+
+    @Override
+    public void init() {
+        happid = "346450436349889";
+        appkey = "98ea7849bb70a99025dfc58b5f57762b";
+    }
+
+}

+ 17 - 17
src/main/java/com/ljsd/plat/PlatProcess.java

@@ -1,18 +1,18 @@
-package com.ljsd.plat;
-
-/**
- * Description:    des
- * Author:         zsx
- * CreateDate:     2020/8/10 15:59
- */
-public interface PlatProcess {
-
-    void init();
-
-    String getName();
-
-    boolean loginVerfify(String channelName, String openId, String token);
-
-    String getVertifyUrl();
-
+package com.ljsd.plat;
+
+/**
+ * Description:    des
+ * Author:         zsx
+ * CreateDate:     2020/8/10 15:59
+ */
+public interface PlatProcess {
+
+    void init();
+
+    String getName();
+
+    boolean loginVerfify(String channelName, String openId, String token);
+
+    String getVertifyUrl();
+
 }

+ 74 - 74
src/main/java/com/ljsd/pojo/NoticeInfo.java

@@ -1,74 +1,74 @@
-package com.ljsd.pojo;
-
-
-import com.mongodb.DBObject;
-import org.bson.BSONObject;
-
-import java.util.Map;
-import java.util.Set;
-
-/**
- *
- * @author Administrator
- * @date 2015/8/13
- */
-
-public class NoticeInfo  {
-
-
-    private String _id;
-    private String content;
-    private String title;
-    private int leve;
-    private long startTime;
-    private long endTime;
-
-    public String getContent() {
-        return content;
-    }
-
-    public void setContent(String content) {
-        this.content = content;
-    }
-
-    public String getTitle() {
-        return title;
-    }
-
-    public void setTitle(String title) {
-        this.title = title;
-    }
-
-    public String get_id() {
-        return _id;
-    }
-
-    public void set_id(String _id) {
-        this._id = _id;
-    }
-
-    public int getLeve() {
-        return leve;
-    }
-
-    public void setLeve(int leve) {
-        this.leve = leve;
-    }
-
-    public long getStartTime() {
-        return startTime;
-    }
-
-    public void setStartTime(long startTime) {
-        this.startTime = startTime;
-    }
-
-    public long getEndTime() {
-        return endTime;
-    }
-
-    public void setEndTime(long endTime) {
-        this.endTime = endTime;
-    }
-
-}
+package com.ljsd.pojo;
+
+
+import com.mongodb.DBObject;
+import org.bson.BSONObject;
+
+import java.util.Map;
+import java.util.Set;
+
+/**
+ *
+ * @author Administrator
+ * @date 2015/8/13
+ */
+
+public class NoticeInfo  {
+
+
+    private String _id;
+    private String content;
+    private String title;
+    private int leve;
+    private long startTime;
+    private long endTime;
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setContent(String content) {
+        this.content = content;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public void setTitle(String title) {
+        this.title = title;
+    }
+
+    public String get_id() {
+        return _id;
+    }
+
+    public void set_id(String _id) {
+        this._id = _id;
+    }
+
+    public int getLeve() {
+        return leve;
+    }
+
+    public void setLeve(int leve) {
+        this.leve = leve;
+    }
+
+    public long getStartTime() {
+        return startTime;
+    }
+
+    public void setStartTime(long startTime) {
+        this.startTime = startTime;
+    }
+
+    public long getEndTime() {
+        return endTime;
+    }
+
+    public void setEndTime(long endTime) {
+        this.endTime = endTime;
+    }
+
+}

+ 36 - 36
src/main/java/com/ljsd/pojo/ResMsg.java

@@ -1,36 +1,36 @@
-package com.ljsd.pojo;
-
-import java.util.Map;
-
-public class ResMsg {
-
-    private int code;
-
-    private String msg;
-
-    private Map<String,String> parms;
-
-    public int getCode() {
-        return code;
-    }
-
-    public void setCode(int code) {
-        this.code = code;
-    }
-
-    public String getMsg() {
-        return msg;
-    }
-
-    public void setMsg(String msg) {
-        this.msg = msg;
-    }
-
-    public Map<String, String> getParms() {
-        return parms;
-    }
-
-    public void setParms(Map<String, String> parms) {
-        this.parms = parms;
-    }
-}
+package com.ljsd.pojo;
+
+import java.util.Map;
+
+public class ResMsg {
+
+    private int code;
+
+    private String msg;
+
+    private Map<String,String> parms;
+
+    public int getCode() {
+        return code;
+    }
+
+    public void setCode(int code) {
+        this.code = code;
+    }
+
+    public String getMsg() {
+        return msg;
+    }
+
+    public void setMsg(String msg) {
+        this.msg = msg;
+    }
+
+    public Map<String, String> getParms() {
+        return parms;
+    }
+
+    public void setParms(Map<String, String> parms) {
+        this.parms = parms;
+    }
+}

+ 72 - 72
src/main/java/com/ljsd/pojo/UserRecentLoginInfo.java

@@ -1,72 +1,72 @@
-package com.ljsd.pojo;
-
-public class UserRecentLoginInfo {
-
-    private long loginTime;
-
-    private int level;
-
-    private int uid;
-
-    private String name;
-
-    private int head;
-    private int headFream;
-
-    public UserRecentLoginInfo(long loginTime, int level, int uid, String name,int head,int headFream) {
-        this.loginTime = loginTime;
-        this.level = level;
-        this.uid = uid;
-        this.name = name;
-        this.head=head;
-        this.headFream=headFream;
-    }
-
-    public long getLoginTime() {
-        return loginTime;
-    }
-
-    public void setLoginTime(long loginTime) {
-        this.loginTime = loginTime;
-    }
-
-    public int getLevel() {
-        return level;
-    }
-
-    public void setLevel(int level) {
-        this.level = level;
-    }
-
-    public int getUid() {
-        return uid;
-    }
-
-    public void setUid(int uid) {
-        this.uid = uid;
-    }
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public int getHead() {
-        return head;
-    }
-
-    public void setHead(int head) {
-        this.head = head;
-    }
-
-    public int getHeadFream() {
-        return headFream;
-    }
-
-    public void setHeadFream(int headFream) {
-        this.headFream = headFream;
-    }
-}
+package com.ljsd.pojo;
+
+public class UserRecentLoginInfo {
+
+    private long loginTime;
+
+    private int level;
+
+    private int uid;
+
+    private String name;
+
+    private int head;
+    private int headFream;
+
+    public UserRecentLoginInfo(long loginTime, int level, int uid, String name,int head,int headFream) {
+        this.loginTime = loginTime;
+        this.level = level;
+        this.uid = uid;
+        this.name = name;
+        this.head=head;
+        this.headFream=headFream;
+    }
+
+    public long getLoginTime() {
+        return loginTime;
+    }
+
+    public void setLoginTime(long loginTime) {
+        this.loginTime = loginTime;
+    }
+
+    public int getLevel() {
+        return level;
+    }
+
+    public void setLevel(int level) {
+        this.level = level;
+    }
+
+    public int getUid() {
+        return uid;
+    }
+
+    public void setUid(int uid) {
+        this.uid = uid;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public int getHead() {
+        return head;
+    }
+
+    public void setHead(int head) {
+        this.head = head;
+    }
+
+    public int getHeadFream() {
+        return headFream;
+    }
+
+    public void setHeadFream(int headFream) {
+        this.headFream = headFream;
+    }
+}

+ 24 - 24
src/main/java/com/ljsd/pojo/UserServerInfo.java

@@ -1,24 +1,24 @@
-package com.ljsd.pojo;
-
-public class UserServerInfo {
-
-    private long loginTime;
-
-    private int level;
-
-    public long getLoginTime() {
-        return loginTime;
-    }
-
-    public void setLoginTime(long loginTime) {
-        this.loginTime = loginTime;
-    }
-
-    public int getLevel() {
-        return level;
-    }
-
-    public void setLevel(int level) {
-        this.level = level;
-    }
-}
+package com.ljsd.pojo;
+
+public class UserServerInfo {
+
+    private long loginTime;
+
+    private int level;
+
+    public long getLoginTime() {
+        return loginTime;
+    }
+
+    public void setLoginTime(long loginTime) {
+        this.loginTime = loginTime;
+    }
+
+    public int getLevel() {
+        return level;
+    }
+
+    public void setLevel(int level) {
+        this.level = level;
+    }
+}

+ 302 - 302
src/main/java/com/ljsd/redis/RedisApp.java

@@ -1,302 +1,302 @@
-package com.ljsd.redis;
-
-import com.google.gson.Gson;
-
-import java.util.*;
-
-public class RedisApp {
-    private final static String Delimiter_colon = ":";
-    private RedisUtil redisUtil = new RedisUtil();
-    private Gson gson = new Gson();
-    private String areaId = "0";
-
-    public RedisApp() {
-        redisUtil.init();
-    }
-
-    private <K, T> String getKey(String type, K key, boolean withServerId) {
-        if (withServerId) {
-            return areaId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);
-        } else {
-            return type + Delimiter_colon + String.valueOf(key);
-        }
-    }
-
-    /***************************************普通键值对操作***************************************/
-    //设置键值
-    public <K, T> void set(final String type, final K key, T value, final int seconds, boolean withServerId) throws Exception {
-        String strValue = gson.toJson(value);
-        String fullKey = getKey(type, key, withServerId);
-        if (seconds <= 0) {
-            redisUtil.set(fullKey, strValue);
-        } else {
-            redisUtil.setex(fullKey, seconds, strValue);
-        }
-    }
-
-    public <T> void set(final String type, final String key, T value, final int seconds) throws Exception {
-        set(type, key, value, seconds, true);
-    }
-
-    //取得键值
-    public <K, T> T get(final String type, final K key, final Class<T> clazz, final int seconds,
-                        boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        String strValue = redisUtil.get(fullKey);
-        if (strValue == null) {
-            return null;
-        }
-        return gson.fromJson(strValue,clazz);
-    }
-
-    public <K, T> T get(final String type, final K key, final Class<T> clazz, final int seconds) throws Exception {
-        return get(type, key, clazz, seconds, false);
-    }
-
-    //取得键值
-    public <K, T> void del(final String type, final K key, final boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        redisUtil.del(fullKey);
-    }
-
-    public <K, T> void del(final String type, final K key) throws Exception {
-        del(type, key, true);
-    }
-
-    public <K> boolean exists(final String type, final K key, final boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        return redisUtil.exists(fullKey);
-    }
-
-    public <K> boolean exists(final String type, final K key) throws Exception {
-        return exists(type, key, true);
-    }
-
-    //设置过期时间
-    public <K, T> void expire(final String type, final K key, final int seconds, boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        redisUtil.expire(fullKey, seconds);
-    }
-
-    public void expire(final String type, final String key, final int seconds) throws Exception {
-        expire(type, key, seconds, true);
-    }
-
-    /***************************************以下是map操作***************************************/
-    //转换map对象类型
-    private <K, T> Map<String, String> converStringMap(Map<K, T> mapValues) {
-        Map<String, String> map = new HashMap<String, String>();
-        for (Map.Entry<K, T> entry : mapValues.entrySet()) {
-            String strKey = String.valueOf(entry.getKey());
-            String strValue = gson.toJson(entry.getValue());
-            map.put(strKey, strValue);
-        }
-        return map;
-    }
-
-    //设置map的
-    public <K, T> void hmset(final String type, final K key, final Map<K, T> hash, int seconds,
-                             boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        Map<String, String> strHash = converStringMap(hash);
-        redisUtil.hmset(fullKey, strHash, seconds);
-    }
-
-    public <K, T> void hmset(final String type, final K key, final Map<K, T> hash, final int seconds) throws Exception {
-        hmset(type, key, hash, seconds, true);
-    }
-
-    //取得map下的子key
-    public <K> Set<String> hkeys(final String type, final K key, final int seconds, boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        return redisUtil.hkeys(fullKey);
-    }
-
-    public <K> Set<String> hkeys(final String type, final K key, final int seconds) throws Exception {
-        return hkeys(type, key, seconds, true);
-    }
-
-    //设置redis map一个键值 下的子key下的值
-    public <K, T> void hset(final String type, final K key, final String field, final T value, int seconds,
-                            boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        String strValue = gson.toJson(value);
-        redisUtil.hset(fullKey, field, strValue, seconds);
-    }
-
-    public <K, T> void hset(final String type, final K key, final String field, final T value, int seconds) throws Exception {
-        hset(type, key, field, value, seconds, true);
-    }
-
-    //转换map对象类型
-    private <T> Map<String, T> converClassMap(final Map<String, String> mapValues, final Class<T> valueClazz) {
-        Map<String, T> map = new HashMap<>();
-        for (Map.Entry<String, String> entry : mapValues.entrySet()) {
-            T value = gson.fromJson(entry.getValue(), valueClazz);
-            map.put(entry.getKey(), value);
-        }
-        return map;
-    }
-
-    //取redis map全部数据的直接方法
-    public <T> Map<String, T> hgetAll(final String type, final String key,
-                                      final Class<T> valueClazz, int seconds,
-                                      boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        Map<String, String> mapValues = redisUtil.hgetAll(fullKey);
-        return converClassMap(mapValues, valueClazz);
-    }
-
-    public <T> Map<String, T> hgetAll(final String type, final String key,
-                                      final Class<T> valueClazz, int seconds) throws Exception {
-        return hgetAll(type, key, valueClazz, seconds, true);
-    }
-
-    //获取redis map下一个key的值的直接方法
-    public <K, SK, T> T hmget(final String type, final K key, final SK field, final Class<T> clazz, int seconds,
-                              boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        String strField = String.valueOf(field);
-        List<String> listStrs = redisUtil.hmget(fullKey, strField);
-        if (listStrs == null || listStrs.size() <= 0) {
-            return null;
-        }
-        return gson.fromJson(listStrs.get(0), clazz);
-    }
-
-    public <K, SK, T> T hmget(final String type, final K key, final SK field, final Class<T> clazz, int seconds) throws Exception {
-        return hmget(type, key, field, clazz, seconds, true);
-    }
-
-    //删除子key
-    public <K, SK> void hdel(final String type, final K key, final SK field, boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        String strField = String.valueOf(field);
-        redisUtil.hdel(fullKey, strField);
-    }
-
-    public void hdel(final String type, final String key, final String field) throws Exception {
-        hdel(type, key, field, true);
-    }
-
-    /***************************************以下是list操作***************************************/
-    //添加list数据
-    public <K, T> long lpush(final String type, final K key, final int seconds, boolean withServerId,
-                             final T... strings) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        String[] strValues = new String[strings.length];
-        for (int i = 0; i < strings.length; i++) {
-            strValues[i] = gson.toJson(strings[i]);
-        }
-        return redisUtil.lpush(fullKey, seconds, strValues);
-    }
-
-    public <K, T> long lpush(final String type, final K key, final int seconds, final T... strings) throws Exception {
-        return lpush(type, key, seconds, true, strings);
-    }
-
-
-    //从左面保留
-    public <K, T> void ltrimLeft(final String type, final K key, final int start, final int end) throws Exception {
-        String fullKey = getKey(type, key, true);
-        redisUtil.ltrim(fullKey, start, end);
-    }
-
-    //移除最早的元素
-    public <K, T> T rpop(final String type, final K key, final Class<T> clazz, boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        String strValue = redisUtil.rpop(fullKey);
-        return gson.fromJson(strValue, clazz);
-    }
-
-    public <K, T> T rpop(final String type, final K key, final Class<T> clazz) throws Exception {
-        return rpop(type, key, clazz);
-    }
-
-    //添加一个新的元素,如果list超过了count,则删除最早的
-    public <K, T> long lpushRpop(final String type, final String key,
-                                 final T value, final int count, final int seconds, boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        long len = redisUtil.llen(fullKey);
-        if (count > 0 && len >= count) {
-            for (int i = 0; i < len - count + 1; i++) {
-                redisUtil.rpop(fullKey);
-            }
-        }
-        String strValue = gson.toJson(value);
-        return redisUtil.lpush(fullKey, seconds, strValue);
-    }
-
-    public <K, T> long lpushRpop(final String type, final String key, final T value,
-                                 final int count, final int seconds) throws Exception {
-        return lpushRpop(type, key, value, count, seconds, true);
-    }
-
-    private <T> List<T> converClassList(final List<String> listValues, final Class<T> clazz) {
-        List<T> list = new ArrayList<>();
-        for (String strValue : listValues) {
-            T value = gson.fromJson(strValue, clazz);
-            list.add(value);
-        }
-
-        return list;
-    }
-
-    //从头开始,向未取数据
-    public <K, T> List<T> lrange(final String type, final K key, final Class<T> clazz,
-                                 final long start, final long end,
-                                 final int seconds, boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        List<String> listValues = redisUtil.lrange(fullKey, start, end);
-        return converClassList(listValues, clazz);
-    }
-
-    public <K, T> List<T> lrange(final String type, final K key, final Class<T> clazz,
-                                 final long start, final long end, final int seconds) throws Exception {
-        return lrange(type, key, clazz, start, end, seconds, true);
-    }
-
-    //取得list的全部数据
-    public <K, T> List<T> lgetAll(final String type, final K key, final Class<T> clazz, final int seconds,
-                                  boolean withServerId) throws Exception {
-        return lrange(type, key, clazz, 0, -1, seconds, withServerId);
-    }
-
-    public <K, T> List<T> lgetAll(final String type, final K key, final Class<T> clazz, final int seconds) throws Exception {
-        return lgetAll(type, key, clazz, seconds, true);
-    }
-
-    //自增
-    public Long incr(final String type, final String key, final boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        return redisUtil.incr(fullKey);
-    }
-
-    public Long incr(final String type, final String key) throws Exception {
-        return incr(type, key, true);
-    }
-
-    //redis分布式锁,加锁
-    public boolean tryGetDistributedLock(final String type, final String key, final String requestId,
-                                         final int expireTime, final boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        return redisUtil.tryGetDistributedLock(fullKey, requestId, expireTime);
-    }
-
-    public boolean tryGetDistributedLock(final String type, final String key, final String requestId,
-                                         final int expireTime) throws Exception {
-//        String fullKey = getKey(type, key, true);
-        return tryGetDistributedLock(type, key, requestId, expireTime, true);
-    }
-
-    //redis分布式锁,解锁
-    public boolean releaseDistributedLock(final String type, final String key, final String requestId,
-                                          final boolean withServerId) throws Exception {
-        String fullKey = getKey(type, key, withServerId);
-        return redisUtil.releaseDistributedLock(fullKey, requestId);
-    }
-
-    public boolean releaseDistributedLock(final String type, final String key, final String requestId) throws Exception {
-        return releaseDistributedLock(type, key, requestId, true);
-    }
-}
+package com.ljsd.redis;
+
+import com.google.gson.Gson;
+
+import java.util.*;
+
+public class RedisApp {
+    private final static String Delimiter_colon = ":";
+    private RedisUtil redisUtil = new RedisUtil();
+    private Gson gson = new Gson();
+    private String areaId = "0";
+
+    public RedisApp() {
+        redisUtil.init();
+    }
+
+    private <K, T> String getKey(String type, K key, boolean withServerId) {
+        if (withServerId) {
+            return areaId + Delimiter_colon + type + Delimiter_colon + String.valueOf(key);
+        } else {
+            return type + Delimiter_colon + String.valueOf(key);
+        }
+    }
+
+    /***************************************普通键值对操作***************************************/
+    //设置键值
+    public <K, T> void set(final String type, final K key, T value, final int seconds, boolean withServerId) throws Exception {
+        String strValue = gson.toJson(value);
+        String fullKey = getKey(type, key, withServerId);
+        if (seconds <= 0) {
+            redisUtil.set(fullKey, strValue);
+        } else {
+            redisUtil.setex(fullKey, seconds, strValue);
+        }
+    }
+
+    public <T> void set(final String type, final String key, T value, final int seconds) throws Exception {
+        set(type, key, value, seconds, true);
+    }
+
+    //取得键值
+    public <K, T> T get(final String type, final K key, final Class<T> clazz, final int seconds,
+                        boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        String strValue = redisUtil.get(fullKey);
+        if (strValue == null) {
+            return null;
+        }
+        return gson.fromJson(strValue,clazz);
+    }
+
+    public <K, T> T get(final String type, final K key, final Class<T> clazz, final int seconds) throws Exception {
+        return get(type, key, clazz, seconds, false);
+    }
+
+    //取得键值
+    public <K, T> void del(final String type, final K key, final boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        redisUtil.del(fullKey);
+    }
+
+    public <K, T> void del(final String type, final K key) throws Exception {
+        del(type, key, true);
+    }
+
+    public <K> boolean exists(final String type, final K key, final boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        return redisUtil.exists(fullKey);
+    }
+
+    public <K> boolean exists(final String type, final K key) throws Exception {
+        return exists(type, key, true);
+    }
+
+    //设置过期时间
+    public <K, T> void expire(final String type, final K key, final int seconds, boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        redisUtil.expire(fullKey, seconds);
+    }
+
+    public void expire(final String type, final String key, final int seconds) throws Exception {
+        expire(type, key, seconds, true);
+    }
+
+    /***************************************以下是map操作***************************************/
+    //转换map对象类型
+    private <K, T> Map<String, String> converStringMap(Map<K, T> mapValues) {
+        Map<String, String> map = new HashMap<String, String>();
+        for (Map.Entry<K, T> entry : mapValues.entrySet()) {
+            String strKey = String.valueOf(entry.getKey());
+            String strValue = gson.toJson(entry.getValue());
+            map.put(strKey, strValue);
+        }
+        return map;
+    }
+
+    //设置map的
+    public <K, T> void hmset(final String type, final K key, final Map<K, T> hash, int seconds,
+                             boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        Map<String, String> strHash = converStringMap(hash);
+        redisUtil.hmset(fullKey, strHash, seconds);
+    }
+
+    public <K, T> void hmset(final String type, final K key, final Map<K, T> hash, final int seconds) throws Exception {
+        hmset(type, key, hash, seconds, true);
+    }
+
+    //取得map下的子key
+    public <K> Set<String> hkeys(final String type, final K key, final int seconds, boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        return redisUtil.hkeys(fullKey);
+    }
+
+    public <K> Set<String> hkeys(final String type, final K key, final int seconds) throws Exception {
+        return hkeys(type, key, seconds, true);
+    }
+
+    //设置redis map一个键值 下的子key下的值
+    public <K, T> void hset(final String type, final K key, final String field, final T value, int seconds,
+                            boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        String strValue = gson.toJson(value);
+        redisUtil.hset(fullKey, field, strValue, seconds);
+    }
+
+    public <K, T> void hset(final String type, final K key, final String field, final T value, int seconds) throws Exception {
+        hset(type, key, field, value, seconds, true);
+    }
+
+    //转换map对象类型
+    private <T> Map<String, T> converClassMap(final Map<String, String> mapValues, final Class<T> valueClazz) {
+        Map<String, T> map = new HashMap<>();
+        for (Map.Entry<String, String> entry : mapValues.entrySet()) {
+            T value = gson.fromJson(entry.getValue(), valueClazz);
+            map.put(entry.getKey(), value);
+        }
+        return map;
+    }
+
+    //取redis map全部数据的直接方法
+    public <T> Map<String, T> hgetAll(final String type, final String key,
+                                      final Class<T> valueClazz, int seconds,
+                                      boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        Map<String, String> mapValues = redisUtil.hgetAll(fullKey);
+        return converClassMap(mapValues, valueClazz);
+    }
+
+    public <T> Map<String, T> hgetAll(final String type, final String key,
+                                      final Class<T> valueClazz, int seconds) throws Exception {
+        return hgetAll(type, key, valueClazz, seconds, true);
+    }
+
+    //获取redis map下一个key的值的直接方法
+    public <K, SK, T> T hmget(final String type, final K key, final SK field, final Class<T> clazz, int seconds,
+                              boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        String strField = String.valueOf(field);
+        List<String> listStrs = redisUtil.hmget(fullKey, strField);
+        if (listStrs == null || listStrs.size() <= 0) {
+            return null;
+        }
+        return gson.fromJson(listStrs.get(0), clazz);
+    }
+
+    public <K, SK, T> T hmget(final String type, final K key, final SK field, final Class<T> clazz, int seconds) throws Exception {
+        return hmget(type, key, field, clazz, seconds, true);
+    }
+
+    //删除子key
+    public <K, SK> void hdel(final String type, final K key, final SK field, boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        String strField = String.valueOf(field);
+        redisUtil.hdel(fullKey, strField);
+    }
+
+    public void hdel(final String type, final String key, final String field) throws Exception {
+        hdel(type, key, field, true);
+    }
+
+    /***************************************以下是list操作***************************************/
+    //添加list数据
+    public <K, T> long lpush(final String type, final K key, final int seconds, boolean withServerId,
+                             final T... strings) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        String[] strValues = new String[strings.length];
+        for (int i = 0; i < strings.length; i++) {
+            strValues[i] = gson.toJson(strings[i]);
+        }
+        return redisUtil.lpush(fullKey, seconds, strValues);
+    }
+
+    public <K, T> long lpush(final String type, final K key, final int seconds, final T... strings) throws Exception {
+        return lpush(type, key, seconds, true, strings);
+    }
+
+
+    //从左面保留
+    public <K, T> void ltrimLeft(final String type, final K key, final int start, final int end) throws Exception {
+        String fullKey = getKey(type, key, true);
+        redisUtil.ltrim(fullKey, start, end);
+    }
+
+    //移除最早的元素
+    public <K, T> T rpop(final String type, final K key, final Class<T> clazz, boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        String strValue = redisUtil.rpop(fullKey);
+        return gson.fromJson(strValue, clazz);
+    }
+
+    public <K, T> T rpop(final String type, final K key, final Class<T> clazz) throws Exception {
+        return rpop(type, key, clazz);
+    }
+
+    //添加一个新的元素,如果list超过了count,则删除最早的
+    public <K, T> long lpushRpop(final String type, final String key,
+                                 final T value, final int count, final int seconds, boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        long len = redisUtil.llen(fullKey);
+        if (count > 0 && len >= count) {
+            for (int i = 0; i < len - count + 1; i++) {
+                redisUtil.rpop(fullKey);
+            }
+        }
+        String strValue = gson.toJson(value);
+        return redisUtil.lpush(fullKey, seconds, strValue);
+    }
+
+    public <K, T> long lpushRpop(final String type, final String key, final T value,
+                                 final int count, final int seconds) throws Exception {
+        return lpushRpop(type, key, value, count, seconds, true);
+    }
+
+    private <T> List<T> converClassList(final List<String> listValues, final Class<T> clazz) {
+        List<T> list = new ArrayList<>();
+        for (String strValue : listValues) {
+            T value = gson.fromJson(strValue, clazz);
+            list.add(value);
+        }
+
+        return list;
+    }
+
+    //从头开始,向未取数据
+    public <K, T> List<T> lrange(final String type, final K key, final Class<T> clazz,
+                                 final long start, final long end,
+                                 final int seconds, boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        List<String> listValues = redisUtil.lrange(fullKey, start, end);
+        return converClassList(listValues, clazz);
+    }
+
+    public <K, T> List<T> lrange(final String type, final K key, final Class<T> clazz,
+                                 final long start, final long end, final int seconds) throws Exception {
+        return lrange(type, key, clazz, start, end, seconds, true);
+    }
+
+    //取得list的全部数据
+    public <K, T> List<T> lgetAll(final String type, final K key, final Class<T> clazz, final int seconds,
+                                  boolean withServerId) throws Exception {
+        return lrange(type, key, clazz, 0, -1, seconds, withServerId);
+    }
+
+    public <K, T> List<T> lgetAll(final String type, final K key, final Class<T> clazz, final int seconds) throws Exception {
+        return lgetAll(type, key, clazz, seconds, true);
+    }
+
+    //自增
+    public Long incr(final String type, final String key, final boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        return redisUtil.incr(fullKey);
+    }
+
+    public Long incr(final String type, final String key) throws Exception {
+        return incr(type, key, true);
+    }
+
+    //redis分布式锁,加锁
+    public boolean tryGetDistributedLock(final String type, final String key, final String requestId,
+                                         final int expireTime, final boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        return redisUtil.tryGetDistributedLock(fullKey, requestId, expireTime);
+    }
+
+    public boolean tryGetDistributedLock(final String type, final String key, final String requestId,
+                                         final int expireTime) throws Exception {
+//        String fullKey = getKey(type, key, true);
+        return tryGetDistributedLock(type, key, requestId, expireTime, true);
+    }
+
+    //redis分布式锁,解锁
+    public boolean releaseDistributedLock(final String type, final String key, final String requestId,
+                                          final boolean withServerId) throws Exception {
+        String fullKey = getKey(type, key, withServerId);
+        return redisUtil.releaseDistributedLock(fullKey, requestId);
+    }
+
+    public boolean releaseDistributedLock(final String type, final String key, final String requestId) throws Exception {
+        return releaseDistributedLock(type, key, requestId, true);
+    }
+}

+ 18 - 18
src/main/java/com/ljsd/redis/RedisKey.java

@@ -1,18 +1,18 @@
-package com.ljsd.redis;
-
-public interface RedisKey {
-    String TOKEN = "JL_TOKEN";
-    String PIDGIDTEMP = "PIDGIDTEMP";
-    String LOGIN_TOKEN = "JL_LOGIN_TOKEN";
-
-    /**
-     * 最近登录服务器列表
-     */
-    String USER_SERVER_INFO = "JL_USER_SERVER_INFO";
-
-    /**
-     * 公告列表
-     */
-    String NOTICE = "NOTICE";
-    String GLOBAL_SYS_PRO= "GLOBAL_SYS_PRO";
-}
+package com.ljsd.redis;
+
+public interface RedisKey {
+    String TOKEN = "JL_TOKEN";
+    String PIDGIDTEMP = "PIDGIDTEMP";
+    String LOGIN_TOKEN = "JL_LOGIN_TOKEN";
+
+    /**
+     * 最近登录服务器列表
+     */
+    String USER_SERVER_INFO = "JL_USER_SERVER_INFO";
+
+    /**
+     * 公告列表
+     */
+    String NOTICE = "NOTICE";
+    String GLOBAL_SYS_PRO= "GLOBAL_SYS_PRO";
+}

+ 423 - 423
src/main/java/com/ljsd/redis/RedisUtil.java

@@ -1,423 +1,423 @@
-package com.ljsd.redis;
-
-import com.ljsd.util.BaseGlobal;
-import com.ljsd.util.TimeUtil;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import redis.clients.jedis.Jedis;
-import redis.clients.jedis.JedisPool;
-import redis.clients.jedis.JedisPoolConfig;
-
-import java.util.*;
-
-public class RedisUtil {
-    private static final Logger LOGGER = LoggerFactory.getLogger(RedisUtil.class);
-
-    private static int MAX_TRY_TIMES = 3;       //最大尝试次数,保障获取/存储成功
-    private static int FAILED_SLEEP = 2;       //每次失败最大停顿时间
-
-    private JedisPool jedisPool;//非切片连接池
-
-    protected void init() {
-        // 池基本配置
-        JedisPoolConfig config = new JedisPoolConfig();
-        Properties properties = BaseGlobal.getInstance().properties;
-        config.setMaxTotal(Integer.parseInt(properties.getProperty("redis_maxTotal")));
-        config.setMinIdle(Integer.parseInt(properties.getProperty("redis_minIdle")));
-        config.setMaxWaitMillis(Integer.parseInt(properties.getProperty("redis_maxWaitMillis")));
-        config.setMaxIdle(Integer.parseInt(properties.getProperty("redis_maxIdle")));
-        config.setTestOnBorrow(Boolean.parseBoolean(properties.getProperty("redis_testOnBorrow")));
-        if (properties.getProperty("redis_password") ==null || properties.getProperty("redis_password").isEmpty()){
-            jedisPool = new JedisPool(config, properties.getProperty("redis_host"), Integer.parseInt(properties.getProperty("redis_port")),0);
-        }else{
-            jedisPool = new JedisPool(config, properties.getProperty("redis_host"), Integer.parseInt(properties.getProperty("redis_port")),0,properties.getProperty("redis_password"));
-        }
-    }
-
-    /***************************************普通键值对操作***************************************/
-    //设置键值
-    protected void set(final String key, String value) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                jedis.set(key, value);
-                return;
-            } catch (Exception e) {
-                LOGGER.error("set->i={}: key={}, value={}", i, key, value, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::set exception");
-    }
-
-    //设置键值,带过期时间
-    protected void setex(final String key, final int seconds, final String value) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                jedis.setex(key, seconds, value);
-                return;
-            } catch (Exception e) {
-                LOGGER.error("setex->i={},key={},value={},seconds={}", i, key, value, seconds, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::setex exception");
-    }
-
-    //取得键的值
-    protected String get(final String key) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                return jedis.get(key);
-            } catch (Exception e) {
-                LOGGER.error("get->i={},key={}", i, key, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::get exception");
-    }
-
-    //删除键值
-    protected void del(String key) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                jedis.del(key);
-                return;
-            } catch (Exception e) {
-                LOGGER.error("del->i={},key={}", i, key, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::del exception");
-    }
-
-    //删除键值
-    protected boolean exists(String key) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                return jedis.exists(key);
-            } catch (Exception e) {
-                LOGGER.error("exists->i={},key={}", i, key, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::exists exception");
-    }
-
-    //设置过期时间
-    protected Long expire(final String key, final int seconds) throws Exception {
-        if (seconds <= 0) {
-            return 0L;
-        }
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                return jedis.expire(key, seconds);
-            } catch (Exception e) {
-                LOGGER.error("expire->i={},key={},seconds={}", i, key, seconds, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::del exception");
-    }
-
-    /***************************************以下是map操作***************************************/
-    //添加redis map
-    protected void hmset(final String key, final Map<String, String> hash, int seconds) throws Exception {
-        int i;
-        for (i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                jedis.hmset(key, hash);
-                break;
-            } catch (Exception e) {
-                LOGGER.error("hmset->i={},key={}", i, key, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        expire(key, seconds);
-        if (i >= MAX_TRY_TIMES) {
-            throw new Exception("RedisUtil::hmset exception");
-        }
-    }
-
-    //取得主key下的所有子key
-    protected Set<String> hkeys(final String key) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                Set<String> keySet = jedis.hkeys(key);
-                return keySet;
-            } catch (Exception e) {
-                LOGGER.error("hkeys->i={},key={}", i, key, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::hkeys exception");
-    }
-
-    //设置redis map一个键值 下的子key下的值
-    protected void hset(final String key, final String field, final String value, int seconds) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                jedis.hset(key, field, value);
-                return;
-            } catch (Exception e) {
-                LOGGER.error("hset->i={},key={},field={},value={}", i, key, field, value, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        expire(key, seconds);
-        throw new Exception("RedisUtil::hset exception");
-    }
-
-    //取redis map全部数据的直接方法
-    protected Map<String, String> hgetAll(final String key) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                return jedis.hgetAll(key);
-            } catch (Exception e) {
-                LOGGER.error("hgetAll->i={},key={}", i, key, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::hgetAll exception");
-    }
-
-    //获取redis map下一个key的值的直接方法
-    protected List<String> hmget(final String key, final String... fields) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                return jedis.hmget(key, fields);
-            } catch (Exception e) {
-                LOGGER.error("hmget->i={},key={}", i, key, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::hmget exception");
-    }
-
-    //删除子key
-    protected void hdel(final String key, final String... fields) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                jedis.hdel(key, fields);
-                return;
-            } catch (Exception e) {
-                LOGGER.error("hdel->i={},key={},fields={}", i, key, fields, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::hdel exception");
-    }
-
-    /***************************************以下是list操作***************************************/
-    //添加list数据
-    protected long lpush(final String key, final int seconds, final String... strings) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                return jedis.lpush(key, strings);
-            } catch (Exception e) {
-                LOGGER.error("lpush->i={},key={},value={}", i, key, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        expire(key, seconds);
-        throw new Exception("RedisUtil::lpush exception");
-    }
-
-    protected void ltrim(final String key, final int start, final int end) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                jedis.ltrim(key, start, end);
-                return;
-            } catch (Exception e) {
-                LOGGER.error("lpush->i={},key={},value={}", i, key, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::ltrim exception");
-    }
-
-
-    //删除元素
-    protected void lrem(final String key, final long count, final String value) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                jedis.lrem(key, count, value);
-                return;
-            } catch (Exception e) {
-                LOGGER.error("lrem->i={},key={},count={},value={}", i, key, count, value, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::lrem exception");
-    }
-
-    //移除最好的元素
-    protected String rpop(final String key) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                return jedis.rpop(key);
-            } catch (Exception e) {
-                LOGGER.error("rpop->i={},key={}", i, key, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::rpop exception");
-    }
-
-    //取得指定范围的元素
-    protected List<String> lrange(final String key, final long start, final long end) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                return jedis.lrange(key, start, end);
-            } catch (Exception e) {
-                LOGGER.error("lrange->i={},key={},start={},end={}", i, key, start, end, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::lrange exception");
-    }
-
-    //取得list的长度
-    protected Long llen(final String key) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                return jedis.llen(key);
-            } catch (Exception e) {
-                LOGGER.error("llen->i={},key={}", i, key, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::llen exception");
-    }
-
-    //自增
-    protected Long incr(final String key) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                return jedis.incr(key);
-            } catch (Exception e) {
-                LOGGER.error("incr->i={},key={}", i, key, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::incr exception");
-    }
-
-    private static final String LOCK_SUCCESS = "OK";
-    private static final String SET_IF_NOT_EXIST = "NX";
-    private static final String SET_WITH_EXPIRE_TIME = "PX";
-
-    /**
-     * 尝试获取分布式锁
-     *
-     * @param lockKey    锁
-     * @param requestId  请求标识
-     * @param expireTime 超期时间,理论上应该比较短,一次请求在500毫秒内即可完成,因此过期时间不应大于1秒
-     * @return 是否获取成功
-     */
-    protected boolean tryGetDistributedLock(String lockKey, String requestId, int expireTime) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                String result = jedis.set(lockKey, requestId, SET_IF_NOT_EXIST, SET_WITH_EXPIRE_TIME, expireTime);
-                if (LOCK_SUCCESS.equals(result)) {
-                    return true;
-                }
-                LOGGER.error("tryGetDistributedLock->i={},key={};failed", i, lockKey);
-                TimeUtil.sleep(200);       //理论上锁冲突的几率很小,如果连续三次加锁失败,直接抛出异常
-            } catch (Exception e) {
-                LOGGER.error("tryGetDistributedLock->i={},key={}", i, lockKey, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::tryGetDistributedLock exception");
-    }
-
-    private static final Long RELEASE_SUCCESS = 1L;
-
-    /**
-     * 释放分布式锁
-     *
-     * @param lockKey   锁
-     * @param requestId 请求标识
-     * @return 是否释放成功
-     */
-    protected boolean releaseDistributedLock(String lockKey, String requestId) throws Exception {
-        for (int i = 0; i < MAX_TRY_TIMES; i++) {
-            Jedis jedis = jedisPool.getResource();
-            try {
-                String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end";
-                Object result = jedis.eval(script, Collections.singletonList(lockKey), Collections.singletonList(requestId));
-
-                if (RELEASE_SUCCESS.equals(result)) {
-                    return true;
-                }
-                return false;       //解锁失败,等待过期自动解锁即可
-            } catch (Exception e) {
-                LOGGER.error("releaseDistributedLock->i={},key={}", i, lockKey, e);
-                TimeUtil.sleep(FAILED_SLEEP);
-            } finally {
-                jedis.close();
-            }
-        }
-        throw new Exception("RedisUtil::releaseDistributedLock exception");
-    }
-}
+package com.ljsd.redis;
+
+import com.ljsd.util.BaseGlobal;
+import com.ljsd.util.TimeUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.JedisPool;
+import redis.clients.jedis.JedisPoolConfig;
+
+import java.util.*;
+
+public class RedisUtil {
+    private static final Logger LOGGER = LoggerFactory.getLogger(RedisUtil.class);
+
+    private static int MAX_TRY_TIMES = 3;       //最大尝试次数,保障获取/存储成功
+    private static int FAILED_SLEEP = 2;       //每次失败最大停顿时间
+
+    private JedisPool jedisPool;//非切片连接池
+
+    protected void init() {
+        // 池基本配置
+        JedisPoolConfig config = new JedisPoolConfig();
+        Properties properties = BaseGlobal.getInstance().properties;
+        config.setMaxTotal(Integer.parseInt(properties.getProperty("redis_maxTotal")));
+        config.setMinIdle(Integer.parseInt(properties.getProperty("redis_minIdle")));
+        config.setMaxWaitMillis(Integer.parseInt(properties.getProperty("redis_maxWaitMillis")));
+        config.setMaxIdle(Integer.parseInt(properties.getProperty("redis_maxIdle")));
+        config.setTestOnBorrow(Boolean.parseBoolean(properties.getProperty("redis_testOnBorrow")));
+        if (properties.getProperty("redis_password") ==null || properties.getProperty("redis_password").isEmpty()){
+            jedisPool = new JedisPool(config, properties.getProperty("redis_host"), Integer.parseInt(properties.getProperty("redis_port")),0);
+        }else{
+            jedisPool = new JedisPool(config, properties.getProperty("redis_host"), Integer.parseInt(properties.getProperty("redis_port")),0,properties.getProperty("redis_password"));
+        }
+    }
+
+    /***************************************普通键值对操作***************************************/
+    //设置键值
+    protected void set(final String key, String value) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                jedis.set(key, value);
+                return;
+            } catch (Exception e) {
+                LOGGER.error("set->i={}: key={}, value={}", i, key, value, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::set exception");
+    }
+
+    //设置键值,带过期时间
+    protected void setex(final String key, final int seconds, final String value) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                jedis.setex(key, seconds, value);
+                return;
+            } catch (Exception e) {
+                LOGGER.error("setex->i={},key={},value={},seconds={}", i, key, value, seconds, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::setex exception");
+    }
+
+    //取得键的值
+    protected String get(final String key) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                return jedis.get(key);
+            } catch (Exception e) {
+                LOGGER.error("get->i={},key={}", i, key, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::get exception");
+    }
+
+    //删除键值
+    protected void del(String key) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                jedis.del(key);
+                return;
+            } catch (Exception e) {
+                LOGGER.error("del->i={},key={}", i, key, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::del exception");
+    }
+
+    //删除键值
+    protected boolean exists(String key) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                return jedis.exists(key);
+            } catch (Exception e) {
+                LOGGER.error("exists->i={},key={}", i, key, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::exists exception");
+    }
+
+    //设置过期时间
+    protected Long expire(final String key, final int seconds) throws Exception {
+        if (seconds <= 0) {
+            return 0L;
+        }
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                return jedis.expire(key, seconds);
+            } catch (Exception e) {
+                LOGGER.error("expire->i={},key={},seconds={}", i, key, seconds, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::del exception");
+    }
+
+    /***************************************以下是map操作***************************************/
+    //添加redis map
+    protected void hmset(final String key, final Map<String, String> hash, int seconds) throws Exception {
+        int i;
+        for (i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                jedis.hmset(key, hash);
+                break;
+            } catch (Exception e) {
+                LOGGER.error("hmset->i={},key={}", i, key, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        expire(key, seconds);
+        if (i >= MAX_TRY_TIMES) {
+            throw new Exception("RedisUtil::hmset exception");
+        }
+    }
+
+    //取得主key下的所有子key
+    protected Set<String> hkeys(final String key) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                Set<String> keySet = jedis.hkeys(key);
+                return keySet;
+            } catch (Exception e) {
+                LOGGER.error("hkeys->i={},key={}", i, key, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::hkeys exception");
+    }
+
+    //设置redis map一个键值 下的子key下的值
+    protected void hset(final String key, final String field, final String value, int seconds) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                jedis.hset(key, field, value);
+                return;
+            } catch (Exception e) {
+                LOGGER.error("hset->i={},key={},field={},value={}", i, key, field, value, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        expire(key, seconds);
+        throw new Exception("RedisUtil::hset exception");
+    }
+
+    //取redis map全部数据的直接方法
+    protected Map<String, String> hgetAll(final String key) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                return jedis.hgetAll(key);
+            } catch (Exception e) {
+                LOGGER.error("hgetAll->i={},key={}", i, key, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::hgetAll exception");
+    }
+
+    //获取redis map下一个key的值的直接方法
+    protected List<String> hmget(final String key, final String... fields) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                return jedis.hmget(key, fields);
+            } catch (Exception e) {
+                LOGGER.error("hmget->i={},key={}", i, key, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::hmget exception");
+    }
+
+    //删除子key
+    protected void hdel(final String key, final String... fields) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                jedis.hdel(key, fields);
+                return;
+            } catch (Exception e) {
+                LOGGER.error("hdel->i={},key={},fields={}", i, key, fields, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::hdel exception");
+    }
+
+    /***************************************以下是list操作***************************************/
+    //添加list数据
+    protected long lpush(final String key, final int seconds, final String... strings) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                return jedis.lpush(key, strings);
+            } catch (Exception e) {
+                LOGGER.error("lpush->i={},key={},value={}", i, key, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        expire(key, seconds);
+        throw new Exception("RedisUtil::lpush exception");
+    }
+
+    protected void ltrim(final String key, final int start, final int end) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                jedis.ltrim(key, start, end);
+                return;
+            } catch (Exception e) {
+                LOGGER.error("lpush->i={},key={},value={}", i, key, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::ltrim exception");
+    }
+
+
+    //删除元素
+    protected void lrem(final String key, final long count, final String value) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                jedis.lrem(key, count, value);
+                return;
+            } catch (Exception e) {
+                LOGGER.error("lrem->i={},key={},count={},value={}", i, key, count, value, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::lrem exception");
+    }
+
+    //移除最好的元素
+    protected String rpop(final String key) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                return jedis.rpop(key);
+            } catch (Exception e) {
+                LOGGER.error("rpop->i={},key={}", i, key, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::rpop exception");
+    }
+
+    //取得指定范围的元素
+    protected List<String> lrange(final String key, final long start, final long end) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                return jedis.lrange(key, start, end);
+            } catch (Exception e) {
+                LOGGER.error("lrange->i={},key={},start={},end={}", i, key, start, end, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::lrange exception");
+    }
+
+    //取得list的长度
+    protected Long llen(final String key) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                return jedis.llen(key);
+            } catch (Exception e) {
+                LOGGER.error("llen->i={},key={}", i, key, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::llen exception");
+    }
+
+    //自增
+    protected Long incr(final String key) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                return jedis.incr(key);
+            } catch (Exception e) {
+                LOGGER.error("incr->i={},key={}", i, key, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::incr exception");
+    }
+
+    private static final String LOCK_SUCCESS = "OK";
+    private static final String SET_IF_NOT_EXIST = "NX";
+    private static final String SET_WITH_EXPIRE_TIME = "PX";
+
+    /**
+     * 尝试获取分布式锁
+     *
+     * @param lockKey    锁
+     * @param requestId  请求标识
+     * @param expireTime 超期时间,理论上应该比较短,一次请求在500毫秒内即可完成,因此过期时间不应大于1秒
+     * @return 是否获取成功
+     */
+    protected boolean tryGetDistributedLock(String lockKey, String requestId, int expireTime) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                String result = jedis.set(lockKey, requestId, SET_IF_NOT_EXIST, SET_WITH_EXPIRE_TIME, expireTime);
+                if (LOCK_SUCCESS.equals(result)) {
+                    return true;
+                }
+                LOGGER.error("tryGetDistributedLock->i={},key={};failed", i, lockKey);
+                TimeUtil.sleep(200);       //理论上锁冲突的几率很小,如果连续三次加锁失败,直接抛出异常
+            } catch (Exception e) {
+                LOGGER.error("tryGetDistributedLock->i={},key={}", i, lockKey, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::tryGetDistributedLock exception");
+    }
+
+    private static final Long RELEASE_SUCCESS = 1L;
+
+    /**
+     * 释放分布式锁
+     *
+     * @param lockKey   锁
+     * @param requestId 请求标识
+     * @return 是否释放成功
+     */
+    protected boolean releaseDistributedLock(String lockKey, String requestId) throws Exception {
+        for (int i = 0; i < MAX_TRY_TIMES; i++) {
+            Jedis jedis = jedisPool.getResource();
+            try {
+                String script = "if redis.call('get', KEYS[1]) == ARGV[1] then return redis.call('del', KEYS[1]) else return 0 end";
+                Object result = jedis.eval(script, Collections.singletonList(lockKey), Collections.singletonList(requestId));
+
+                if (RELEASE_SUCCESS.equals(result)) {
+                    return true;
+                }
+                return false;       //解锁失败,等待过期自动解锁即可
+            } catch (Exception e) {
+                LOGGER.error("releaseDistributedLock->i={},key={}", i, lockKey, e);
+                TimeUtil.sleep(FAILED_SLEEP);
+            } finally {
+                jedis.close();
+            }
+        }
+        throw new Exception("RedisUtil::releaseDistributedLock exception");
+    }
+}

+ 79 - 79
src/main/java/com/ljsd/util/BaseGlobal.java

@@ -1,79 +1,79 @@
-package com.ljsd.util;
-
-import com.ljsd.controller.GetUserController;
-import com.ljsd.plat.PlatProcess;
-import com.ljsd.redis.RedisApp;
-
-import java.util.*;
-
-public class BaseGlobal {
-    public Properties properties = new Properties();
-    public MyMongoDBPool mongoDBPool;
-    public RedisApp redisApp;
-    private Map<String, PlatProcess> handlers = new HashMap<>();
-
-    private BaseGlobal() {
-    }
-
-    /**
-     * 获取单例
-     *
-     * @return
-     */
-    public static BaseGlobal getInstance() {
-        return Instance.instance;
-    }
-
-    public static class Instance {
-        public final static BaseGlobal instance = new BaseGlobal();
-    }
-
-    public void init() {
-        mongoDBPool = new MyMongoDBPool();
-        redisApp = new RedisApp();
-        initHandler("com.ljsd.plat");
-        GetUserController.initLanState();
-    }
-
-
-    public void initHandler(String pck) {
-        List<Class<?>> handlers = new LinkedList<>();
-        try {
-            try {
-                ClassLoaderHelper.findLocalClass(pck, PlatProcess.class, Thread.currentThread().getContextClassLoader(), handlers);
-            } catch (RuntimeException e) {
-
-            }
-            try {
-                ClassLoaderHelper.findClassJar(pck, PlatProcess.class, Thread.currentThread().getContextClassLoader(), handlers);
-            } catch (RuntimeException e) {
-
-            }
-
-            handlers.forEach(hand ->
-            {
-                PlatProcess baseHandler = null;
-
-                try {
-                    baseHandler = (PlatProcess) hand.newInstance();
-                } catch (Exception ex) {
-                    ex.printStackTrace();
-                }
-                if (null != baseHandler) {
-                    addHandler(baseHandler);
-                }
-            });
-        } catch (RuntimeException e2) {
-        }
-    }
-
-    private void addHandler(PlatProcess handler) {
-        if(null!=handler.getName()){
-            handlers.put(handler.getName(), handler);
-        }
-    }
-
-    public PlatProcess getHandlers(String name) {
-        return handlers.get(name);
-    }
-}
+package com.ljsd.util;
+
+import com.ljsd.controller.GetUserController;
+import com.ljsd.plat.PlatProcess;
+import com.ljsd.redis.RedisApp;
+
+import java.util.*;
+
+public class BaseGlobal {
+    public Properties properties = new Properties();
+    public MyMongoDBPool mongoDBPool;
+    public RedisApp redisApp;
+    private Map<String, PlatProcess> handlers = new HashMap<>();
+
+    private BaseGlobal() {
+    }
+
+    /**
+     * 获取单例
+     *
+     * @return
+     */
+    public static BaseGlobal getInstance() {
+        return Instance.instance;
+    }
+
+    public static class Instance {
+        public final static BaseGlobal instance = new BaseGlobal();
+    }
+
+    public void init() {
+        mongoDBPool = new MyMongoDBPool();
+        redisApp = new RedisApp();
+        initHandler("com.ljsd.plat");
+        GetUserController.initLanState();
+    }
+
+
+    public void initHandler(String pck) {
+        List<Class<?>> handlers = new LinkedList<>();
+        try {
+            try {
+                ClassLoaderHelper.findLocalClass(pck, PlatProcess.class, Thread.currentThread().getContextClassLoader(), handlers);
+            } catch (RuntimeException e) {
+
+            }
+            try {
+                ClassLoaderHelper.findClassJar(pck, PlatProcess.class, Thread.currentThread().getContextClassLoader(), handlers);
+            } catch (RuntimeException e) {
+
+            }
+
+            handlers.forEach(hand ->
+            {
+                PlatProcess baseHandler = null;
+
+                try {
+                    baseHandler = (PlatProcess) hand.newInstance();
+                } catch (Exception ex) {
+                    ex.printStackTrace();
+                }
+                if (null != baseHandler) {
+                    addHandler(baseHandler);
+                }
+            });
+        } catch (RuntimeException e2) {
+        }
+    }
+
+    private void addHandler(PlatProcess handler) {
+        if(null!=handler.getName()){
+            handlers.put(handler.getName(), handler);
+        }
+    }
+
+    public PlatProcess getHandlers(String name) {
+        return handlers.get(name);
+    }
+}

+ 162 - 162
src/main/java/com/ljsd/util/ClassLoaderHelper.java

@@ -1,162 +1,162 @@
-package com.ljsd.util;
-
-import java.io.File;
-import java.io.IOException;
-import java.lang.reflect.Modifier;
-import java.net.JarURLConnection;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.jar.JarEntry;
-import java.util.jar.JarFile;
-
-/**
- * Description:    des
- * Author:         zsx
- * CreateDate:     2019/10/8 17:23
- */
-public class ClassLoaderHelper {
-
-    final static ConcurrentHashMap<String, Class<?>> CLS_CACHE = new ConcurrentHashMap<>();
-
-    public static Class<?> forName(String clsname) throws ClassNotFoundException{
-        Class<?> cls =  CLS_CACHE.get(clsname);
-        if(null == cls){
-            cls = Class.forName(clsname);
-            CLS_CACHE.put(clsname, cls);
-        }
-        return cls;
-    }
-
-    /**
-     * 获取指定接口的某个包下的所有实现类(不包括接口和抽象类)
-     */
-    public static void findLocalClass(String packName, Class<?> classinterface, ClassLoader classLoader, List<Class<?>> classes)
-    {
-        URI url;
-        try
-        {
-            url = classLoader.getResource(packName.replace(".", "/")).toURI();
-        }
-        catch(URISyntaxException e1)
-        {
-            return;
-        }
-        File file = new File(url);
-        file.listFiles((subfile) ->
-        {
-            if(subfile.isDirectory())
-            {
-                findLocalClass(packName + "." + subfile.getName(), classinterface,classLoader,classes);
-            }
-            if(subfile.getName().endsWith(".class"))
-            {
-                Class<?> clazz = null;
-                try
-                {
-                    String classname = packName + "." + subfile.getName().replace(".class", "");
-                    clazz = classLoader.loadClass(classname);
-                }
-                catch(ClassNotFoundException e)
-                {
-                    e.printStackTrace();
-                }
-                if(clazz == null)
-                {
-                    return false;
-                }
-
-                if(ClassLoaderHelper.filter(clazz, classinterface))
-                {
-                    classes.add(clazz);
-                    return true;
-                }
-            }
-            return false;
-        });
-    }
-
-    /**
-     * 过滤接口和抽象类
-     */
-    public static boolean filter(Class<?> clazz, Class<?> filterclass)
-    {
-        if(clazz.isInterface())
-        {
-            return false;
-        }
-        if(Modifier.isAbstract(clazz.getModifiers()))
-        {
-            return false;
-        }
-        return filterclass.isAssignableFrom(clazz);
-    }
-
-
-    /**
-     * jar包查找
-     */
-    public static void findClassJar(final String packName, Class<?> classinterface, ClassLoader classLoader, List<Class<?>> classes)
-    {
-        String pathName = packName.replace(".", "/");
-        JarFile jarFile;
-        try
-        {
-            URL url = classLoader.getResource(pathName);
-            JarURLConnection jarURLConnection = (JarURLConnection)url.openConnection();
-            jarFile = jarURLConnection.getJarFile();
-        }
-        catch(IOException |NullPointerException e)
-        {
-            return;
-        }
-
-        Enumeration<JarEntry> jarEntries = jarFile.entries();
-        while(jarEntries.hasMoreElements())
-        {
-            JarEntry jarEntry = jarEntries.nextElement();
-            String jarEntryName = jarEntry.getName();
-            if(jarEntryName.contains(pathName) && !jarEntryName.equals(pathName + "/"))
-            {
-                if(jarEntry.isDirectory())
-                {
-                    String clazzName = jarEntry.getName().replace("/", ".");
-                    int endIndex = clazzName.lastIndexOf(".");
-                    String prefix = null;
-                    if(endIndex > 0)
-                    {
-                        prefix = clazzName.substring(0, endIndex);
-                    }
-                    findClassJar(prefix, classinterface,classLoader,classes);
-                }
-                if(jarEntry.getName().endsWith(".class"))
-                {
-                    Class<?> clazz = null;
-                    try
-                    {
-                        clazz = classLoader.loadClass(jarEntry.getName().replace("/", ".").replace(".class", ""));
-                    }
-                    catch(ClassNotFoundException e)
-                    {
-                        e.printStackTrace();
-                    }
-                    if(clazz == null)
-                    {
-                        return;
-                    }
-                    if(filter(clazz, classinterface))
-                    {
-                        classes.add(clazz);
-                    }
-                }
-            }
-
-        }
-
-    }
-
-
-}
+package com.ljsd.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.lang.reflect.Modifier;
+import java.net.JarURLConnection;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+
+/**
+ * Description:    des
+ * Author:         zsx
+ * CreateDate:     2019/10/8 17:23
+ */
+public class ClassLoaderHelper {
+
+    final static ConcurrentHashMap<String, Class<?>> CLS_CACHE = new ConcurrentHashMap<>();
+
+    public static Class<?> forName(String clsname) throws ClassNotFoundException{
+        Class<?> cls =  CLS_CACHE.get(clsname);
+        if(null == cls){
+            cls = Class.forName(clsname);
+            CLS_CACHE.put(clsname, cls);
+        }
+        return cls;
+    }
+
+    /**
+     * 获取指定接口的某个包下的所有实现类(不包括接口和抽象类)
+     */
+    public static void findLocalClass(String packName, Class<?> classinterface, ClassLoader classLoader, List<Class<?>> classes)
+    {
+        URI url;
+        try
+        {
+            url = classLoader.getResource(packName.replace(".", "/")).toURI();
+        }
+        catch(URISyntaxException e1)
+        {
+            return;
+        }
+        File file = new File(url);
+        file.listFiles((subfile) ->
+        {
+            if(subfile.isDirectory())
+            {
+                findLocalClass(packName + "." + subfile.getName(), classinterface,classLoader,classes);
+            }
+            if(subfile.getName().endsWith(".class"))
+            {
+                Class<?> clazz = null;
+                try
+                {
+                    String classname = packName + "." + subfile.getName().replace(".class", "");
+                    clazz = classLoader.loadClass(classname);
+                }
+                catch(ClassNotFoundException e)
+                {
+                    e.printStackTrace();
+                }
+                if(clazz == null)
+                {
+                    return false;
+                }
+
+                if(ClassLoaderHelper.filter(clazz, classinterface))
+                {
+                    classes.add(clazz);
+                    return true;
+                }
+            }
+            return false;
+        });
+    }
+
+    /**
+     * 过滤接口和抽象类
+     */
+    public static boolean filter(Class<?> clazz, Class<?> filterclass)
+    {
+        if(clazz.isInterface())
+        {
+            return false;
+        }
+        if(Modifier.isAbstract(clazz.getModifiers()))
+        {
+            return false;
+        }
+        return filterclass.isAssignableFrom(clazz);
+    }
+
+
+    /**
+     * jar包查找
+     */
+    public static void findClassJar(final String packName, Class<?> classinterface, ClassLoader classLoader, List<Class<?>> classes)
+    {
+        String pathName = packName.replace(".", "/");
+        JarFile jarFile;
+        try
+        {
+            URL url = classLoader.getResource(pathName);
+            JarURLConnection jarURLConnection = (JarURLConnection)url.openConnection();
+            jarFile = jarURLConnection.getJarFile();
+        }
+        catch(IOException |NullPointerException e)
+        {
+            return;
+        }
+
+        Enumeration<JarEntry> jarEntries = jarFile.entries();
+        while(jarEntries.hasMoreElements())
+        {
+            JarEntry jarEntry = jarEntries.nextElement();
+            String jarEntryName = jarEntry.getName();
+            if(jarEntryName.contains(pathName) && !jarEntryName.equals(pathName + "/"))
+            {
+                if(jarEntry.isDirectory())
+                {
+                    String clazzName = jarEntry.getName().replace("/", ".");
+                    int endIndex = clazzName.lastIndexOf(".");
+                    String prefix = null;
+                    if(endIndex > 0)
+                    {
+                        prefix = clazzName.substring(0, endIndex);
+                    }
+                    findClassJar(prefix, classinterface,classLoader,classes);
+                }
+                if(jarEntry.getName().endsWith(".class"))
+                {
+                    Class<?> clazz = null;
+                    try
+                    {
+                        clazz = classLoader.loadClass(jarEntry.getName().replace("/", ".").replace(".class", ""));
+                    }
+                    catch(ClassNotFoundException e)
+                    {
+                        e.printStackTrace();
+                    }
+                    if(clazz == null)
+                    {
+                        return;
+                    }
+                    if(filter(clazz, classinterface))
+                    {
+                        classes.add(clazz);
+                    }
+                }
+            }
+
+        }
+
+    }
+
+
+}

+ 52 - 52
src/main/java/com/ljsd/util/EncryptUtils.java

@@ -1,52 +1,52 @@
-package com.ljsd.util;
-
-import sun.security.provider.MD5;
-
-import java.security.MessageDigest;
-
-public class EncryptUtils {
-
-    /**
-     * 将输入的字符串进行MD5加密(编码)
-     *
-     * @param inputString
-     * @return
-     */
-    public static String createMD5String(String inputString) {
-        return encodeByMD5(inputString);
-    }
-
-    /**
-     * 对字符串进行MD5编码
-     *
-     * @param originStr
-     * @return
-     */
-    public static String encodeByMD5(String originStr) {
-        if (originStr != null) {
-            try {
-                // 创建具有指定算法名称的信息摘要
-                MessageDigest md = MessageDigest.getInstance("MD5");
-                // 使用指定的字节数组对摘要进行最后的更新,然后完成摘要计算
-                char[] _charStr = originStr.toCharArray();
-                byte[] _byteStr = new byte[_charStr.length];
-                for (int i = 0; i < _charStr.length; i++) {
-                    _byteStr[i] = (byte)_charStr[i];
-                }
-                byte[] _results = md.digest(_byteStr);
-                StringBuffer _hexValue = new StringBuffer();
-                for (int i = 0; i < _results.length; i++) {
-                    int _val = ((int)_results[i]) & 0xff;
-                    if(_val < 16){
-                        _hexValue.append("0");
-                    }
-                    _hexValue.append(Integer.toHexString(_val));
-                }
-                return _hexValue.toString();
-            } catch (Exception ex) {
-                ex.printStackTrace();
-            }
-        }
-        return null;
-    }
-}
+package com.ljsd.util;
+
+import sun.security.provider.MD5;
+
+import java.security.MessageDigest;
+
+public class EncryptUtils {
+
+    /**
+     * 将输入的字符串进行MD5加密(编码)
+     *
+     * @param inputString
+     * @return
+     */
+    public static String createMD5String(String inputString) {
+        return encodeByMD5(inputString);
+    }
+
+    /**
+     * 对字符串进行MD5编码
+     *
+     * @param originStr
+     * @return
+     */
+    public static String encodeByMD5(String originStr) {
+        if (originStr != null) {
+            try {
+                // 创建具有指定算法名称的信息摘要
+                MessageDigest md = MessageDigest.getInstance("MD5");
+                // 使用指定的字节数组对摘要进行最后的更新,然后完成摘要计算
+                char[] _charStr = originStr.toCharArray();
+                byte[] _byteStr = new byte[_charStr.length];
+                for (int i = 0; i < _charStr.length; i++) {
+                    _byteStr[i] = (byte)_charStr[i];
+                }
+                byte[] _results = md.digest(_byteStr);
+                StringBuffer _hexValue = new StringBuffer();
+                for (int i = 0; i < _results.length; i++) {
+                    int _val = ((int)_results[i]) & 0xff;
+                    if(_val < 16){
+                        _hexValue.append("0");
+                    }
+                    _hexValue.append(Integer.toHexString(_val));
+                }
+                return _hexValue.toString();
+            } catch (Exception ex) {
+                ex.printStackTrace();
+            }
+        }
+        return null;
+    }
+}

+ 325 - 325
src/main/java/com/ljsd/util/ExcelUtils.java

@@ -1,326 +1,326 @@
-package com.ljsd.util;
-
-import jcifs.smb.SmbFile;
-import org.apache.poi.hssf.usermodel.HSSFWorkbook;
-import org.apache.poi.ss.usermodel.*;
-import org.apache.poi.xssf.usermodel.XSSFWorkbook;
-
-import java.io.*;
-import java.util.*;
-
-public class ExcelUtils {
-    private static boolean isWrite = true;
-    private static String excelPath ="smb://60.1.1.12/Public/jieling/conf/data_execl/"; //excel 文件
-    private static String path = "//60.1.1.12/Public/jieling/conf/server/";
-//    private static String path = "D:/tmp/";
-    private static  Set<String> oldFileNames = new HashSet<>();
-
-    public static void main(String[] args) throws IOException {
-        File oldfile = new File(path);
-        String[] list = oldfile.list();
-        oldFileNames.addAll(Arrays.asList(list));
-        readExcelData();
-
-    }
-
-    public static void readExcelData() throws IOException {
-        SmbFile file = new SmbFile(excelPath);
-        if (file.exists()) {
-            SmbFile[] files = file.listFiles();
-            for (SmbFile file1 : files) {
-                if (file1.isDirectory()) {
-                    continue;
-                }
-                String extString = file1.getName().substring(file1.getName().lastIndexOf("."));
-                if (!".xlsx".equals(extString)) {
-                    continue;
-                }
-                String filePath =file1.getUncPath();
-                Workbook wb = readExcel(filePath);
-                if(file1.getName().contains("Map_")){
-                    bulidMapInfo(wb);
-                }else{
-                    buildDataInfo(wb);
-                }
-            }
-        }
-    }
-
-    private static String typeInfo(String fieldInfo){
-        //mut,int#int,2
-        if(fieldInfo.contains("mut")){
-            String[] split = fieldInfo.split("#");
-            String[] typeInfos = split[1].split(",");
-            int nums = Integer.parseInt(typeInfos[1]);
-            StringBuffer sb = new StringBuffer();
-            if("string".equals(typeInfos[0])){
-               sb.append("String");
-            }else{
-                sb.append(typeInfos[0]);
-            }
-
-
-            for(int i=0;i<nums;i++){
-                sb.append("[]");
-            }
-            return sb.toString();
-        }
-        if("string".equals(fieldInfo)){
-            return "String";
-        }
-        return fieldInfo;
-    }
-
-    private static void buildDataInfo(Workbook wb) throws IOException {
-        Sheet sheet;
-        Row row;
-        Object cellData;
-        sheet = wb.getSheetAt(0);
-        String sheetName = sheet.getSheetName();
-        System.out.println("bulidMapInfo => collection name="+sheetName);
-        int rownum = sheet.getLastRowNum();
-        FileWriter fw = new FileWriter(path + sheetName + ".txt");
-        PrintWriter out = new PrintWriter(fw);
-        for (int i = 0; i <= rownum; i++) {
-            if (i == 2 || i == 3 || i == 4 ||i == 5||i == 6){
-                continue;
-            }
-            Row row1 = sheet.getRow(2);
-            Row row2 = sheet.getRow(1);
-            Row row4 = sheet.getRow(4);
-            row = sheet.getRow(i);
-//            for (Cell c :row){
-//                System.out.println(c.getColumnIndex() +"==="+row.getCell(c.getColumnIndex()));
-//            }
-            if (row != null) {
-                StringBuilder info = new StringBuilder();
-                int colnum = row1.getLastCellNum();
-                for (int j = 1; j < colnum; j++) {
-                    int cellFormatValue = (int) getCellFormatValue(row1.getCell(j),null);
-                    if (cellFormatValue == 3){
-                        continue;
-                    }
-                    Cell cell = row.getCell(j);
-                    if (cell == null){
-                        Cell cell1 = row4.getCell(j);
-                        info = getStringBuilder(row2, info, j, cell1);
-                    }else{
-                        if (getCellFormatValue(row1.getCell(j),null).toString().isEmpty()){
-                            continue;
-                        }
-                        //文件名
-                        cellData = getCellFormatValue(cell,row2.getCell(j));
-                        if ("".equals(cellData.toString())){
-                            cellData = getIn(row2.getCell(j).toString());
-                        }
-                        if (info.length() == 0){
-                            info = info.append(cellData);
-                        }else{
-                            info.append("\t").append(cellData);
-                        }
-                    }
-                }
-                out.write(info.toString());
-                out.write("\r\n");
-            }
-        }
-        fw.close();
-        out.close();
-    }
-
-    private static StringBuilder getStringBuilder(Row row2, StringBuilder info, int j, Cell cell1) {
-        Object cellData;
-        if (cell1==null){
-            String in = getIn(row2.getCell(j).toString());
-            if (info.length() == 0){
-                info = info.append(in);
-            }else{
-                info.append("\t").append(in);
-            }
-        }else{
-            cellData = getCellFormatValue(cell1,row2.getCell(j));
-            if (info.length() == 0){
-                info = info.append(cellData);
-            }else{
-                info.append("\t").append(cellData);
-            }
-        }
-        return info;
-    }
-
-    private static String getIn(String row2) {
-        String str = "";
-        switch (row2) {
-            case "bool":
-                str = "false";
-                break;
-            case "int":
-            case "float":
-                str = "0";
-                break;
-            case "string":
-                break;
-            default:
-                str = null;
-        }
-        return str;
-    }
-
-    private static void bulidMapInfo(Workbook wb) throws IOException {
-        Sheet sheet = wb.getSheetAt(0);
-        String sheetName = sheet.getSheetName();
-        System.out.println("bulidMapInfo => collection name="+sheetName);
-        int rowNum = sheet.getPhysicalNumberOfRows();
-        FileWriter fw = new FileWriter(path + sheetName + ".txt");
-        PrintWriter out = new PrintWriter(fw);
-        Object[][] aa = new Object[rowNum][];
-        for (int i = 0; i < rowNum; i++) {
-            Row row = sheet.getRow(i);
-            Object[] bb = new Object[rowNum];
-            for (int j = 0; j < rowNum; j++) {
-                //文件名
-                Object cellData = getCellFormatValue(row.getCell(j),null);
-                if (!"".equals(cellData)) {
-                    bb[j] = cellData;
-                }
-            }
-            aa[i] = bb;
-        }
-        Map<Object, List<Object>> infoMap = getObjectListMap(aa,sheetName);
-        buildJson(out, infoMap);
-        fw.close();
-        out.close();
-    }
-
-    private static Map<Object, List<Object>> getObjectListMap(Object[][] aa,String sheetName) throws IOException {
-        Map<Object, List<Object>> infoMap = new HashMap<>();
-        for (int i = 1; i < aa.length; i++) {
-            for (int j = 1; j < aa[i].length; j++) {
-                if (aa[i][j] == null) {
-                    continue;
-                }
-                if (isWrite) {
-//                    FileWriter fw = new FileWriter("tmp/json/"+sheetName+"_size.txt");
-//                    PrintWriter out = new PrintWriter(fw);
-//                    String[] split = aa[0][0].toString().split(",");
-//                    out.write("id"+"\t"+"Length"+"\t"+"Width");
-//                    out.write("\r\n");
-//                    out.write("int\tint\tint");
-//                    out.write("\r\n");
-//                    out.write(1+"\t"+split[0] +"\t"+ split[1]);
-//                    out.write("\r\n");
-//                    out.close();
-                    isWrite = false;
-                }
-                List<Object> objects = new ArrayList<>();
-                Object cc = aa[0][j] +"#"+ aa[i][0];
-                if (infoMap.containsKey(aa[i][j])) {
-                    objects = infoMap.get(aa[i][j]);
-                    objects.add(cc);
-                } else {
-                    objects.add(cc);
-                }
-                infoMap.put(aa[i][j], objects);
-            }
-        }
-        isWrite = true;
-        return infoMap;
-    }
-
-    private static void buildJson(PrintWriter out, Map<Object, List<Object>> infoMap) {
-        int i = 0;
-        for (Map.Entry<Object, List<Object>> entry : infoMap.entrySet()) {
-            String[] split = entry.getKey().toString().split("#");
-            Object npc  = entry.getKey();
-            if (split.length >= 2){
-                npc = split[1];
-            }
-            List<Object> value = entry.getValue();
-            StringBuilder groups = new StringBuilder();
-            for (Object info :value){
-                if (groups.length() == 0){
-                    groups = new StringBuilder((String) info);
-                }else{
-                    groups.append("|").append(info);
-                }
-            }
-            if (i == 0){
-                out.write("id\tEvent\tGroups");
-                out.write("\r\n");
-                out.write("int"+"\t"+"int"+"\t"+"mut,int#int,2");
-                out.write("\r\n");
-            }
-            i = i +1 ;
-            out.write( i+"\t"+npc+"\t"+groups.toString());
-            out.write("\r\n");
-        }
-    }
-
-    //读取excel
-    private static Workbook readExcel(String filePath) {
-        Workbook wb = null;
-        if (filePath == null) {
-            return null;
-        }
-        String extString = filePath.substring(filePath.lastIndexOf("."));
-        InputStream is;
-        try {
-            is = new FileInputStream(filePath);
-            if (".xls".equals(extString)) {
-                return wb = new HSSFWorkbook(is);
-            } else if (".xlsx".equals(extString)) {
-                wb = new XSSFWorkbook(is);
-                return wb;
-            } else {
-                return wb = null;
-            }
-
-        } catch (FileNotFoundException e) {
-            e.printStackTrace();
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return wb;
-    }
-
-    public static Object getCellFormatValue(Cell cell,Cell cellType) {
-        Object cellValue = null;
-        if (cell != null) {
-            //判断cell类型
-            switch (cell.getCellType()) {
-                case Cell.CELL_TYPE_NUMERIC: {
-                    if (cellType != null && cellType.toString().equals("float")){
-                        cellValue =  cell.getNumericCellValue();
-                    }else{
-                        cellValue = (int) cell.getNumericCellValue();
-                    }
-                    break;
-                }
-                case Cell.CELL_TYPE_FORMULA: {
-                    //判断cell是否为日期格式
-                    if (DateUtil.isCellDateFormatted(cell)) {
-                        //转换为日期格式YYYY-mm-dd
-                        cellValue = cell.getDateCellValue();
-                    } else {
-                        //数字
-                        cellValue = String.valueOf(cell.getNumericCellValue());
-                    }
-                    break;
-                }
-                case Cell.CELL_TYPE_BOOLEAN:{
-                    cellValue =cell.getBooleanCellValue();
-                    break;
-                }
-                case Cell.CELL_TYPE_STRING: {
-                    cellValue = cell.getRichStringCellValue().getString();
-                    break;
-                }
-                default:
-                    cellValue = "";
-            }
-        } else {
-            cellValue = "";
-        }
-        return cellValue;
-    }
+package com.ljsd.util;
+
+import jcifs.smb.SmbFile;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+
+import java.io.*;
+import java.util.*;
+
+public class ExcelUtils {
+    private static boolean isWrite = true;
+    private static String excelPath ="smb://60.1.1.12/Public/jieling/conf/data_execl/"; //excel 文件
+    private static String path = "//60.1.1.12/Public/jieling/conf/server/";
+//    private static String path = "D:/tmp/";
+    private static  Set<String> oldFileNames = new HashSet<>();
+
+    public static void main(String[] args) throws IOException {
+        File oldfile = new File(path);
+        String[] list = oldfile.list();
+        oldFileNames.addAll(Arrays.asList(list));
+        readExcelData();
+
+    }
+
+    public static void readExcelData() throws IOException {
+        SmbFile file = new SmbFile(excelPath);
+        if (file.exists()) {
+            SmbFile[] files = file.listFiles();
+            for (SmbFile file1 : files) {
+                if (file1.isDirectory()) {
+                    continue;
+                }
+                String extString = file1.getName().substring(file1.getName().lastIndexOf("."));
+                if (!".xlsx".equals(extString)) {
+                    continue;
+                }
+                String filePath =file1.getUncPath();
+                Workbook wb = readExcel(filePath);
+                if(file1.getName().contains("Map_")){
+                    bulidMapInfo(wb);
+                }else{
+                    buildDataInfo(wb);
+                }
+            }
+        }
+    }
+
+    private static String typeInfo(String fieldInfo){
+        //mut,int#int,2
+        if(fieldInfo.contains("mut")){
+            String[] split = fieldInfo.split("#");
+            String[] typeInfos = split[1].split(",");
+            int nums = Integer.parseInt(typeInfos[1]);
+            StringBuffer sb = new StringBuffer();
+            if("string".equals(typeInfos[0])){
+               sb.append("String");
+            }else{
+                sb.append(typeInfos[0]);
+            }
+
+
+            for(int i=0;i<nums;i++){
+                sb.append("[]");
+            }
+            return sb.toString();
+        }
+        if("string".equals(fieldInfo)){
+            return "String";
+        }
+        return fieldInfo;
+    }
+
+    private static void buildDataInfo(Workbook wb) throws IOException {
+        Sheet sheet;
+        Row row;
+        Object cellData;
+        sheet = wb.getSheetAt(0);
+        String sheetName = sheet.getSheetName();
+        System.out.println("bulidMapInfo => collection name="+sheetName);
+        int rownum = sheet.getLastRowNum();
+        FileWriter fw = new FileWriter(path + sheetName + ".txt");
+        PrintWriter out = new PrintWriter(fw);
+        for (int i = 0; i <= rownum; i++) {
+            if (i == 2 || i == 3 || i == 4 ||i == 5||i == 6){
+                continue;
+            }
+            Row row1 = sheet.getRow(2);
+            Row row2 = sheet.getRow(1);
+            Row row4 = sheet.getRow(4);
+            row = sheet.getRow(i);
+//            for (Cell c :row){
+//                System.out.println(c.getColumnIndex() +"==="+row.getCell(c.getColumnIndex()));
+//            }
+            if (row != null) {
+                StringBuilder info = new StringBuilder();
+                int colnum = row1.getLastCellNum();
+                for (int j = 1; j < colnum; j++) {
+                    int cellFormatValue = (int) getCellFormatValue(row1.getCell(j),null);
+                    if (cellFormatValue == 3){
+                        continue;
+                    }
+                    Cell cell = row.getCell(j);
+                    if (cell == null){
+                        Cell cell1 = row4.getCell(j);
+                        info = getStringBuilder(row2, info, j, cell1);
+                    }else{
+                        if (getCellFormatValue(row1.getCell(j),null).toString().isEmpty()){
+                            continue;
+                        }
+                        //文件名
+                        cellData = getCellFormatValue(cell,row2.getCell(j));
+                        if ("".equals(cellData.toString())){
+                            cellData = getIn(row2.getCell(j).toString());
+                        }
+                        if (info.length() == 0){
+                            info = info.append(cellData);
+                        }else{
+                            info.append("\t").append(cellData);
+                        }
+                    }
+                }
+                out.write(info.toString());
+                out.write("\r\n");
+            }
+        }
+        fw.close();
+        out.close();
+    }
+
+    private static StringBuilder getStringBuilder(Row row2, StringBuilder info, int j, Cell cell1) {
+        Object cellData;
+        if (cell1==null){
+            String in = getIn(row2.getCell(j).toString());
+            if (info.length() == 0){
+                info = info.append(in);
+            }else{
+                info.append("\t").append(in);
+            }
+        }else{
+            cellData = getCellFormatValue(cell1,row2.getCell(j));
+            if (info.length() == 0){
+                info = info.append(cellData);
+            }else{
+                info.append("\t").append(cellData);
+            }
+        }
+        return info;
+    }
+
+    private static String getIn(String row2) {
+        String str = "";
+        switch (row2) {
+            case "bool":
+                str = "false";
+                break;
+            case "int":
+            case "float":
+                str = "0";
+                break;
+            case "string":
+                break;
+            default:
+                str = null;
+        }
+        return str;
+    }
+
+    private static void bulidMapInfo(Workbook wb) throws IOException {
+        Sheet sheet = wb.getSheetAt(0);
+        String sheetName = sheet.getSheetName();
+        System.out.println("bulidMapInfo => collection name="+sheetName);
+        int rowNum = sheet.getPhysicalNumberOfRows();
+        FileWriter fw = new FileWriter(path + sheetName + ".txt");
+        PrintWriter out = new PrintWriter(fw);
+        Object[][] aa = new Object[rowNum][];
+        for (int i = 0; i < rowNum; i++) {
+            Row row = sheet.getRow(i);
+            Object[] bb = new Object[rowNum];
+            for (int j = 0; j < rowNum; j++) {
+                //文件名
+                Object cellData = getCellFormatValue(row.getCell(j),null);
+                if (!"".equals(cellData)) {
+                    bb[j] = cellData;
+                }
+            }
+            aa[i] = bb;
+        }
+        Map<Object, List<Object>> infoMap = getObjectListMap(aa,sheetName);
+        buildJson(out, infoMap);
+        fw.close();
+        out.close();
+    }
+
+    private static Map<Object, List<Object>> getObjectListMap(Object[][] aa,String sheetName) throws IOException {
+        Map<Object, List<Object>> infoMap = new HashMap<>();
+        for (int i = 1; i < aa.length; i++) {
+            for (int j = 1; j < aa[i].length; j++) {
+                if (aa[i][j] == null) {
+                    continue;
+                }
+                if (isWrite) {
+//                    FileWriter fw = new FileWriter("tmp/json/"+sheetName+"_size.txt");
+//                    PrintWriter out = new PrintWriter(fw);
+//                    String[] split = aa[0][0].toString().split(",");
+//                    out.write("id"+"\t"+"Length"+"\t"+"Width");
+//                    out.write("\r\n");
+//                    out.write("int\tint\tint");
+//                    out.write("\r\n");
+//                    out.write(1+"\t"+split[0] +"\t"+ split[1]);
+//                    out.write("\r\n");
+//                    out.close();
+                    isWrite = false;
+                }
+                List<Object> objects = new ArrayList<>();
+                Object cc = aa[0][j] +"#"+ aa[i][0];
+                if (infoMap.containsKey(aa[i][j])) {
+                    objects = infoMap.get(aa[i][j]);
+                    objects.add(cc);
+                } else {
+                    objects.add(cc);
+                }
+                infoMap.put(aa[i][j], objects);
+            }
+        }
+        isWrite = true;
+        return infoMap;
+    }
+
+    private static void buildJson(PrintWriter out, Map<Object, List<Object>> infoMap) {
+        int i = 0;
+        for (Map.Entry<Object, List<Object>> entry : infoMap.entrySet()) {
+            String[] split = entry.getKey().toString().split("#");
+            Object npc  = entry.getKey();
+            if (split.length >= 2){
+                npc = split[1];
+            }
+            List<Object> value = entry.getValue();
+            StringBuilder groups = new StringBuilder();
+            for (Object info :value){
+                if (groups.length() == 0){
+                    groups = new StringBuilder((String) info);
+                }else{
+                    groups.append("|").append(info);
+                }
+            }
+            if (i == 0){
+                out.write("id\tEvent\tGroups");
+                out.write("\r\n");
+                out.write("int"+"\t"+"int"+"\t"+"mut,int#int,2");
+                out.write("\r\n");
+            }
+            i = i +1 ;
+            out.write( i+"\t"+npc+"\t"+groups.toString());
+            out.write("\r\n");
+        }
+    }
+
+    //读取excel
+    private static Workbook readExcel(String filePath) {
+        Workbook wb = null;
+        if (filePath == null) {
+            return null;
+        }
+        String extString = filePath.substring(filePath.lastIndexOf("."));
+        InputStream is;
+        try {
+            is = new FileInputStream(filePath);
+            if (".xls".equals(extString)) {
+                return wb = new HSSFWorkbook(is);
+            } else if (".xlsx".equals(extString)) {
+                wb = new XSSFWorkbook(is);
+                return wb;
+            } else {
+                return wb = null;
+            }
+
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return wb;
+    }
+
+    public static Object getCellFormatValue(Cell cell,Cell cellType) {
+        Object cellValue = null;
+        if (cell != null) {
+            //判断cell类型
+            switch (cell.getCellType()) {
+                case Cell.CELL_TYPE_NUMERIC: {
+                    if (cellType != null && cellType.toString().equals("float")){
+                        cellValue =  cell.getNumericCellValue();
+                    }else{
+                        cellValue = (int) cell.getNumericCellValue();
+                    }
+                    break;
+                }
+                case Cell.CELL_TYPE_FORMULA: {
+                    //判断cell是否为日期格式
+                    if (DateUtil.isCellDateFormatted(cell)) {
+                        //转换为日期格式YYYY-mm-dd
+                        cellValue = cell.getDateCellValue();
+                    } else {
+                        //数字
+                        cellValue = String.valueOf(cell.getNumericCellValue());
+                    }
+                    break;
+                }
+                case Cell.CELL_TYPE_BOOLEAN:{
+                    cellValue =cell.getBooleanCellValue();
+                    break;
+                }
+                case Cell.CELL_TYPE_STRING: {
+                    cellValue = cell.getRichStringCellValue().getString();
+                    break;
+                }
+                default:
+                    cellValue = "";
+            }
+        } else {
+            cellValue = "";
+        }
+        return cellValue;
+    }
 }

+ 45 - 45
src/main/java/com/ljsd/util/HttpUtils.java

@@ -1,45 +1,45 @@
-package com.ljsd.util;
-
-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.HttpPost;
-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 java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-public class HttpUtils {
-
-    public static String doPost(String url, Map<String,String> parms) throws IOException {
-        CloseableHttpClient httpclient = HttpClients.createDefault();
-        HttpPost httpPost = new HttpPost(url);
-        List<NameValuePair> nvps =getFromMap(parms);
-        httpPost.setEntity(new UrlEncodedFormEntity(nvps));
-        CloseableHttpResponse response2 = httpclient.execute(httpPost);
-
-        try {
-            HttpEntity entity = response2.getEntity();
-           return  EntityUtils.toString(entity);
-        } catch (IOException e) {
-            e.printStackTrace();
-            return null;
-        } finally {
-            response2.close();
-        }
-    }
-
-    public static List<NameValuePair> getFromMap(Map<String,String> parms){
-        List<NameValuePair> nvps = new ArrayList<NameValuePair>(parms.size());
-        for(Map.Entry<String,String> item : parms.entrySet()){
-            nvps.add(new BasicNameValuePair(item.getKey(), item.getValue()));
-        }
-        return nvps;
-    }
-}
+package com.ljsd.util;
+
+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.HttpPost;
+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 java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+public class HttpUtils {
+
+    public static String doPost(String url, Map<String,String> parms) throws IOException {
+        CloseableHttpClient httpclient = HttpClients.createDefault();
+        HttpPost httpPost = new HttpPost(url);
+        List<NameValuePair> nvps =getFromMap(parms);
+        httpPost.setEntity(new UrlEncodedFormEntity(nvps));
+        CloseableHttpResponse response2 = httpclient.execute(httpPost);
+
+        try {
+            HttpEntity entity = response2.getEntity();
+           return  EntityUtils.toString(entity);
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        } finally {
+            response2.close();
+        }
+    }
+
+    public static List<NameValuePair> getFromMap(Map<String,String> parms){
+        List<NameValuePair> nvps = new ArrayList<NameValuePair>(parms.size());
+        for(Map.Entry<String,String> item : parms.entrySet()){
+            nvps.add(new BasicNameValuePair(item.getKey(), item.getValue()));
+        }
+        return nvps;
+    }
+}

+ 211 - 211
src/main/java/com/ljsd/util/IdCard.java

@@ -1,211 +1,211 @@
-package com.ljsd.util;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class IdCard {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(TimeUtil.class);
-
-    public static boolean isAdult(String idStr){
-        try {
-            LOGGER.info("idStr:"+idStr);
-            if (null == idStr) {// 验证非空
-                LOGGER.info("身份证号码不能为空");
-                return false;
-            }
-            if (idStr.length() != 15 && idStr.length() != 18) {// 只能是15位或者18位
-                LOGGER.info("身份证号码长度只能是15位或者18位"+idStr);
-                return false;
-            }
-
-            String Ai = "";
-            if (idStr.length() == 18) {
-                Ai = idStr.substring(0, 17);
-            }
-
-            if (idStr.length() == 15) {//  将15位身份证转换为 17位身份证,最后加上最后一位,转换为18位身份证
-                // 15位身份证是没有校验位的,同时采用的是2位数字来表示出生年份,并且 15位的身份证号码确定都是19**年的
-                Ai = idStr.substring(0, 6) + "19" + idStr.substring(6, 15);
-            }
-            if (!isNumber(Ai)) { // 验证身份证前17位是否都是数字
-                LOGGER.info("身份证15位号码都应为数字 ; 18位号码除最后一位外,都应为数字。");
-                return false;
-            }
-
-            int year = Integer.parseInt(Ai.substring(6, 10));// 出生年份
-            int month = Integer.parseInt(Ai.substring(10, 12));// 出生月份
-            int day = Integer.parseInt(Ai.substring(12, 14));// 出生日期
-            String birthDay = year + "-" + month + "-" + day;
-
-            Date birthdate = null;
-            try {// 将出生日期转换为Date类型
-                birthdate = new SimpleDateFormat("yyyyMMdd").parse(birthDay);
-            } catch (ParseException e) {
-                e.printStackTrace();
-                LOGGER.info("身份证生日无效。");
-                return false;
-            }
-            if (birthdate == null || new Date().before(birthdate)) {
-                LOGGER.info("身份证生日无效。");
-                return false;
-            }
-
-            GregorianCalendar gc = new GregorianCalendar();//GregorianCalendar 是 Calendar 的一个具体子类,提供了世界上大多数国家/地区使用的标准日历系统。
-            SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
-            // 验证生日年份是否在范围之内
-            if ((gc.get(Calendar.YEAR) - year) > 150 || (gc.getTime().getTime() - s.parse(birthDay).getTime()) < 0) {
-                LOGGER.info("身份证生日不在有效范围。");
-                return false;
-            }
-
-            //验证月份
-            if (month > 12 || month <= 0) {
-                LOGGER.info("身份证号中的月份无效");
-                return false;
-            }
-
-            //验证日期
-            gc.setTime(birthdate);
-            boolean mflag = false;
-            switch (month) {
-                case 1:
-                case 3:
-                case 5:
-                case 7:
-                case 8:
-                case 10:
-                case 12:
-                    mflag = (day >= 1 && day <= 31);
-                    break;
-                case 2: // 公历的2月非闰年有28天,闰年的2月是29天。
-                    if (gc.isLeapYear(gc.get(Calendar.YEAR))) {
-                        mflag = (day >= 1 && day <= 29);
-                    } else {
-                        mflag = (day >= 1 && day <= 28);
-                    }
-                    break;
-                case 4:
-                case 6:
-                case 9:
-                case 11:
-                    mflag = (day >= 1 && day <= 30);
-                    break;
-            }
-            if (!mflag) {// 日期不对
-                LOGGER.info("省份证号中的出生日期不对");
-                return false;
-            }
-            // 验证 开头两位数是否是真实有效的地区编码
-            if (cityCodeMap.get(Ai.substring(0, 2)) == null) {
-                LOGGER.info("身份证地区编码错误。");
-                return false;
-            }
-
-            int TotalmulAiWi = 0;
-            for (int i = 0; i < 17; i++) {//先对前17位数字的权求和 ,使用十七位数字本体码加权求和公式   S = Sum(Ai * Wi)
-                TotalmulAiWi = TotalmulAiWi + Integer.parseInt(String.valueOf(Ai.charAt(i))) * Integer.parseInt(Wi[i]);
-            }
-            int modValue = TotalmulAiWi % 11;//计算模  Y = mod(S, 11) 用计算出来的结果除以11,这样就会出现
-            String strVerifyCode = ValCodeArr[modValue]; // 获取最后一位的校验码字符值
-            Ai = Ai + strVerifyCode; // 17位身份证 加上最后以为验证数字   得到18位有效的身份证号
-
-            if (!idStr.toUpperCase().equals(Ai.toUpperCase())) {// 判断传过来的身份证号 和 计算得到的身份证号是否相同
-                LOGGER.info(idStr.toUpperCase()+"身份证号码不对"+Ai.toUpperCase());
-                return false;
-            }
-            LOGGER.info("正确");
-
-            if(getAgeByBirthday(birthdate)<18){
-                LOGGER.info("未满18岁");
-                return false;
-            }else{
-                return true;
-            }
-        } catch (Exception e) {
-            LOGGER.info("验证出错");
-            e.printStackTrace();
-            return false;
-        }
-    }
-    private static boolean isNumber(String str) {
-        Pattern pattern = Pattern.compile("[0-9]*");
-        Matcher isNum = pattern.matcher(str);
-        return isNum.matches();
-    }
-    private static Map<String, String> cityCodeMap = new HashMap<String, String>() {
-        {
-            this.put("11", "北京");
-            this.put("12", "天津");
-            this.put("13", "河北");
-            this.put("14", "山西");
-            this.put("15", "内蒙古");
-            this.put("21", "辽宁");
-            this.put("22", "吉林");
-            this.put("23", "黑龙江");
-            this.put("31", "上海");
-            this.put("32", "江苏");
-            this.put("33", "浙江");
-            this.put("34", "安徽");
-            this.put("35", "福建");
-            this.put("36", "江西");
-            this.put("37", "山东");
-            this.put("41", "河南");
-            this.put("42", "湖北");
-            this.put("43", "湖南");
-            this.put("44", "广东");
-            this.put("45", "广西");
-            this.put("46", "海南");
-            this.put("50", "重庆");
-            this.put("51", "四川");
-            this.put("52", "贵州");
-            this.put("53", "云南");
-            this.put("54", "西藏");
-            this.put("61", "陕西");
-            this.put("62", "甘肃");
-            this.put("63", "青海");
-            this.put("64", "宁夏");
-            this.put("65", "新疆");
-            this.put("71", "台湾");
-            this.put("81", "香港");
-            this.put("82", "澳门");
-            this.put("91", "国外");
-        }
-    };
-    static String[] ValCodeArr = { "1", "0", "x", "9", "8", "7", "6", "5", "4","3", "2" }; //最后一位的校验码字符值
-    static String[] Wi = { "7", "9", "10", "5", "8", "4", "2", "1", "6", "3", "7","9", "10", "5", "8", "4", "2" };//十七位数字
-    public static int getAgeByBirthday(Date birthday) {
-        Calendar cal = Calendar.getInstance();
-        if (cal.before(birthday)) {
-            throw new IllegalArgumentException(
-                    "The birthDay is before Now.It's unbelievable!");
-        }
-        int yearNow = cal.get(Calendar.YEAR);
-        int monthNow = cal.get(Calendar.MONTH) + 1;
-        int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
-        cal.setTime(birthday);
-        int yearBirth = cal.get(Calendar.YEAR);
-        int monthBirth = cal.get(Calendar.MONTH) + 1;
-        int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
-        int age = yearNow - yearBirth;
-        if (monthNow <= monthBirth) {
-            if (monthNow == monthBirth) {
-                // monthNow==monthBirth
-                if (dayOfMonthNow < dayOfMonthBirth) {
-                    age--;
-                }
-            } else {
-                // monthNow>monthBirth
-                age--;
-            }
-        }
-        return age;
-    }
-
-}
+package com.ljsd.util;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class IdCard {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(TimeUtil.class);
+
+    public static boolean isAdult(String idStr){
+        try {
+            LOGGER.info("idStr:"+idStr);
+            if (null == idStr) {// 验证非空
+                LOGGER.info("身份证号码不能为空");
+                return false;
+            }
+            if (idStr.length() != 15 && idStr.length() != 18) {// 只能是15位或者18位
+                LOGGER.info("身份证号码长度只能是15位或者18位"+idStr);
+                return false;
+            }
+
+            String Ai = "";
+            if (idStr.length() == 18) {
+                Ai = idStr.substring(0, 17);
+            }
+
+            if (idStr.length() == 15) {//  将15位身份证转换为 17位身份证,最后加上最后一位,转换为18位身份证
+                // 15位身份证是没有校验位的,同时采用的是2位数字来表示出生年份,并且 15位的身份证号码确定都是19**年的
+                Ai = idStr.substring(0, 6) + "19" + idStr.substring(6, 15);
+            }
+            if (!isNumber(Ai)) { // 验证身份证前17位是否都是数字
+                LOGGER.info("身份证15位号码都应为数字 ; 18位号码除最后一位外,都应为数字。");
+                return false;
+            }
+
+            int year = Integer.parseInt(Ai.substring(6, 10));// 出生年份
+            int month = Integer.parseInt(Ai.substring(10, 12));// 出生月份
+            int day = Integer.parseInt(Ai.substring(12, 14));// 出生日期
+            String birthDay = year + "-" + month + "-" + day;
+
+            Date birthdate = null;
+            try {// 将出生日期转换为Date类型
+                birthdate = new SimpleDateFormat("yyyyMMdd").parse(birthDay);
+            } catch (ParseException e) {
+                e.printStackTrace();
+                LOGGER.info("身份证生日无效。");
+                return false;
+            }
+            if (birthdate == null || new Date().before(birthdate)) {
+                LOGGER.info("身份证生日无效。");
+                return false;
+            }
+
+            GregorianCalendar gc = new GregorianCalendar();//GregorianCalendar 是 Calendar 的一个具体子类,提供了世界上大多数国家/地区使用的标准日历系统。
+            SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
+            // 验证生日年份是否在范围之内
+            if ((gc.get(Calendar.YEAR) - year) > 150 || (gc.getTime().getTime() - s.parse(birthDay).getTime()) < 0) {
+                LOGGER.info("身份证生日不在有效范围。");
+                return false;
+            }
+
+            //验证月份
+            if (month > 12 || month <= 0) {
+                LOGGER.info("身份证号中的月份无效");
+                return false;
+            }
+
+            //验证日期
+            gc.setTime(birthdate);
+            boolean mflag = false;
+            switch (month) {
+                case 1:
+                case 3:
+                case 5:
+                case 7:
+                case 8:
+                case 10:
+                case 12:
+                    mflag = (day >= 1 && day <= 31);
+                    break;
+                case 2: // 公历的2月非闰年有28天,闰年的2月是29天。
+                    if (gc.isLeapYear(gc.get(Calendar.YEAR))) {
+                        mflag = (day >= 1 && day <= 29);
+                    } else {
+                        mflag = (day >= 1 && day <= 28);
+                    }
+                    break;
+                case 4:
+                case 6:
+                case 9:
+                case 11:
+                    mflag = (day >= 1 && day <= 30);
+                    break;
+            }
+            if (!mflag) {// 日期不对
+                LOGGER.info("省份证号中的出生日期不对");
+                return false;
+            }
+            // 验证 开头两位数是否是真实有效的地区编码
+            if (cityCodeMap.get(Ai.substring(0, 2)) == null) {
+                LOGGER.info("身份证地区编码错误。");
+                return false;
+            }
+
+            int TotalmulAiWi = 0;
+            for (int i = 0; i < 17; i++) {//先对前17位数字的权求和 ,使用十七位数字本体码加权求和公式   S = Sum(Ai * Wi)
+                TotalmulAiWi = TotalmulAiWi + Integer.parseInt(String.valueOf(Ai.charAt(i))) * Integer.parseInt(Wi[i]);
+            }
+            int modValue = TotalmulAiWi % 11;//计算模  Y = mod(S, 11) 用计算出来的结果除以11,这样就会出现
+            String strVerifyCode = ValCodeArr[modValue]; // 获取最后一位的校验码字符值
+            Ai = Ai + strVerifyCode; // 17位身份证 加上最后以为验证数字   得到18位有效的身份证号
+
+            if (!idStr.toUpperCase().equals(Ai.toUpperCase())) {// 判断传过来的身份证号 和 计算得到的身份证号是否相同
+                LOGGER.info(idStr.toUpperCase()+"身份证号码不对"+Ai.toUpperCase());
+                return false;
+            }
+            LOGGER.info("正确");
+
+            if(getAgeByBirthday(birthdate)<18){
+                LOGGER.info("未满18岁");
+                return false;
+            }else{
+                return true;
+            }
+        } catch (Exception e) {
+            LOGGER.info("验证出错");
+            e.printStackTrace();
+            return false;
+        }
+    }
+    private static boolean isNumber(String str) {
+        Pattern pattern = Pattern.compile("[0-9]*");
+        Matcher isNum = pattern.matcher(str);
+        return isNum.matches();
+    }
+    private static Map<String, String> cityCodeMap = new HashMap<String, String>() {
+        {
+            this.put("11", "北京");
+            this.put("12", "天津");
+            this.put("13", "河北");
+            this.put("14", "山西");
+            this.put("15", "内蒙古");
+            this.put("21", "辽宁");
+            this.put("22", "吉林");
+            this.put("23", "黑龙江");
+            this.put("31", "上海");
+            this.put("32", "江苏");
+            this.put("33", "浙江");
+            this.put("34", "安徽");
+            this.put("35", "福建");
+            this.put("36", "江西");
+            this.put("37", "山东");
+            this.put("41", "河南");
+            this.put("42", "湖北");
+            this.put("43", "湖南");
+            this.put("44", "广东");
+            this.put("45", "广西");
+            this.put("46", "海南");
+            this.put("50", "重庆");
+            this.put("51", "四川");
+            this.put("52", "贵州");
+            this.put("53", "云南");
+            this.put("54", "西藏");
+            this.put("61", "陕西");
+            this.put("62", "甘肃");
+            this.put("63", "青海");
+            this.put("64", "宁夏");
+            this.put("65", "新疆");
+            this.put("71", "台湾");
+            this.put("81", "香港");
+            this.put("82", "澳门");
+            this.put("91", "国外");
+        }
+    };
+    static String[] ValCodeArr = { "1", "0", "x", "9", "8", "7", "6", "5", "4","3", "2" }; //最后一位的校验码字符值
+    static String[] Wi = { "7", "9", "10", "5", "8", "4", "2", "1", "6", "3", "7","9", "10", "5", "8", "4", "2" };//十七位数字
+    public static int getAgeByBirthday(Date birthday) {
+        Calendar cal = Calendar.getInstance();
+        if (cal.before(birthday)) {
+            throw new IllegalArgumentException(
+                    "The birthDay is before Now.It's unbelievable!");
+        }
+        int yearNow = cal.get(Calendar.YEAR);
+        int monthNow = cal.get(Calendar.MONTH) + 1;
+        int dayOfMonthNow = cal.get(Calendar.DAY_OF_MONTH);
+        cal.setTime(birthday);
+        int yearBirth = cal.get(Calendar.YEAR);
+        int monthBirth = cal.get(Calendar.MONTH) + 1;
+        int dayOfMonthBirth = cal.get(Calendar.DAY_OF_MONTH);
+        int age = yearNow - yearBirth;
+        if (monthNow <= monthBirth) {
+            if (monthNow == monthBirth) {
+                // monthNow==monthBirth
+                if (dayOfMonthNow < dayOfMonthBirth) {
+                    age--;
+                }
+            } else {
+                // monthNow>monthBirth
+                age--;
+            }
+        }
+        return age;
+    }
+
+}

+ 11 - 11
src/main/java/com/ljsd/util/KTSDKConstans.java

@@ -1,11 +1,11 @@
-package com.ljsd.util;
-
-public class KTSDKConstans {
-    public static String appid = "129213";
-    public static String appkey = "c0fb59eb68559b6c9c1463e4d5d0c806";
-    public static String appsecret = "d53b3e8ef74bf72d8aafce3a1c8671a0";
-
-    public static String androidVerify = "http://sujie.passport.ktsdk.com/user/verifyAccount";
-    public static String iosVerify = "http://sujie.passport.ktsdk.com/userios/verifyAccount";
-
-}
+package com.ljsd.util;
+
+public class KTSDKConstans {
+    public static String appid = "129213";
+    public static String appkey = "c0fb59eb68559b6c9c1463e4d5d0c806";
+    public static String appsecret = "d53b3e8ef74bf72d8aafce3a1c8671a0";
+
+    public static String androidVerify = "http://sujie.passport.ktsdk.com/user/verifyAccount";
+    public static String iosVerify = "http://sujie.passport.ktsdk.com/userios/verifyAccount";
+
+}

+ 37 - 37
src/main/java/com/ljsd/util/MD5Util.java

@@ -1,37 +1,37 @@
-package com.ljsd.util;
-
-import java.security.MessageDigest;
-import java.security.NoSuchAlgorithmException;
-
-public class MD5Util {
-
-    public static final String salt = "d13b3e8ef74bf72d8aafce3a1c8672a0";
-
-    public static String encrypByMd5(String context) {
-        try {
-            MessageDigest md = MessageDigest.getInstance("MD5");
-            md.update(context.getBytes());//update处理
-            byte [] encryContext = md.digest();//调用该方法完成计算
-
-            int i;
-            StringBuffer buf = new StringBuffer("");
-            for (int offset = 0; offset < encryContext.length; offset++) {//做相应的转化(十六进制)
-                i = encryContext[offset];
-                if (i < 0) i += 256;
-                if (i < 16) buf.append("0");
-                buf.append(Integer.toHexString(i));
-            }
-
-            return buf.toString().toLowerCase();
-
-        } catch (NoSuchAlgorithmException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
-        }
-        return "";
-    }
-
-    public static void main(String[] args) {
-        System.out.println(MD5Util.encrypByMd5("pc2222" + salt));
-    }
-}
+package com.ljsd.util;
+
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+public class MD5Util {
+
+    public static final String salt = "d13b3e8ef74bf72d8aafce3a1c8672a0";
+
+    public static String encrypByMd5(String context) {
+        try {
+            MessageDigest md = MessageDigest.getInstance("MD5");
+            md.update(context.getBytes());//update处理
+            byte [] encryContext = md.digest();//调用该方法完成计算
+
+            int i;
+            StringBuffer buf = new StringBuffer("");
+            for (int offset = 0; offset < encryContext.length; offset++) {//做相应的转化(十六进制)
+                i = encryContext[offset];
+                if (i < 0) i += 256;
+                if (i < 16) buf.append("0");
+                buf.append(Integer.toHexString(i));
+            }
+
+            return buf.toString().toLowerCase();
+
+        } catch (NoSuchAlgorithmException e) {
+            // TODO Auto-generated catch block
+            e.printStackTrace();
+        }
+        return "";
+    }
+
+    public static void main(String[] args) {
+        System.out.println(MD5Util.encrypByMd5("pc2222" + salt));
+    }
+}

+ 37 - 37
src/main/java/com/ljsd/util/MHTSDKConstans.java

@@ -1,37 +1,37 @@
-package com.ljsd.util;
-
-/**
- * 游戏名称:	     代号:源起
- * appid:b5122eb744689d247d82eea37e9741f6
- * rhappid:7bb5f604306ccd93fc19f05d3a374e84
- * 支付秘钥:5b980134872a8afa993f8a3b35a8efbd
- * channelid:MHT
- */
-public class MHTSDKConstans {
-    public static String appid = "e4ecefecc8034cffaa69e81b2c044f2c";
-    public static String rhappid = "d0265404f55536a5c8b0ec33a9da27d3";
-    public static String rhappidOnline = "7bb5f604306ccd93fc19f05d3a374e84";
-    public static String back = "http://kwsdk.17173g.cn/platformPay/MHT/callBack";
-
-    //    public static String androidVerify = "http://sujie.passport.ktsdk.com/user/verifyAccount";
-//    public static String iosVerify = "http://sujie.passport.ktsdk.com/userios/verifyAccount";
-    public static String loginVerify = "http://kwsdk.17173g.cn/cp/checkLogin";
-    public static String secretKey = "5b980134872a8afa993f8a3b35a8efbd";
-
-
-
-
-
-
-
-
-    public static String channelid = "MHT";
-
-    public static void main(String[] args) {
-       // boolean equals = "http://sujie.passport.ktsdk.com/user/verifyAccount".equals(androidVerify);
-      //  System.out.println(equals);
-    }
-
-}
-
-
+package com.ljsd.util;
+
+/**
+ * 游戏名称:	     代号:源起
+ * appid:b5122eb744689d247d82eea37e9741f6
+ * rhappid:7bb5f604306ccd93fc19f05d3a374e84
+ * 支付秘钥:5b980134872a8afa993f8a3b35a8efbd
+ * channelid:MHT
+ */
+public class MHTSDKConstans {
+    public static String appid = "e4ecefecc8034cffaa69e81b2c044f2c";
+    public static String rhappid = "d0265404f55536a5c8b0ec33a9da27d3";
+    public static String rhappidOnline = "7bb5f604306ccd93fc19f05d3a374e84";
+    public static String back = "http://kwsdk.17173g.cn/platformPay/MHT/callBack";
+
+    //    public static String androidVerify = "http://sujie.passport.ktsdk.com/user/verifyAccount";
+//    public static String iosVerify = "http://sujie.passport.ktsdk.com/userios/verifyAccount";
+    public static String loginVerify = "http://kwsdk.17173g.cn/cp/checkLogin";
+    public static String secretKey = "5b980134872a8afa993f8a3b35a8efbd";
+
+
+
+
+
+
+
+
+    public static String channelid = "MHT";
+
+    public static void main(String[] args) {
+       // boolean equals = "http://sujie.passport.ktsdk.com/user/verifyAccount".equals(androidVerify);
+      //  System.out.println(equals);
+    }
+
+}
+
+

+ 130 - 130
src/main/java/com/ljsd/util/MyMongoDBPool.java

@@ -1,131 +1,131 @@
-package com.ljsd.util;
-
-import com.ljsd.controller.GetUserController;
-import com.mongodb.*;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Properties;
-
-/*
- * mongodb数据库链接池
- */
-public class MyMongoDBPool {
-    private static final Logger LOGGER = LoggerFactory.getLogger(MyMongoDBPool.class);
-    private MongoClient mongoClient = null;
-    private String dbName;
-    private DB db;
-
-    public MyMongoDBPool() {
-        MongoClientOptions.Builder buide = new MongoClientOptions.Builder();
-        Properties properties = BaseGlobal.getInstance().properties;
-        buide.connectionsPerHost(Integer.parseInt(properties.getProperty("mongodb_maximumNumberOfConnections")));// 与目标数据库可以建立的最大链接数
-        buide.connectTimeout(Integer.parseInt(properties.getProperty("mongodb_connectTimeout")));// 与数据库建立链接的超时时间
-        buide.maxWaitTime(Integer.parseInt(properties.getProperty("mongodb_maxWaitTime")));// 一个线程成功获取到一个可用数据库之前的最大等待时间
-        buide.threadsAllowedToBlockForConnectionMultiplier(Integer.parseInt(properties.getProperty("mongodb_threadsAllowedToBlockForConnectionMultiplier")));
-        buide.maxConnectionIdleTime(Integer.parseInt(properties.getProperty("mongodb_maxConnectionIdleTime")));
-        buide.maxConnectionLifeTime(Integer.parseInt(properties.getProperty("mongodb_maxConnectionLifeTime")));
-        buide.socketTimeout(Integer.parseInt(properties.getProperty("mongodb_socketTimeout")));
-        buide.socketKeepAlive(Boolean.parseBoolean(properties.getProperty("mongodb_socketKeepAlive")));
-        MongoClientURI mongodb_host = new MongoClientURI(properties.getProperty("mongodb_url"),buide);
-        mongoClient = new MongoClient(mongodb_host);
-        dbName = properties.getProperty("mongodb_name");
-        db = mongoClient.getDB(dbName);
-        LOGGER.info("the dbName={},mongoUrl={}",dbName,properties.getProperty("mongodb_url"));
-    }
-
-    public DBCollection getCollection(String collectionName) {
-        return db.getCollection(collectionName);
-    }
-
-
-    public   List<DBObject> findAll(String collectionName) throws Exception {
-        DBCollection coll = db.getCollection(collectionName);
-        DBCursor cursor = coll.find();
-        List<DBObject> docs = new ArrayList<>();
-
-        while (cursor.hasNext()) {
-            DBObject doc = cursor.next();
-            docs.add(doc);
-        }
-        return docs;
-    }
-
-    public DBObject findOne(String collectionName, String id) throws Exception {
-        return findOne2(collectionName, id);
-    }
-
-    public List<DBObject> find(String collectionName, DBObject object) throws Exception {
-        DBCollection coll = db.getCollection(collectionName);
-        DBCursor cursor = coll.find(object);
-        List<DBObject> docs = new ArrayList<>();
-        while (cursor.hasNext()) {
-            DBObject doc = cursor.next();
-            docs.add(doc);
-        }
-        return docs;
-    }
-
-    public String findList(String collectionName) throws Exception {
-        DBCollection coll = db.getCollection(collectionName);
-        DBCursor cursor = coll.find();
-        List<DBObject> docs = new ArrayList<>();
-
-        while (cursor.hasNext()) {
-            DBObject doc = cursor.next();
-            docs.add(doc);
-        }
-        return docs.toString();
-    }
-
-
-    public DBObject findOne(String collectionName, Integer id) throws Exception {
-        return findOne2(collectionName, id);
-    }
-
-    private DBObject findOne2(String collectionName, Object id) throws Exception {
-        LOGGER.info("the collection={},id={}",collectionName,id);
-        DBCollection coll = db.getCollection(collectionName);
-        if(coll == null){
-            LOGGER.info("the collection={},id={} is null",collectionName,id);
-            return null;
-        }
-        return coll.findOne(id.toString());
-    }
-
-    public void updateValue(String collectionName, BasicDBObject searchQuery, BasicDBObject dbObject) {
-        DBCollection coll = db.getCollection(collectionName);
-        coll.update(searchQuery, dbObject);
-    }
-
-    public void save(String collectionName, DBObject doc) {
-        DBCollection coll = db.getCollection(collectionName);
-        coll.save(doc);
-    }
-
-
-    public synchronized int inc(String collectionName, String id, String key) {
-        DBCollection collection = db.getCollection(collectionName);
-        BasicDBObject searchQuery = new BasicDBObject();
-        searchQuery.put("_id", id);
-        // 使用collection的find方法查找document
-        DBCursor cursor = collection.find(searchQuery);
-        // 循环输出结果
-        if (cursor.hasNext()) {
-            BasicDBObject update = new BasicDBObject().append("$inc", new BasicDBObject().append(key, 1));
-            DBObject query = cursor.next();
-            DBObject result = collection.findAndModify(query, update);
-            return Integer.parseInt(result.get(key).toString()) + 1;
-        } else {
-            searchQuery.put(key, 1);
-            collection.insert(searchQuery);
-            return 1;
-        }
-    }
-
-    public int inc(String key) {
-        return inc("inc_c", "inc_k", key);
-    }
+package com.ljsd.util;
+
+import com.ljsd.controller.GetUserController;
+import com.mongodb.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Properties;
+
+/*
+ * mongodb数据库链接池
+ */
+public class MyMongoDBPool {
+    private static final Logger LOGGER = LoggerFactory.getLogger(MyMongoDBPool.class);
+    private MongoClient mongoClient = null;
+    private String dbName;
+    private DB db;
+
+    public MyMongoDBPool() {
+        MongoClientOptions.Builder buide = new MongoClientOptions.Builder();
+        Properties properties = BaseGlobal.getInstance().properties;
+        buide.connectionsPerHost(Integer.parseInt(properties.getProperty("mongodb_maximumNumberOfConnections")));// 与目标数据库可以建立的最大链接数
+        buide.connectTimeout(Integer.parseInt(properties.getProperty("mongodb_connectTimeout")));// 与数据库建立链接的超时时间
+        buide.maxWaitTime(Integer.parseInt(properties.getProperty("mongodb_maxWaitTime")));// 一个线程成功获取到一个可用数据库之前的最大等待时间
+        buide.threadsAllowedToBlockForConnectionMultiplier(Integer.parseInt(properties.getProperty("mongodb_threadsAllowedToBlockForConnectionMultiplier")));
+        buide.maxConnectionIdleTime(Integer.parseInt(properties.getProperty("mongodb_maxConnectionIdleTime")));
+        buide.maxConnectionLifeTime(Integer.parseInt(properties.getProperty("mongodb_maxConnectionLifeTime")));
+        buide.socketTimeout(Integer.parseInt(properties.getProperty("mongodb_socketTimeout")));
+        buide.socketKeepAlive(Boolean.parseBoolean(properties.getProperty("mongodb_socketKeepAlive")));
+        MongoClientURI mongodb_host = new MongoClientURI(properties.getProperty("mongodb_url"),buide);
+        mongoClient = new MongoClient(mongodb_host);
+        dbName = properties.getProperty("mongodb_name");
+        db = mongoClient.getDB(dbName);
+        LOGGER.info("the dbName={},mongoUrl={}",dbName,properties.getProperty("mongodb_url"));
+    }
+
+    public DBCollection getCollection(String collectionName) {
+        return db.getCollection(collectionName);
+    }
+
+
+    public   List<DBObject> findAll(String collectionName) throws Exception {
+        DBCollection coll = db.getCollection(collectionName);
+        DBCursor cursor = coll.find();
+        List<DBObject> docs = new ArrayList<>();
+
+        while (cursor.hasNext()) {
+            DBObject doc = cursor.next();
+            docs.add(doc);
+        }
+        return docs;
+    }
+
+    public DBObject findOne(String collectionName, String id) throws Exception {
+        return findOne2(collectionName, id);
+    }
+
+    public List<DBObject> find(String collectionName, DBObject object) throws Exception {
+        DBCollection coll = db.getCollection(collectionName);
+        DBCursor cursor = coll.find(object);
+        List<DBObject> docs = new ArrayList<>();
+        while (cursor.hasNext()) {
+            DBObject doc = cursor.next();
+            docs.add(doc);
+        }
+        return docs;
+    }
+
+    public String findList(String collectionName) throws Exception {
+        DBCollection coll = db.getCollection(collectionName);
+        DBCursor cursor = coll.find();
+        List<DBObject> docs = new ArrayList<>();
+
+        while (cursor.hasNext()) {
+            DBObject doc = cursor.next();
+            docs.add(doc);
+        }
+        return docs.toString();
+    }
+
+
+    public DBObject findOne(String collectionName, Integer id) throws Exception {
+        return findOne2(collectionName, id);
+    }
+
+    private DBObject findOne2(String collectionName, Object id) throws Exception {
+        LOGGER.info("the collection={},id={}",collectionName,id);
+        DBCollection coll = db.getCollection(collectionName);
+        if(coll == null){
+            LOGGER.info("the collection={},id={} is null",collectionName,id);
+            return null;
+        }
+        return coll.findOne(id.toString());
+    }
+
+    public void updateValue(String collectionName, BasicDBObject searchQuery, BasicDBObject dbObject) {
+        DBCollection coll = db.getCollection(collectionName);
+        coll.update(searchQuery, dbObject);
+    }
+
+    public void save(String collectionName, DBObject doc) {
+        DBCollection coll = db.getCollection(collectionName);
+        coll.save(doc);
+    }
+
+
+    public synchronized int inc(String collectionName, String id, String key) {
+        DBCollection collection = db.getCollection(collectionName);
+        BasicDBObject searchQuery = new BasicDBObject();
+        searchQuery.put("_id", id);
+        // 使用collection的find方法查找document
+        DBCursor cursor = collection.find(searchQuery);
+        // 循环输出结果
+        if (cursor.hasNext()) {
+            BasicDBObject update = new BasicDBObject().append("$inc", new BasicDBObject().append(key, 1));
+            DBObject query = cursor.next();
+            DBObject result = collection.findAndModify(query, update);
+            return Integer.parseInt(result.get(key).toString()) + 1;
+        } else {
+            searchQuery.put(key, 1);
+            collection.insert(searchQuery);
+            return 1;
+        }
+    }
+
+    public int inc(String key) {
+        return inc("inc_c", "inc_k", key);
+    }
 }

+ 40 - 40
src/main/java/com/ljsd/util/NetUtil.java

@@ -1,40 +1,40 @@
-package com.ljsd.util;
-
-import javax.servlet.http.HttpServletRequest;
-
-public class NetUtil {
-    /**
-     * 获得真实IP
-     * @param request
-     * @return
-     */
-    public static String getIpAddr(HttpServletRequest request) {
-        String ip = request.getHeader("x-forwarded-for");
-        if (ip != null && ip.length() != 0 && !"unknown".equalsIgnoreCase(ip)) {
-            // 多次反向代理后会有多个ip值,第一个ip才是真实ip
-            if( ip.indexOf(",")!=-1 ){
-                ip = ip.split(",")[0];
-            }
-        }
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
-            ip = request.getHeader("Proxy-Client-IP");
-        }
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
-            ip = request.getHeader("WL-Proxy-Client-IP");
-        }
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
-            ip = request.getHeader("HTTP_CLIENT_IP");
-        }
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
-            ip = request.getHeader("HTTP_X_FORWARDED_FOR");
-        }
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
-            ip = request.getHeader("X-Real-IP");
-        }
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
-            ip = request.getRemoteAddr();
-        }
-        System.out.println("获取客户端ip: " + ip);
-        return ip;
-    }
-}
+package com.ljsd.util;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class NetUtil {
+    /**
+     * 获得真实IP
+     * @param request
+     * @return
+     */
+    public static String getIpAddr(HttpServletRequest request) {
+        String ip = request.getHeader("x-forwarded-for");
+        if (ip != null && ip.length() != 0 && !"unknown".equalsIgnoreCase(ip)) {
+            // 多次反向代理后会有多个ip值,第一个ip才是真实ip
+            if( ip.indexOf(",")!=-1 ){
+                ip = ip.split(",")[0];
+            }
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("Proxy-Client-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("WL-Proxy-Client-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("HTTP_CLIENT_IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("HTTP_X_FORWARDED_FOR");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getHeader("X-Real-IP");
+        }
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
+            ip = request.getRemoteAddr();
+        }
+        System.out.println("获取客户端ip: " + ip);
+        return ip;
+    }
+}

+ 201 - 201
src/main/java/com/ljsd/util/StringUtils.java

@@ -1,201 +1,201 @@
-package com.ljsd.util;
-
-import org.apache.http.client.utils.DateUtils;
-
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.*;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class StringUtils {
-
-    public static boolean checkIsEmpty(String source) {
-        if (source == null || "".equals(source))
-            return true;
-        return false;
-    }
-
-    public static boolean checkIsNumberOrChar(String source) {
-        return source.matches("[a-zA-Z0-9]+");
-    }
-
-
-
-    public static boolean checkName(String str) {
-        Pattern pattern = Pattern.compile("[\\u4e00-\\u9fa5]+");
-        Matcher matcher = pattern.matcher(str);
-        return matcher.matches();
-    }
-
-    private static Map<String, String> cityCodeMap = new HashMap<String, String>() {
-        {
-            this.put("11", "北京");
-            this.put("12", "天津");
-            this.put("13", "河北");
-            this.put("14", "山西");
-            this.put("15", "内蒙古");
-            this.put("21", "辽宁");
-            this.put("22", "吉林");
-            this.put("23", "黑龙江");
-            this.put("31", "上海");
-            this.put("32", "江苏");
-            this.put("33", "浙江");
-            this.put("34", "安徽");
-            this.put("35", "福建");
-            this.put("36", "江西");
-            this.put("37", "山东");
-            this.put("41", "河南");
-            this.put("42", "湖北");
-            this.put("43", "湖南");
-            this.put("44", "广东");
-            this.put("45", "广西");
-            this.put("46", "海南");
-            this.put("50", "重庆");
-            this.put("51", "四川");
-            this.put("52", "贵州");
-            this.put("53", "云南");
-            this.put("54", "西藏");
-            this.put("61", "陕西");
-            this.put("62", "甘肃");
-            this.put("63", "青海");
-            this.put("64", "宁夏");
-            this.put("65", "新疆");
-            this.put("71", "台湾");
-            this.put("81", "香港");
-            this.put("82", "澳门");
-            this.put("91", "国外");
-        }
-    };
-    static String[] ValCodeArr = { "1", "0", "x", "9", "8", "7", "6", "5", "4","3", "2" }; //最后一位的校验码字符值
-    static String[] Wi = { "7", "9", "10", "5", "8", "4", "2", "1", "6", "3", "7","9", "10", "5", "8", "4", "2" };//十七位数字
-    /***
-     * 验证身份证
-     * @param idStr
-     * @return
-     */
-    public static boolean check(String idStr) {
-        try {
-            System.out.println("idStr:"+idStr);
-            if (null == idStr) {// 验证非空
-                System.out.println("身份证号码不能为空");
-                return false;
-            }
-            if (idStr.length() != 15 && idStr.length() != 18) {// 只能是15位或者18位
-                System.out.println("身份证号码长度只能是15位或者18位"+idStr);
-                return false;
-            }
-
-            String Ai = "";
-            if (idStr.length() == 18) {
-                Ai = idStr.substring(0, 17);
-            }
-
-            if (idStr.length() == 15) {//  将15位身份证转换为 17位身份证,最后加上最后一位,转换为18位身份证
-                // 15位身份证是没有校验位的,同时采用的是2位数字来表示出生年份,并且 15位的身份证号码确定都是19**年的
-                Ai = idStr.substring(0, 6) + "19" + idStr.substring(6, 15);
-            }
-            if (!isNumber(Ai)) { // 验证身份证前17位是否都是数字
-                System.out.println("身份证15位号码都应为数字 ; 18位号码除最后一位外,都应为数字。");
-                return false;
-            }
-
-            int year = Integer.parseInt(Ai.substring(6, 10));// 出生年份
-            int month = Integer.parseInt(Ai.substring(10, 12));// 出生月份
-            int day = Integer.parseInt(Ai.substring(12, 14));// 出生日期
-            String birthDay = year + "-" + month + "-" + day;
-
-            Date birthdate = null;
-            try {// 将出生日期转换为Date类型
-                birthdate = new SimpleDateFormat("yyyyMMdd").parse(birthDay);
-            } catch (ParseException e) {
-                e.printStackTrace();
-                System.out.println("身份证生日无效。");
-                return false;
-            }
-            if (birthdate == null || new Date().before(birthdate)) {
-                System.out.println("身份证生日无效。");
-                return false;
-            }
-
-            GregorianCalendar gc = new GregorianCalendar();//GregorianCalendar 是 Calendar 的一个具体子类,提供了世界上大多数国家/地区使用的标准日历系统。
-            SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
-            // 验证生日年份是否在范围之内
-            if ((gc.get(Calendar.YEAR) - year) > 150 || (gc.getTime().getTime() - s.parse(birthDay).getTime()) < 0) {
-                System.out.println("身份证生日不在有效范围。");
-                return false;
-            }
-
-            //验证月份
-            if (month > 12 || month <= 0) {
-                System.out.println("身份证号中的月份无效");
-                return false;
-            }
-
-            //验证日期
-            gc.setTime(birthdate);
-            boolean mflag = false;
-            switch (month) {
-                case 1:
-                case 3:
-                case 5:
-                case 7:
-                case 8:
-                case 10:
-                case 12:
-                    mflag = (day >= 1 && day <= 31);
-                    break;
-                case 2: // 公历的2月非闰年有28天,闰年的2月是29天。
-                    if (gc.isLeapYear(gc.get(Calendar.YEAR))) {
-                        mflag = (day >= 1 && day <= 29);
-                    } else {
-                        mflag = (day >= 1 && day <= 28);
-                    }
-                    break;
-                case 4:
-                case 6:
-                case 9:
-                case 11:
-                    mflag = (day >= 1 && day <= 30);
-                    break;
-            }
-            if (!mflag) {// 日期不对
-                System.out.println("省份证号中的出生日期不对");
-                return false;
-            }
-            // 验证 开头两位数是否是真实有效的地区编码
-            if (cityCodeMap.get(Ai.substring(0, 2)) == null) {
-                System.out.println("身份证地区编码错误。");
-                return false;
-            }
-
-            int TotalmulAiWi = 0;
-            for (int i = 0; i < 17; i++) {//先对前17位数字的权求和 ,使用十七位数字本体码加权求和公式   S = Sum(Ai * Wi)
-                TotalmulAiWi = TotalmulAiWi + Integer.parseInt(String.valueOf(Ai.charAt(i))) * Integer.parseInt(Wi[i]);
-            }
-            int modValue = TotalmulAiWi % 11;//计算模  Y = mod(S, 11) 用计算出来的结果除以11,这样就会出现
-            String strVerifyCode = ValCodeArr[modValue]; // 获取最后一位的校验码字符值
-            Ai = Ai + strVerifyCode; // 17位身份证 加上最后以为验证数字   得到18位有效的身份证号
-
-            if (!idStr.toUpperCase().equals(Ai.toUpperCase())) {// 判断传过来的身份证号 和 计算得到的身份证号是否相同
-                System.out.println(idStr.toUpperCase()+"身份证号码不对"+Ai.toUpperCase());
-                return false;
-            }
-            System.out.println("正确");
-            return true;
-        } catch (Exception e) {
-            System.out.println("验证出错");
-            e.printStackTrace();
-            return false;
-        }
-
-
-    }
-
-    private static boolean isNumber(String str) {
-        Pattern pattern = Pattern.compile("[0-9]*");
-        Matcher isNum = pattern.matcher(str);
-        return isNum.matches();
-    }
-
-}
+package com.ljsd.util;
+
+import org.apache.http.client.utils.DateUtils;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class StringUtils {
+
+    public static boolean checkIsEmpty(String source) {
+        if (source == null || "".equals(source))
+            return true;
+        return false;
+    }
+
+    public static boolean checkIsNumberOrChar(String source) {
+        return source.matches("[a-zA-Z0-9]+");
+    }
+
+
+
+    public static boolean checkName(String str) {
+        Pattern pattern = Pattern.compile("[\\u4e00-\\u9fa5]+");
+        Matcher matcher = pattern.matcher(str);
+        return matcher.matches();
+    }
+
+    private static Map<String, String> cityCodeMap = new HashMap<String, String>() {
+        {
+            this.put("11", "北京");
+            this.put("12", "天津");
+            this.put("13", "河北");
+            this.put("14", "山西");
+            this.put("15", "内蒙古");
+            this.put("21", "辽宁");
+            this.put("22", "吉林");
+            this.put("23", "黑龙江");
+            this.put("31", "上海");
+            this.put("32", "江苏");
+            this.put("33", "浙江");
+            this.put("34", "安徽");
+            this.put("35", "福建");
+            this.put("36", "江西");
+            this.put("37", "山东");
+            this.put("41", "河南");
+            this.put("42", "湖北");
+            this.put("43", "湖南");
+            this.put("44", "广东");
+            this.put("45", "广西");
+            this.put("46", "海南");
+            this.put("50", "重庆");
+            this.put("51", "四川");
+            this.put("52", "贵州");
+            this.put("53", "云南");
+            this.put("54", "西藏");
+            this.put("61", "陕西");
+            this.put("62", "甘肃");
+            this.put("63", "青海");
+            this.put("64", "宁夏");
+            this.put("65", "新疆");
+            this.put("71", "台湾");
+            this.put("81", "香港");
+            this.put("82", "澳门");
+            this.put("91", "国外");
+        }
+    };
+    static String[] ValCodeArr = { "1", "0", "x", "9", "8", "7", "6", "5", "4","3", "2" }; //最后一位的校验码字符值
+    static String[] Wi = { "7", "9", "10", "5", "8", "4", "2", "1", "6", "3", "7","9", "10", "5", "8", "4", "2" };//十七位数字
+    /***
+     * 验证身份证
+     * @param idStr
+     * @return
+     */
+    public static boolean check(String idStr) {
+        try {
+            System.out.println("idStr:"+idStr);
+            if (null == idStr) {// 验证非空
+                System.out.println("身份证号码不能为空");
+                return false;
+            }
+            if (idStr.length() != 15 && idStr.length() != 18) {// 只能是15位或者18位
+                System.out.println("身份证号码长度只能是15位或者18位"+idStr);
+                return false;
+            }
+
+            String Ai = "";
+            if (idStr.length() == 18) {
+                Ai = idStr.substring(0, 17);
+            }
+
+            if (idStr.length() == 15) {//  将15位身份证转换为 17位身份证,最后加上最后一位,转换为18位身份证
+                // 15位身份证是没有校验位的,同时采用的是2位数字来表示出生年份,并且 15位的身份证号码确定都是19**年的
+                Ai = idStr.substring(0, 6) + "19" + idStr.substring(6, 15);
+            }
+            if (!isNumber(Ai)) { // 验证身份证前17位是否都是数字
+                System.out.println("身份证15位号码都应为数字 ; 18位号码除最后一位外,都应为数字。");
+                return false;
+            }
+
+            int year = Integer.parseInt(Ai.substring(6, 10));// 出生年份
+            int month = Integer.parseInt(Ai.substring(10, 12));// 出生月份
+            int day = Integer.parseInt(Ai.substring(12, 14));// 出生日期
+            String birthDay = year + "-" + month + "-" + day;
+
+            Date birthdate = null;
+            try {// 将出生日期转换为Date类型
+                birthdate = new SimpleDateFormat("yyyyMMdd").parse(birthDay);
+            } catch (ParseException e) {
+                e.printStackTrace();
+                System.out.println("身份证生日无效。");
+                return false;
+            }
+            if (birthdate == null || new Date().before(birthdate)) {
+                System.out.println("身份证生日无效。");
+                return false;
+            }
+
+            GregorianCalendar gc = new GregorianCalendar();//GregorianCalendar 是 Calendar 的一个具体子类,提供了世界上大多数国家/地区使用的标准日历系统。
+            SimpleDateFormat s = new SimpleDateFormat("yyyy-MM-dd");
+            // 验证生日年份是否在范围之内
+            if ((gc.get(Calendar.YEAR) - year) > 150 || (gc.getTime().getTime() - s.parse(birthDay).getTime()) < 0) {
+                System.out.println("身份证生日不在有效范围。");
+                return false;
+            }
+
+            //验证月份
+            if (month > 12 || month <= 0) {
+                System.out.println("身份证号中的月份无效");
+                return false;
+            }
+
+            //验证日期
+            gc.setTime(birthdate);
+            boolean mflag = false;
+            switch (month) {
+                case 1:
+                case 3:
+                case 5:
+                case 7:
+                case 8:
+                case 10:
+                case 12:
+                    mflag = (day >= 1 && day <= 31);
+                    break;
+                case 2: // 公历的2月非闰年有28天,闰年的2月是29天。
+                    if (gc.isLeapYear(gc.get(Calendar.YEAR))) {
+                        mflag = (day >= 1 && day <= 29);
+                    } else {
+                        mflag = (day >= 1 && day <= 28);
+                    }
+                    break;
+                case 4:
+                case 6:
+                case 9:
+                case 11:
+                    mflag = (day >= 1 && day <= 30);
+                    break;
+            }
+            if (!mflag) {// 日期不对
+                System.out.println("省份证号中的出生日期不对");
+                return false;
+            }
+            // 验证 开头两位数是否是真实有效的地区编码
+            if (cityCodeMap.get(Ai.substring(0, 2)) == null) {
+                System.out.println("身份证地区编码错误。");
+                return false;
+            }
+
+            int TotalmulAiWi = 0;
+            for (int i = 0; i < 17; i++) {//先对前17位数字的权求和 ,使用十七位数字本体码加权求和公式   S = Sum(Ai * Wi)
+                TotalmulAiWi = TotalmulAiWi + Integer.parseInt(String.valueOf(Ai.charAt(i))) * Integer.parseInt(Wi[i]);
+            }
+            int modValue = TotalmulAiWi % 11;//计算模  Y = mod(S, 11) 用计算出来的结果除以11,这样就会出现
+            String strVerifyCode = ValCodeArr[modValue]; // 获取最后一位的校验码字符值
+            Ai = Ai + strVerifyCode; // 17位身份证 加上最后以为验证数字   得到18位有效的身份证号
+
+            if (!idStr.toUpperCase().equals(Ai.toUpperCase())) {// 判断传过来的身份证号 和 计算得到的身份证号是否相同
+                System.out.println(idStr.toUpperCase()+"身份证号码不对"+Ai.toUpperCase());
+                return false;
+            }
+            System.out.println("正确");
+            return true;
+        } catch (Exception e) {
+            System.out.println("验证出错");
+            e.printStackTrace();
+            return false;
+        }
+
+
+    }
+
+    private static boolean isNumber(String str) {
+        Pattern pattern = Pattern.compile("[0-9]*");
+        Matcher isNum = pattern.matcher(str);
+        return isNum.matches();
+    }
+
+}

+ 76 - 76
src/main/java/com/ljsd/util/TimeUtil.java

@@ -1,77 +1,77 @@
-package com.ljsd.util;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-
-
-/**
- * 时间的工具类
- */
-public class TimeUtil {
-
-    private static final Logger LOGGER = LoggerFactory.getLogger(TimeUtil.class);
-
-    private final static SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD hh:mm:ss");
-
-    public static void sleep(long millis) {
-        try {
-            Thread.sleep(millis);
-        } catch (Exception e) {
-            LOGGER.error("sleep->msg=null", e.getMessage(), e);
-        }
-    }
-
-    public static boolean inCorrectTime(String startTime, String endTime) throws Exception {
-        long now = System.currentTimeMillis();
-        long start = sdf.parse(startTime).getTime();
-        long end = sdf.parse(endTime).getTime();
-        if (now < start) {
-            return false;
-        }
-        if (now > end) {
-            return false;
-        }
-        return true;
-    }
-
-    public static long fixTime(String fixTime) {
-        String[] temp = fixTime.split(":");
-        int hour = Integer.parseInt(temp[0]);
-        int minute = Integer.parseInt(temp[1]);
-        int second = Integer.parseInt(temp[2]);
-
-        Calendar c = Calendar.getInstance();
-        c.set(Calendar.HOUR_OF_DAY, hour);
-        c.set(Calendar.MINUTE, minute);
-        c.set(Calendar.SECOND, second);
-        c.set(Calendar.MILLISECOND, 0);
-        return c.getTimeInMillis();
-    }
-
-    /**
-     * 获取周几
-     *
-     * @return
-     */
-    public static int getDayOfWeek() {
-        Calendar calendar = Calendar.getInstance();
-        calendar.setTimeInMillis(System.currentTimeMillis());
-        int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
-        return (week == 0) ? 7 : week;
-    }
-
-    /**
-     * 获取指定时间 周几
-     *
-     * @return
-     */
-    public static int getDayOfWeek(long time) {
-        Calendar calendar = Calendar.getInstance();
-        calendar.setTimeInMillis(time);
-        int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
-        return (week == 0) ? 7 : week;
-    }
+package com.ljsd.util;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+
+
+/**
+ * 时间的工具类
+ */
+public class TimeUtil {
+
+    private static final Logger LOGGER = LoggerFactory.getLogger(TimeUtil.class);
+
+    private final static SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-DD hh:mm:ss");
+
+    public static void sleep(long millis) {
+        try {
+            Thread.sleep(millis);
+        } catch (Exception e) {
+            LOGGER.error("sleep->msg=null", e.getMessage(), e);
+        }
+    }
+
+    public static boolean inCorrectTime(String startTime, String endTime) throws Exception {
+        long now = System.currentTimeMillis();
+        long start = sdf.parse(startTime).getTime();
+        long end = sdf.parse(endTime).getTime();
+        if (now < start) {
+            return false;
+        }
+        if (now > end) {
+            return false;
+        }
+        return true;
+    }
+
+    public static long fixTime(String fixTime) {
+        String[] temp = fixTime.split(":");
+        int hour = Integer.parseInt(temp[0]);
+        int minute = Integer.parseInt(temp[1]);
+        int second = Integer.parseInt(temp[2]);
+
+        Calendar c = Calendar.getInstance();
+        c.set(Calendar.HOUR_OF_DAY, hour);
+        c.set(Calendar.MINUTE, minute);
+        c.set(Calendar.SECOND, second);
+        c.set(Calendar.MILLISECOND, 0);
+        return c.getTimeInMillis();
+    }
+
+    /**
+     * 获取周几
+     *
+     * @return
+     */
+    public static int getDayOfWeek() {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeInMillis(System.currentTimeMillis());
+        int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
+        return (week == 0) ? 7 : week;
+    }
+
+    /**
+     * 获取指定时间 周几
+     *
+     * @return
+     */
+    public static int getDayOfWeek(long time) {
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTimeInMillis(time);
+        int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
+        return (week == 0) ? 7 : week;
+    }
 }

+ 42 - 42
src/main/resources/application.properties

@@ -1,42 +1,42 @@
-#mogodb服务地址
-#mongodb_url = mongodb://admin:123456@120.92.119.145:27020/?&authSource=admin
-#mongodb_url = mongodb://ljkji54$^fj5K:dk3$k8G5^a67@10.2.0.3:27020/?&authSource=admin
-#mongodb_url = mongodb://root:123456@10.255.255.4:27020/?&authSource=admin
-mongodb_url = mongodb://root:kjm2022&WH@10.0.0.92:27020/?&authSource=admin
-#mongodb_name = m5_tk_login
-#mongodb_name = m5_x1_login
-mongodb_name = x1_cn_test_login
-#与目标数据库可以建立的最大链接数
-mongodb_maximumNumberOfConnections = 100
-#与数据库建立链接的超时时间 2分钟
-mongodb_connectTimeout = 1200000
-#一个线程成功获取到一个可用数据库之前的最大等待时间 3秒
-mongodb_maxWaitTime = 30000
-#最多xx个线程等级一个链接,推荐配置为5
-mongodb_threadsAllowedToBlockForConnectionMultiplier = 5
-#最大空闲时间,为0时,表示没有限制
-mongodb_maxConnectionIdleTime = 0
-#最大生存时间,为0时,表示没有限制
-mongodb_maxConnectionLifeTime = 0
-#连接过期时间
-mongodb_socketTimeout = 0
-#连接保持活跃
-mongodb_socketKeepAlive = true
-
-
-#redis_host = 120.92.119.145
-#redis_host = 10.255.255.4
-redis_host = 127.0.0.1
-redis_port=6080
-redis_password=kjm2022@WH_redis
-#redis_password=@emiplay_m5fangzhi_redis
-redis_maxTotal = 10
-redis_minIdle = 3
-redis_maxWaitMillis = 20
-redis_maxIdle = 5
-redis_testOnBorrow = false
-
-isTestLan = 1
-
-#防沉迷开关
-openAdultCheck = false
+#mogodb服务地址
+#mongodb_url = mongodb://admin:123456@120.92.119.145:27020/?&authSource=admin
+#mongodb_url = mongodb://ljkji54$^fj5K:dk3$k8G5^a67@10.2.0.3:27020/?&authSource=admin
+#mongodb_url = mongodb://root:123456@10.255.255.4:27020/?&authSource=admin
+mongodb_url = mongodb://root:kjm2022&WH@10.0.0.92:27020/?&authSource=admin
+#mongodb_name = m5_tk_login
+#mongodb_name = m5_x1_login
+mongodb_name = x1_cn_test_login
+#与目标数据库可以建立的最大链接数
+mongodb_maximumNumberOfConnections = 100
+#与数据库建立链接的超时时间 2分钟
+mongodb_connectTimeout = 1200000
+#一个线程成功获取到一个可用数据库之前的最大等待时间 3秒
+mongodb_maxWaitTime = 30000
+#最多xx个线程等级一个链接,推荐配置为5
+mongodb_threadsAllowedToBlockForConnectionMultiplier = 5
+#最大空闲时间,为0时,表示没有限制
+mongodb_maxConnectionIdleTime = 0
+#最大生存时间,为0时,表示没有限制
+mongodb_maxConnectionLifeTime = 0
+#连接过期时间
+mongodb_socketTimeout = 0
+#连接保持活跃
+mongodb_socketKeepAlive = true
+
+
+#redis_host = 120.92.119.145
+#redis_host = 10.255.255.4
+redis_host = 127.0.0.1
+redis_port=6080
+redis_password=kjm2022@WH_redis
+#redis_password=@emiplay_m5fangzhi_redis
+redis_maxTotal = 10
+redis_minIdle = 3
+redis_maxWaitMillis = 20
+redis_maxIdle = 5
+redis_testOnBorrow = false
+
+isTestLan = 1
+
+#防沉迷开关
+openAdultCheck = false

+ 49 - 49
src/main/resources/logback.xml

@@ -1,50 +1,50 @@
-<configuration scan="true" scanPeriod="60 seconds">
-    <contextName>YSJLogging</contextName>
-
-    <property name="tip" value="INFO"/>
-
-    <!-- 定义日志文件 输入位置 -->
-    <property name="log_dir" value="../logs"/>
-    <!-- 日志最大的历史 30天 -->
-    <property name="maxHistory" value="30"/>
-
-    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
-        <encoder charset="UTF-8">
-            <pattern>[%level] - %d{yyyy-MM-dd HH:mm:ss.SSS} - [%thread] - %logger{0}#%line - ${tip}:%msg%n</pattern>
-        </encoder>
-        <filter class="ch.qos.logback.classic.filter.LevelFilter">
-            <level>INFO</level>
-            <onMatch>ACCEPT</onMatch>
-            <onMismatch>ACCEPT</onMismatch>
-        </filter>
-    </appender>
-
-    <appender name="file_console" class="ch.qos.logback.core.rolling.RollingFileAppender">
-        <!--<Encoding>UTF-8</Encoding>-->
-        <!-- 过滤器,只记录WARN级别的日志 -->
-        <encoder charset="UTF-8">
-            <pattern>[%level] - %d{yyyy-MM-dd HH:mm:ss.SSS} - [%thread] - %logger{0}#%line - ${tip}:%msg%n</pattern>
-        </encoder>
-        <!-- 最常用的滚动策略,它根据时间来制定滚动策略.既负责滚动也负责出发滚动 -->
-        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
-            <!--日志输出位置  可相对、和绝对路径 -->
-            <fileNamePattern>${log_dir}/%d{yyyy-MM-dd}.log</fileNamePattern>
-        </rollingPolicy>
-    </appender>
-
-    <logger name="org.mongodb.driver" level="ERROR"/>
-
-    <logger name="org.apache.commons.httpclient" level="WARN"/>
-
-
-    <root level="INFO">
-        <!-- 控制台输出 -->
-        <appender-ref ref="console"/>
-
-        <appender-ref ref="file_console"/>
-
-        <!--<appender-ref ref="TRACE" />-->
-
-    </root>
-
+<configuration scan="true" scanPeriod="60 seconds">
+    <contextName>YSJLogging</contextName>
+
+    <property name="tip" value="INFO"/>
+
+    <!-- 定义日志文件 输入位置 -->
+    <property name="log_dir" value="../logs"/>
+    <!-- 日志最大的历史 30天 -->
+    <property name="maxHistory" value="30"/>
+
+    <appender name="console" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder charset="UTF-8">
+            <pattern>[%level] - %d{yyyy-MM-dd HH:mm:ss.SSS} - [%thread] - %logger{0}#%line - ${tip}:%msg%n</pattern>
+        </encoder>
+        <filter class="ch.qos.logback.classic.filter.LevelFilter">
+            <level>INFO</level>
+            <onMatch>ACCEPT</onMatch>
+            <onMismatch>ACCEPT</onMismatch>
+        </filter>
+    </appender>
+
+    <appender name="file_console" class="ch.qos.logback.core.rolling.RollingFileAppender">
+        <!--<Encoding>UTF-8</Encoding>-->
+        <!-- 过滤器,只记录WARN级别的日志 -->
+        <encoder charset="UTF-8">
+            <pattern>[%level] - %d{yyyy-MM-dd HH:mm:ss.SSS} - [%thread] - %logger{0}#%line - ${tip}:%msg%n</pattern>
+        </encoder>
+        <!-- 最常用的滚动策略,它根据时间来制定滚动策略.既负责滚动也负责出发滚动 -->
+        <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
+            <!--日志输出位置  可相对、和绝对路径 -->
+            <fileNamePattern>${log_dir}/%d{yyyy-MM-dd}.log</fileNamePattern>
+        </rollingPolicy>
+    </appender>
+
+    <logger name="org.mongodb.driver" level="ERROR"/>
+
+    <logger name="org.apache.commons.httpclient" level="WARN"/>
+
+
+    <root level="INFO">
+        <!-- 控制台输出 -->
+        <appender-ref ref="console"/>
+
+        <appender-ref ref="file_console"/>
+
+        <!--<appender-ref ref="TRACE" />-->
+
+    </root>
+
 </configuration>

+ 149 - 149
src/main/webapp/WEB-INF/web.xml

@@ -1,150 +1,150 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
-         version="3.1">
-
-
-    <context-param>
-        <param-name>logbackConfigLocation</param-name>
-        <param-value>classpath:main/resources/logback.xml</param-value>
-    </context-param>
-
-    <servlet>
-        <servlet-name>index</servlet-name>
-        <servlet-class>com.ljsd.controller.IndexController</servlet-class>
-    </servlet>
-
-    <servlet-mapping>
-        <servlet-name>index</servlet-name>
-        <url-pattern>/index</url-pattern>
-    </servlet-mapping>
-
-    <servlet>
-        <servlet-name>updateNotice</servlet-name>
-        <servlet-class>com.ljsd.controller.RoutePublishNoticeController</servlet-class>
-    </servlet>
-
-    <servlet-mapping>
-        <servlet-name>updateNotice</servlet-name>
-        <url-pattern>/updateNotice</url-pattern>
-    </servlet-mapping>
-
-    <servlet>
-        <servlet-name>publishNotice</servlet-name>
-        <servlet-class>com.ljsd.controller.PublishNoticeController</servlet-class>
-    </servlet>
-
-    <servlet-mapping>
-        <servlet-name>publishNotice</servlet-name>
-        <url-pattern>/publishNotice</url-pattern>
-    </servlet-mapping>
-
-    <servlet>
-        <servlet-name>getNotice</servlet-name>
-        <servlet-class>com.ljsd.controller.GetNoticeController</servlet-class>
-    </servlet>
-
-    <servlet-mapping>
-        <servlet-name>getNotice</servlet-name>
-        <url-pattern>/getNotice</url-pattern>
-    </servlet-mapping>
-
-    <servlet>
-        <servlet-name>getServerList</servlet-name>
-        <servlet-class>com.ljsd.controller.GetServerListController</servlet-class>
-    </servlet>
-
-    <servlet-mapping>
-        <servlet-name>getServerList</servlet-name>
-        <url-pattern>/getServerList</url-pattern>
-    </servlet-mapping>
-
-    <servlet>
-        <servlet-name>regist</servlet-name>
-        <servlet-class>com.ljsd.controller.RegistController</servlet-class>
-    </servlet>
-
-    <servlet-mapping>
-        <servlet-name>regist</servlet-name>
-        <url-pattern>/regist</url-pattern>
-    </servlet-mapping>
-
-    <servlet>
-        <servlet-name>getUserInfo</servlet-name>
-        <servlet-class>com.ljsd.controller.GetUserController</servlet-class>
-    </servlet>
-
-    <servlet-mapping>
-        <servlet-name>getUserInfo</servlet-name>
-        <url-pattern>/getUserInfo</url-pattern>
-    </servlet-mapping>
-
-    <servlet>
-        <servlet-name>registerUser</servlet-name>
-        <servlet-class>com.ljsd.controller.UserRegisterController</servlet-class>
-    </servlet>
-
-    <servlet-mapping>
-        <servlet-name>registerUser</servlet-name>
-        <url-pattern>/registerUser</url-pattern>
-    </servlet-mapping>
-
-
-    <servlet>
-        <servlet-name>registerUserIDCard</servlet-name>
-        <servlet-class>com.ljsd.controller.UserRegisterIDCardController</servlet-class>
-    </servlet>
-
-    <servlet-mapping>
-        <servlet-name>registerUserIDCard</servlet-name>
-        <url-pattern>/registerUserIDCard</url-pattern>
-    </servlet-mapping>
-
-    <!--<servlet>-->
-        <!--<servlet-name>test</servlet-name>-->
-        <!--<servlet-class>com.ljsd.controller.TestController</servlet-class>-->
-    <!--</servlet>-->
-
-    <!--<servlet-mapping>-->
-        <!--<servlet-name>test</servlet-name>-->
-        <!--<url-pattern>/test1</url-pattern>-->
-    <!--</servlet-mapping>-->
-
-
-
-    <servlet>
-        <servlet-name>userLogin</servlet-name>
-        <servlet-class>com.ljsd.controller.UserLoginController</servlet-class>
-    </servlet>
-
-    <servlet-mapping>
-        <servlet-name>userLogin</servlet-name>
-        <url-pattern>/userLogin</url-pattern>
-    </servlet-mapping>
-
-    <servlet>
-        <servlet-name>serverList</servlet-name>
-        <servlet-class>com.ljsd.controller.ServerListController</servlet-class>
-    </servlet>
-    <servlet-mapping>
-        <servlet-name>serverList</servlet-name>
-        <url-pattern>/serverList</url-pattern>
-    </servlet-mapping>
-
-    <servlet>
-        <servlet-name>excelData</servlet-name>
-        <servlet-class>com.ljsd.controller.ExcelController</servlet-class>
-    </servlet>
-
-    <servlet-mapping>
-        <servlet-name>excelData</servlet-name>
-        <url-pattern>/excelData</url-pattern>
-    </servlet-mapping>
-
-
-    <listener>
-        <listener-class>com.ljsd.listener.WebContextListener</listener-class>
-    </listener>
-
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
+         version="3.1">
+
+
+    <context-param>
+        <param-name>logbackConfigLocation</param-name>
+        <param-value>classpath:main/resources/logback.xml</param-value>
+    </context-param>
+
+    <servlet>
+        <servlet-name>index</servlet-name>
+        <servlet-class>com.ljsd.controller.IndexController</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>index</servlet-name>
+        <url-pattern>/index</url-pattern>
+    </servlet-mapping>
+
+    <servlet>
+        <servlet-name>updateNotice</servlet-name>
+        <servlet-class>com.ljsd.controller.RoutePublishNoticeController</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>updateNotice</servlet-name>
+        <url-pattern>/updateNotice</url-pattern>
+    </servlet-mapping>
+
+    <servlet>
+        <servlet-name>publishNotice</servlet-name>
+        <servlet-class>com.ljsd.controller.PublishNoticeController</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>publishNotice</servlet-name>
+        <url-pattern>/publishNotice</url-pattern>
+    </servlet-mapping>
+
+    <servlet>
+        <servlet-name>getNotice</servlet-name>
+        <servlet-class>com.ljsd.controller.GetNoticeController</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>getNotice</servlet-name>
+        <url-pattern>/getNotice</url-pattern>
+    </servlet-mapping>
+
+    <servlet>
+        <servlet-name>getServerList</servlet-name>
+        <servlet-class>com.ljsd.controller.GetServerListController</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>getServerList</servlet-name>
+        <url-pattern>/getServerList</url-pattern>
+    </servlet-mapping>
+
+    <servlet>
+        <servlet-name>regist</servlet-name>
+        <servlet-class>com.ljsd.controller.RegistController</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>regist</servlet-name>
+        <url-pattern>/regist</url-pattern>
+    </servlet-mapping>
+
+    <servlet>
+        <servlet-name>getUserInfo</servlet-name>
+        <servlet-class>com.ljsd.controller.GetUserController</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>getUserInfo</servlet-name>
+        <url-pattern>/getUserInfo</url-pattern>
+    </servlet-mapping>
+
+    <servlet>
+        <servlet-name>registerUser</servlet-name>
+        <servlet-class>com.ljsd.controller.UserRegisterController</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>registerUser</servlet-name>
+        <url-pattern>/registerUser</url-pattern>
+    </servlet-mapping>
+
+
+    <servlet>
+        <servlet-name>registerUserIDCard</servlet-name>
+        <servlet-class>com.ljsd.controller.UserRegisterIDCardController</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>registerUserIDCard</servlet-name>
+        <url-pattern>/registerUserIDCard</url-pattern>
+    </servlet-mapping>
+
+    <!--<servlet>-->
+        <!--<servlet-name>test</servlet-name>-->
+        <!--<servlet-class>com.ljsd.controller.TestController</servlet-class>-->
+    <!--</servlet>-->
+
+    <!--<servlet-mapping>-->
+        <!--<servlet-name>test</servlet-name>-->
+        <!--<url-pattern>/test1</url-pattern>-->
+    <!--</servlet-mapping>-->
+
+
+
+    <servlet>
+        <servlet-name>userLogin</servlet-name>
+        <servlet-class>com.ljsd.controller.UserLoginController</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>userLogin</servlet-name>
+        <url-pattern>/userLogin</url-pattern>
+    </servlet-mapping>
+
+    <servlet>
+        <servlet-name>serverList</servlet-name>
+        <servlet-class>com.ljsd.controller.ServerListController</servlet-class>
+    </servlet>
+    <servlet-mapping>
+        <servlet-name>serverList</servlet-name>
+        <url-pattern>/serverList</url-pattern>
+    </servlet-mapping>
+
+    <servlet>
+        <servlet-name>excelData</servlet-name>
+        <servlet-class>com.ljsd.controller.ExcelController</servlet-class>
+    </servlet>
+
+    <servlet-mapping>
+        <servlet-name>excelData</servlet-name>
+        <url-pattern>/excelData</url-pattern>
+    </servlet-mapping>
+
+
+    <listener>
+        <listener-class>com.ljsd.listener.WebContextListener</listener-class>
+    </listener>
+
 </web-app>

+ 65 - 65
src/main/webapp/index.jsp

@@ -1,65 +1,65 @@
-<%--
-  Created by IntelliJ IDEA.
-  User: Lee
-  Date: 2018/11/9
-  Time: 11:29
-  To change this template use File | Settings | File Templates.
---%>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<html>
-<STYLE type="text/css">
-    #login {
-        width: 400px;
-        height: 280px;
-        position: absolute;
-        left: 50%;
-        top: 20%;
-        margin-left: -200px;
-        margin-top: -140px;
-        border: 1px;
-       /* background-color: #befff1;*/
-        align: center;
-    }
-
-    #form {
-        width: 300px;
-        height: 160px;
-        position: relative;
-        left: 50%;
-        top: 50%;
-        margin-left: -150px;
-        margin-top: -80px;
-    }
-</STYLE>
-
-<head>
-    <title>《戒灵》添加服务器</title>
-</head>
-<body>
-<div id="login">
-    <h1 style="color: #000000" onresize="50">《戒灵》添加服务器</h1>
-    <div id="form">
-        <form action="regist" method="post" accept-charset="UTF-8">
-            <p>name: <input type="text" name="name" placeholder="请输入游戏服务器名字" required /></p>
-            <p>ip: <input type="text" name="ip" pattern="(\d+)\.(\d+)\.(\d+)\.(\d+)" placeholder="请输入服务器IP地址" required /></p>
-            <p>port: <input type="text" value="9000" name="port" pattern="[0-9]{0,6}" placeholder="请输入端口号" required /></p>
-            <p>server_id: <input type="text" name="server_id" pattern="[0-9]{0,6}" placeholder="请输入server id" required />  </p>
-            <p>channel:<select name="channel">
-                <option value="pc" selected>pc</option>
-                <option value="qq">qq</option>
-                <option value="wx">wx</option>
-            </select></p>
-            <p>sub_channel: <input type="text" name="sub_channel" required /></p>
-            <p>plat:<select name="plat">
-                <option value="android" selected>android</option>
-                <option value="ios">ios</option>
-            </select></p>
-            <p>state: <input type="text" value="0" name="state"  /></p>
-            <p>open_time: <input type="text" value="0" name="open_time" /></p>
-            <p>isnew: <input type="text" value="0" name="isnew" /></p>
-            <input type="submit" value="Submit"/>
-        </form>
-    </div>
-</div>
-</body>
-</html>
+<%--
+  Created by IntelliJ IDEA.
+  User: Lee
+  Date: 2018/11/9
+  Time: 11:29
+  To change this template use File | Settings | File Templates.
+--%>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<STYLE type="text/css">
+    #login {
+        width: 400px;
+        height: 280px;
+        position: absolute;
+        left: 50%;
+        top: 20%;
+        margin-left: -200px;
+        margin-top: -140px;
+        border: 1px;
+       /* background-color: #befff1;*/
+        align: center;
+    }
+
+    #form {
+        width: 300px;
+        height: 160px;
+        position: relative;
+        left: 50%;
+        top: 50%;
+        margin-left: -150px;
+        margin-top: -80px;
+    }
+</STYLE>
+
+<head>
+    <title>《戒灵》添加服务器</title>
+</head>
+<body>
+<div id="login">
+    <h1 style="color: #000000" onresize="50">《戒灵》添加服务器</h1>
+    <div id="form">
+        <form action="regist" method="post" accept-charset="UTF-8">
+            <p>name: <input type="text" name="name" placeholder="请输入游戏服务器名字" required /></p>
+            <p>ip: <input type="text" name="ip" pattern="(\d+)\.(\d+)\.(\d+)\.(\d+)" placeholder="请输入服务器IP地址" required /></p>
+            <p>port: <input type="text" value="9000" name="port" pattern="[0-9]{0,6}" placeholder="请输入端口号" required /></p>
+            <p>server_id: <input type="text" name="server_id" pattern="[0-9]{0,6}" placeholder="请输入server id" required />  </p>
+            <p>channel:<select name="channel">
+                <option value="pc" selected>pc</option>
+                <option value="qq">qq</option>
+                <option value="wx">wx</option>
+            </select></p>
+            <p>sub_channel: <input type="text" name="sub_channel" required /></p>
+            <p>plat:<select name="plat">
+                <option value="android" selected>android</option>
+                <option value="ios">ios</option>
+            </select></p>
+            <p>state: <input type="text" value="0" name="state"  /></p>
+            <p>open_time: <input type="text" value="0" name="open_time" /></p>
+            <p>isnew: <input type="text" value="0" name="isnew" /></p>
+            <input type="submit" value="Submit"/>
+        </form>
+    </div>
+</div>
+</body>
+</html>

+ 57 - 57
src/main/webapp/list.jsp

@@ -1,58 +1,58 @@
-<%@ page import="com.ljsd.util.BaseGlobal" %>
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<%
-    String serverInfoList = BaseGlobal.getInstance().mongoDBPool.findList("server_info");
-
-%>
-<html>
-<title>戒灵服务器列表</title>
-</head>
-<body>
-<h1>戒灵服务器列表</h1>
-<table id="table" border="1" cellspacing="0" cellpadding="15" >
-    <tr>
-        <th>_id</th>
-        <th>name</th>
-        <th>ip</th>
-        <th>port</th>
-        <th>server_id</th>
-        <th>channel</th>
-        <th>sub_channel</th>
-        <th>plat</th>
-        <th>state</th>
-        <th>open_time</th>
-    </tr>
-</table>
-<script>
-    window.onload=function(){
-        var data=<%=serverInfoList%>;
-
-
-        var table=document.getElementById("table");
-        for(var i=0;i<data.length;i++){
-            var row=table.insertRow(table.rows.length);
-            var c1=row.insertCell(0);
-            c1.innerHTML=data[i]._id;
-            var c2=row.insertCell(1);
-            c2.innerHTML=data[i].name;
-            var c3=row.insertCell(2);
-            c3.innerHTML=data[i].ip;
-            var c4=row.insertCell(3);
-            c4.innerHTML=data[i].port;
-            var c5=row.insertCell(4);
-            c5.innerHTML=data[i].server_id;
-            var c5=row.insertCell(5);
-            c5.innerHTML=data[i].channel;
-            var c5=row.insertCell(6);
-            c5.innerHTML=data[i].sub_channel;
-            var c5=row.insertCell(7);
-            c5.innerHTML=data[i].plat;
-            var c5=row.insertCell(8);
-            c5.innerHTML=data[i].state;
-            var c5=row.insertCell(9);
-            c5.innerHTML=data[i].open_time;
-        }
-    }
-</script>
-</body>
+<%@ page import="com.ljsd.util.BaseGlobal" %>
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<%
+    String serverInfoList = BaseGlobal.getInstance().mongoDBPool.findList("server_info");
+
+%>
+<html>
+<title>戒灵服务器列表</title>
+</head>
+<body>
+<h1>戒灵服务器列表</h1>
+<table id="table" border="1" cellspacing="0" cellpadding="15" >
+    <tr>
+        <th>_id</th>
+        <th>name</th>
+        <th>ip</th>
+        <th>port</th>
+        <th>server_id</th>
+        <th>channel</th>
+        <th>sub_channel</th>
+        <th>plat</th>
+        <th>state</th>
+        <th>open_time</th>
+    </tr>
+</table>
+<script>
+    window.onload=function(){
+        var data=<%=serverInfoList%>;
+
+
+        var table=document.getElementById("table");
+        for(var i=0;i<data.length;i++){
+            var row=table.insertRow(table.rows.length);
+            var c1=row.insertCell(0);
+            c1.innerHTML=data[i]._id;
+            var c2=row.insertCell(1);
+            c2.innerHTML=data[i].name;
+            var c3=row.insertCell(2);
+            c3.innerHTML=data[i].ip;
+            var c4=row.insertCell(3);
+            c4.innerHTML=data[i].port;
+            var c5=row.insertCell(4);
+            c5.innerHTML=data[i].server_id;
+            var c5=row.insertCell(5);
+            c5.innerHTML=data[i].channel;
+            var c5=row.insertCell(6);
+            c5.innerHTML=data[i].sub_channel;
+            var c5=row.insertCell(7);
+            c5.innerHTML=data[i].plat;
+            var c5=row.insertCell(8);
+            c5.innerHTML=data[i].state;
+            var c5=row.insertCell(9);
+            c5.innerHTML=data[i].open_time;
+        }
+    }
+</script>
+</body>
 </html>

+ 44 - 44
src/main/webapp/updateNotice.jsp

@@ -1,44 +1,44 @@
-
-<%@ page contentType="text/html;charset=UTF-8" language="java" %>
-<html>
-<STYLE type="text/css">
-    #publish {
-        width: 400px;
-        height: 280px;
-        position: absolute;
-        left: 50%;
-        top: 20%;
-        margin-left: -200px;
-        margin-top: -140px;
-        border: 1px;
-       /* background-color: #befff1;*/
-        align: center;
-    }
-
-    #form {
-        width: 300px;
-        height: 160px;
-        position: relative;
-        left: 50%;
-        top: 50%;
-        margin-left: -150px;
-        margin-top: -80px;
-    }
-</STYLE>
-
-<head>
-    <title>《戒灵》发布公告</title>
-</head>
-<body>
-<div id="publish">
-    <h1 style="color: #000000" onresize="50">《戒灵》发布公告</h1>
-    <div id="form">
-        <form action="publishNotice" method="post" accept-charset="UTF-8">
-            <p>name: <input type="text" name="title" placeholder="游戏公告标题" required /></p>
-            <p>name: <input type="text" name="content" placeholder="游戏公告内容" required /></p>
-            <input type="submit" value="Submit"/>
-        </form>
-    </div>
-</div>
-</body>
-</html>
+
+<%@ page contentType="text/html;charset=UTF-8" language="java" %>
+<html>
+<STYLE type="text/css">
+    #publish {
+        width: 400px;
+        height: 280px;
+        position: absolute;
+        left: 50%;
+        top: 20%;
+        margin-left: -200px;
+        margin-top: -140px;
+        border: 1px;
+       /* background-color: #befff1;*/
+        align: center;
+    }
+
+    #form {
+        width: 300px;
+        height: 160px;
+        position: relative;
+        left: 50%;
+        top: 50%;
+        margin-left: -150px;
+        margin-top: -80px;
+    }
+</STYLE>
+
+<head>
+    <title>《戒灵》发布公告</title>
+</head>
+<body>
+<div id="publish">
+    <h1 style="color: #000000" onresize="50">《戒灵》发布公告</h1>
+    <div id="form">
+        <form action="publishNotice" method="post" accept-charset="UTF-8">
+            <p>name: <input type="text" name="title" placeholder="游戏公告标题" required /></p>
+            <p>name: <input type="text" name="content" placeholder="游戏公告内容" required /></p>
+            <input type="submit" value="Submit"/>
+        </form>
+    </div>
+</div>
+</body>
+</html>