xushili 1 yıl önce
ebeveyn
işleme
ce2a69efcb
100 değiştirilmiş dosya ile 2500 ekleme ve 3586 silme
  1. 24 17
      README.md
  2. 4 4
      pom.xml
  3. 0 1
      ruoyi-admin/src/main/java/com/ruoyi/RuoYiApp.java
  4. 0 3
      ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java
  5. 25 13
      ruoyi-admin/src/main/java/com/ruoyi/web/runner/LoadDataSourceRunner.java
  6. 4 1
      ruoyi-admin/src/main/resources/static/assets/index-s7f4Etvv.css
  7. 217 215
      ruoyi-admin/src/main/resources/static/index.html
  8. 20 49
      ruoyi-admin/src/test/java/com/ruoyi/UcpAppTests.java
  9. 7 7
      ruoyi-common/pom.xml
  10. 5 10
      ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java
  11. 4 8
      ruoyi-common/src/main/java/com/ruoyi/common/annotation/RateLimiter.java
  12. 3 10
      ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java
  13. 39 42
      ruoyi-common/src/main/java/com/ruoyi/common/config/RuoYiConfig.java
  14. 2 3
      ruoyi-common/src/main/java/com/ruoyi/common/constant/HttpStatus.java
  15. 20 14
      ruoyi-common/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java
  16. 54 21
      ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java
  17. 26 39
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/R.java
  18. 27 28
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeEntity.java
  19. 24 27
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java
  20. 85 85
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java
  21. 70 71
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java
  22. 40 40
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java
  23. 110 110
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java
  24. 94 98
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java
  25. 127 129
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java
  26. 10 19
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java
  27. 42 75
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java
  28. 2 3
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/RegisterBody.java
  29. 33 41
      ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java
  30. 26 29
      ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java
  31. 4 7
      ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java
  32. 40 65
      ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java
  33. 15 31
      ruoyi-common/src/main/java/com/ruoyi/common/core/text/StrFormatter.java
  34. 7 11
      ruoyi-common/src/main/java/com/ruoyi/common/enums/HttpMethod.java
  35. 1 2
      ruoyi-common/src/main/java/com/ruoyi/common/enums/LimitType.java
  36. 2 3
      ruoyi-common/src/main/java/com/ruoyi/common/enums/OperatorType.java
  37. 5 9
      ruoyi-common/src/main/java/com/ruoyi/common/enums/UserStatus.java
  38. 11 20
      ruoyi-common/src/main/java/com/ruoyi/common/exception/ServiceException.java
  39. 5 9
      ruoyi-common/src/main/java/com/ruoyi/common/exception/UtilException.java
  40. 14 27
      ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java
  41. 6 11
      ruoyi-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java
  42. 3 5
      ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserException.java
  43. 3 5
      ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserNotExistsException.java
  44. 3 5
      ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java
  45. 4 6
      ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordRetryLimitExceedException.java
  46. 5 9
      ruoyi-common/src/main/java/com/ruoyi/common/filter/PropertyPreExcludeFilter.java
  47. 13 25
      ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java
  48. 18 27
      ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java
  49. 16 29
      ruoyi-common/src/main/java/com/ruoyi/common/filter/XssFilter.java
  50. 25 39
      ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java
  51. 4 7
      ruoyi-common/src/main/java/com/ruoyi/common/utils/LogUtils.java
  52. 4 6
      ruoyi-common/src/main/java/com/ruoyi/common/utils/MessageUtils.java
  53. 9 15
      ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java
  54. 24 45
      ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java
  55. 43 72
      ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java
  56. 137 229
      ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java
  57. 21 47
      ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java
  58. 22 41
      ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java
  59. 11 14
      ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java
  60. 72 145
      ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java
  61. 11 22
      ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java
  62. 54 118
      ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java
  63. 68 126
      ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/IpUtils.java
  64. 76 162
      ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java
  65. 13 25
      ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Md5Utils.java
  66. 19 36
      ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java
  67. 9 17
      ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java
  68. 10 15
      ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/IdUtils.java
  69. 14 20
      ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/Seq.java
  70. 60 103
      ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/UUID.java
  71. 5 6
      ruoyi-common/src/main/java/com/ruoyi/common/xss/Xss.java
  72. 6 9
      ruoyi-common/src/main/java/com/ruoyi/common/xss/XssValidator.java
  73. 1 1
      ruoyi-framework/pom.xml
  74. 60 90
      ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java
  75. 19 30
      ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java
  76. 11 23
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java
  77. 6 10
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java
  78. 12 14
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java
  79. 12 17
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
  80. 8 10
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java
  81. 6 10
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/ThreadPoolConfig.java
  82. 10 18
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/PermitAllUrlProperties.java
  83. 13 19
      ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java
  84. 19 28
      ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java
  85. 6 11
      ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java
  86. 5 8
      ruoyi-framework/src/main/java/com/ruoyi/framework/security/context/PermissionContextHolder.java
  87. 14 16
      ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java
  88. 14 16
      ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java
  89. 32 61
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java
  90. 20 36
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java
  91. 9 17
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java
  92. 12 23
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java
  93. 16 31
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java
  94. 37 54
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java
  95. 35 57
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java
  96. 18 28
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPasswordService.java
  97. 19 31
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPermissionService.java
  98. 22 42
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysRegisterService.java
  99. 28 48
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java
  100. 0 0
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java

Dosya farkı çok büyük olduğundan ihmal edildi
+ 24 - 17
README.md


+ 4 - 4
pom.xml

@@ -2,8 +2,8 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
-	<modelVersion>4.0.0</modelVersion>
-	
+    <modelVersion>4.0.0</modelVersion>
+
     <groupId>com.ruoyi</groupId>
     <artifactId>ruoyi</artifactId>
     <version>3.8.5</version>
@@ -11,7 +11,7 @@
     <name>ruoyi</name>
     <url>http://www.ruoyi.vip</url>
     <description>若依管理系统</description>
-    
+
     <properties>
         <ruoyi.version>3.8.5</ruoyi.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
@@ -31,7 +31,7 @@
         <velocity.version>2.3</velocity.version>
         <jwt.version>0.9.1</jwt.version>
     </properties>
-	
+
     <!-- 依赖声明 -->
     <dependencyManagement>
         <dependencies>

+ 0 - 1
ruoyi-admin/src/main/java/com/ruoyi/RuoYiApp.java

@@ -5,7 +5,6 @@ import org.springframework.boot.SpringApplication;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
 import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
 import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.cloud.openfeign.EnableFeignClients;
 
 /**
  * 启动程序

+ 0 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java

@@ -1,8 +1,5 @@
 package com.ruoyi.web.core.config;
 
-import com.baomidou.mybatisplus.core.incrementer.IKeyGenerator;
-import com.baomidou.mybatisplus.extension.incrementer.H2KeyGenerator;
-import com.baomidou.mybatisplus.extension.incrementer.PostgreKeyGenerator;
 import com.ruoyi.common.config.RuoYiConfig;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.models.auth.In;

+ 25 - 13
ruoyi-admin/src/main/java/com/ruoyi/web/runner/LoadDataSourceRunner.java

@@ -2,38 +2,32 @@ package com.ruoyi.web.runner;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.io.file.FileReader;
-import cn.hutool.core.io.resource.ResourceUtil;
 import com.alibaba.druid.pool.DruidDataSource;
 import com.alibaba.fastjson2.JSON;
-import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.TypeReference;
 import com.ruoyi.framework.datasource.DynamicDataSource;
 import com.ruoyi.quartz.glue.GlueFactory;
+import com.ruoyi.quartz.handler.IJobHandler;
 import com.ruoyi.quartz.handler.impl.MyJobHandler;
-import com.ruoyi.quartz.task.ChangedSave;
 import com.ruoyi.ucp.entity.Formula;
 import com.ruoyi.ucp.entity.Method;
-import com.ruoyi.ucp.entity.ProEconWtCurveFittingMonth;
+import com.ruoyi.ucp.entity.ProBasicModelPowerRd;
 import com.ruoyi.ucp.entity.UcpDataSource;
 import com.ruoyi.ucp.feign.AdapterApi;
-import com.ruoyi.quartz.handler.IJobHandler;
 import com.ruoyi.ucp.service.*;
 import com.ruoyi.ucp.util.CalcCache;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.CommandLineRunner;
-import org.springframework.boot.system.ApplicationHome;
 import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.Resource;
 import java.io.File;
-import java.io.InputStream;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
-import java.util.stream.Collectors;
 
 @Component
 public class LoadDataSourceRunner implements CommandLineRunner {
@@ -78,10 +72,10 @@ public class LoadDataSourceRunner implements CommandLineRunner {
 
         List<Method> methods = methodService.list();
         List<Formula> formulas = formulaService.list();
-//        String functionCode = GlueFactory.getFunctionTemplate();
+        //        String functionCode = GlueFactory.getFunctionTemplate();
         String jarPath = path + "FunctionTemplate.java";
         String functionCode = FileReader.create(new File(jarPath)).readString();
-//        String functionCode = ResourceUtil.readUtf8Str("FunctionTemplate.java");
+        //        String functionCode = ResourceUtil.readUtf8Str("FunctionTemplate.java");
         try {
             for (Method method : methods) {
                 //engine.eval(method.getMethodExpression());
@@ -103,7 +97,7 @@ public class LoadDataSourceRunner implements CommandLineRunner {
         redisTemplate.setConnectionFactory(factory);
         factory.afterPropertiesSet();
         factory.resetConnection();
-        Set<String> keys = redisTemplate.keys("monthCurve_*");
+        /*Set<String> keys = redisTemplate.keys("monthCurve_*");
         for (String key : keys) {
             //redis缓存中获取到字符串
             JSONArray o = (JSONArray) redisTemplate.opsForValue().get(key);
@@ -113,9 +107,27 @@ public class LoadDataSourceRunner implements CommandLineRunner {
 //            List<ProEconWtCurveFittingMonth> powerList = JSONObject.parseObject((String) o, new TypeReference<List<ProEconWtCurveFittingMonth>>() {});
             Map<Double, Double> collect = powerList.stream().collect(Collectors.toMap(ProEconWtCurveFittingMonth::getSpeed, ProEconWtCurveFittingMonth::getActualPower,(v1,v2)->v1));
             CalcCache.wtMcfMap.put(powerList.get(0).getWindturbineId(), collect);
-        }
+        }*/
+
+        String zllgl = (String) redisTemplate.opsForValue().get("ZLLGL");
+        //字符串类型转换为list月拟合曲线集合
+        Map<String, Map<Double, ProBasicModelPowerRd>> bzgl = JSON.parseObject(zllgl, new TypeReference<Map<String, Map<Double, ProBasicModelPowerRd>>>() {
+        }.getType());
+        Map<String, Map<Double, Double>> bz = new HashMap<>();
+        bzgl.forEach((modeId, map) -> {
+            Map<Double, Double> mdd = new HashMap<>();
+            map.forEach((speed, mprd) -> {
+                mdd.put(speed, mprd.getEnsurePower());
+            });
+            bz.put(modeId, mdd);
+        });
+        CalcCache.bzgl = bz;
+
         factory.setDatabase(database);
         factory.afterPropertiesSet();
         factory.resetConnection();
+        String glqxnh = (String) redisTemplate.opsForValue().get("glqxnh");
+        CalcCache.fitcoef = JSON.parseObject(glqxnh, new TypeReference<Map<String, double[]>>() {
+        }.getType());
     }
 }

+ 4 - 1
ruoyi-admin/src/main/resources/static/assets/index-s7f4Etvv.css

@@ -1 +1,4 @@
-.run-all-script[data-v-4d476186]{position:absolute;right:120px}
+.run-all-script[data-v-4d476186] {
+    position: absolute;
+    right: 120px
+}

+ 217 - 215
ruoyi-admin/src/main/resources/static/index.html

@@ -1,216 +1,218 @@
-<!DOCTYPE html>
-<html>
-
-<head>
-  <meta charset="utf-8">
-  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
-  <meta name="renderer" content="webkit">
-  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
-  <link rel="icon" href="/assets/logo-tUHuhCm6.png">
-  <title>风光计算平台</title>
-  <!--[if lt IE 11]><script>window.location.href='/html/ie.html';</script><![endif]-->
-  <style>
-    html,
-    body,
-    #app {
-      height: 100%;
-      margin: 0px;
-      padding: 0px;
-    }
-
-    .chromeframe {
-      margin: 0.2em 0;
-      background: #ccc;
-      color: #000;
-      padding: 0.2em 0;
-    }
-
-    #loader-wrapper {
-      position: fixed;
-      top: 0;
-      left: 0;
-      width: 100%;
-      height: 100%;
-      z-index: 999999;
-    }
-
-    #loader {
-      display: block;
-      position: relative;
-      left: 50%;
-      top: 50%;
-      width: 150px;
-      height: 150px;
-      margin: -75px 0 0 -75px;
-      border-radius: 50%;
-      border: 3px solid transparent;
-      border-top-color: #FFF;
-      -webkit-animation: spin 2s linear infinite;
-      -ms-animation: spin 2s linear infinite;
-      -moz-animation: spin 2s linear infinite;
-      -o-animation: spin 2s linear infinite;
-      animation: spin 2s linear infinite;
-      z-index: 1001;
-    }
-
-    #loader:before {
-      content: "";
-      position: absolute;
-      top: 5px;
-      left: 5px;
-      right: 5px;
-      bottom: 5px;
-      border-radius: 50%;
-      border: 3px solid transparent;
-      border-top-color: #FFF;
-      -webkit-animation: spin 3s linear infinite;
-      -moz-animation: spin 3s linear infinite;
-      -o-animation: spin 3s linear infinite;
-      -ms-animation: spin 3s linear infinite;
-      animation: spin 3s linear infinite;
-    }
-
-    #loader:after {
-      content: "";
-      position: absolute;
-      top: 15px;
-      left: 15px;
-      right: 15px;
-      bottom: 15px;
-      border-radius: 50%;
-      border: 3px solid transparent;
-      border-top-color: #FFF;
-      -moz-animation: spin 1.5s linear infinite;
-      -o-animation: spin 1.5s linear infinite;
-      -ms-animation: spin 1.5s linear infinite;
-      -webkit-animation: spin 1.5s linear infinite;
-      animation: spin 1.5s linear infinite;
-    }
-
-
-    @-webkit-keyframes spin {
-      0% {
-        -webkit-transform: rotate(0deg);
-        -ms-transform: rotate(0deg);
-        transform: rotate(0deg);
-      }
-
-      100% {
-        -webkit-transform: rotate(360deg);
-        -ms-transform: rotate(360deg);
-        transform: rotate(360deg);
-      }
-    }
-
-    @keyframes spin {
-      0% {
-        -webkit-transform: rotate(0deg);
-        -ms-transform: rotate(0deg);
-        transform: rotate(0deg);
-      }
-
-      100% {
-        -webkit-transform: rotate(360deg);
-        -ms-transform: rotate(360deg);
-        transform: rotate(360deg);
-      }
-    }
-
-
-    #loader-wrapper .loader-section {
-      position: fixed;
-      top: 0;
-      width: 51%;
-      height: 100%;
-      background: #7171C6;
-      z-index: 1000;
-      -webkit-transform: translateX(0);
-      -ms-transform: translateX(0);
-      transform: translateX(0);
-    }
-
-    #loader-wrapper .loader-section.section-left {
-      left: 0;
-    }
-
-    #loader-wrapper .loader-section.section-right {
-      right: 0;
-    }
-
-
-    .loaded #loader-wrapper .loader-section.section-left {
-      -webkit-transform: translateX(-100%);
-      -ms-transform: translateX(-100%);
-      transform: translateX(-100%);
-      -webkit-transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1.000);
-      transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1.000);
-    }
-
-    .loaded #loader-wrapper .loader-section.section-right {
-      -webkit-transform: translateX(100%);
-      -ms-transform: translateX(100%);
-      transform: translateX(100%);
-      -webkit-transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1.000);
-      transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1.000);
-    }
-
-    .loaded #loader {
-      opacity: 0;
-      -webkit-transition: all 0.3s ease-out;
-      transition: all 0.3s ease-out;
-    }
-
-    .loaded #loader-wrapper {
-      visibility: hidden;
-      -webkit-transform: translateY(-100%);
-      -ms-transform: translateY(-100%);
-      transform: translateY(-100%);
-      -webkit-transition: all 0.3s 1s ease-out;
-      transition: all 0.3s 1s ease-out;
-    }
-
-    .no-js #loader-wrapper {
-      display: none;
-    }
-
-    .no-js h1 {
-      color: #222222;
-    }
-
-    #loader-wrapper .load_title {
-      font-family: 'Open Sans';
-      color: #FFF;
-      font-size: 19px;
-      width: 100%;
-      text-align: center;
-      z-index: 9999999999999;
-      position: absolute;
-      top: 60%;
-      opacity: 1;
-      line-height: 30px;
-    }
-
-    #loader-wrapper .load_title span {
-      font-weight: normal;
-      font-style: italic;
-      font-size: 13px;
-      color: #FFF;
-      opacity: 0.5;
-    }
-  </style>
-  <script type="module" crossorigin src="/assets/index-TnLvmlMR.js"></script>
-  <link rel="stylesheet" crossorigin href="/assets/index-hae3yAhb.css">
-</head>
-
-<body>
-  <div id="app">
-    <div id="loader-wrapper">
-      <div id="loader"></div>
-      <div class="loader-section section-left"></div>
-      <div class="loader-section section-right"></div>
-      <div class="load_title">正在加载系统资源,请耐心等待</div>
-    </div>
-  </div>

-</body>
-
+<!DOCTYPE html>
+<html>
+
+<head>
+    <meta charset="utf-8">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <meta name="renderer" content="webkit">
+    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
+    <link rel="icon" href="/assets/logo-tUHuhCm6.png">
+    <title>风光计算平台</title>
+    <!--[if lt IE 11]>
+    <script>window.location.href='/html/ie.html';</script><![endif]-->
+    <style>
+        html,
+        body,
+        #app {
+            height: 100%;
+            margin: 0px;
+            padding: 0px;
+        }
+
+        .chromeframe {
+            margin: 0.2em 0;
+            background: #ccc;
+            color: #000;
+            padding: 0.2em 0;
+        }
+
+        #loader-wrapper {
+            position: fixed;
+            top: 0;
+            left: 0;
+            width: 100%;
+            height: 100%;
+            z-index: 999999;
+        }
+
+        #loader {
+            display: block;
+            position: relative;
+            left: 50%;
+            top: 50%;
+            width: 150px;
+            height: 150px;
+            margin: -75px 0 0 -75px;
+            border-radius: 50%;
+            border: 3px solid transparent;
+            border-top-color: #FFF;
+            -webkit-animation: spin 2s linear infinite;
+            -ms-animation: spin 2s linear infinite;
+            -moz-animation: spin 2s linear infinite;
+            -o-animation: spin 2s linear infinite;
+            animation: spin 2s linear infinite;
+            z-index: 1001;
+        }
+
+        #loader:before {
+            content: "";
+            position: absolute;
+            top: 5px;
+            left: 5px;
+            right: 5px;
+            bottom: 5px;
+            border-radius: 50%;
+            border: 3px solid transparent;
+            border-top-color: #FFF;
+            -webkit-animation: spin 3s linear infinite;
+            -moz-animation: spin 3s linear infinite;
+            -o-animation: spin 3s linear infinite;
+            -ms-animation: spin 3s linear infinite;
+            animation: spin 3s linear infinite;
+        }
+
+        #loader:after {
+            content: "";
+            position: absolute;
+            top: 15px;
+            left: 15px;
+            right: 15px;
+            bottom: 15px;
+            border-radius: 50%;
+            border: 3px solid transparent;
+            border-top-color: #FFF;
+            -moz-animation: spin 1.5s linear infinite;
+            -o-animation: spin 1.5s linear infinite;
+            -ms-animation: spin 1.5s linear infinite;
+            -webkit-animation: spin 1.5s linear infinite;
+            animation: spin 1.5s linear infinite;
+        }
+
+
+        @-webkit-keyframes spin {
+            0% {
+                -webkit-transform: rotate(0deg);
+                -ms-transform: rotate(0deg);
+                transform: rotate(0deg);
+            }
+
+            100% {
+                -webkit-transform: rotate(360deg);
+                -ms-transform: rotate(360deg);
+                transform: rotate(360deg);
+            }
+        }
+
+        @keyframes spin {
+            0% {
+                -webkit-transform: rotate(0deg);
+                -ms-transform: rotate(0deg);
+                transform: rotate(0deg);
+            }
+
+            100% {
+                -webkit-transform: rotate(360deg);
+                -ms-transform: rotate(360deg);
+                transform: rotate(360deg);
+            }
+        }
+
+
+        #loader-wrapper .loader-section {
+            position: fixed;
+            top: 0;
+            width: 51%;
+            height: 100%;
+            background: #7171C6;
+            z-index: 1000;
+            -webkit-transform: translateX(0);
+            -ms-transform: translateX(0);
+            transform: translateX(0);
+        }
+
+        #loader-wrapper .loader-section.section-left {
+            left: 0;
+        }
+
+        #loader-wrapper .loader-section.section-right {
+            right: 0;
+        }
+
+
+        .loaded #loader-wrapper .loader-section.section-left {
+            -webkit-transform: translateX(-100%);
+            -ms-transform: translateX(-100%);
+            transform: translateX(-100%);
+            -webkit-transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1.000);
+            transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1.000);
+        }
+
+        .loaded #loader-wrapper .loader-section.section-right {
+            -webkit-transform: translateX(100%);
+            -ms-transform: translateX(100%);
+            transform: translateX(100%);
+            -webkit-transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1.000);
+            transition: all 0.7s 0.3s cubic-bezier(0.645, 0.045, 0.355, 1.000);
+        }
+
+        .loaded #loader {
+            opacity: 0;
+            -webkit-transition: all 0.3s ease-out;
+            transition: all 0.3s ease-out;
+        }
+
+        .loaded #loader-wrapper {
+            visibility: hidden;
+            -webkit-transform: translateY(-100%);
+            -ms-transform: translateY(-100%);
+            transform: translateY(-100%);
+            -webkit-transition: all 0.3s 1s ease-out;
+            transition: all 0.3s 1s ease-out;
+        }
+
+        .no-js #loader-wrapper {
+            display: none;
+        }
+
+        .no-js h1 {
+            color: #222222;
+        }
+
+        #loader-wrapper .load_title {
+            font-family: 'Open Sans';
+            color: #FFF;
+            font-size: 19px;
+            width: 100%;
+            text-align: center;
+            z-index: 9999999999999;
+            position: absolute;
+            top: 60%;
+            opacity: 1;
+            line-height: 30px;
+        }
+
+        #loader-wrapper .load_title span {
+            font-weight: normal;
+            font-style: italic;
+            font-size: 13px;
+            color: #FFF;
+            opacity: 0.5;
+        }
+    </style>
+    <script type="module" crossorigin src="/assets/index-TnLvmlMR.js"></script>
+    <link rel="stylesheet" crossorigin href="/assets/index-hae3yAhb.css">
+</head>
+
+<body>
+<div id="app">
+    <div id="loader-wrapper">
+        <div id="loader"></div>
+        <div class="loader-section section-left"></div>
+        <div class="loader-section section-right"></div>
+        <div class="load_title">正在加载系统资源,请耐心等待</div>
+    </div>
+</div>
+
+</body>
+
 </html>

+ 20 - 49
ruoyi-admin/src/test/java/com/ruoyi/UcpAppTests.java

@@ -1,10 +1,9 @@
 package com.ruoyi;
 
-import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.ruoyi.ucp.entity.*;
+import com.ruoyi.ucp.entity.PointInfo;
+import com.ruoyi.ucp.entity.StationInfoDay;
 import com.ruoyi.ucp.feign.AdapterApi;
 import com.ruoyi.ucp.service.*;
 import org.junit.Test;
@@ -14,10 +13,9 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.annotation.Resource;
-import javax.script.ScriptEngine;
 import java.net.URI;
-import java.util.*;
-import java.util.function.Function;
+import java.util.Date;
+import java.util.List;
 import java.util.stream.Collectors;
 
 @SpringBootTest//classes = RuoYiApp.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT
@@ -43,56 +41,28 @@ public class UcpAppTests {
 
     @Test
     public void test() {
+        // 创建日期范围生成器
+        /*DateTime start = DateUtil.parse("2023-05-24");
+        DateTime end = DateUtil.parse("2024-05-24");
+        DateRange range = DateUtil.range(start, end, DateField.DAY_OF_YEAR);
+        for (DateTime time : range) {
+            System.out.println(DateUtil.date().toString()+":"+time.toString());
+        }*/
+
         Date date = DateUtil.date().toJdkDate();
-        calcTurbineSsztAi(date);
+        //calcTurbineSsztAi(date);
     }
 
-    public void calcTurbineSsztAi(Date date) {
-
-        Map<Object, Object> stateai = redisTemplate.opsForHash().entries("stateai");
-        stateai.put("eee", 3);
-        Object oo = stateai.get("eee");
-        Integer o = (Integer) stateai.get("rrr");
-        if(1==o){
-
-            System.out.println();
-        }
-
+    /*public void getData(String uniformcode){
         PointInfo pi = new PointInfo();
-        pi.setUniformCode("AI422");
-        pi.setInstitutionType("state");
-        List<PointInfo> entity = pointService.getByEntity(pi);
-        Map<String, PointInfo> collect = entity.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
-        String keys = pointInfos2Keys(entity);
-
-        PointInfo pimx = new PointInfo();
-        pimx.setUniformCode("MXZT");
-        pimx.setInstitutionType("turbine");
-        List<PointInfo> entityMx = pointService.getByEntity(pimx);
-        Map<String, PointInfo> collectMX = entityMx.stream().collect(Collectors.toMap(PointInfo::getTurbineId, Function.identity()));
-
-        Map<String, PointData> latest = adapter.getLatest(taosGoldenUriTest(), keys);
-        List<StateAi> list = stateAiService.list();
-        Map<String,Map<Integer,Integer>> collectAi = list.stream().collect(Collectors.groupingBy(StateAi::getModel,Collectors.toMap(StateAi::getOriginalState,StateAi::getMappingState)));
+        pi.
+    }*/
 
-        List<PointData> pointDatas = new ArrayList<>();
-        for (PointInfo info : entity) {
-            PointData data = latest.get(info.getPointKey());
-            data.setTagName(collectMX.get(info.getTurbineId()).getPointKey());
-            Integer i = collectAi.get(info.getSpare()).get((int)data.getDoubleValue());
-            data.setDoubleValue(i);
-            pointDatas.add(data);
-        }
-        adapter.writeHistoryBatch(taosGoldenUriTest(), pointDatas);
-
-        //redisTemplate.opsForHash().put("state_point",key,value);
-
-    }
-
-    public String pointInfos2Keys(List<PointInfo> entity){
+    public String pointInfos2Keys(List<PointInfo> entity) {
         return entity.stream().map(PointInfo::getPointKey).collect(Collectors.joining(","));
     }
-    public URI taosGoldenUriTest(){
+
+    public URI taosGoldenUriTest() {
         return URI.create("http://127.0.0.1:8011/ts");
     }
 
@@ -101,4 +71,5 @@ public class UcpAppTests {
         wrapper.eq("record_date", date);
         return stationInfoDayService.list(wrapper);
     }
+
 }

+ 7 - 7
ruoyi-common/pom.xml

@@ -52,19 +52,19 @@
             <groupId>org.apache.commons</groupId>
             <artifactId>commons-lang3</artifactId>
         </dependency>
-  
+
         <!-- JSON工具类 -->
         <dependency>
             <groupId>com.fasterxml.jackson.core</groupId>
             <artifactId>jackson-databind</artifactId>
         </dependency>
-        
+
         <!-- 动态数据源 -->
-		<dependency>
-			<groupId>com.baomidou</groupId>
-			<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
-			<version>3.5.2</version>
-		</dependency>
+        <dependency>
+            <groupId>com.baomidou</groupId>
+            <artifactId>dynamic-datasource-spring-boot-starter</artifactId>
+            <version>3.5.2</version>
+        </dependency>
 
         <!-- 阿里JSON解析器 -->
         <dependency>

+ 5 - 10
ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java

@@ -1,24 +1,19 @@
 package com.ruoyi.common.annotation;
 
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
 import com.ruoyi.common.enums.BusinessType;
 import com.ruoyi.common.enums.OperatorType;
 
+import java.lang.annotation.*;
+
 /**
  * 自定义操作日志记录注解
- * 
- * @author ruoyi
  *
+ * @author ruoyi
  */
-@Target({ ElementType.PARAMETER, ElementType.METHOD })
+@Target({ElementType.PARAMETER, ElementType.METHOD})
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
-public @interface Log
-{
+public @interface Log {
     /**
      * 模块
      */

+ 4 - 8
ruoyi-common/src/main/java/com/ruoyi/common/annotation/RateLimiter.java

@@ -1,23 +1,19 @@
 package com.ruoyi.common.annotation;
 
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
 import com.ruoyi.common.constant.CacheConstants;
 import com.ruoyi.common.enums.LimitType;
 
+import java.lang.annotation.*;
+
 /**
  * 限流注解
- * 
+ *
  * @author ruoyi
  */
 @Target(ElementType.METHOD)
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
-public @interface RateLimiter
-{
+public @interface RateLimiter {
     /**
      * 限流key
      */

+ 3 - 10
ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java

@@ -1,24 +1,17 @@
 package com.ruoyi.common.annotation;
 
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Inherited;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
+import java.lang.annotation.*;
 
 /**
  * 自定义注解防止表单重复提交
- * 
- * @author ruoyi
  *
+ * @author ruoyi
  */
 @Inherited
 @Target(ElementType.METHOD)
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
-public @interface RepeatSubmit
-{
+public @interface RepeatSubmit {
     /**
      * 间隔时间(ms),小于此时间视为重复提交
      */

+ 39 - 42
ruoyi-common/src/main/java/com/ruoyi/common/config/RuoYiConfig.java

@@ -5,91 +5,92 @@ import org.springframework.stereotype.Component;
 
 /**
  * 读取项目相关配置
- * 
+ *
  * @author ruoyi
  */
 @Component
 @ConfigurationProperties(prefix = "ruoyi")
-public class RuoYiConfig
-{
-    /** 项目名称 */
+public class RuoYiConfig {
+    /**
+     * 项目名称
+     */
     private String name;
 
-    /** 版本 */
+    /**
+     * 版本
+     */
     private String version;
 
-    /** 版权年份 */
+    /**
+     * 版权年份
+     */
     private String copyrightYear;
 
-    /** 实例演示开关 */
+    /**
+     * 实例演示开关
+     */
     private boolean demoEnabled;
 
-    /** 上传路径 */
+    /**
+     * 上传路径
+     */
     private static String profile;
 
-    /** 获取地址开关 */
+    /**
+     * 获取地址开关
+     */
     private static boolean addressEnabled;
 
-    /** 验证码类型 */
+    /**
+     * 验证码类型
+     */
     private static String captchaType;
 
-    public String getName()
-    {
+    public String getName() {
         return name;
     }
 
-    public void setName(String name)
-    {
+    public void setName(String name) {
         this.name = name;
     }
 
-    public String getVersion()
-    {
+    public String getVersion() {
         return version;
     }
 
-    public void setVersion(String version)
-    {
+    public void setVersion(String version) {
         this.version = version;
     }
 
-    public String getCopyrightYear()
-    {
+    public String getCopyrightYear() {
         return copyrightYear;
     }
 
-    public void setCopyrightYear(String copyrightYear)
-    {
+    public void setCopyrightYear(String copyrightYear) {
         this.copyrightYear = copyrightYear;
     }
 
-    public boolean isDemoEnabled()
-    {
+    public boolean isDemoEnabled() {
         return demoEnabled;
     }
 
-    public void setDemoEnabled(boolean demoEnabled)
-    {
+    public void setDemoEnabled(boolean demoEnabled) {
         this.demoEnabled = demoEnabled;
     }
 
-    public static String getProfile()
-    {
+    public static String getProfile() {
         return profile;
     }
 
-    public void setProfile(String profile)
-    {
+    public void setProfile(String profile) {
         RuoYiConfig.profile = profile;
     }
 
-    public static boolean isAddressEnabled()
-    {
+    public static boolean isAddressEnabled() {
         return addressEnabled;
     }
 
-    public void setAddressEnabled(boolean addressEnabled)
-    {
+    public void setAddressEnabled(boolean addressEnabled) {
         RuoYiConfig.addressEnabled = addressEnabled;
     }
 
@@ -104,32 +105,28 @@ public class RuoYiConfig
     /**
      * 获取导入上传路径
      */
-    public static String getImportPath()
-    {
+    public static String getImportPath() {
         return getProfile() + "/import";
     }
 
     /**
      * 获取头像上传路径
      */
-    public static String getAvatarPath()
-    {
+    public static String getAvatarPath() {
         return getProfile() + "/avatar";
     }
 
     /**
      * 获取下载路径
      */
-    public static String getDownloadPath()
-    {
+    public static String getDownloadPath() {
         return getProfile() + "/download/";
     }
 
     /**
      * 获取上传路径
      */
-    public static String getUploadPath()
-    {
+    public static String getUploadPath() {
         return getProfile() + "/upload";
     }
 }

+ 2 - 3
ruoyi-common/src/main/java/com/ruoyi/common/constant/HttpStatus.java

@@ -2,11 +2,10 @@ package com.ruoyi.common.constant;
 
 /**
  * 返回状态码
- * 
+ *
  * @author ruoyi
  */
-public class HttpStatus
-{
+public class HttpStatus {
     /**
      * 操作成功
      */

+ 20 - 14
ruoyi-common/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java

@@ -2,30 +2,38 @@ package com.ruoyi.common.constant;
 
 /**
  * 任务调度通用常量
- * 
+ *
  * @author ruoyi
  */
-public class ScheduleConstants
-{
+public class ScheduleConstants {
     public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME";
 
-    /** 执行目标key */
+    /**
+     * 执行目标key
+     */
     public static final String TASK_PROPERTIES = "TASK_PROPERTIES";
 
-    /** 默认 */
+    /**
+     * 默认
+     */
     public static final String MISFIRE_DEFAULT = "0";
 
-    /** 立即触发执行 */
+    /**
+     * 立即触发执行
+     */
     public static final String MISFIRE_IGNORE_MISFIRES = "1";
 
-    /** 触发一次执行 */
+    /**
+     * 触发一次执行
+     */
     public static final String MISFIRE_FIRE_AND_PROCEED = "2";
 
-    /** 不触发立即执行 */
+    /**
+     * 不触发立即执行
+     */
     public static final String MISFIRE_DO_NOTHING = "3";
 
-    public enum Status
-    {
+    public enum Status {
         /**
          * 正常
          */
@@ -37,13 +45,11 @@ public class ScheduleConstants
 
         private String value;
 
-        private Status(String value)
-        {
+        private Status(String value) {
             this.value = value;
         }
 
-        public String getValue()
-        {
+        public String getValue() {
             return value;
         }
     }

+ 54 - 21
ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java

@@ -2,65 +2,98 @@ package com.ruoyi.common.constant;
 
 /**
  * 用户常量信息
- * 
+ *
  * @author ruoyi
  */
-public class UserConstants
-{
+public class UserConstants {
     /**
      * 平台内系统用户的唯一标志
      */
     public static final String SYS_USER = "SYS_USER";
 
-    /** 正常状态 */
+    /**
+     * 正常状态
+     */
     public static final String NORMAL = "0";
 
-    /** 异常状态 */
+    /**
+     * 异常状态
+     */
     public static final String EXCEPTION = "1";
 
-    /** 用户封禁状态 */
+    /**
+     * 用户封禁状态
+     */
     public static final String USER_DISABLE = "1";
 
-    /** 角色封禁状态 */
+    /**
+     * 角色封禁状态
+     */
     public static final String ROLE_DISABLE = "1";
 
-    /** 部门正常状态 */
+    /**
+     * 部门正常状态
+     */
     public static final String DEPT_NORMAL = "0";
 
-    /** 部门停用状态 */
+    /**
+     * 部门停用状态
+     */
     public static final String DEPT_DISABLE = "1";
 
-    /** 字典正常状态 */
+    /**
+     * 字典正常状态
+     */
     public static final String DICT_NORMAL = "0";
 
-    /** 是否为系统默认(是) */
+    /**
+     * 是否为系统默认(是)
+     */
     public static final String YES = "Y";
 
-    /** 是否菜单外链(是) */
+    /**
+     * 是否菜单外链(是)
+     */
     public static final String YES_FRAME = "0";
 
-    /** 是否菜单外链(否) */
+    /**
+     * 是否菜单外链(否)
+     */
     public static final String NO_FRAME = "1";
 
-    /** 菜单类型(目录) */
+    /**
+     * 菜单类型(目录)
+     */
     public static final String TYPE_DIR = "M";
 
-    /** 菜单类型(菜单) */
+    /**
+     * 菜单类型(菜单)
+     */
     public static final String TYPE_MENU = "C";
 
-    /** 菜单类型(按钮) */
+    /**
+     * 菜单类型(按钮)
+     */
     public static final String TYPE_BUTTON = "F";
 
-    /** Layout组件标识 */
+    /**
+     * Layout组件标识
+     */
     public final static String LAYOUT = "Layout";
-    
-    /** ParentView组件标识 */
+
+    /**
+     * ParentView组件标识
+     */
     public final static String PARENT_VIEW = "ParentView";
 
-    /** InnerLink组件标识 */
+    /**
+     * InnerLink组件标识
+     */
     public final static String INNER_LINK = "InnerLink";
 
-    /** 校验是否唯一的返回标识 */
+    /**
+     * 校验是否唯一的返回标识
+     */
     public final static boolean UNIQUE = true;
     public final static boolean NOT_UNIQUE = false;
 

+ 26 - 39
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/R.java

@@ -1,21 +1,25 @@
 package com.ruoyi.common.core.domain;
 
-import java.io.Serializable;
 import com.ruoyi.common.constant.HttpStatus;
 
+import java.io.Serializable;
+
 /**
  * 响应信息主体
  *
  * @author ruoyi
  */
-public class R<T> implements Serializable
-{
+public class R<T> implements Serializable {
     private static final long serialVersionUID = 1L;
 
-    /** 成功 */
+    /**
+     * 成功
+     */
     public static final int SUCCESS = HttpStatus.SUCCESS;
 
-    /** 失败 */
+    /**
+     * 失败
+     */
     public static final int FAIL = HttpStatus.ERROR;
 
     private int code;
@@ -24,48 +28,39 @@ public class R<T> implements Serializable
 
     private T data;
 
-    public static <T> R<T> ok()
-    {
+    public static <T> R<T> ok() {
         return restResult(null, SUCCESS, "操作成功");
     }
 
-    public static <T> R<T> ok(T data)
-    {
+    public static <T> R<T> ok(T data) {
         return restResult(data, SUCCESS, "操作成功");
     }
 
-    public static <T> R<T> ok(T data, String msg)
-    {
+    public static <T> R<T> ok(T data, String msg) {
         return restResult(data, SUCCESS, msg);
     }
 
-    public static <T> R<T> fail()
-    {
+    public static <T> R<T> fail() {
         return restResult(null, FAIL, "操作失败");
     }
 
-    public static <T> R<T> fail(String msg)
-    {
+    public static <T> R<T> fail(String msg) {
         return restResult(null, FAIL, msg);
     }
 
-    public static <T> R<T> fail(T data)
-    {
+    public static <T> R<T> fail(T data) {
         return restResult(data, FAIL, "操作失败");
     }
 
-    public static <T> R<T> fail(T data, String msg)
-    {
+    public static <T> R<T> fail(T data, String msg) {
         return restResult(data, FAIL, msg);
     }
 
-    public static <T> R<T> fail(int code, String msg)
-    {
+    public static <T> R<T> fail(int code, String msg) {
         return restResult(null, code, msg);
     }
 
-    private static <T> R<T> restResult(T data, int code, String msg)
-    {
+    private static <T> R<T> restResult(T data, int code, String msg) {
         R<T> apiResult = new R<>();
         apiResult.setCode(code);
         apiResult.setData(data);
@@ -73,43 +68,35 @@ public class R<T> implements Serializable
         return apiResult;
     }
 
-    public int getCode()
-    {
+    public int getCode() {
         return code;
     }
 
-    public void setCode(int code)
-    {
+    public void setCode(int code) {
         this.code = code;
     }
 
-    public String getMsg()
-    {
+    public String getMsg() {
         return msg;
     }
 
-    public void setMsg(String msg)
-    {
+    public void setMsg(String msg) {
         this.msg = msg;
     }
 
-    public T getData()
-    {
+    public T getData() {
         return data;
     }
 
-    public void setData(T data)
-    {
+    public void setData(T data) {
         this.data = data;
     }
 
-    public static <T> Boolean isError(R<T> ret)
-    {
+    public static <T> Boolean isError(R<T> ret) {
         return !isSuccess(ret);
     }
 
-    public static <T> Boolean isSuccess(R<T> ret)
-    {
+    public static <T> Boolean isSuccess(R<T> ret) {
         return R.SUCCESS == ret.getCode();
     }
 }

+ 27 - 28
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeEntity.java

@@ -5,75 +5,74 @@ import java.util.List;
 
 /**
  * Tree基类
- * 
+ *
  * @author ruoyi
  */
-public class TreeEntity extends BaseEntity
-{
+public class TreeEntity extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 父菜单名称 */
+    /**
+     * 父菜单名称
+     */
     private String parentName;
 
-    /** 父菜单ID */
+    /**
+     * 父菜单ID
+     */
     private Long parentId;
 
-    /** 显示顺序 */
+    /**
+     * 显示顺序
+     */
     private Integer orderNum;
 
-    /** 祖级列表 */
+    /**
+     * 祖级列表
+     */
     private String ancestors;
 
-    /** 子部门 */
+    /**
+     * 子部门
+     */
     private List<?> children = new ArrayList<>();
 
-    public String getParentName()
-    {
+    public String getParentName() {
         return parentName;
     }
 
-    public void setParentName(String parentName)
-    {
+    public void setParentName(String parentName) {
         this.parentName = parentName;
     }
 
-    public Long getParentId()
-    {
+    public Long getParentId() {
         return parentId;
     }
 
-    public void setParentId(Long parentId)
-    {
+    public void setParentId(Long parentId) {
         this.parentId = parentId;
     }
 
-    public Integer getOrderNum()
-    {
+    public Integer getOrderNum() {
         return orderNum;
     }
 
-    public void setOrderNum(Integer orderNum)
-    {
+    public void setOrderNum(Integer orderNum) {
         this.orderNum = orderNum;
     }
 
-    public String getAncestors()
-    {
+    public String getAncestors() {
         return ancestors;
     }
 
-    public void setAncestors(String ancestors)
-    {
+    public void setAncestors(String ancestors) {
         this.ancestors = ancestors;
     }
 
-    public List<?> getChildren()
-    {
+    public List<?> getChildren() {
         return children;
     }
 
-    public void setChildren(List<?> children)
-    {
+    public void setChildren(List<?> children) {
         this.children = children;
     }
 }

+ 24 - 27
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java

@@ -1,77 +1,74 @@
 package com.ruoyi.common.core.domain;
 
-import java.io.Serializable;
-import java.util.List;
-import java.util.stream.Collectors;
 import com.fasterxml.jackson.annotation.JsonInclude;
 import com.ruoyi.common.core.domain.entity.SysDept;
 import com.ruoyi.common.core.domain.entity.SysMenu;
 
+import java.io.Serializable;
+import java.util.List;
+import java.util.stream.Collectors;
+
 /**
  * Treeselect树结构实体类
- * 
+ *
  * @author ruoyi
  */
-public class TreeSelect implements Serializable
-{
+public class TreeSelect implements Serializable {
     private static final long serialVersionUID = 1L;
 
-    /** 节点ID */
+    /**
+     * 节点ID
+     */
     private Long id;
 
-    /** 节点名称 */
+    /**
+     * 节点名称
+     */
     private String label;
 
-    /** 子节点 */
+    /**
+     * 子节点
+     */
     @JsonInclude(JsonInclude.Include.NON_EMPTY)
     private List<TreeSelect> children;
 
-    public TreeSelect()
-    {
+    public TreeSelect() {
 
     }
 
-    public TreeSelect(SysDept dept)
-    {
+    public TreeSelect(SysDept dept) {
         this.id = dept.getDeptId();
         this.label = dept.getDeptName();
         this.children = dept.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
     }
 
-    public TreeSelect(SysMenu menu)
-    {
+    public TreeSelect(SysMenu menu) {
         this.id = menu.getMenuId();
         this.label = menu.getMenuName();
         this.children = menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList());
     }
 
-    public Long getId()
-    {
+    public Long getId() {
         return id;
     }
 
-    public void setId(Long id)
-    {
+    public void setId(Long id) {
         this.id = id;
     }
 
-    public String getLabel()
-    {
+    public String getLabel() {
         return label;
     }
 
-    public void setLabel(String label)
-    {
+    public void setLabel(String label) {
         this.label = label;
     }
 
-    public List<TreeSelect> getChildren()
-    {
+    public List<TreeSelect> getChildren() {
         return children;
     }
 
-    public void setChildren(List<TreeSelect> children)
-    {
+    public void setChildren(List<TreeSelect> children) {
         this.children = children;
     }
 }

+ 85 - 85
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java

@@ -1,203 +1,203 @@
 package com.ruoyi.common.core.domain.entity;
 
-import java.util.ArrayList;
-import java.util.List;
+import com.ruoyi.common.core.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
 import javax.validation.constraints.Email;
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import com.ruoyi.common.core.domain.BaseEntity;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * 部门表 sys_dept
- * 
+ *
  * @author ruoyi
  */
-public class SysDept extends BaseEntity
-{
+public class SysDept extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 部门ID */
+    /**
+     * 部门ID
+     */
     private Long deptId;
 
-    /** 父部门ID */
+    /**
+     * 父部门ID
+     */
     private Long parentId;
 
-    /** 祖级列表 */
+    /**
+     * 祖级列表
+     */
     private String ancestors;
 
-    /** 部门名称 */
+    /**
+     * 部门名称
+     */
     private String deptName;
 
-    /** 显示顺序 */
+    /**
+     * 显示顺序
+     */
     private Integer orderNum;
 
-    /** 负责人 */
+    /**
+     * 负责人
+     */
     private String leader;
 
-    /** 联系电话 */
+    /**
+     * 联系电话
+     */
     private String phone;
 
-    /** 邮箱 */
+    /**
+     * 邮箱
+     */
     private String email;
 
-    /** 部门状态:0正常,1停用 */
+    /**
+     * 部门状态:0正常,1停用
+     */
     private String status;
 
-    /** 删除标志(0代表存在 2代表删除) */
+    /**
+     * 删除标志(0代表存在 2代表删除)
+     */
     private String delFlag;
 
-    /** 父部门名称 */
+    /**
+     * 父部门名称
+     */
     private String parentName;
-    
-    /** 子部门 */
+
+    /**
+     * 子部门
+     */
     private List<SysDept> children = new ArrayList<SysDept>();
 
-    public Long getDeptId()
-    {
+    public Long getDeptId() {
         return deptId;
     }
 
-    public void setDeptId(Long deptId)
-    {
+    public void setDeptId(Long deptId) {
         this.deptId = deptId;
     }
 
-    public Long getParentId()
-    {
+    public Long getParentId() {
         return parentId;
     }
 
-    public void setParentId(Long parentId)
-    {
+    public void setParentId(Long parentId) {
         this.parentId = parentId;
     }
 
-    public String getAncestors()
-    {
+    public String getAncestors() {
         return ancestors;
     }
 
-    public void setAncestors(String ancestors)
-    {
+    public void setAncestors(String ancestors) {
         this.ancestors = ancestors;
     }
 
     @NotBlank(message = "部门名称不能为空")
     @Size(min = 0, max = 30, message = "部门名称长度不能超过30个字符")
-    public String getDeptName()
-    {
+    public String getDeptName() {
         return deptName;
     }
 
-    public void setDeptName(String deptName)
-    {
+    public void setDeptName(String deptName) {
         this.deptName = deptName;
     }
 
     @NotNull(message = "显示顺序不能为空")
-    public Integer getOrderNum()
-    {
+    public Integer getOrderNum() {
         return orderNum;
     }
 
-    public void setOrderNum(Integer orderNum)
-    {
+    public void setOrderNum(Integer orderNum) {
         this.orderNum = orderNum;
     }
 
-    public String getLeader()
-    {
+    public String getLeader() {
         return leader;
     }
 
-    public void setLeader(String leader)
-    {
+    public void setLeader(String leader) {
         this.leader = leader;
     }
 
     @Size(min = 0, max = 11, message = "联系电话长度不能超过11个字符")
-    public String getPhone()
-    {
+    public String getPhone() {
         return phone;
     }
 
-    public void setPhone(String phone)
-    {
+    public void setPhone(String phone) {
         this.phone = phone;
     }
 
     @Email(message = "邮箱格式不正确")
     @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
-    public String getEmail()
-    {
+    public String getEmail() {
         return email;
     }
 
-    public void setEmail(String email)
-    {
+    public void setEmail(String email) {
         this.email = email;
     }
 
-    public String getStatus()
-    {
+    public String getStatus() {
         return status;
     }
 
-    public void setStatus(String status)
-    {
+    public void setStatus(String status) {
         this.status = status;
     }
 
-    public String getDelFlag()
-    {
+    public String getDelFlag() {
         return delFlag;
     }
 
-    public void setDelFlag(String delFlag)
-    {
+    public void setDelFlag(String delFlag) {
         this.delFlag = delFlag;
     }
 
-    public String getParentName()
-    {
+    public String getParentName() {
         return parentName;
     }
 
-    public void setParentName(String parentName)
-    {
+    public void setParentName(String parentName) {
         this.parentName = parentName;
     }
 
-    public List<SysDept> getChildren()
-    {
+    public List<SysDept> getChildren() {
         return children;
     }
 
-    public void setChildren(List<SysDept> children)
-    {
+    public void setChildren(List<SysDept> children) {
         this.children = children;
     }
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("deptId", getDeptId())
-            .append("parentId", getParentId())
-            .append("ancestors", getAncestors())
-            .append("deptName", getDeptName())
-            .append("orderNum", getOrderNum())
-            .append("leader", getLeader())
-            .append("phone", getPhone())
-            .append("email", getEmail())
-            .append("status", getStatus())
-            .append("delFlag", getDelFlag())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .toString();
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("deptId", getDeptId())
+                .append("parentId", getParentId())
+                .append("ancestors", getAncestors())
+                .append("deptName", getDeptName())
+                .append("orderNum", getOrderNum())
+                .append("leader", getLeader())
+                .append("phone", getPhone())
+                .append("email", getEmail())
+                .append("status", getStatus())
+                .append("delFlag", getDelFlag())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .toString();
     }
 }

+ 70 - 71
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java

@@ -1,176 +1,175 @@
 package com.ruoyi.common.core.domain.entity;
 
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.Size;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.annotation.Excel.ColumnType;
 import com.ruoyi.common.constant.UserConstants;
 import com.ruoyi.common.core.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
 
 /**
  * 字典数据表 sys_dict_data
- * 
+ *
  * @author ruoyi
  */
-public class SysDictData extends BaseEntity
-{
+public class SysDictData extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 字典编码 */
+    /**
+     * 字典编码
+     */
     @Excel(name = "字典编码", cellType = ColumnType.NUMERIC)
     private Long dictCode;
 
-    /** 字典排序 */
+    /**
+     * 字典排序
+     */
     @Excel(name = "字典排序", cellType = ColumnType.NUMERIC)
     private Long dictSort;
 
-    /** 字典标签 */
+    /**
+     * 字典标签
+     */
     @Excel(name = "字典标签")
     private String dictLabel;
 
-    /** 字典键值 */
+    /**
+     * 字典键值
+     */
     @Excel(name = "字典键值")
     private String dictValue;
 
-    /** 字典类型 */
+    /**
+     * 字典类型
+     */
     @Excel(name = "字典类型")
     private String dictType;
 
-    /** 样式属性(其他样式扩展) */
+    /**
+     * 样式属性(其他样式扩展)
+     */
     private String cssClass;
 
-    /** 表格字典样式 */
+    /**
+     * 表格字典样式
+     */
     private String listClass;
 
-    /** 是否默认(Y是 N否) */
+    /**
+     * 是否默认(Y是 N否)
+     */
     @Excel(name = "是否默认", readConverterExp = "Y=是,N=否")
     private String isDefault;
 
-    /** 状态(0正常 1停用) */
+    /**
+     * 状态(0正常 1停用)
+     */
     @Excel(name = "状态", readConverterExp = "0=正常,1=停用")
     private String status;
 
-    public Long getDictCode()
-    {
+    public Long getDictCode() {
         return dictCode;
     }
 
-    public void setDictCode(Long dictCode)
-    {
+    public void setDictCode(Long dictCode) {
         this.dictCode = dictCode;
     }
 
-    public Long getDictSort()
-    {
+    public Long getDictSort() {
         return dictSort;
     }
 
-    public void setDictSort(Long dictSort)
-    {
+    public void setDictSort(Long dictSort) {
         this.dictSort = dictSort;
     }
 
     @NotBlank(message = "字典标签不能为空")
     @Size(min = 0, max = 100, message = "字典标签长度不能超过100个字符")
-    public String getDictLabel()
-    {
+    public String getDictLabel() {
         return dictLabel;
     }
 
-    public void setDictLabel(String dictLabel)
-    {
+    public void setDictLabel(String dictLabel) {
         this.dictLabel = dictLabel;
     }
 
     @NotBlank(message = "字典键值不能为空")
     @Size(min = 0, max = 100, message = "字典键值长度不能超过100个字符")
-    public String getDictValue()
-    {
+    public String getDictValue() {
         return dictValue;
     }
 
-    public void setDictValue(String dictValue)
-    {
+    public void setDictValue(String dictValue) {
         this.dictValue = dictValue;
     }
 
     @NotBlank(message = "字典类型不能为空")
     @Size(min = 0, max = 100, message = "字典类型长度不能超过100个字符")
-    public String getDictType()
-    {
+    public String getDictType() {
         return dictType;
     }
 
-    public void setDictType(String dictType)
-    {
+    public void setDictType(String dictType) {
         this.dictType = dictType;
     }
 
     @Size(min = 0, max = 100, message = "样式属性长度不能超过100个字符")
-    public String getCssClass()
-    {
+    public String getCssClass() {
         return cssClass;
     }
 
-    public void setCssClass(String cssClass)
-    {
+    public void setCssClass(String cssClass) {
         this.cssClass = cssClass;
     }
 
-    public String getListClass()
-    {
+    public String getListClass() {
         return listClass;
     }
 
-    public void setListClass(String listClass)
-    {
+    public void setListClass(String listClass) {
         this.listClass = listClass;
     }
 
-    public boolean getDefault()
-    {
+    public boolean getDefault() {
         return UserConstants.YES.equals(this.isDefault);
     }
 
-    public String getIsDefault()
-    {
+    public String getIsDefault() {
         return isDefault;
     }
 
-    public void setIsDefault(String isDefault)
-    {
+    public void setIsDefault(String isDefault) {
         this.isDefault = isDefault;
     }
 
-    public String getStatus()
-    {
+    public String getStatus() {
         return status;
     }
 
-    public void setStatus(String status)
-    {
+    public void setStatus(String status) {
         this.status = status;
     }
-    
+
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("dictCode", getDictCode())
-            .append("dictSort", getDictSort())
-            .append("dictLabel", getDictLabel())
-            .append("dictValue", getDictValue())
-            .append("dictType", getDictType())
-            .append("cssClass", getCssClass())
-            .append("listClass", getListClass())
-            .append("isDefault", getIsDefault())
-            .append("status", getStatus())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .toString();
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("dictCode", getDictCode())
+                .append("dictSort", getDictSort())
+                .append("dictLabel", getDictLabel())
+                .append("dictValue", getDictValue())
+                .append("dictType", getDictType())
+                .append("cssClass", getCssClass())
+                .append("listClass", getListClass())
+                .append("isDefault", getIsDefault())
+                .append("status", getStatus())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .append("remark", getRemark())
+                .toString();
     }
 }

+ 40 - 40
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java

@@ -1,96 +1,96 @@
 package com.ruoyi.common.core.domain.entity;
 
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.Pattern;
-import javax.validation.constraints.Size;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.annotation.Excel.ColumnType;
 import com.ruoyi.common.core.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Pattern;
+import javax.validation.constraints.Size;
 
 /**
  * 字典类型表 sys_dict_type
- * 
+ *
  * @author ruoyi
  */
-public class SysDictType extends BaseEntity
-{
+public class SysDictType extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 字典主键 */
+    /**
+     * 字典主键
+     */
     @Excel(name = "字典主键", cellType = ColumnType.NUMERIC)
     private Long dictId;
 
-    /** 字典名称 */
+    /**
+     * 字典名称
+     */
     @Excel(name = "字典名称")
     private String dictName;
 
-    /** 字典类型 */
+    /**
+     * 字典类型
+     */
     @Excel(name = "字典类型")
     private String dictType;
 
-    /** 状态(0正常 1停用) */
+    /**
+     * 状态(0正常 1停用)
+     */
     @Excel(name = "状态", readConverterExp = "0=正常,1=停用")
     private String status;
 
-    public Long getDictId()
-    {
+    public Long getDictId() {
         return dictId;
     }
 
-    public void setDictId(Long dictId)
-    {
+    public void setDictId(Long dictId) {
         this.dictId = dictId;
     }
 
     @NotBlank(message = "字典名称不能为空")
     @Size(min = 0, max = 100, message = "字典类型名称长度不能超过100个字符")
-    public String getDictName()
-    {
+    public String getDictName() {
         return dictName;
     }
 
-    public void setDictName(String dictName)
-    {
+    public void setDictName(String dictName) {
         this.dictName = dictName;
     }
 
     @NotBlank(message = "字典类型不能为空")
     @Size(min = 0, max = 100, message = "字典类型类型长度不能超过100个字符")
     @Pattern(regexp = "^[a-z][a-z0-9_]*$", message = "字典类型必须以字母开头,且只能为(小写字母,数字,下滑线)")
-    public String getDictType()
-    {
+    public String getDictType() {
         return dictType;
     }
 
-    public void setDictType(String dictType)
-    {
+    public void setDictType(String dictType) {
         this.dictType = dictType;
     }
 
-    public String getStatus()
-    {
+    public String getStatus() {
         return status;
     }
 
-    public void setStatus(String status)
-    {
+    public void setStatus(String status) {
         this.status = status;
     }
-    
+
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("dictId", getDictId())
-            .append("dictName", getDictName())
-            .append("dictType", getDictType())
-            .append("status", getStatus())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .toString();
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("dictId", getDictId())
+                .append("dictName", getDictName())
+                .append("dictType", getDictType())
+                .append("status", getStatus())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .append("remark", getRemark())
+                .toString();
     }
 }

+ 110 - 110
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java

@@ -1,259 +1,259 @@
 package com.ruoyi.common.core.domain.entity;
 
-import java.util.ArrayList;
-import java.util.List;
+import com.ruoyi.common.core.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
 import javax.validation.constraints.NotBlank;
 import javax.validation.constraints.NotNull;
 import javax.validation.constraints.Size;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
-import com.ruoyi.common.core.domain.BaseEntity;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * 菜单权限表 sys_menu
- * 
+ *
  * @author ruoyi
  */
-public class SysMenu extends BaseEntity
-{
+public class SysMenu extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 菜单ID */
+    /**
+     * 菜单ID
+     */
     private Long menuId;
 
-    /** 菜单名称 */
+    /**
+     * 菜单名称
+     */
     private String menuName;
 
-    /** 父菜单名称 */
+    /**
+     * 父菜单名称
+     */
     private String parentName;
 
-    /** 父菜单ID */
+    /**
+     * 父菜单ID
+     */
     private Long parentId;
 
-    /** 显示顺序 */
+    /**
+     * 显示顺序
+     */
     private Integer orderNum;
 
-    /** 路由地址 */
+    /**
+     * 路由地址
+     */
     private String path;
 
-    /** 组件路径 */
+    /**
+     * 组件路径
+     */
     private String component;
 
-    /** 路由参数 */
+    /**
+     * 路由参数
+     */
     private String query;
 
-    /** 是否为外链(0是 1否) */
+    /**
+     * 是否为外链(0是 1否)
+     */
     private String isFrame;
 
-    /** 是否缓存(0缓存 1不缓存) */
+    /**
+     * 是否缓存(0缓存 1不缓存)
+     */
     private String isCache;
 
-    /** 类型(M目录 C菜单 F按钮) */
+    /**
+     * 类型(M目录 C菜单 F按钮)
+     */
     private String menuType;
 
-    /** 显示状态(0显示 1隐藏) */
+    /**
+     * 显示状态(0显示 1隐藏)
+     */
     private String visible;
-    
-    /** 菜单状态(0正常 1停用) */
+
+    /**
+     * 菜单状态(0正常 1停用)
+     */
     private String status;
 
-    /** 权限字符串 */
+    /**
+     * 权限字符串
+     */
     private String perms;
 
-    /** 菜单图标 */
+    /**
+     * 菜单图标
+     */
     private String icon;
 
-    /** 子菜单 */
+    /**
+     * 子菜单
+     */
     private List<SysMenu> children = new ArrayList<SysMenu>();
 
-    public Long getMenuId()
-    {
+    public Long getMenuId() {
         return menuId;
     }
 
-    public void setMenuId(Long menuId)
-    {
+    public void setMenuId(Long menuId) {
         this.menuId = menuId;
     }
 
     @NotBlank(message = "菜单名称不能为空")
     @Size(min = 0, max = 50, message = "菜单名称长度不能超过50个字符")
-    public String getMenuName()
-    {
+    public String getMenuName() {
         return menuName;
     }
 
-    public void setMenuName(String menuName)
-    {
+    public void setMenuName(String menuName) {
         this.menuName = menuName;
     }
 
-    public String getParentName()
-    {
+    public String getParentName() {
         return parentName;
     }
 
-    public void setParentName(String parentName)
-    {
+    public void setParentName(String parentName) {
         this.parentName = parentName;
     }
 
-    public Long getParentId()
-    {
+    public Long getParentId() {
         return parentId;
     }
 
-    public void setParentId(Long parentId)
-    {
+    public void setParentId(Long parentId) {
         this.parentId = parentId;
     }
 
     @NotNull(message = "显示顺序不能为空")
-    public Integer getOrderNum()
-    {
+    public Integer getOrderNum() {
         return orderNum;
     }
 
-    public void setOrderNum(Integer orderNum)
-    {
+    public void setOrderNum(Integer orderNum) {
         this.orderNum = orderNum;
     }
 
     @Size(min = 0, max = 200, message = "路由地址不能超过200个字符")
-    public String getPath()
-    {
+    public String getPath() {
         return path;
     }
 
-    public void setPath(String path)
-    {
+    public void setPath(String path) {
         this.path = path;
     }
 
     @Size(min = 0, max = 200, message = "组件路径不能超过255个字符")
-    public String getComponent()
-    {
+    public String getComponent() {
         return component;
     }
 
-    public void setComponent(String component)
-    {
+    public void setComponent(String component) {
         this.component = component;
     }
 
-    public String getQuery()
-    {
+    public String getQuery() {
         return query;
     }
 
-    public void setQuery(String query)
-    {
+    public void setQuery(String query) {
         this.query = query;
     }
 
-    public String getIsFrame()
-    {
+    public String getIsFrame() {
         return isFrame;
     }
 
-    public void setIsFrame(String isFrame)
-    {
+    public void setIsFrame(String isFrame) {
         this.isFrame = isFrame;
     }
 
-    public String getIsCache()
-    {
+    public String getIsCache() {
         return isCache;
     }
 
-    public void setIsCache(String isCache)
-    {
+    public void setIsCache(String isCache) {
         this.isCache = isCache;
     }
 
     @NotBlank(message = "菜单类型不能为空")
-    public String getMenuType()
-    {
+    public String getMenuType() {
         return menuType;
     }
 
-    public void setMenuType(String menuType)
-    {
+    public void setMenuType(String menuType) {
         this.menuType = menuType;
     }
 
-    public String getVisible()
-    {
+    public String getVisible() {
         return visible;
     }
 
-    public void setVisible(String visible)
-    {
+    public void setVisible(String visible) {
         this.visible = visible;
     }
 
-    public String getStatus()
-    {
+    public String getStatus() {
         return status;
     }
 
-    public void setStatus(String status)
-    {
+    public void setStatus(String status) {
         this.status = status;
     }
 
     @Size(min = 0, max = 100, message = "权限标识长度不能超过100个字符")
-    public String getPerms()
-    {
+    public String getPerms() {
         return perms;
     }
 
-    public void setPerms(String perms)
-    {
+    public void setPerms(String perms) {
         this.perms = perms;
     }
 
-    public String getIcon()
-    {
+    public String getIcon() {
         return icon;
     }
 
-    public void setIcon(String icon)
-    {
+    public void setIcon(String icon) {
         this.icon = icon;
     }
 
-    public List<SysMenu> getChildren()
-    {
+    public List<SysMenu> getChildren() {
         return children;
     }
 
-    public void setChildren(List<SysMenu> children)
-    {
+    public void setChildren(List<SysMenu> children) {
         this.children = children;
     }
-    
+
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("menuId", getMenuId())
-            .append("menuName", getMenuName())
-            .append("parentId", getParentId())
-            .append("orderNum", getOrderNum())
-            .append("path", getPath())
-            .append("component", getComponent())
-            .append("isFrame", getIsFrame())
-            .append("IsCache", getIsCache())
-            .append("menuType", getMenuType())
-            .append("visible", getVisible())
-            .append("status ", getStatus())
-            .append("perms", getPerms())
-            .append("icon", getIcon())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .toString();
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("menuId", getMenuId())
+                .append("menuName", getMenuName())
+                .append("parentId", getParentId())
+                .append("orderNum", getOrderNum())
+                .append("path", getPath())
+                .append("component", getComponent())
+                .append("isFrame", getIsFrame())
+                .append("IsCache", getIsCache())
+                .append("menuType", getMenuType())
+                .append("visible", getVisible())
+                .append("status ", getStatus())
+                .append("perms", getPerms())
+                .append("icon", getIcon())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .append("remark", getRemark())
+                .toString();
     }
 }

+ 94 - 98
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java

@@ -1,241 +1,237 @@
 package com.ruoyi.common.core.domain.entity;
 
-import java.util.Set;
-import javax.validation.constraints.NotBlank;
-import javax.validation.constraints.NotNull;
-import javax.validation.constraints.Size;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.annotation.Excel.ColumnType;
 import com.ruoyi.common.core.domain.BaseEntity;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.util.Set;
 
 /**
  * 角色表 sys_role
- * 
+ *
  * @author ruoyi
  */
-public class SysRole extends BaseEntity
-{
+public class SysRole extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 角色ID */
+    /**
+     * 角色ID
+     */
     @Excel(name = "角色序号", cellType = ColumnType.NUMERIC)
     private Long roleId;
 
-    /** 角色名称 */
+    /**
+     * 角色名称
+     */
     @Excel(name = "角色名称")
     private String roleName;
 
-    /** 角色权限 */
+    /**
+     * 角色权限
+     */
     @Excel(name = "角色权限")
     private String roleKey;
 
-    /** 角色排序 */
+    /**
+     * 角色排序
+     */
     @Excel(name = "角色排序")
     private Integer roleSort;
 
-    /** 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限) */
+    /**
+     * 数据范围(1:所有数据权限;2:自定义数据权限;3:本部门数据权限;4:本部门及以下数据权限;5:仅本人数据权限)
+     */
     @Excel(name = "数据范围", readConverterExp = "1=所有数据权限,2=自定义数据权限,3=本部门数据权限,4=本部门及以下数据权限,5=仅本人数据权限")
     private String dataScope;
 
-    /** 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示) */
+    /**
+     * 菜单树选择项是否关联显示( 0:父子不互相关联显示 1:父子互相关联显示)
+     */
     private boolean menuCheckStrictly;
 
-    /** 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 ) */
+    /**
+     * 部门树选择项是否关联显示(0:父子不互相关联显示 1:父子互相关联显示 )
+     */
     private boolean deptCheckStrictly;
 
-    /** 角色状态(0正常 1停用) */
+    /**
+     * 角色状态(0正常 1停用)
+     */
     @Excel(name = "角色状态", readConverterExp = "0=正常,1=停用")
     private String status;
 
-    /** 删除标志(0代表存在 2代表删除) */
+    /**
+     * 删除标志(0代表存在 2代表删除)
+     */
     private String delFlag;
 
-    /** 用户是否存在此角色标识 默认不存在 */
+    /**
+     * 用户是否存在此角色标识 默认不存在
+     */
     private boolean flag = false;
 
-    /** 菜单组 */
+    /**
+     * 菜单组
+     */
     private Long[] menuIds;
 
-    /** 部门组(数据权限) */
+    /**
+     * 部门组(数据权限)
+     */
     private Long[] deptIds;
 
-    /** 角色菜单权限 */
+    /**
+     * 角色菜单权限
+     */
     private Set<String> permissions;
 
-    public SysRole()
-    {
+    public SysRole() {
 
     }
 
-    public SysRole(Long roleId)
-    {
+    public SysRole(Long roleId) {
         this.roleId = roleId;
     }
 
-    public Long getRoleId()
-    {
+    public Long getRoleId() {
         return roleId;
     }
 
-    public void setRoleId(Long roleId)
-    {
+    public void setRoleId(Long roleId) {
         this.roleId = roleId;
     }
 
-    public boolean isAdmin()
-    {
+    public boolean isAdmin() {
         return isAdmin(this.roleId);
     }
 
-    public static boolean isAdmin(Long roleId)
-    {
+    public static boolean isAdmin(Long roleId) {
         return roleId != null && 1L == roleId;
     }
 
     @NotBlank(message = "角色名称不能为空")
     @Size(min = 0, max = 30, message = "角色名称长度不能超过30个字符")
-    public String getRoleName()
-    {
+    public String getRoleName() {
         return roleName;
     }
 
-    public void setRoleName(String roleName)
-    {
+    public void setRoleName(String roleName) {
         this.roleName = roleName;
     }
 
     @NotBlank(message = "权限字符不能为空")
     @Size(min = 0, max = 100, message = "权限字符长度不能超过100个字符")
-    public String getRoleKey()
-    {
+    public String getRoleKey() {
         return roleKey;
     }
 
-    public void setRoleKey(String roleKey)
-    {
+    public void setRoleKey(String roleKey) {
         this.roleKey = roleKey;
     }
 
     @NotNull(message = "显示顺序不能为空")
-    public Integer getRoleSort()
-    {
+    public Integer getRoleSort() {
         return roleSort;
     }
 
-    public void setRoleSort(Integer roleSort)
-    {
+    public void setRoleSort(Integer roleSort) {
         this.roleSort = roleSort;
     }
 
-    public String getDataScope()
-    {
+    public String getDataScope() {
         return dataScope;
     }
 
-    public void setDataScope(String dataScope)
-    {
+    public void setDataScope(String dataScope) {
         this.dataScope = dataScope;
     }
 
-    public boolean isMenuCheckStrictly()
-    {
+    public boolean isMenuCheckStrictly() {
         return menuCheckStrictly;
     }
 
-    public void setMenuCheckStrictly(boolean menuCheckStrictly)
-    {
+    public void setMenuCheckStrictly(boolean menuCheckStrictly) {
         this.menuCheckStrictly = menuCheckStrictly;
     }
 
-    public boolean isDeptCheckStrictly()
-    {
+    public boolean isDeptCheckStrictly() {
         return deptCheckStrictly;
     }
 
-    public void setDeptCheckStrictly(boolean deptCheckStrictly)
-    {
+    public void setDeptCheckStrictly(boolean deptCheckStrictly) {
         this.deptCheckStrictly = deptCheckStrictly;
     }
 
-    public String getStatus()
-    {
+    public String getStatus() {
         return status;
     }
 
-    public void setStatus(String status)
-    {
+    public void setStatus(String status) {
         this.status = status;
     }
 
-    public String getDelFlag()
-    {
+    public String getDelFlag() {
         return delFlag;
     }
 
-    public void setDelFlag(String delFlag)
-    {
+    public void setDelFlag(String delFlag) {
         this.delFlag = delFlag;
     }
 
-    public boolean isFlag()
-    {
+    public boolean isFlag() {
         return flag;
     }
 
-    public void setFlag(boolean flag)
-    {
+    public void setFlag(boolean flag) {
         this.flag = flag;
     }
 
-    public Long[] getMenuIds()
-    {
+    public Long[] getMenuIds() {
         return menuIds;
     }
 
-    public void setMenuIds(Long[] menuIds)
-    {
+    public void setMenuIds(Long[] menuIds) {
         this.menuIds = menuIds;
     }
 
-    public Long[] getDeptIds()
-    {
+    public Long[] getDeptIds() {
         return deptIds;
     }
 
-    public void setDeptIds(Long[] deptIds)
-    {
+    public void setDeptIds(Long[] deptIds) {
         this.deptIds = deptIds;
     }
 
-    public Set<String> getPermissions()
-    {
+    public Set<String> getPermissions() {
         return permissions;
     }
 
-    public void setPermissions(Set<String> permissions)
-    {
+    public void setPermissions(Set<String> permissions) {
         this.permissions = permissions;
     }
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("roleId", getRoleId())
-            .append("roleName", getRoleName())
-            .append("roleKey", getRoleKey())
-            .append("roleSort", getRoleSort())
-            .append("dataScope", getDataScope())
-            .append("menuCheckStrictly", isMenuCheckStrictly())
-            .append("deptCheckStrictly", isDeptCheckStrictly())
-            .append("status", getStatus())
-            .append("delFlag", getDelFlag())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .toString();
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("roleId", getRoleId())
+                .append("roleName", getRoleName())
+                .append("roleKey", getRoleKey())
+                .append("roleSort", getRoleSort())
+                .append("dataScope", getDataScope())
+                .append("menuCheckStrictly", isMenuCheckStrictly())
+                .append("deptCheckStrictly", isDeptCheckStrictly())
+                .append("status", getStatus())
+                .append("delFlag", getDelFlag())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .append("remark", getRemark())
+                .toString();
     }
 }

+ 127 - 129
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java

@@ -1,92 +1,130 @@
 package com.ruoyi.common.core.domain.entity;
 
-import java.util.Date;
-import java.util.List;
-import javax.validation.constraints.*;
-import org.apache.commons.lang3.builder.ToStringBuilder;
-import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.annotation.Excel.ColumnType;
 import com.ruoyi.common.annotation.Excel.Type;
 import com.ruoyi.common.annotation.Excels;
 import com.ruoyi.common.core.domain.BaseEntity;
 import com.ruoyi.common.xss.Xss;
+import org.apache.commons.lang3.builder.ToStringBuilder;
+import org.apache.commons.lang3.builder.ToStringStyle;
+
+import javax.validation.constraints.Email;
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.Size;
+import java.util.Date;
+import java.util.List;
 
 /**
  * 用户对象 sys_user
- * 
+ *
  * @author ruoyi
  */
-public class SysUser extends BaseEntity
-{
+public class SysUser extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 用户ID */
+    /**
+     * 用户ID
+     */
     @Excel(name = "用户序号", cellType = ColumnType.NUMERIC, prompt = "用户编号")
     private Long userId;
 
-    /** 部门ID */
+    /**
+     * 部门ID
+     */
     @Excel(name = "部门编号", type = Type.IMPORT)
     private Long deptId;
 
-    /** 用户账号 */
+    /**
+     * 用户账号
+     */
     @Excel(name = "登录名称")
     private String userName;
 
-    /** 用户昵称 */
+    /**
+     * 用户昵称
+     */
     @Excel(name = "用户名称")
     private String nickName;
 
-    /** 用户邮箱 */
+    /**
+     * 用户邮箱
+     */
     @Excel(name = "用户邮箱")
     private String email;
 
-    /** 手机号码 */
+    /**
+     * 手机号码
+     */
     @Excel(name = "手机号码")
     private String phonenumber;
 
-    /** 用户性别 */
+    /**
+     * 用户性别
+     */
     @Excel(name = "用户性别", readConverterExp = "0=男,1=女,2=未知")
     private String sex;
 
-    /** 用户头像 */
+    /**
+     * 用户头像
+     */
     private String avatar;
 
-    /** 密码 */
+    /**
+     * 密码
+     */
     private String password;
 
-    /** 帐号状态(0正常 1停用) */
+    /**
+     * 帐号状态(0正常 1停用)
+     */
     @Excel(name = "帐号状态", readConverterExp = "0=正常,1=停用")
     private String status;
 
-    /** 删除标志(0代表存在 2代表删除) */
+    /**
+     * 删除标志(0代表存在 2代表删除)
+     */
     private String delFlag;
 
-    /** 最后登录IP */
+    /**
+     * 最后登录IP
+     */
     @Excel(name = "最后登录IP", type = Type.EXPORT)
     private String loginIp;
 
-    /** 最后登录时间 */
+    /**
+     * 最后登录时间
+     */
     @Excel(name = "最后登录时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss", type = Type.EXPORT)
     private Date loginDate;
 
-    /** 部门对象 */
+    /**
+     * 部门对象
+     */
     @Excels({
-        @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
-        @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
+            @Excel(name = "部门名称", targetAttr = "deptName", type = Type.EXPORT),
+            @Excel(name = "部门负责人", targetAttr = "leader", type = Type.EXPORT)
     })
     private SysDept dept;
 
-    /** 角色对象 */
+    /**
+     * 角色对象
+     */
     private List<SysRole> roles;
 
-    /** 角色组 */
+    /**
+     * 角色组
+     */
     private Long[] roleIds;
 
-    /** 岗位组 */
+    /**
+     * 岗位组
+     */
     private Long[] postIds;
 
-    /** 角色ID */
+    /**
+     * 角色ID
+     */
     private Long roleId;
 
     private int points;
@@ -94,211 +132,171 @@ public class SysUser extends BaseEntity
     private int totalPoints;
     private int trialCount;
 
-    public SysUser()
-    {
+    public SysUser() {
 
     }
 
-    public SysUser(Long userId)
-    {
+    public SysUser(Long userId) {
         this.userId = userId;
     }
 
-    public Long getUserId()
-    {
+    public Long getUserId() {
         return userId;
     }
 
-    public void setUserId(Long userId)
-    {
+    public void setUserId(Long userId) {
         this.userId = userId;
     }
 
-    public boolean isAdmin()
-    {
+    public boolean isAdmin() {
         return isAdmin(this.userId);
     }
 
-    public static boolean isAdmin(Long userId)
-    {
+    public static boolean isAdmin(Long userId) {
         return userId != null && 1L == userId;
     }
 
-    public Long getDeptId()
-    {
+    public Long getDeptId() {
         return deptId;
     }
 
-    public void setDeptId(Long deptId)
-    {
+    public void setDeptId(Long deptId) {
         this.deptId = deptId;
     }
 
     @Xss(message = "用户昵称不能包含脚本字符")
     @Size(min = 0, max = 30, message = "用户昵称长度不能超过30个字符")
-    public String getNickName()
-    {
+    public String getNickName() {
         return nickName;
     }
 
-    public void setNickName(String nickName)
-    {
+    public void setNickName(String nickName) {
         this.nickName = nickName;
     }
 
     @Xss(message = "用户账号不能包含脚本字符")
     @NotBlank(message = "用户账号不能为空")
     @Size(min = 0, max = 30, message = "用户账号长度不能超过30个字符")
-    public String getUserName()
-    {
+    public String getUserName() {
         return userName;
     }
 
-    public void setUserName(String userName)
-    {
+    public void setUserName(String userName) {
         this.userName = userName;
     }
 
     @Email(message = "邮箱格式不正确")
     @Size(min = 0, max = 50, message = "邮箱长度不能超过50个字符")
-    public String getEmail()
-    {
+    public String getEmail() {
         return email;
     }
 
-    public void setEmail(String email)
-    {
+    public void setEmail(String email) {
         this.email = email;
     }
 
     @Size(min = 0, max = 11, message = "手机号码长度不能超过11个字符")
-    public String getPhonenumber()
-    {
+    public String getPhonenumber() {
         return phonenumber;
     }
 
-    public void setPhonenumber(String phonenumber)
-    {
+    public void setPhonenumber(String phonenumber) {
         this.phonenumber = phonenumber;
     }
 
-    public String getSex()
-    {
+    public String getSex() {
         return sex;
     }
 
-    public void setSex(String sex)
-    {
+    public void setSex(String sex) {
         this.sex = sex;
     }
 
-    public String getAvatar()
-    {
+    public String getAvatar() {
         return avatar;
     }
 
-    public void setAvatar(String avatar)
-    {
+    public void setAvatar(String avatar) {
         this.avatar = avatar;
     }
 
-    public String getPassword()
-    {
+    public String getPassword() {
         return password;
     }
 
-    public void setPassword(String password)
-    {
+    public void setPassword(String password) {
         this.password = password;
     }
 
-    public String getStatus()
-    {
+    public String getStatus() {
         return status;
     }
 
-    public void setStatus(String status)
-    {
+    public void setStatus(String status) {
         this.status = status;
     }
 
-    public String getDelFlag()
-    {
+    public String getDelFlag() {
         return delFlag;
     }
 
-    public void setDelFlag(String delFlag)
-    {
+    public void setDelFlag(String delFlag) {
         this.delFlag = delFlag;
     }
 
-    public String getLoginIp()
-    {
+    public String getLoginIp() {
         return loginIp;
     }
 
-    public void setLoginIp(String loginIp)
-    {
+    public void setLoginIp(String loginIp) {
         this.loginIp = loginIp;
     }
 
-    public Date getLoginDate()
-    {
+    public Date getLoginDate() {
         return loginDate;
     }
 
-    public void setLoginDate(Date loginDate)
-    {
+    public void setLoginDate(Date loginDate) {
         this.loginDate = loginDate;
     }
 
-    public SysDept getDept()
-    {
+    public SysDept getDept() {
         return dept;
     }
 
-    public void setDept(SysDept dept)
-    {
+    public void setDept(SysDept dept) {
         this.dept = dept;
     }
 
-    public List<SysRole> getRoles()
-    {
+    public List<SysRole> getRoles() {
         return roles;
     }
 
-    public void setRoles(List<SysRole> roles)
-    {
+    public void setRoles(List<SysRole> roles) {
         this.roles = roles;
     }
 
-    public Long[] getRoleIds()
-    {
+    public Long[] getRoleIds() {
         return roleIds;
     }
 
-    public void setRoleIds(Long[] roleIds)
-    {
+    public void setRoleIds(Long[] roleIds) {
         this.roleIds = roleIds;
     }
 
-    public Long[] getPostIds()
-    {
+    public Long[] getPostIds() {
         return postIds;
     }
 
-    public void setPostIds(Long[] postIds)
-    {
+    public void setPostIds(Long[] postIds) {
         this.postIds = postIds;
     }
 
-    public Long getRoleId()
-    {
+    public Long getRoleId() {
         return roleId;
     }
 
-    public void setRoleId(Long roleId)
-    {
+    public void setRoleId(Long roleId) {
         this.roleId = roleId;
     }
 
@@ -336,26 +334,26 @@ public class SysUser extends BaseEntity
 
     @Override
     public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-            .append("userId", getUserId())
-            .append("deptId", getDeptId())
-            .append("userName", getUserName())
-            .append("nickName", getNickName())
-            .append("email", getEmail())
-            .append("phonenumber", getPhonenumber())
-            .append("sex", getSex())
-            .append("avatar", getAvatar())
-            .append("password", getPassword())
-            .append("status", getStatus())
-            .append("delFlag", getDelFlag())
-            .append("loginIp", getLoginIp())
-            .append("loginDate", getLoginDate())
-            .append("createBy", getCreateBy())
-            .append("createTime", getCreateTime())
-            .append("updateBy", getUpdateBy())
-            .append("updateTime", getUpdateTime())
-            .append("remark", getRemark())
-            .append("dept", getDept())
-            .toString();
+        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+                .append("userId", getUserId())
+                .append("deptId", getDeptId())
+                .append("userName", getUserName())
+                .append("nickName", getNickName())
+                .append("email", getEmail())
+                .append("phonenumber", getPhonenumber())
+                .append("sex", getSex())
+                .append("avatar", getAvatar())
+                .append("password", getPassword())
+                .append("status", getStatus())
+                .append("delFlag", getDelFlag())
+                .append("loginIp", getLoginIp())
+                .append("loginDate", getLoginDate())
+                .append("createBy", getCreateBy())
+                .append("createTime", getCreateTime())
+                .append("updateBy", getUpdateBy())
+                .append("updateTime", getUpdateTime())
+                .append("remark", getRemark())
+                .append("dept", getDept())
+                .toString();
     }
 }

+ 10 - 19
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java

@@ -2,11 +2,10 @@ package com.ruoyi.common.core.domain.model;
 
 /**
  * 用户登录对象
- * 
+ *
  * @author ruoyi
  */
-public class LoginBody
-{
+public class LoginBody {
     /**
      * 用户名
      */
@@ -27,43 +26,35 @@ public class LoginBody
      */
     private String uuid;
 
-    public String getUsername()
-    {
+    public String getUsername() {
         return username;
     }
 
-    public void setUsername(String username)
-    {
+    public void setUsername(String username) {
         this.username = username;
     }
 
-    public String getPassword()
-    {
+    public String getPassword() {
         return password;
     }
 
-    public void setPassword(String password)
-    {
+    public void setPassword(String password) {
         this.password = password;
     }
 
-    public String getCode()
-    {
+    public String getCode() {
         return code;
     }
 
-    public void setCode(String code)
-    {
+    public void setCode(String code) {
         this.code = code;
     }
 
-    public String getUuid()
-    {
+    public String getUuid() {
         return uuid;
     }
 
-    public void setUuid(String uuid)
-    {
+    public void setUuid(String uuid) {
         this.uuid = uuid;
     }
 }

+ 42 - 75
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java

@@ -1,20 +1,19 @@
 package com.ruoyi.common.core.domain.model;
 
-import java.util.Collection;
-import java.util.Date;
-import java.util.Set;
-import org.springframework.security.core.GrantedAuthority;
-import org.springframework.security.core.userdetails.UserDetails;
 import com.alibaba.fastjson2.annotation.JSONField;
 import com.ruoyi.common.core.domain.entity.SysUser;
+import org.springframework.security.core.GrantedAuthority;
+import org.springframework.security.core.userdetails.UserDetails;
+
+import java.util.Collection;
+import java.util.Set;
 
 /**
  * 登录用户身份权限
- * 
+ *
  * @author ruoyi
  */
-public class LoginUser implements UserDetails
-{
+public class LoginUser implements UserDetails {
     private static final long serialVersionUID = 1L;
 
     /**
@@ -72,48 +71,39 @@ public class LoginUser implements UserDetails
      */
     private SysUser user;
 
-    public Long getUserId()
-    {
+    public Long getUserId() {
         return userId;
     }
 
-    public void setUserId(Long userId)
-    {
+    public void setUserId(Long userId) {
         this.userId = userId;
     }
 
-    public Long getDeptId()
-    {
+    public Long getDeptId() {
         return deptId;
     }
 
-    public void setDeptId(Long deptId)
-    {
+    public void setDeptId(Long deptId) {
         this.deptId = deptId;
     }
 
-    public String getToken()
-    {
+    public String getToken() {
         return token;
     }
 
-    public void setToken(String token)
-    {
+    public void setToken(String token) {
         this.token = token;
     }
 
-    public LoginUser()
-    {
+    public LoginUser() {
     }
 
-    public LoginUser(SysUser user, Set<String> permissions)
-    {
+    public LoginUser(SysUser user, Set<String> permissions) {
         this.user = user;
         this.permissions = permissions;
     }
 
-    public LoginUser(Long userId, Long deptId, SysUser user, Set<String> permissions)
-    {
+    public LoginUser(Long userId, Long deptId, SysUser user, Set<String> permissions) {
         this.userId = userId;
         this.deptId = deptId;
         this.user = user;
@@ -122,14 +112,12 @@ public class LoginUser implements UserDetails
 
     @JSONField(serialize = false)
     @Override
-    public String getPassword()
-    {
+    public String getPassword() {
         return user.getPassword();
     }
 
     @Override
-    public String getUsername()
-    {
+    public String getUsername() {
         return user.getUserName();
     }
 
@@ -138,124 +126,104 @@ public class LoginUser implements UserDetails
      */
     @JSONField(serialize = false)
     @Override
-    public boolean isAccountNonExpired()
-    {
+    public boolean isAccountNonExpired() {
         return true;
     }
 
     /**
      * 指定用户是否解锁,锁定的用户无法进行身份验证
-     * 
+     *
      * @return
      */
     @JSONField(serialize = false)
     @Override
-    public boolean isAccountNonLocked()
-    {
+    public boolean isAccountNonLocked() {
         return true;
     }
 
     /**
      * 指示是否已过期的用户的凭据(密码),过期的凭据防止认证
-     * 
+     *
      * @return
      */
     @JSONField(serialize = false)
     @Override
-    public boolean isCredentialsNonExpired()
-    {
+    public boolean isCredentialsNonExpired() {
         return true;
     }
 
     /**
      * 是否可用 ,禁用的用户不能身份验证
-     * 
+     *
      * @return
      */
     @JSONField(serialize = false)
     @Override
-    public boolean isEnabled()
-    {
+    public boolean isEnabled() {
         return true;
     }
 
-    public Long getLoginTime()
-    {
+    public Long getLoginTime() {
         return loginTime;
     }
 
-    public void setLoginTime(Long loginTime)
-    {
+    public void setLoginTime(Long loginTime) {
         this.loginTime = loginTime;
     }
 
-    public String getIpaddr()
-    {
+    public String getIpaddr() {
         return ipaddr;
     }
 
-    public void setIpaddr(String ipaddr)
-    {
+    public void setIpaddr(String ipaddr) {
         this.ipaddr = ipaddr;
     }
 
-    public String getLoginLocation()
-    {
+    public String getLoginLocation() {
         return loginLocation;
     }
 
-    public void setLoginLocation(String loginLocation)
-    {
+    public void setLoginLocation(String loginLocation) {
         this.loginLocation = loginLocation;
     }
 
-    public String getBrowser()
-    {
+    public String getBrowser() {
         return browser;
     }
 
-    public void setBrowser(String browser)
-    {
+    public void setBrowser(String browser) {
         this.browser = browser;
     }
 
-    public String getOs()
-    {
+    public String getOs() {
         return os;
     }
 
-    public void setOs(String os)
-    {
+    public void setOs(String os) {
         this.os = os;
     }
 
-    public Long getExpireTime()
-    {
+    public Long getExpireTime() {
         return expireTime;
     }
 
-    public void setExpireTime(Long expireTime)
-    {
+    public void setExpireTime(Long expireTime) {
         this.expireTime = expireTime;
     }
 
-    public Set<String> getPermissions()
-    {
+    public Set<String> getPermissions() {
         return permissions;
     }
 
-    public void setPermissions(Set<String> permissions)
-    {
+    public void setPermissions(Set<String> permissions) {
         this.permissions = permissions;
     }
 
-    public SysUser getUser()
-    {
+    public SysUser getUser() {
         return user;
     }
 
-    public void setUser(SysUser user)
-    {
+    public void setUser(SysUser user) {
         this.user = user;
     }
 /*
@@ -276,8 +244,7 @@ public class LoginUser implements UserDetails
     }*/
 
     @Override
-    public Collection<? extends GrantedAuthority> getAuthorities()
-    {
+    public Collection<? extends GrantedAuthority> getAuthorities() {
         return null;
     }
 }

+ 2 - 3
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/RegisterBody.java

@@ -2,10 +2,9 @@ package com.ruoyi.common.core.domain.model;
 
 /**
  * 用户注册对象
- * 
+ *
  * @author ruoyi
  */
-public class RegisterBody extends LoginBody
-{
+public class RegisterBody extends LoginBody {
 
 }

+ 33 - 41
ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java

@@ -4,98 +4,90 @@ import com.ruoyi.common.utils.StringUtils;
 
 /**
  * 分页数据
- * 
+ *
  * @author ruoyi
  */
-public class PageDomain
-{
-    /** 当前记录起始索引 */
+public class PageDomain {
+    /**
+     * 当前记录起始索引
+     */
     private Integer pageNum;
 
-    /** 每页显示记录数 */
+    /**
+     * 每页显示记录数
+     */
     private Integer pageSize;
 
-    /** 排序列 */
+    /**
+     * 排序列
+     */
     private String orderByColumn;
 
-    /** 排序的方向desc或者asc */
+    /**
+     * 排序的方向desc或者asc
+     */
     private String isAsc = "asc";
 
-    /** 分页参数合理化 */
+    /**
+     * 分页参数合理化
+     */
     private Boolean reasonable = true;
 
-    public String getOrderBy()
-    {
-        if (StringUtils.isEmpty(orderByColumn))
-        {
+    public String getOrderBy() {
+        if (StringUtils.isEmpty(orderByColumn)) {
             return "";
         }
         return StringUtils.toUnderScoreCase(orderByColumn) + " " + isAsc;
     }
 
-    public Integer getPageNum()
-    {
+    public Integer getPageNum() {
         return pageNum;
     }
 
-    public void setPageNum(Integer pageNum)
-    {
+    public void setPageNum(Integer pageNum) {
         this.pageNum = pageNum;
     }
 
-    public Integer getPageSize()
-    {
+    public Integer getPageSize() {
         return pageSize;
     }
 
-    public void setPageSize(Integer pageSize)
-    {
+    public void setPageSize(Integer pageSize) {
         this.pageSize = pageSize;
     }
 
-    public String getOrderByColumn()
-    {
+    public String getOrderByColumn() {
         return orderByColumn;
     }
 
-    public void setOrderByColumn(String orderByColumn)
-    {
+    public void setOrderByColumn(String orderByColumn) {
         this.orderByColumn = orderByColumn;
     }
 
-    public String getIsAsc()
-    {
+    public String getIsAsc() {
         return isAsc;
     }
 
-    public void setIsAsc(String isAsc)
-    {
-        if (StringUtils.isNotEmpty(isAsc))
-        {
+    public void setIsAsc(String isAsc) {
+        if (StringUtils.isNotEmpty(isAsc)) {
             // 兼容前端排序类型
-            if ("ascending".equals(isAsc))
-            {
+            if ("ascending".equals(isAsc)) {
                 isAsc = "asc";
-            }
-            else if ("descending".equals(isAsc))
-            {
+            } else if ("descending".equals(isAsc)) {
                 isAsc = "desc";
             }
             this.isAsc = isAsc;
         }
     }
 
-    public Boolean getReasonable()
-    {
-        if (StringUtils.isNull(reasonable))
-        {
+    public Boolean getReasonable() {
+        if (StringUtils.isNull(reasonable)) {
             return Boolean.TRUE;
         }
         return reasonable;
     }
 
-    public void setReasonable(Boolean reasonable)
-    {
+    public void setReasonable(Boolean reasonable) {
         this.reasonable = reasonable;
     }
 }

+ 26 - 29
ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java

@@ -5,81 +5,78 @@ import java.util.List;
 
 /**
  * 表格分页数据对象
- * 
+ *
  * @author ruoyi
  */
-public class TableDataInfo implements Serializable
-{
+public class TableDataInfo implements Serializable {
     private static final long serialVersionUID = 1L;
 
-    /** 总记录数 */
+    /**
+     * 总记录数
+     */
     private long total;
 
-    /** 列表数据 */
+    /**
+     * 列表数据
+     */
     private List<?> rows;
 
-    /** 消息状态码 */
+    /**
+     * 消息状态码
+     */
     private int code;
 
-    /** 消息内容 */
+    /**
+     * 消息内容
+     */
     private String msg;
 
     /**
      * 表格数据对象
      */
-    public TableDataInfo()
-    {
+    public TableDataInfo() {
     }
 
     /**
      * 分页
-     * 
-     * @param list 列表数据
+     *
+     * @param list  列表数据
      * @param total 总记录数
      */
-    public TableDataInfo(List<?> list, int total)
-    {
+    public TableDataInfo(List<?> list, int total) {
         this.rows = list;
         this.total = total;
     }
 
-    public long getTotal()
-    {
+    public long getTotal() {
         return total;
     }
 
-    public void setTotal(long total)
-    {
+    public void setTotal(long total) {
         this.total = total;
     }
 
-    public List<?> getRows()
-    {
+    public List<?> getRows() {
         return rows;
     }
 
-    public void setRows(List<?> rows)
-    {
+    public void setRows(List<?> rows) {
         this.rows = rows;
     }
 
-    public int getCode()
-    {
+    public int getCode() {
         return code;
     }
 
-    public void setCode(int code)
-    {
+    public void setCode(int code) {
         this.code = code;
     }
 
-    public String getMsg()
-    {
+    public String getMsg() {
         return msg;
     }
 
-    public void setMsg(String msg)
-    {
+    public void setMsg(String msg) {
         this.msg = msg;
     }
 }

+ 4 - 7
ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java

@@ -5,11 +5,10 @@ import com.ruoyi.common.utils.ServletUtils;
 
 /**
  * 表格数据处理
- * 
+ *
  * @author ruoyi
  */
-public class TableSupport
-{
+public class TableSupport {
     /**
      * 当前记录起始索引
      */
@@ -38,8 +37,7 @@ public class TableSupport
     /**
      * 封装分页对象
      */
-    public static PageDomain getPageDomain()
-    {
+    public static PageDomain getPageDomain() {
         PageDomain pageDomain = new PageDomain();
         pageDomain.setPageNum(Convert.toInt(ServletUtils.getParameter(PAGE_NUM), 1));
         pageDomain.setPageSize(Convert.toInt(ServletUtils.getParameter(PAGE_SIZE), 10));
@@ -49,8 +47,7 @@ public class TableSupport
         return pageDomain;
     }
 
-    public static PageDomain buildPageRequest()
-    {
+    public static PageDomain buildPageRequest() {
         return getPageDomain();
     }
 }

+ 40 - 65
ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java

@@ -1,11 +1,5 @@
 package com.ruoyi.common.core.redis;
 
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.TimeUnit;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.BoundSetOperations;
 import org.springframework.data.redis.core.HashOperations;
@@ -13,64 +7,62 @@ import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.ValueOperations;
 import org.springframework.stereotype.Component;
 
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
 /**
  * spring redis 工具类
  *
  * @author ruoyi
  **/
-@SuppressWarnings(value = { "unchecked", "rawtypes" })
+@SuppressWarnings(value = {"unchecked", "rawtypes"})
 @Component
-public class RedisCache
-{
+public class RedisCache {
     @Autowired
     public RedisTemplate redisTemplate;
 
     /**
      * 缓存基本的对象,Integer、String、实体类等
      *
-     * @param key 缓存的键值
+     * @param key   缓存的键值
      * @param value 缓存的值
      */
-    public <T> void setCacheObject(final String key, final T value)
-    {
+    public <T> void setCacheObject(final String key, final T value) {
         redisTemplate.opsForValue().set(key, value);
     }
 
     /**
      * 缓存基本的对象,Integer、String、实体类等
      *
-     * @param key 缓存的键值
-     * @param value 缓存的值
-     * @param timeout 时间
+     * @param key      缓存的键值
+     * @param value    缓存的值
+     * @param timeout  时间
      * @param timeUnit 时间颗粒度
      */
-    public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit)
-    {
+    public <T> void setCacheObject(final String key, final T value, final Integer timeout, final TimeUnit timeUnit) {
         redisTemplate.opsForValue().set(key, value, timeout, timeUnit);
     }
 
     /**
      * 设置有效时间
      *
-     * @param key Redis键
+     * @param key     Redis键
      * @param timeout 超时时间
      * @return true=设置成功;false=设置失败
      */
-    public boolean expire(final String key, final long timeout)
-    {
+    public boolean expire(final String key, final long timeout) {
         return expire(key, timeout, TimeUnit.SECONDS);
     }
 
     /**
      * 设置有效时间
      *
-     * @param key Redis键
+     * @param key     Redis键
      * @param timeout 超时时间
-     * @param unit 时间单位
+     * @param unit    时间单位
      * @return true=设置成功;false=设置失败
      */
-    public boolean expire(final String key, final long timeout, final TimeUnit unit)
-    {
+    public boolean expire(final String key, final long timeout, final TimeUnit unit) {
         return redisTemplate.expire(key, timeout, unit);
     }
 
@@ -80,8 +72,7 @@ public class RedisCache
      * @param key Redis键
      * @return 有效时间
      */
-    public long getExpire(final String key)
-    {
+    public long getExpire(final String key) {
         return redisTemplate.getExpire(key);
     }
 
@@ -91,8 +82,7 @@ public class RedisCache
      * @param key 键
      * @return true 存在 false不存在
      */
-    public Boolean hasKey(String key)
-    {
+    public Boolean hasKey(String key) {
         return redisTemplate.hasKey(key);
     }
 
@@ -102,8 +92,7 @@ public class RedisCache
      * @param key 缓存键值
      * @return 缓存键值对应的数据
      */
-    public <T> T getCacheObject(final String key)
-    {
+    public <T> T getCacheObject(final String key) {
         ValueOperations<String, T> operation = redisTemplate.opsForValue();
         return operation.get(key);
     }
@@ -113,8 +102,7 @@ public class RedisCache
      *
      * @param key
      */
-    public boolean deleteObject(final String key)
-    {
+    public boolean deleteObject(final String key) {
         return redisTemplate.delete(key);
     }
 
@@ -124,20 +112,18 @@ public class RedisCache
      * @param collection 多个对象
      * @return
      */
-    public boolean deleteObject(final Collection collection)
-    {
+    public boolean deleteObject(final Collection collection) {
         return redisTemplate.delete(collection) > 0;
     }
 
     /**
      * 缓存List数据
      *
-     * @param key 缓存的键值
+     * @param key      缓存的键值
      * @param dataList 待缓存的List数据
      * @return 缓存的对象
      */
-    public <T> long setCacheList(final String key, final List<T> dataList)
-    {
+    public <T> long setCacheList(final String key, final List<T> dataList) {
         Long count = redisTemplate.opsForList().rightPushAll(key, dataList);
         return count == null ? 0 : count;
     }
@@ -148,24 +134,21 @@ public class RedisCache
      * @param key 缓存的键值
      * @return 缓存键值对应的数据
      */
-    public <T> List<T> getCacheList(final String key)
-    {
+    public <T> List<T> getCacheList(final String key) {
         return redisTemplate.opsForList().range(key, 0, -1);
     }
 
     /**
      * 缓存Set
      *
-     * @param key 缓存键值
+     * @param key     缓存键值
      * @param dataSet 缓存的数据
      * @return 缓存数据的对象
      */
-    public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet)
-    {
+    public <T> BoundSetOperations<String, T> setCacheSet(final String key, final Set<T> dataSet) {
         BoundSetOperations<String, T> setOperation = redisTemplate.boundSetOps(key);
         Iterator<T> it = dataSet.iterator();
-        while (it.hasNext())
-        {
+        while (it.hasNext()) {
             setOperation.add(it.next());
         }
         return setOperation;
@@ -177,8 +160,7 @@ public class RedisCache
      * @param key
      * @return
      */
-    public <T> Set<T> getCacheSet(final String key)
-    {
+    public <T> Set<T> getCacheSet(final String key) {
         return redisTemplate.opsForSet().members(key);
     }
 
@@ -188,8 +170,7 @@ public class RedisCache
      * @param key
      * @param dataMap
      */
-    public <T> void setCacheMap(final String key, final Map<String, T> dataMap)
-    {
+    public <T> void setCacheMap(final String key, final Map<String, T> dataMap) {
         if (dataMap != null) {
             redisTemplate.opsForHash().putAll(key, dataMap);
         }
@@ -201,32 +182,29 @@ public class RedisCache
      * @param key
      * @return
      */
-    public <T> Map<String, T> getCacheMap(final String key)
-    {
+    public <T> Map<String, T> getCacheMap(final String key) {
         return redisTemplate.opsForHash().entries(key);
     }
 
     /**
      * 往Hash中存入数据
      *
-     * @param key Redis键
-     * @param hKey Hash键
+     * @param key   Redis键
+     * @param hKey  Hash键
      * @param value 值
      */
-    public <T> void setCacheMapValue(final String key, final String hKey, final T value)
-    {
+    public <T> void setCacheMapValue(final String key, final String hKey, final T value) {
         redisTemplate.opsForHash().put(key, hKey, value);
     }
 
     /**
      * 获取Hash中的数据
      *
-     * @param key Redis键
+     * @param key  Redis键
      * @param hKey Hash键
      * @return Hash中的对象
      */
-    public <T> T getCacheMapValue(final String key, final String hKey)
-    {
+    public <T> T getCacheMapValue(final String key, final String hKey) {
         HashOperations<String, String, T> opsForHash = redisTemplate.opsForHash();
         return opsForHash.get(key, hKey);
     }
@@ -234,24 +212,22 @@ public class RedisCache
     /**
      * 获取多个Hash中的数据
      *
-     * @param key Redis键
+     * @param key   Redis键
      * @param hKeys Hash键集合
      * @return Hash对象集合
      */
-    public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys)
-    {
+    public <T> List<T> getMultiCacheMapValue(final String key, final Collection<Object> hKeys) {
         return redisTemplate.opsForHash().multiGet(key, hKeys);
     }
 
     /**
      * 删除Hash中的某条数据
      *
-     * @param key Redis键
+     * @param key  Redis键
      * @param hKey Hash键
      * @return 是否成功
      */
-    public boolean deleteCacheMapValue(final String key, final String hKey)
-    {
+    public boolean deleteCacheMapValue(final String key, final String hKey) {
         return redisTemplate.opsForHash().delete(key, hKey) > 0;
     }
 
@@ -261,8 +237,7 @@ public class RedisCache
      * @param pattern 字符串前缀
      * @return 对象列表
      */
-    public Collection<String> keys(final String pattern)
-    {
+    public Collection<String> keys(final String pattern) {
         return redisTemplate.keys(pattern);
     }
 }

+ 15 - 31
ruoyi-common/src/main/java/com/ruoyi/common/core/text/StrFormatter.java

@@ -4,11 +4,10 @@ import com.ruoyi.common.utils.StringUtils;
 
 /**
  * 字符串格式化
- * 
+ *
  * @author ruoyi
  */
-public class StrFormatter
-{
+public class StrFormatter {
     public static final String EMPTY_JSON = "{}";
     public static final char C_BACKSLASH = '\\';
     public static final char C_DELIM_START = '{';
@@ -22,15 +21,13 @@ public class StrFormatter
      * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
      * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
      * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
-     * 
+     *
      * @param strPattern 字符串模板
-     * @param argArray 参数列表
+     * @param argArray   参数列表
      * @return 结果
      */
-    public static String format(final String strPattern, final Object... argArray)
-    {
-        if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray))
-        {
+    public static String format(final String strPattern, final Object... argArray) {
+        if (StringUtils.isEmpty(strPattern) || StringUtils.isEmpty(argArray)) {
             return strPattern;
         }
         final int strPatternLength = strPattern.length();
@@ -40,43 +37,30 @@ public class StrFormatter
 
         int handledPosition = 0;
         int delimIndex;// 占位符所在位置
-        for (int argIndex = 0; argIndex < argArray.length; argIndex++)
-        {
+        for (int argIndex = 0; argIndex < argArray.length; argIndex++) {
             delimIndex = strPattern.indexOf(EMPTY_JSON, handledPosition);
-            if (delimIndex == -1)
-            {
-                if (handledPosition == 0)
-                {
+            if (delimIndex == -1) {
+                if (handledPosition == 0) {
                     return strPattern;
-                }
-                else
-                { // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果
+                } else { // 字符串模板剩余部分不再包含占位符,加入剩余部分后返回结果
                     sbuf.append(strPattern, handledPosition, strPatternLength);
                     return sbuf.toString();
                 }
-            }
-            else
-            {
-                if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH)
-                {
-                    if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH)
-                    {
+            } else {
+                if (delimIndex > 0 && strPattern.charAt(delimIndex - 1) == C_BACKSLASH) {
+                    if (delimIndex > 1 && strPattern.charAt(delimIndex - 2) == C_BACKSLASH) {
                         // 转义符之前还有一个转义符,占位符依旧有效
                         sbuf.append(strPattern, handledPosition, delimIndex - 1);
                         sbuf.append(Convert.utf8Str(argArray[argIndex]));
                         handledPosition = delimIndex + 2;
-                    }
-                    else
-                    {
+                    } else {
                         // 占位符被转义
                         argIndex--;
                         sbuf.append(strPattern, handledPosition, delimIndex - 1);
                         sbuf.append(C_DELIM_START);
                         handledPosition = delimIndex + 1;
                     }
-                }
-                else
-                {
+                } else {
                     // 正常占位符
                     sbuf.append(strPattern, handledPosition, delimIndex);
                     sbuf.append(Convert.utf8Str(argArray[argIndex]));

+ 7 - 11
ruoyi-common/src/main/java/com/ruoyi/common/enums/HttpMethod.java

@@ -1,36 +1,32 @@
 package com.ruoyi.common.enums;
 
+import org.springframework.lang.Nullable;
+
 import java.util.HashMap;
 import java.util.Map;
-import org.springframework.lang.Nullable;
 
 /**
  * 请求方式
  *
  * @author ruoyi
  */
-public enum HttpMethod
-{
+public enum HttpMethod {
     GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
 
     private static final Map<String, HttpMethod> mappings = new HashMap<>(16);
 
-    static
-    {
-        for (HttpMethod httpMethod : values())
-        {
+    static {
+        for (HttpMethod httpMethod : values()) {
             mappings.put(httpMethod.name(), httpMethod);
         }
     }
 
     @Nullable
-    public static HttpMethod resolve(@Nullable String method)
-    {
+    public static HttpMethod resolve(@Nullable String method) {
         return (method != null ? mappings.get(method) : null);
     }
 
-    public boolean matches(String method)
-    {
+    public boolean matches(String method) {
         return (this == resolve(method));
     }
 }

+ 1 - 2
ruoyi-common/src/main/java/com/ruoyi/common/enums/LimitType.java

@@ -6,8 +6,7 @@ package com.ruoyi.common.enums;
  * @author ruoyi
  */
 
-public enum LimitType
-{
+public enum LimitType {
     /**
      * 默认策略全局限流
      */

+ 2 - 3
ruoyi-common/src/main/java/com/ruoyi/common/enums/OperatorType.java

@@ -2,11 +2,10 @@ package com.ruoyi.common.enums;
 
 /**
  * 操作人类别
- * 
+ *
  * @author ruoyi
  */
-public enum OperatorType
-{
+public enum OperatorType {
     /**
      * 其它
      */

+ 5 - 9
ruoyi-common/src/main/java/com/ruoyi/common/enums/UserStatus.java

@@ -2,29 +2,25 @@ package com.ruoyi.common.enums;
 
 /**
  * 用户状态
- * 
+ *
  * @author ruoyi
  */
-public enum UserStatus
-{
+public enum UserStatus {
     OK("0", "正常"), DISABLE("1", "停用"), DELETED("2", "删除");
 
     private final String code;
     private final String info;
 
-    UserStatus(String code, String info)
-    {
+    UserStatus(String code, String info) {
         this.code = code;
         this.info = info;
     }
 
-    public String getCode()
-    {
+    public String getCode() {
         return code;
     }
 
-    public String getInfo()
-    {
+    public String getInfo() {
         return info;
     }
 }

+ 11 - 20
ruoyi-common/src/main/java/com/ruoyi/common/exception/ServiceException.java

@@ -2,11 +2,10 @@ package com.ruoyi.common.exception;
 
 /**
  * 业务异常
- * 
+ *
  * @author ruoyi
  */
-public final class ServiceException extends RuntimeException
-{
+public final class ServiceException extends RuntimeException {
     private static final long serialVersionUID = 1L;
 
     /**
@@ -21,7 +20,7 @@ public final class ServiceException extends RuntimeException
 
     /**
      * 错误明细,内部调试错误
-     *
+     * <p>
      * 和 {@link CommonResult#getDetailMessage()} 一致的设计
      */
     private String detailMessage;
@@ -29,45 +28,37 @@ public final class ServiceException extends RuntimeException
     /**
      * 空构造方法,避免反序列化问题
      */
-    public ServiceException()
-    {
+    public ServiceException() {
     }
 
-    public ServiceException(String message)
-    {
+    public ServiceException(String message) {
         this.message = message;
     }
 
-    public ServiceException(String message, Integer code)
-    {
+    public ServiceException(String message, Integer code) {
         this.message = message;
         this.code = code;
     }
 
-    public String getDetailMessage()
-    {
+    public String getDetailMessage() {
         return detailMessage;
     }
 
     @Override
-    public String getMessage()
-    {
+    public String getMessage() {
         return message;
     }
 
-    public Integer getCode()
-    {
+    public Integer getCode() {
         return code;
     }
 
-    public ServiceException setMessage(String message)
-    {
+    public ServiceException setMessage(String message) {
         this.message = message;
         return this;
     }
 
-    public ServiceException setDetailMessage(String detailMessage)
-    {
+    public ServiceException setDetailMessage(String detailMessage) {
         this.detailMessage = detailMessage;
         return this;
     }

+ 5 - 9
ruoyi-common/src/main/java/com/ruoyi/common/exception/UtilException.java

@@ -2,25 +2,21 @@ package com.ruoyi.common.exception;
 
 /**
  * 工具类异常
- * 
+ *
  * @author ruoyi
  */
-public class UtilException extends RuntimeException
-{
+public class UtilException extends RuntimeException {
     private static final long serialVersionUID = 8247610319171014183L;
 
-    public UtilException(Throwable e)
-    {
+    public UtilException(Throwable e) {
         super(e.getMessage(), e);
     }
 
-    public UtilException(String message)
-    {
+    public UtilException(String message) {
         super(message);
     }
 
-    public UtilException(String message, Throwable throwable)
-    {
+    public UtilException(String message, Throwable throwable) {
         super(message, throwable);
     }
 }

+ 14 - 27
ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java

@@ -4,76 +4,63 @@ import java.util.Arrays;
 
 /**
  * 文件上传 误异常类
- * 
+ *
  * @author ruoyi
  */
-public class InvalidExtensionException extends FileUploadException
-{
+public class InvalidExtensionException extends FileUploadException {
     private static final long serialVersionUID = 1L;
 
     private String[] allowedExtension;
     private String extension;
     private String filename;
 
-    public InvalidExtensionException(String[] allowedExtension, String extension, String filename)
-    {
+    public InvalidExtensionException(String[] allowedExtension, String extension, String filename) {
         super("文件[" + filename + "]后缀[" + extension + "]不正确,请上传" + Arrays.toString(allowedExtension) + "格式");
         this.allowedExtension = allowedExtension;
         this.extension = extension;
         this.filename = filename;
     }
 
-    public String[] getAllowedExtension()
-    {
+    public String[] getAllowedExtension() {
         return allowedExtension;
     }
 
-    public String getExtension()
-    {
+    public String getExtension() {
         return extension;
     }
 
-    public String getFilename()
-    {
+    public String getFilename() {
         return filename;
     }
 
-    public static class InvalidImageExtensionException extends InvalidExtensionException
-    {
+    public static class InvalidImageExtensionException extends InvalidExtensionException {
         private static final long serialVersionUID = 1L;
 
-        public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename)
-        {
+        public InvalidImageExtensionException(String[] allowedExtension, String extension, String filename) {
             super(allowedExtension, extension, filename);
         }
     }
 
-    public static class InvalidFlashExtensionException extends InvalidExtensionException
-    {
+    public static class InvalidFlashExtensionException extends InvalidExtensionException {
         private static final long serialVersionUID = 1L;
 
-        public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename)
-        {
+        public InvalidFlashExtensionException(String[] allowedExtension, String extension, String filename) {
             super(allowedExtension, extension, filename);
         }
     }
 
-    public static class InvalidMediaExtensionException extends InvalidExtensionException
-    {
+    public static class InvalidMediaExtensionException extends InvalidExtensionException {
         private static final long serialVersionUID = 1L;
 
-        public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename)
-        {
+        public InvalidMediaExtensionException(String[] allowedExtension, String extension, String filename) {
             super(allowedExtension, extension, filename);
         }
     }
 
-    public static class InvalidVideoExtensionException extends InvalidExtensionException
-    {
+    public static class InvalidVideoExtensionException extends InvalidExtensionException {
         private static final long serialVersionUID = 1L;
 
-        public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename)
-        {
+        public InvalidVideoExtensionException(String[] allowedExtension, String extension, String filename) {
             super(allowedExtension, extension, filename);
         }
     }

+ 6 - 11
ruoyi-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java

@@ -2,33 +2,28 @@ package com.ruoyi.common.exception.job;
 
 /**
  * 计划策略异常
- * 
+ *
  * @author ruoyi
  */
-public class TaskException extends Exception
-{
+public class TaskException extends Exception {
     private static final long serialVersionUID = 1L;
 
     private Code code;
 
-    public TaskException(String msg, Code code)
-    {
+    public TaskException(String msg, Code code) {
         this(msg, code, null);
     }
 
-    public TaskException(String msg, Code code, Exception nestedEx)
-    {
+    public TaskException(String msg, Code code, Exception nestedEx) {
         super(msg, nestedEx);
         this.code = code;
     }
 
-    public Code getCode()
-    {
+    public Code getCode() {
         return code;
     }
 
-    public enum Code
-    {
+    public enum Code {
         TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE
     }
 }

+ 3 - 5
ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserException.java

@@ -4,15 +4,13 @@ import com.ruoyi.common.exception.base.BaseException;
 
 /**
  * 用户信息异常类
- * 
+ *
  * @author ruoyi
  */
-public class UserException extends BaseException
-{
+public class UserException extends BaseException {
     private static final long serialVersionUID = 1L;
 
-    public UserException(String code, Object[] args)
-    {
+    public UserException(String code, Object[] args) {
         super("user", code, args, null);
     }
 }

+ 3 - 5
ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserNotExistsException.java

@@ -2,15 +2,13 @@ package com.ruoyi.common.exception.user;
 
 /**
  * 用户不存在异常类
- * 
+ *
  * @author ruoyi
  */
-public class UserNotExistsException extends UserException
-{
+public class UserNotExistsException extends UserException {
     private static final long serialVersionUID = 1L;
 
-    public UserNotExistsException()
-    {
+    public UserNotExistsException() {
         super("user.not.exists", null);
     }
 }

+ 3 - 5
ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java

@@ -2,15 +2,13 @@ package com.ruoyi.common.exception.user;
 
 /**
  * 用户密码不正确或不符合规范异常类
- * 
+ *
  * @author ruoyi
  */
-public class UserPasswordNotMatchException extends UserException
-{
+public class UserPasswordNotMatchException extends UserException {
     private static final long serialVersionUID = 1L;
 
-    public UserPasswordNotMatchException()
-    {
+    public UserPasswordNotMatchException() {
         super("user.password.not.match", null);
     }
 }

+ 4 - 6
ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordRetryLimitExceedException.java

@@ -2,15 +2,13 @@ package com.ruoyi.common.exception.user;
 
 /**
  * 用户错误最大次数异常类
- * 
+ *
  * @author ruoyi
  */
-public class UserPasswordRetryLimitExceedException extends UserException
-{
+public class UserPasswordRetryLimitExceedException extends UserException {
     private static final long serialVersionUID = 1L;
 
-    public UserPasswordRetryLimitExceedException(int retryLimitCount, int lockTime)
-    {
-        super("user.password.retry.limit.exceed", new Object[] { retryLimitCount, lockTime });
+    public UserPasswordRetryLimitExceedException(int retryLimitCount, int lockTime) {
+        super("user.password.retry.limit.exceed", new Object[]{retryLimitCount, lockTime});
     }
 }

+ 5 - 9
ruoyi-common/src/main/java/com/ruoyi/common/filter/PropertyPreExcludeFilter.java

@@ -4,19 +4,15 @@ import com.alibaba.fastjson2.filter.SimplePropertyPreFilter;
 
 /**
  * 排除JSON敏感属性
- * 
+ *
  * @author ruoyi
  */
-public class PropertyPreExcludeFilter extends SimplePropertyPreFilter
-{
-    public PropertyPreExcludeFilter()
-    {
+public class PropertyPreExcludeFilter extends SimplePropertyPreFilter {
+    public PropertyPreExcludeFilter() {
     }
 
-    public PropertyPreExcludeFilter addExcludes(String... filters)
-    {
-        for (int i = 0; i < filters.length; i++)
-        {
+    public PropertyPreExcludeFilter addExcludes(String... filters) {
+        for (int i = 0; i < filters.length; i++) {
             this.getExcludes().add(filters[i]);
         }
         return this;

+ 13 - 25
ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java

@@ -1,52 +1,40 @@
 package com.ruoyi.common.filter;
 
-import java.io.IOException;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import org.springframework.http.MediaType;
 import com.ruoyi.common.utils.StringUtils;
+import org.springframework.http.MediaType;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import java.io.IOException;
 
 /**
  * Repeatable 过滤器
- * 
+ *
  * @author ruoyi
  */
-public class RepeatableFilter implements Filter
-{
+public class RepeatableFilter implements Filter {
     @Override
-    public void init(FilterConfig filterConfig) throws ServletException
-    {
+    public void init(FilterConfig filterConfig) throws ServletException {
 
     }
 
     @Override
     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
-            throws IOException, ServletException
-    {
+            throws IOException, ServletException {
         ServletRequest requestWrapper = null;
         if (request instanceof HttpServletRequest
-                && StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE))
-        {
+                && StringUtils.startsWithIgnoreCase(request.getContentType(), MediaType.APPLICATION_JSON_VALUE)) {
             requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response);
         }
-        if (null == requestWrapper)
-        {
+        if (null == requestWrapper) {
             chain.doFilter(request, response);
-        }
-        else
-        {
+        } else {
             chain.doFilter(requestWrapper, response);
         }
     }
 
     @Override
-    public void destroy()
-    {
+    public void destroy() {
 
     }
 }

+ 18 - 27
ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java

@@ -1,28 +1,27 @@
 package com.ruoyi.common.filter;
 
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.utils.http.HttpHelper;
+
 import javax.servlet.ReadListener;
 import javax.servlet.ServletInputStream;
 import javax.servlet.ServletResponse;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequestWrapper;
-import com.ruoyi.common.utils.http.HttpHelper;
-import com.ruoyi.common.constant.Constants;
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
 
 /**
  * 构建可重复读取inputStream的request
- * 
+ *
  * @author ruoyi
  */
-public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper
-{
+public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper {
     private final byte[] body;
 
-    public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException
-    {
+    public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException {
         super(request);
         request.setCharacterEncoding(Constants.UTF8);
         response.setCharacterEncoding(Constants.UTF8);
@@ -31,44 +30,36 @@ public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper
     }
 
     @Override
-    public BufferedReader getReader() throws IOException
-    {
+    public BufferedReader getReader() throws IOException {
         return new BufferedReader(new InputStreamReader(getInputStream()));
     }
 
     @Override
-    public ServletInputStream getInputStream() throws IOException
-    {
+    public ServletInputStream getInputStream() throws IOException {
         final ByteArrayInputStream bais = new ByteArrayInputStream(body);
-        return new ServletInputStream()
-        {
+        return new ServletInputStream() {
             @Override
-            public int read() throws IOException
-            {
+            public int read() throws IOException {
                 return bais.read();
             }
 
             @Override
-            public int available() throws IOException
-            {
+            public int available() throws IOException {
                 return body.length;
             }
 
             @Override
-            public boolean isFinished()
-            {
+            public boolean isFinished() {
                 return false;
             }
 
             @Override
-            public boolean isReady()
-            {
+            public boolean isReady() {
                 return false;
             }
 
             @Override
-            public void setReadListener(ReadListener readListener)
-            {
+            public void setReadListener(ReadListener readListener) {
 
             }
         };

+ 16 - 29
ruoyi-common/src/main/java/com/ruoyi/common/filter/XssFilter.java

@@ -1,40 +1,32 @@
 package com.ruoyi.common.filter;
 
+import com.ruoyi.common.enums.HttpMethod;
+import com.ruoyi.common.utils.StringUtils;
+
+import javax.servlet.*;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.FilterConfig;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.enums.HttpMethod;
 
 /**
  * 防止XSS攻击的过滤器
- * 
+ *
  * @author ruoyi
  */
-public class XssFilter implements Filter
-{
+public class XssFilter implements Filter {
     /**
      * 排除链接
      */
     public List<String> excludes = new ArrayList<>();
 
     @Override
-    public void init(FilterConfig filterConfig) throws ServletException
-    {
+    public void init(FilterConfig filterConfig) throws ServletException {
         String tempExcludes = filterConfig.getInitParameter("excludes");
-        if (StringUtils.isNotEmpty(tempExcludes))
-        {
+        if (StringUtils.isNotEmpty(tempExcludes)) {
             String[] url = tempExcludes.split(",");
-            for (int i = 0; url != null && i < url.length; i++)
-            {
+            for (int i = 0; url != null && i < url.length; i++) {
                 excludes.add(url[i]);
             }
         }
@@ -42,12 +34,10 @@ public class XssFilter implements Filter
 
     @Override
     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
-            throws IOException, ServletException
-    {
+            throws IOException, ServletException {
         HttpServletRequest req = (HttpServletRequest) request;
         HttpServletResponse resp = (HttpServletResponse) response;
-        if (handleExcludeURL(req, resp))
-        {
+        if (handleExcludeURL(req, resp)) {
             chain.doFilter(request, response);
             return;
         }
@@ -55,21 +45,18 @@ public class XssFilter implements Filter
         chain.doFilter(xssRequest, response);
     }
 
-    private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response)
-    {
+    private boolean handleExcludeURL(HttpServletRequest request, HttpServletResponse response) {
         String url = request.getServletPath();
         String method = request.getMethod();
         // GET DELETE 不过滤
-        if (method == null || HttpMethod.GET.matches(method) || HttpMethod.DELETE.matches(method))
-        {
+        if (method == null || HttpMethod.GET.matches(method) || HttpMethod.DELETE.matches(method)) {
             return true;
         }
         return StringUtils.matches(url, excludes);
     }
 
     @Override
-    public void destroy()
-    {
+    public void destroy() {
 
     }
 }

+ 25 - 39
ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java

@@ -1,42 +1,38 @@
 package com.ruoyi.common.filter;
 
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.html.EscapeUtil;
+import org.apache.commons.io.IOUtils;
+import org.springframework.http.HttpHeaders;
+import org.springframework.http.MediaType;
+
 import javax.servlet.ReadListener;
 import javax.servlet.ServletInputStream;
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletRequestWrapper;
-import org.apache.commons.io.IOUtils;
-import org.springframework.http.HttpHeaders;
-import org.springframework.http.MediaType;
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.html.EscapeUtil;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
 
 /**
  * XSS过滤处理
- * 
+ *
  * @author ruoyi
  */
-public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
-{
+public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper {
     /**
      * @param request
      */
-    public XssHttpServletRequestWrapper(HttpServletRequest request)
-    {
+    public XssHttpServletRequestWrapper(HttpServletRequest request) {
         super(request);
     }
 
     @Override
-    public String[] getParameterValues(String name)
-    {
+    public String[] getParameterValues(String name) {
         String[] values = super.getParameterValues(name);
-        if (values != null)
-        {
+        if (values != null) {
             int length = values.length;
             String[] escapesValues = new String[length];
-            for (int i = 0; i < length; i++)
-            {
+            for (int i = 0; i < length; i++) {
                 // 防xss攻击和过滤前后空格
                 escapesValues[i] = EscapeUtil.clean(values[i]).trim();
             }
@@ -46,18 +42,15 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
     }
 
     @Override
-    public ServletInputStream getInputStream() throws IOException
-    {
+    public ServletInputStream getInputStream() throws IOException {
         // 非json类型,直接返回
-        if (!isJsonRequest())
-        {
+        if (!isJsonRequest()) {
             return super.getInputStream();
         }
 
         // 为空,直接返回
         String json = IOUtils.toString(super.getInputStream(), "utf-8");
-        if (StringUtils.isEmpty(json))
-        {
+        if (StringUtils.isEmpty(json)) {
             return super.getInputStream();
         }
 
@@ -65,34 +58,28 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
         json = EscapeUtil.clean(json).trim();
         byte[] jsonBytes = json.getBytes("utf-8");
         final ByteArrayInputStream bis = new ByteArrayInputStream(jsonBytes);
-        return new ServletInputStream()
-        {
+        return new ServletInputStream() {
             @Override
-            public boolean isFinished()
-            {
+            public boolean isFinished() {
                 return true;
             }
 
             @Override
-            public boolean isReady()
-            {
+            public boolean isReady() {
                 return true;
             }
 
             @Override
-            public int available() throws IOException
-            {
+            public int available() throws IOException {
                 return jsonBytes.length;
             }
 
             @Override
-            public void setReadListener(ReadListener readListener)
-            {
+            public void setReadListener(ReadListener readListener) {
             }
 
             @Override
-            public int read() throws IOException
-            {
+            public int read() throws IOException {
                 return bis.read();
             }
         };
@@ -100,11 +87,10 @@ public class XssHttpServletRequestWrapper extends HttpServletRequestWrapper
 
     /**
      * 是否是Json请求
-     * 
+     *
      * @param request
      */
-    public boolean isJsonRequest()
-    {
+    public boolean isJsonRequest() {
         String header = super.getHeader(HttpHeaders.CONTENT_TYPE);
         return StringUtils.startsWithIgnoreCase(header, MediaType.APPLICATION_JSON_VALUE);
     }

+ 4 - 7
ruoyi-common/src/main/java/com/ruoyi/common/utils/LogUtils.java

@@ -2,15 +2,12 @@ package com.ruoyi.common.utils;
 
 /**
  * 处理并记录日志文件
- * 
+ *
  * @author ruoyi
  */
-public class LogUtils
-{
-    public static String getBlock(Object msg)
-    {
-        if (msg == null)
-        {
+public class LogUtils {
+    public static String getBlock(Object msg) {
+        if (msg == null) {
             msg = "";
         }
         return "[" + msg.toString() + "]";

+ 4 - 6
ruoyi-common/src/main/java/com/ruoyi/common/utils/MessageUtils.java

@@ -1,16 +1,15 @@
 package com.ruoyi.common.utils;
 
+import com.ruoyi.common.utils.spring.SpringUtils;
 import org.springframework.context.MessageSource;
 import org.springframework.context.i18n.LocaleContextHolder;
-import com.ruoyi.common.utils.spring.SpringUtils;
 
 /**
  * 获取i18n资源文件
- * 
+ *
  * @author ruoyi
  */
-public class MessageUtils
-{
+public class MessageUtils {
     /**
      * 根据消息键和参数 获取消息 委托给spring messageSource
      *
@@ -18,8 +17,7 @@ public class MessageUtils
      * @param args 参数
      * @return 获取国际化翻译值
      */
-    public static String message(String code, Object... args)
-    {
+    public static String message(String code, Object... args) {
         MessageSource messageSource = SpringUtils.getBean(MessageSource.class);
         return messageSource.getMessage(code, args, LocaleContextHolder.getLocale());
     }

+ 9 - 15
ruoyi-common/src/main/java/com/ruoyi/common/utils/PageUtils.java

@@ -2,25 +2,21 @@ package com.ruoyi.common.utils;
 
 import com.baomidou.mybatisplus.core.metadata.OrderItem;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.github.pagehelper.IPage;
 import com.github.pagehelper.PageHelper;
 import com.ruoyi.common.core.page.PageDomain;
 import com.ruoyi.common.core.page.TableSupport;
 import com.ruoyi.common.utils.sql.SqlUtil;
-import org.apache.poi.ss.formula.functions.T;
 
 /**
  * 分页工具类
- * 
+ *
  * @author ruoyi
  */
-public class PageUtils extends PageHelper
-{
+public class PageUtils extends PageHelper {
     /**
      * 设置请求分页数据
      */
-    public static void startPage()
-    {
+    public static void startPage() {
         PageDomain pageDomain = TableSupport.buildPageRequest();
         Integer pageNum = pageDomain.getPageNum();
         Integer pageSize = pageDomain.getPageSize();
@@ -32,16 +28,15 @@ public class PageUtils extends PageHelper
     /**
      * 设置请求分页数据
      */
-    public static <T> Page<T> startPage2()
-    {
+    public static <T> Page<T> startPage2() {
         PageDomain pageDomain = TableSupport.buildPageRequest();
-        Page<T> page = new Page<>(pageDomain.getPageNum(),pageDomain.getPageSize());
+        Page<T> page = new Page<>(pageDomain.getPageNum(), pageDomain.getPageSize());
         String orderByColumn = pageDomain.getOrderByColumn();
-        if(StringUtils.isNotEmpty(orderByColumn)){
+        if (StringUtils.isNotEmpty(orderByColumn)) {
             SqlUtil.escapeOrderBySql(orderByColumn);
-            if("desc".equals(pageDomain.getIsAsc())){
+            if ("desc".equals(pageDomain.getIsAsc())) {
                 page.addOrder(OrderItem.descs(orderByColumn));
-            }else {
+            } else {
                 page.addOrder(OrderItem.ascs(orderByColumn));
             }
         }
@@ -51,8 +46,7 @@ public class PageUtils extends PageHelper
     /**
      * 清理分页的线程变量
      */
-    public static void clearPage()
-    {
+    public static void clearPage() {
         PageHelper.clearPage();
     }
 }

+ 24 - 45
ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java

@@ -1,30 +1,25 @@
 package com.ruoyi.common.utils;
 
-import org.springframework.security.core.Authentication;
-import org.springframework.security.core.context.SecurityContextHolder;
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import com.ruoyi.common.constant.HttpStatus;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.exception.ServiceException;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.core.context.SecurityContextHolder;
+import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 
 /**
  * 安全服务工具类
- * 
+ *
  * @author ruoyi
  */
-public class SecurityUtils
-{
+public class SecurityUtils {
     /**
      * 用户ID
      **/
-    public static Long getUserId()
-    {
-        try
-        {
+    public static Long getUserId() {
+        try {
             return getLoginUser().getUserId();
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             throw new ServiceException("获取用户ID异常", HttpStatus.UNAUTHORIZED);
         }
     }
@@ -32,29 +27,21 @@ public class SecurityUtils
     /**
      * 获取部门ID
      **/
-    public static Long getDeptId()
-    {
-        try
-        {
+    public static Long getDeptId() {
+        try {
             return getLoginUser().getDeptId();
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             throw new ServiceException("获取部门ID异常", HttpStatus.UNAUTHORIZED);
         }
     }
-    
+
     /**
      * 获取用户账户
      **/
-    public static String getUsername()
-    {
-        try
-        {
+    public static String getUsername() {
+        try {
             return getLoginUser().getUsername();
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED);
         }
     }
@@ -62,14 +49,10 @@ public class SecurityUtils
     /**
      * 获取用户
      **/
-    public static LoginUser getLoginUser()
-    {
-        try
-        {
+    public static LoginUser getLoginUser() {
+        try {
             return (LoginUser) getAuthentication().getPrincipal();
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             throw new ServiceException("获取用户信息异常", HttpStatus.UNAUTHORIZED);
         }
     }
@@ -77,8 +60,7 @@ public class SecurityUtils
     /**
      * 获取Authentication
      */
-    public static Authentication getAuthentication()
-    {
+    public static Authentication getAuthentication() {
         return SecurityContextHolder.getContext().getAuthentication();
     }
 
@@ -88,8 +70,7 @@ public class SecurityUtils
      * @param password 密码
      * @return 加密字符串
      */
-    public static String encryptPassword(String password)
-    {
+    public static String encryptPassword(String password) {
         BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
         return passwordEncoder.encode(password);
     }
@@ -97,24 +78,22 @@ public class SecurityUtils
     /**
      * 判断密码是否相同
      *
-     * @param rawPassword 真实密码
+     * @param rawPassword     真实密码
      * @param encodedPassword 加密后字符
      * @return 结果
      */
-    public static boolean matchesPassword(String rawPassword, String encodedPassword)
-    {
+    public static boolean matchesPassword(String rawPassword, String encodedPassword) {
         BCryptPasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
         return passwordEncoder.matches(rawPassword, encodedPassword);
     }
 
     /**
      * 是否为管理员
-     * 
+     *
      * @param userId 用户ID
      * @return 结果
      */
-    public static boolean isAdmin(Long userId)
-    {
+    public static boolean isAdmin(Long userId) {
         return userId != null && 1L == userId;
     }
 }

+ 43 - 72
ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java

@@ -1,5 +1,15 @@
 package com.ruoyi.common.utils;
 
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.core.text.Convert;
+import org.springframework.web.context.request.RequestAttributes;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.ServletRequest;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.net.URLDecoder;
@@ -7,68 +17,52 @@ import java.net.URLEncoder;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import javax.servlet.http.HttpSession;
-import org.springframework.web.context.request.RequestAttributes;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
-import com.ruoyi.common.constant.Constants;
-import com.ruoyi.common.core.text.Convert;
 
 /**
  * 客户端工具类
- * 
+ *
  * @author ruoyi
  */
-public class ServletUtils
-{
+public class ServletUtils {
     /**
      * 获取String参数
      */
-    public static String getParameter(String name)
-    {
+    public static String getParameter(String name) {
         return getRequest().getParameter(name);
     }
 
     /**
      * 获取String参数
      */
-    public static String getParameter(String name, String defaultValue)
-    {
+    public static String getParameter(String name, String defaultValue) {
         return Convert.toStr(getRequest().getParameter(name), defaultValue);
     }
 
     /**
      * 获取Integer参数
      */
-    public static Integer getParameterToInt(String name)
-    {
+    public static Integer getParameterToInt(String name) {
         return Convert.toInt(getRequest().getParameter(name));
     }
 
     /**
      * 获取Integer参数
      */
-    public static Integer getParameterToInt(String name, Integer defaultValue)
-    {
+    public static Integer getParameterToInt(String name, Integer defaultValue) {
         return Convert.toInt(getRequest().getParameter(name), defaultValue);
     }
 
     /**
      * 获取Boolean参数
      */
-    public static Boolean getParameterToBool(String name)
-    {
+    public static Boolean getParameterToBool(String name) {
         return Convert.toBool(getRequest().getParameter(name));
     }
 
     /**
      * 获取Boolean参数
      */
-    public static Boolean getParameterToBool(String name, Boolean defaultValue)
-    {
+    public static Boolean getParameterToBool(String name, Boolean defaultValue) {
         return Convert.toBool(getRequest().getParameter(name), defaultValue);
     }
 
@@ -78,8 +72,7 @@ public class ServletUtils
      * @param request 请求对象{@link ServletRequest}
      * @return Map
      */
-    public static Map<String, String[]> getParams(ServletRequest request)
-    {
+    public static Map<String, String[]> getParams(ServletRequest request) {
         final Map<String, String[]> map = request.getParameterMap();
         return Collections.unmodifiableMap(map);
     }
@@ -90,11 +83,9 @@ public class ServletUtils
      * @param request 请求对象{@link ServletRequest}
      * @return Map
      */
-    public static Map<String, String> getParamMap(ServletRequest request)
-    {
+    public static Map<String, String> getParamMap(ServletRequest request) {
         Map<String, String> params = new HashMap<>();
-        for (Map.Entry<String, String[]> entry : getParams(request).entrySet())
-        {
+        for (Map.Entry<String, String[]> entry : getParams(request).entrySet()) {
             params.put(entry.getKey(), StringUtils.join(entry.getValue(), ","));
         }
         return params;
@@ -103,76 +94,64 @@ public class ServletUtils
     /**
      * 获取request
      */
-    public static HttpServletRequest getRequest()
-    {
+    public static HttpServletRequest getRequest() {
         return getRequestAttributes().getRequest();
     }
 
     /**
      * 获取response
      */
-    public static HttpServletResponse getResponse()
-    {
+    public static HttpServletResponse getResponse() {
         return getRequestAttributes().getResponse();
     }
 
     /**
      * 获取session
      */
-    public static HttpSession getSession()
-    {
+    public static HttpSession getSession() {
         return getRequest().getSession();
     }
 
-    public static ServletRequestAttributes getRequestAttributes()
-    {
+    public static ServletRequestAttributes getRequestAttributes() {
         RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
         return (ServletRequestAttributes) attributes;
     }
 
     /**
      * 将字符串渲染到客户端
-     * 
+     *
      * @param response 渲染对象
-     * @param string 待渲染的字符串
+     * @param string   待渲染的字符串
      */
-    public static void renderString(HttpServletResponse response, String string)
-    {
-        try
-        {
+    public static void renderString(HttpServletResponse response, String string) {
+        try {
             response.setStatus(200);
             response.setContentType("application/json");
             response.setCharacterEncoding("utf-8");
             response.getWriter().print(string);
-        }
-        catch (IOException e)
-        {
+        } catch (IOException e) {
             e.printStackTrace();
         }
     }
 
     /**
      * 是否是Ajax异步请求
-     * 
+     *
      * @param request
      */
-    public static boolean isAjaxRequest(HttpServletRequest request)
-    {
+    public static boolean isAjaxRequest(HttpServletRequest request) {
         String accept = request.getHeader("accept");
-        if (accept != null && accept.contains("application/json"))
-        {
+        if (accept != null && accept.contains("application/json")) {
             return true;
         }
 
         String xRequestedWith = request.getHeader("X-Requested-With");
-        if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest"))
-        {
+        if (xRequestedWith != null && xRequestedWith.contains("XMLHttpRequest")) {
             return true;
         }
 
         String uri = request.getRequestURI();
-        if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml"))
-        {
+        if (StringUtils.inStringIgnoreCase(uri, ".json", ".xml")) {
             return true;
         }
 
@@ -182,36 +161,28 @@ public class ServletUtils
 
     /**
      * 内容编码
-     * 
+     *
      * @param str 内容
      * @return 编码后的内容
      */
-    public static String urlEncode(String str)
-    {
-        try
-        {
+    public static String urlEncode(String str) {
+        try {
             return URLEncoder.encode(str, Constants.UTF8);
-        }
-        catch (UnsupportedEncodingException e)
-        {
+        } catch (UnsupportedEncodingException e) {
             return StringUtils.EMPTY;
         }
     }
 
     /**
      * 内容解码
-     * 
+     *
      * @param str 内容
      * @return 解码后的内容
      */
-    public static String urlDecode(String str)
-    {
-        try
-        {
+    public static String urlDecode(String str) {
+        try {
             return URLDecoder.decode(str, Constants.UTF8);
-        }
-        catch (UnsupportedEncodingException e)
-        {
+        } catch (UnsupportedEncodingException e) {
             return StringUtils.EMPTY;
         }
     }

+ 137 - 229
ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java

@@ -1,193 +1,174 @@
 package com.ruoyi.common.utils;
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import org.springframework.util.AntPathMatcher;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.text.StrFormatter;
+import org.springframework.util.AntPathMatcher;
+
+import java.util.*;
 
 /**
  * 字符串工具类
- * 
+ *
  * @author ruoyi
  */
-public class StringUtils extends org.apache.commons.lang3.StringUtils
-{
-    /** 空字符串 */
+public class StringUtils extends org.apache.commons.lang3.StringUtils {
+    /**
+     * 空字符串
+     */
     private static final String NULLSTR = "";
 
-    /** 下划线 */
+    /**
+     * 下划线
+     */
     private static final char SEPARATOR = '_';
 
     /**
      * 获取参数不为空值
-     * 
+     *
      * @param value defaultValue 要判断的value
      * @return value 返回值
      */
-    public static <T> T nvl(T value, T defaultValue)
-    {
+    public static <T> T nvl(T value, T defaultValue) {
         return value != null ? value : defaultValue;
     }
 
     /**
      * * 判断一个Collection是否为空, 包含List,Set,Queue
-     * 
+     *
      * @param coll 要判断的Collection
      * @return true:为空 false:非空
      */
-    public static boolean isEmpty(Collection<?> coll)
-    {
+    public static boolean isEmpty(Collection<?> coll) {
         return isNull(coll) || coll.isEmpty();
     }
 
     /**
      * * 判断一个Collection是否非空,包含List,Set,Queue
-     * 
+     *
      * @param coll 要判断的Collection
      * @return true:非空 false:空
      */
-    public static boolean isNotEmpty(Collection<?> coll)
-    {
+    public static boolean isNotEmpty(Collection<?> coll) {
         return !isEmpty(coll);
     }
 
     /**
      * * 判断一个对象数组是否为空
-     * 
+     *
      * @param objects 要判断的对象数组
-     ** @return true:为空 false:非空
+     *                * @return true:为空 false:非空
      */
-    public static boolean isEmpty(Object[] objects)
-    {
+    public static boolean isEmpty(Object[] objects) {
         return isNull(objects) || (objects.length == 0);
     }
 
     /**
      * * 判断一个对象数组是否非空
-     * 
+     *
      * @param objects 要判断的对象数组
      * @return true:非空 false:空
      */
-    public static boolean isNotEmpty(Object[] objects)
-    {
+    public static boolean isNotEmpty(Object[] objects) {
         return !isEmpty(objects);
     }
 
     /**
      * * 判断一个Map是否为空
-     * 
+     *
      * @param map 要判断的Map
      * @return true:为空 false:非空
      */
-    public static boolean isEmpty(Map<?, ?> map)
-    {
+    public static boolean isEmpty(Map<?, ?> map) {
         return isNull(map) || map.isEmpty();
     }
 
     /**
      * * 判断一个Map是否为空
-     * 
+     *
      * @param map 要判断的Map
      * @return true:非空 false:空
      */
-    public static boolean isNotEmpty(Map<?, ?> map)
-    {
+    public static boolean isNotEmpty(Map<?, ?> map) {
         return !isEmpty(map);
     }
 
     /**
      * * 判断一个字符串是否为空串
-     * 
+     *
      * @param str String
      * @return true:为空 false:非空
      */
-    public static boolean isEmpty(String str)
-    {
+    public static boolean isEmpty(String str) {
         return isNull(str) || NULLSTR.equals(str.trim());
     }
 
     /**
      * * 判断一个字符串是否为非空串
-     * 
+     *
      * @param str String
      * @return true:非空串 false:空串
      */
-    public static boolean isNotEmpty(String str)
-    {
+    public static boolean isNotEmpty(String str) {
         return !isEmpty(str);
     }
 
     /**
      * * 判断一个对象是否为空
-     * 
+     *
      * @param object Object
      * @return true:为空 false:非空
      */
-    public static boolean isNull(Object object)
-    {
+    public static boolean isNull(Object object) {
         return object == null;
     }
 
     /**
      * * 判断一个对象是否非空
-     * 
+     *
      * @param object Object
      * @return true:非空 false:空
      */
-    public static boolean isNotNull(Object object)
-    {
+    public static boolean isNotNull(Object object) {
         return !isNull(object);
     }
 
     /**
      * * 判断一个对象是否是数组类型(Java基本型别的数组)
-     * 
+     *
      * @param object 对象
      * @return true:是数组 false:不是数组
      */
-    public static boolean isArray(Object object)
-    {
+    public static boolean isArray(Object object) {
         return isNotNull(object) && object.getClass().isArray();
     }
 
     /**
      * 去空格
      */
-    public static String trim(String str)
-    {
+    public static String trim(String str) {
         return (str == null ? "" : str.trim());
     }
 
     /**
      * 截取字符串
-     * 
-     * @param str 字符串
+     *
+     * @param str   字符串
      * @param start 开始
      * @return 结果
      */
-    public static String substring(final String str, int start)
-    {
-        if (str == null)
-        {
+    public static String substring(final String str, int start) {
+        if (str == null) {
             return NULLSTR;
         }
 
-        if (start < 0)
-        {
+        if (start < 0) {
             start = str.length() + start;
         }
 
-        if (start < 0)
-        {
+        if (start < 0) {
             start = 0;
         }
-        if (start > str.length())
-        {
+        if (start > str.length()) {
             return NULLSTR;
         }
 
@@ -196,44 +177,36 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
 
     /**
      * 截取字符串
-     * 
-     * @param str 字符串
+     *
+     * @param str   字符串
      * @param start 开始
-     * @param end 结束
+     * @param end   结束
      * @return 结果
      */
-    public static String substring(final String str, int start, int end)
-    {
-        if (str == null)
-        {
+    public static String substring(final String str, int start, int end) {
+        if (str == null) {
             return NULLSTR;
         }
 
-        if (end < 0)
-        {
+        if (end < 0) {
             end = str.length() + end;
         }
-        if (start < 0)
-        {
+        if (start < 0) {
             start = str.length() + start;
         }
 
-        if (end > str.length())
-        {
+        if (end > str.length()) {
             end = str.length();
         }
 
-        if (start > end)
-        {
+        if (start > end) {
             return NULLSTR;
         }
 
-        if (start < 0)
-        {
+        if (start < 0) {
             start = 0;
         }
-        if (end < 0)
-        {
+        if (end < 0) {
             end = 0;
         }
 
@@ -248,15 +221,13 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
      * 通常使用:format("this is {} for {}", "a", "b") -> this is a for b<br>
      * 转义{}: format("this is \\{} for {}", "a", "b") -> this is \{} for a<br>
      * 转义\: format("this is \\\\{} for {}", "a", "b") -> this is \a for b<br>
-     * 
+     *
      * @param template 文本模板,被替换的部分用 {} 表示
-     * @param params 参数值
+     * @param params   参数值
      * @return 格式化后的文本
      */
-    public static String format(String template, Object... params)
-    {
-        if (isEmpty(params) || isEmpty(template))
-        {
+    public static String format(String template, Object... params) {
+        if (isEmpty(params) || isEmpty(template)) {
             return template;
         }
         return StrFormatter.format(template, params);
@@ -264,58 +235,50 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
 
     /**
      * 是否为http(s)://开头
-     * 
+     *
      * @param link 链接
      * @return 结果
      */
-    public static boolean ishttp(String link)
-    {
+    public static boolean ishttp(String link) {
         return StringUtils.startsWithAny(link, Constants.HTTP, Constants.HTTPS);
     }
 
     /**
      * 字符串转set
-     * 
+     *
      * @param str 字符串
      * @param sep 分隔符
      * @return set集合
      */
-    public static final Set<String> str2Set(String str, String sep)
-    {
+    public static final Set<String> str2Set(String str, String sep) {
         return new HashSet<String>(str2List(str, sep, true, false));
     }
 
     /**
      * 字符串转list
-     * 
-     * @param str 字符串
-     * @param sep 分隔符
+     *
+     * @param str         字符串
+     * @param sep         分隔符
      * @param filterBlank 过滤纯空白
-     * @param trim 去掉首尾空白
+     * @param trim        去掉首尾空白
      * @return list集合
      */
-    public static final List<String> str2List(String str, String sep, boolean filterBlank, boolean trim)
-    {
+    public static final List<String> str2List(String str, String sep, boolean filterBlank, boolean trim) {
         List<String> list = new ArrayList<String>();
-        if (StringUtils.isEmpty(str))
-        {
+        if (StringUtils.isEmpty(str)) {
             return list;
         }
 
         // 过滤空白字符串
-        if (filterBlank && StringUtils.isBlank(str))
-        {
+        if (filterBlank && StringUtils.isBlank(str)) {
             return list;
         }
         String[] split = str.split(sep);
-        for (String string : split)
-        {
-            if (filterBlank && StringUtils.isBlank(string))
-            {
+        for (String string : split) {
+            if (filterBlank && StringUtils.isBlank(string)) {
                 continue;
             }
-            if (trim)
-            {
+            if (trim) {
                 string = string.trim();
             }
             list.add(string);
@@ -328,21 +291,15 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
      * 判断给定的collection列表中是否包含数组array 判断给定的数组array中是否包含给定的元素value
      *
      * @param collection 给定的集合
-     * @param array 给定的数组
+     * @param array      给定的数组
      * @return boolean 结果
      */
-    public static boolean containsAny(Collection<String> collection, String... array)
-    {
-        if (isEmpty(collection) || isEmpty(array))
-        {
+    public static boolean containsAny(Collection<String> collection, String... array) {
+        if (isEmpty(collection) || isEmpty(array)) {
             return false;
-        }
-        else
-        {
-            for (String str : array)
-            {
-                if (collection.contains(str))
-                {
+        } else {
+            for (String str : array) {
+                if (collection.contains(str)) {
                     return true;
                 }
             }
@@ -353,20 +310,16 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
     /**
      * 查找指定字符串是否包含指定字符串列表中的任意一个字符串同时串忽略大小写
      *
-     * @param cs 指定字符串
+     * @param cs                  指定字符串
      * @param searchCharSequences 需要检查的字符串数组
      * @return 是否包含任意一个字符串
      */
-    public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences)
-    {
-        if (isEmpty(cs) || isEmpty(searchCharSequences))
-        {
+    public static boolean containsAnyIgnoreCase(CharSequence cs, CharSequence... searchCharSequences) {
+        if (isEmpty(cs) || isEmpty(searchCharSequences)) {
             return false;
         }
-        for (CharSequence testStr : searchCharSequences)
-        {
-            if (containsIgnoreCase(cs, testStr))
-            {
+        for (CharSequence testStr : searchCharSequences) {
+            if (containsIgnoreCase(cs, testStr)) {
                 return true;
             }
         }
@@ -376,10 +329,8 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
     /**
      * 驼峰转下划线命名
      */
-    public static String toUnderScoreCase(String str)
-    {
-        if (str == null)
-        {
+    public static String toUnderScoreCase(String str) {
+        if (str == null) {
             return null;
         }
         StringBuilder sb = new StringBuilder();
@@ -389,31 +340,23 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
         boolean curreCharIsUpperCase = true;
         // 下一字符是否大写
         boolean nexteCharIsUpperCase = true;
-        for (int i = 0; i < str.length(); i++)
-        {
+        for (int i = 0; i < str.length(); i++) {
             char c = str.charAt(i);
-            if (i > 0)
-            {
+            if (i > 0) {
                 preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1));
-            }
-            else
-            {
+            } else {
                 preCharIsUpperCase = false;
             }
 
             curreCharIsUpperCase = Character.isUpperCase(c);
 
-            if (i < (str.length() - 1))
-            {
+            if (i < (str.length() - 1)) {
                 nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1));
             }
 
-            if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase)
-            {
+            if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) {
                 sb.append(SEPARATOR);
-            }
-            else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase)
-            {
+            } else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) {
                 sb.append(SEPARATOR);
             }
             sb.append(Character.toLowerCase(c));
@@ -424,19 +367,15 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
 
     /**
      * 是否包含字符串
-     * 
-     * @param str 验证字符串
+     *
+     * @param str  验证字符串
      * @param strs 字符串组
      * @return 包含返回true
      */
-    public static boolean inStringIgnoreCase(String str, String... strs)
-    {
-        if (str != null && strs != null)
-        {
-            for (String s : strs)
-            {
-                if (str.equalsIgnoreCase(trim(s)))
-                {
+    public static boolean inStringIgnoreCase(String str, String... strs) {
+        if (str != null && strs != null) {
+            for (String s : strs) {
+                if (str.equalsIgnoreCase(trim(s))) {
                     return true;
                 }
             }
@@ -446,31 +385,25 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
 
     /**
      * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld
-     * 
+     *
      * @param name 转换前的下划线大写方式命名的字符串
      * @return 转换后的驼峰式命名的字符串
      */
-    public static String convertToCamelCase(String name)
-    {
+    public static String convertToCamelCase(String name) {
         StringBuilder result = new StringBuilder();
         // 快速检查
-        if (name == null || name.isEmpty())
-        {
+        if (name == null || name.isEmpty()) {
             // 没必要转换
             return "";
-        }
-        else if (!name.contains("_"))
-        {
+        } else if (!name.contains("_")) {
             // 不含下划线,仅将首字母大写
             return name.substring(0, 1).toUpperCase() + name.substring(1);
         }
         // 用下划线将原始字符串分割
         String[] camels = name.split("_");
-        for (String camel : camels)
-        {
+        for (String camel : camels) {
             // 跳过原始字符串中开头、结尾的下换线或双重下划线
-            if (camel.isEmpty())
-            {
+            if (camel.isEmpty()) {
                 continue;
             }
             // 首字母大写
@@ -484,34 +417,25 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
      * 驼峰式命名法
      * 例如:user_name->userName
      */
-    public static String toCamelCase(String s)
-    {
-        if (s == null)
-        {
+    public static String toCamelCase(String s) {
+        if (s == null) {
             return null;
         }
-        if (s.indexOf(SEPARATOR) == -1)
-        {
+        if (s.indexOf(SEPARATOR) == -1) {
             return s;
         }
         s = s.toLowerCase();
         StringBuilder sb = new StringBuilder(s.length());
         boolean upperCase = false;
-        for (int i = 0; i < s.length(); i++)
-        {
+        for (int i = 0; i < s.length(); i++) {
             char c = s.charAt(i);
 
-            if (c == SEPARATOR)
-            {
+            if (c == SEPARATOR) {
                 upperCase = true;
-            }
-            else if (upperCase)
-            {
+            } else if (upperCase) {
                 sb.append(Character.toUpperCase(c));
                 upperCase = false;
-            }
-            else
-            {
+            } else {
                 sb.append(c);
             }
         }
@@ -520,21 +444,17 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
 
     /**
      * 查找指定字符串是否匹配指定字符串列表中的任意一个字符串
-     * 
-     * @param str 指定字符串
+     *
+     * @param str  指定字符串
      * @param strs 需要检查的字符串数组
      * @return 是否匹配
      */
-    public static boolean matches(String str, List<String> strs)
-    {
-        if (isEmpty(str) || isEmpty(strs))
-        {
+    public static boolean matches(String str, List<String> strs) {
+        if (isEmpty(str) || isEmpty(strs)) {
             return false;
         }
-        for (String pattern : strs)
-        {
-            if (isMatch(pattern, str))
-            {
+        for (String pattern : strs) {
+            if (isMatch(pattern, str)) {
                 return true;
             }
         }
@@ -542,70 +462,58 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils
     }
 
     /**
-     * 判断url是否与规则配置: 
-     * ? 表示单个字符; 
-     * * 表示一层路径内的任意字符串,不可跨层级; 
+     * 判断url是否与规则配置:
+     * ? 表示单个字符;
+     * * 表示一层路径内的任意字符串,不可跨层级;
      * ** 表示任意层路径;
-     * 
+     *
      * @param pattern 匹配规则
-     * @param url 需要匹配的url
+     * @param url     需要匹配的url
      * @return
      */
-    public static boolean isMatch(String pattern, String url)
-    {
+    public static boolean isMatch(String pattern, String url) {
         AntPathMatcher matcher = new AntPathMatcher();
         return matcher.match(pattern, url);
     }
 
     @SuppressWarnings("unchecked")
-    public static <T> T cast(Object obj)
-    {
+    public static <T> T cast(Object obj) {
         return (T) obj;
     }
 
     /**
      * 数字左边补齐0,使之达到指定长度。注意,如果数字转换为字符串后,长度大于size,则只保留 最后size个字符。
-     * 
-     * @param num 数字对象
+     *
+     * @param num  数字对象
      * @param size 字符串指定长度
      * @return 返回数字的字符串格式,该字符串为指定长度。
      */
-    public static final String padl(final Number num, final int size)
-    {
+    public static final String padl(final Number num, final int size) {
         return padl(num.toString(), size, '0');
     }
 
     /**
      * 字符串左补齐。如果原始字符串s长度大于size,则只保留最后size个字符。
-     * 
-     * @param s 原始字符串
+     *
+     * @param s    原始字符串
      * @param size 字符串指定长度
-     * @param c 用于补齐的字符
+     * @param c    用于补齐的字符
      * @return 返回指定长度的字符串,由原字符串左补齐或截取得到。
      */
-    public static final String padl(final String s, final int size, final char c)
-    {
+    public static final String padl(final String s, final int size, final char c) {
         final StringBuilder sb = new StringBuilder(size);
-        if (s != null)
-        {
+        if (s != null) {
             final int len = s.length();
-            if (s.length() <= size)
-            {
-                for (int i = size - len; i > 0; i--)
-                {
+            if (s.length() <= size) {
+                for (int i = size - len; i > 0; i--) {
                     sb.append(c);
                 }
                 sb.append(s);
-            }
-            else
-            {
+            } else {
                 return s.substring(len - size, len);
             }
-        }
-        else
-        {
-            for (int i = size; i > 0; i--)
-            {
+        } else {
+            for (int i = size; i > 0; i--) {
                 sb.append(c);
             }
         }

+ 21 - 47
ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java

@@ -1,33 +1,25 @@
 package com.ruoyi.common.utils;
 
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import java.util.concurrent.*;
+
 /**
  * 线程相关工具类.
- * 
+ *
  * @author ruoyi
  */
-public class Threads
-{
+public class Threads {
     private static final Logger logger = LoggerFactory.getLogger(Threads.class);
 
     /**
      * sleep等待,单位为毫秒
      */
-    public static void sleep(long milliseconds)
-    {
-        try
-        {
+    public static void sleep(long milliseconds) {
+        try {
             Thread.sleep(milliseconds);
-        }
-        catch (InterruptedException e)
-        {
+        } catch (InterruptedException e) {
             return;
         }
     }
@@ -39,24 +31,17 @@ public class Threads
      * 如果仍然超時,則強制退出.
      * 另对在shutdown时线程本身被调用中断做了处理.
      */
-    public static void shutdownAndAwaitTermination(ExecutorService pool)
-    {
-        if (pool != null && !pool.isShutdown())
-        {
+    public static void shutdownAndAwaitTermination(ExecutorService pool) {
+        if (pool != null && !pool.isShutdown()) {
             pool.shutdown();
-            try
-            {
-                if (!pool.awaitTermination(120, TimeUnit.SECONDS))
-                {
+            try {
+                if (!pool.awaitTermination(120, TimeUnit.SECONDS)) {
                     pool.shutdownNow();
-                    if (!pool.awaitTermination(120, TimeUnit.SECONDS))
-                    {
+                    if (!pool.awaitTermination(120, TimeUnit.SECONDS)) {
                         logger.info("Pool did not terminate");
                     }
                 }
-            }
-            catch (InterruptedException ie)
-            {
+            } catch (InterruptedException ie) {
                 pool.shutdownNow();
                 Thread.currentThread().interrupt();
             }
@@ -66,33 +51,22 @@ public class Threads
     /**
      * 打印线程异常信息
      */
-    public static void printException(Runnable r, Throwable t)
-    {
-        if (t == null && r instanceof Future<?>)
-        {
-            try
-            {
+    public static void printException(Runnable r, Throwable t) {
+        if (t == null && r instanceof Future<?>) {
+            try {
                 Future<?> future = (Future<?>) r;
-                if (future.isDone())
-                {
+                if (future.isDone()) {
                     future.get();
                 }
-            }
-            catch (CancellationException ce)
-            {
+            } catch (CancellationException ce) {
                 t = ce;
-            }
-            catch (ExecutionException ee)
-            {
+            } catch (ExecutionException ee) {
                 t = ee.getCause();
-            }
-            catch (InterruptedException ie)
-            {
+            } catch (InterruptedException ie) {
                 Thread.currentThread().interrupt();
             }
         }
-        if (t != null)
-        {
+        if (t != null) {
             logger.error(t.getMessage(), t);
         }
     }

+ 22 - 41
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/ImageUtils.java

@@ -1,55 +1,45 @@
 package com.ruoyi.common.utils.file;
 
+import com.ruoyi.common.config.RuoYiConfig;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.utils.StringUtils;
+import org.apache.poi.util.IOUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
 import java.io.ByteArrayInputStream;
 import java.io.FileInputStream;
 import java.io.InputStream;
 import java.net.URL;
 import java.net.URLConnection;
 import java.util.Arrays;
-import org.apache.poi.util.IOUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import com.ruoyi.common.config.RuoYiConfig;
-import com.ruoyi.common.constant.Constants;
-import com.ruoyi.common.utils.StringUtils;
 
 /**
  * 图片处理工具类
  *
  * @author ruoyi
  */
-public class ImageUtils
-{
+public class ImageUtils {
     private static final Logger log = LoggerFactory.getLogger(ImageUtils.class);
 
-    public static byte[] getImage(String imagePath)
-    {
+    public static byte[] getImage(String imagePath) {
         InputStream is = getFile(imagePath);
-        try
-        {
+        try {
             return IOUtils.toByteArray(is);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("图片加载异常 {}", e);
             return null;
-        }
-        finally
-        {
+        } finally {
             IOUtils.closeQuietly(is);
         }
     }
 
-    public static InputStream getFile(String imagePath)
-    {
-        try
-        {
+    public static InputStream getFile(String imagePath) {
+        try {
             byte[] result = readFile(imagePath);
             result = Arrays.copyOf(result, result.length);
             return new ByteArrayInputStream(result);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("获取图片异常 {}", e);
         }
         return null;
@@ -57,17 +47,14 @@ public class ImageUtils
 
     /**
      * 读取文件为字节数据
-     * 
+     *
      * @param url 地址
      * @return 字节数据
      */
-    public static byte[] readFile(String url)
-    {
+    public static byte[] readFile(String url) {
         InputStream in = null;
-        try
-        {
-            if (url.startsWith("http"))
-            {
+        try {
+            if (url.startsWith("http")) {
                 // 网络地址
                 URL urlObj = new URL(url);
                 URLConnection urlConnection = urlObj.openConnection();
@@ -75,23 +62,17 @@ public class ImageUtils
                 urlConnection.setReadTimeout(60 * 1000);
                 urlConnection.setDoInput(true);
                 in = urlConnection.getInputStream();
-            }
-            else
-            {
+            } else {
                 // 本机地址
                 String localPath = RuoYiConfig.getProfile();
                 String downloadPath = localPath + StringUtils.substringAfter(url, Constants.RESOURCE_PREFIX);
                 in = new FileInputStream(downloadPath);
             }
             return IOUtils.toByteArray(in);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("获取文件路径异常 {}", e);
             return null;
-        }
-        finally
-        {
+        } finally {
             IOUtils.closeQuietly(in);
         }
     }

+ 11 - 14
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java

@@ -2,11 +2,10 @@ package com.ruoyi.common.utils.file;
 
 /**
  * 媒体类型工具类
- * 
+ *
  * @author ruoyi
  */
-public class MimeTypeUtils
-{
+public class MimeTypeUtils {
     public static final String IMAGE_PNG = "image/png";
 
     public static final String IMAGE_JPG = "image/jpg";
@@ -16,15 +15,15 @@ public class MimeTypeUtils
     public static final String IMAGE_BMP = "image/bmp";
 
     public static final String IMAGE_GIF = "image/gif";
-    
-    public static final String[] IMAGE_EXTENSION = { "bmp", "gif", "jpg", "jpeg", "png" };
 
-    public static final String[] FLASH_EXTENSION = { "swf", "flv" };
+    public static final String[] IMAGE_EXTENSION = {"bmp", "gif", "jpg", "jpeg", "png"};
 
-    public static final String[] MEDIA_EXTENSION = { "swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg",
-            "asf", "rm", "rmvb" };
+    public static final String[] FLASH_EXTENSION = {"swf", "flv"};
 
-    public static final String[] VIDEO_EXTENSION = { "mp4", "avi", "rmvb" };
+    public static final String[] MEDIA_EXTENSION = {"swf", "flv", "mp3", "wav", "wma", "wmv", "mid", "avi", "mpg",
+            "asf", "rm", "rmvb"};
+
+    public static final String[] VIDEO_EXTENSION = {"mp4", "avi", "rmvb"};
 
     public static final String[] DEFAULT_ALLOWED_EXTENSION = {
             // 图片
@@ -36,12 +35,10 @@ public class MimeTypeUtils
             // 视频格式
             "mp4", "avi", "rmvb",
             // pdf
-            "pdf" };
+            "pdf"};
 
-    public static String getExtension(String prefix)
-    {
-        switch (prefix)
-        {
+    public static String getExtension(String prefix) {
+        switch (prefix) {
             case IMAGE_PNG:
                 return "png";
             case IMAGE_JPG:

+ 72 - 145
ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java

@@ -1,10 +1,6 @@
 package com.ruoyi.common.utils.html;
 
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
 import java.util.regex.Matcher;
@@ -15,8 +11,7 @@ import java.util.regex.Pattern;
  *
  * @author ruoyi
  */
-public final class HTMLFilter
-{
+public final class HTMLFilter {
     /**
      * regex flag union representing /si modifiers in php
      **/
@@ -100,8 +95,7 @@ public final class HTMLFilter
     /**
      * Default constructor.
      */
-    public HTMLFilter()
-    {
+    public HTMLFilter() {
         vAllowed = new HashMap<>();
 
         final ArrayList<String> a_atts = new ArrayList<>();
@@ -122,13 +116,13 @@ public final class HTMLFilter
         vAllowed.put("i", no_atts);
         vAllowed.put("em", no_atts);
 
-        vSelfClosingTags = new String[] { "img" };
-        vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" };
-        vDisallowed = new String[] {};
-        vAllowedProtocols = new String[] { "http", "mailto", "https" }; // no ftp.
-        vProtocolAtts = new String[] { "src", "href" };
-        vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" };
-        vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" };
+        vSelfClosingTags = new String[]{"img"};
+        vNeedClosingTags = new String[]{"a", "b", "strong", "i", "em"};
+        vDisallowed = new String[]{};
+        vAllowedProtocols = new String[]{"http", "mailto", "https"}; // no ftp.
+        vProtocolAtts = new String[]{"src", "href"};
+        vRemoveBlanks = new String[]{"a", "b", "strong", "i", "em"};
+        vAllowedEntities = new String[]{"amp", "gt", "lt", "quot"};
         stripComment = true;
         encodeQuotes = true;
         alwaysMakeTags = false;
@@ -140,8 +134,7 @@ public final class HTMLFilter
      * @param conf map containing configuration. keys match field names.
      */
     @SuppressWarnings("unchecked")
-    public HTMLFilter(final Map<String, Object> conf)
-    {
+    public HTMLFilter(final Map<String, Object> conf) {
 
         assert conf.containsKey("vAllowed") : "configuration requires vAllowed";
         assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags";
@@ -165,20 +158,17 @@ public final class HTMLFilter
         alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true;
     }
 
-    private void reset()
-    {
+    private void reset() {
         vTagCounts.clear();
     }
 
     // ---------------------------------------------------------------
     // my versions of some PHP library functions
-    public static String chr(final int decimal)
-    {
+    public static String chr(final int decimal) {
         return String.valueOf((char) decimal);
     }
 
-    public static String htmlSpecialChars(final String s)
-    {
+    public static String htmlSpecialChars(final String s) {
         String result = s;
         result = regexReplace(P_AMP, "&amp;", result);
         result = regexReplace(P_QUOTE, "&quot;", result);
@@ -195,8 +185,7 @@ public final class HTMLFilter
      * @param input text (i.e. submitted by a user) than may contain html
      * @return "clean" version of input, with only valid, whitelisted html elements allowed
      */
-    public String filter(final String input)
-    {
+    public String filter(final String input) {
         reset();
         String s = input;
 
@@ -213,22 +202,18 @@ public final class HTMLFilter
         return s;
     }
 
-    public boolean isAlwaysMakeTags()
-    {
+    public boolean isAlwaysMakeTags() {
         return alwaysMakeTags;
     }
 
-    public boolean isStripComments()
-    {
+    public boolean isStripComments() {
         return stripComment;
     }
 
-    private String escapeComments(final String s)
-    {
+    private String escapeComments(final String s) {
         final Matcher m = P_COMMENTS.matcher(s);
         final StringBuffer buf = new StringBuffer();
-        if (m.find())
-        {
+        if (m.find()) {
             final String match = m.group(1); // (.*?)
             m.appendReplacement(buf, Matcher.quoteReplacement("<!--" + htmlSpecialChars(match) + "-->"));
         }
@@ -237,10 +222,8 @@ public final class HTMLFilter
         return buf.toString();
     }
 
-    private String balanceHTML(String s)
-    {
-        if (alwaysMakeTags)
-        {
+    private String balanceHTML(String s) {
+        if (alwaysMakeTags) {
             //
             // try and form html
             //
@@ -249,9 +232,7 @@ public final class HTMLFilter
             s = regexReplace(P_BODY_TO_END, "<$1>", s);
             s = regexReplace(P_XML_CONTENT, "$1<$2", s);
 
-        }
-        else
-        {
+        } else {
             //
             // escape stray brackets
             //
@@ -269,13 +250,11 @@ public final class HTMLFilter
         return s;
     }
 
-    private String checkTags(String s)
-    {
+    private String checkTags(String s) {
         Matcher m = P_TAGS.matcher(s);
 
         final StringBuffer buf = new StringBuffer();
-        while (m.find())
-        {
+        while (m.find()) {
             String replaceStr = m.group(1);
             replaceStr = processTag(replaceStr);
             m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr));
@@ -285,10 +264,8 @@ public final class HTMLFilter
         // these get tallied in processTag
         // (remember to reset before subsequent calls to filter method)
         final StringBuilder sBuilder = new StringBuilder(buf.toString());
-        for (String key : vTagCounts.keySet())
-        {
-            for (int ii = 0; ii < vTagCounts.get(key); ii++)
-            {
+        for (String key : vTagCounts.keySet()) {
+            for (int ii = 0; ii < vTagCounts.get(key); ii++) {
                 sBuilder.append("</").append(key).append(">");
             }
         }
@@ -297,18 +274,14 @@ public final class HTMLFilter
         return s;
     }
 
-    private String processRemoveBlanks(final String s)
-    {
+    private String processRemoveBlanks(final String s) {
         String result = s;
-        for (String tag : vRemoveBlanks)
-        {
-            if (!P_REMOVE_PAIR_BLANKS.containsKey(tag))
-            {
+        for (String tag : vRemoveBlanks) {
+            if (!P_REMOVE_PAIR_BLANKS.containsKey(tag)) {
                 P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?></" + tag + ">"));
             }
             result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result);
-            if (!P_REMOVE_SELF_BLANKS.containsKey(tag))
-            {
+            if (!P_REMOVE_SELF_BLANKS.containsKey(tag)) {
                 P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>"));
             }
             result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result);
@@ -317,25 +290,19 @@ public final class HTMLFilter
         return result;
     }
 
-    private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s)
-    {
+    private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) {
         Matcher m = regex_pattern.matcher(s);
         return m.replaceAll(replacement);
     }
 
-    private String processTag(final String s)
-    {
+    private String processTag(final String s) {
         // ending tags
         Matcher m = P_END_TAG.matcher(s);
-        if (m.find())
-        {
+        if (m.find()) {
             final String name = m.group(1).toLowerCase();
-            if (allowed(name))
-            {
-                if (!inArray(name, vSelfClosingTags))
-                {
-                    if (vTagCounts.containsKey(name))
-                    {
+            if (allowed(name)) {
+                if (!inArray(name, vSelfClosingTags)) {
+                    if (vTagCounts.containsKey(name)) {
                         vTagCounts.put(name, vTagCounts.get(name) - 1);
                         return "</" + name + ">";
                     }
@@ -345,35 +312,30 @@ public final class HTMLFilter
 
         // starting tags
         m = P_START_TAG.matcher(s);
-        if (m.find())
-        {
+        if (m.find()) {
             final String name = m.group(1).toLowerCase();
             final String body = m.group(2);
             String ending = m.group(3);
 
             // debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" );
-            if (allowed(name))
-            {
+            if (allowed(name)) {
                 final StringBuilder params = new StringBuilder();
 
                 final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body);
                 final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body);
                 final List<String> paramNames = new ArrayList<>();
                 final List<String> paramValues = new ArrayList<>();
-                while (m2.find())
-                {
+                while (m2.find()) {
                     paramNames.add(m2.group(1)); // ([a-z0-9]+)
                     paramValues.add(m2.group(3)); // (.*?)
                 }
-                while (m3.find())
-                {
+                while (m3.find()) {
                     paramNames.add(m3.group(1)); // ([a-z0-9]+)
                     paramValues.add(m3.group(3)); // ([^\"\\s']+)
                 }
 
                 String paramName, paramValue;
-                for (int ii = 0; ii < paramNames.size(); ii++)
-                {
+                for (int ii = 0; ii < paramNames.size(); ii++) {
                     paramName = paramNames.get(ii).toLowerCase();
                     paramValue = paramValues.get(ii);
 
@@ -381,72 +343,55 @@ public final class HTMLFilter
                     // debug( "paramValue='" + paramValue + "'" );
                     // debug( "allowed? " + vAllowed.get( name ).contains( paramName ) );
 
-                    if (allowedAttribute(name, paramName))
-                    {
-                        if (inArray(paramName, vProtocolAtts))
-                        {
+                    if (allowedAttribute(name, paramName)) {
+                        if (inArray(paramName, vProtocolAtts)) {
                             paramValue = processParamProtocol(paramValue);
                         }
                         params.append(' ').append(paramName).append("=\\\"").append(paramValue).append("\\\"");
                     }
                 }
 
-                if (inArray(name, vSelfClosingTags))
-                {
+                if (inArray(name, vSelfClosingTags)) {
                     ending = " /";
                 }
 
-                if (inArray(name, vNeedClosingTags))
-                {
+                if (inArray(name, vNeedClosingTags)) {
                     ending = "";
                 }
 
-                if (ending == null || ending.length() < 1)
-                {
-                    if (vTagCounts.containsKey(name))
-                    {
+                if (ending == null || ending.length() < 1) {
+                    if (vTagCounts.containsKey(name)) {
                         vTagCounts.put(name, vTagCounts.get(name) + 1);
-                    }
-                    else
-                    {
+                    } else {
                         vTagCounts.put(name, 1);
                     }
-                }
-                else
-                {
+                } else {
                     ending = " /";
                 }
                 return "<" + name + params + ending + ">";
-            }
-            else
-            {
+            } else {
                 return "";
             }
         }
 
         // comments
         m = P_COMMENT.matcher(s);
-        if (!stripComment && m.find())
-        {
+        if (!stripComment && m.find()) {
             return "<" + m.group() + ">";
         }
 
         return "";
     }
 
-    private String processParamProtocol(String s)
-    {
+    private String processParamProtocol(String s) {
         s = decodeEntities(s);
         final Matcher m = P_PROTOCOL.matcher(s);
-        if (m.find())
-        {
+        if (m.find()) {
             final String protocol = m.group(1);
-            if (!inArray(protocol, vAllowedProtocols))
-            {
+            if (!inArray(protocol, vAllowedProtocols)) {
                 // bad protocol, turn into local anchor link instead
                 s = "#" + s.substring(protocol.length() + 1);
-                if (s.startsWith("#//"))
-                {
+                if (s.startsWith("#//")) {
                     s = "#" + s.substring(3);
                 }
             }
@@ -455,13 +400,11 @@ public final class HTMLFilter
         return s;
     }
 
-    private String decodeEntities(String s)
-    {
+    private String decodeEntities(String s) {
         StringBuffer buf = new StringBuffer();
 
         Matcher m = P_ENTITY.matcher(s);
-        while (m.find())
-        {
+        while (m.find()) {
             final String match = m.group(1);
             final int decimal = Integer.decode(match).intValue();
             m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
@@ -471,8 +414,7 @@ public final class HTMLFilter
 
         buf = new StringBuffer();
         m = P_ENTITY_UNICODE.matcher(s);
-        while (m.find())
-        {
+        while (m.find()) {
             final String match = m.group(1);
             final int decimal = Integer.valueOf(match, 16).intValue();
             m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
@@ -482,8 +424,7 @@ public final class HTMLFilter
 
         buf = new StringBuffer();
         m = P_ENCODE.matcher(s);
-        while (m.find())
-        {
+        while (m.find()) {
             final String match = m.group(1);
             final int decimal = Integer.valueOf(match, 16).intValue();
             m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal)));
@@ -495,14 +436,12 @@ public final class HTMLFilter
         return s;
     }
 
-    private String validateEntities(final String s)
-    {
+    private String validateEntities(final String s) {
         StringBuffer buf = new StringBuffer();
 
         // validate entities throughout the string
         Matcher m = P_VALID_ENTITIES.matcher(s);
-        while (m.find())
-        {
+        while (m.find()) {
             final String one = m.group(1); // ([^&;]*)
             final String two = m.group(2); // (?=(;|&|$))
             m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two)));
@@ -512,14 +451,11 @@ public final class HTMLFilter
         return encodeQuotes(buf.toString());
     }
 
-    private String encodeQuotes(final String s)
-    {
-        if (encodeQuotes)
-        {
+    private String encodeQuotes(final String s) {
+        if (encodeQuotes) {
             StringBuffer buf = new StringBuffer();
             Matcher m = P_VALID_QUOTES.matcher(s);
-            while (m.find())
-            {
+            while (m.find()) {
                 final String one = m.group(1); // (>|^)
                 final String two = m.group(2); // ([^<]+?)
                 final String three = m.group(3); // (<|$)
@@ -528,43 +464,34 @@ public final class HTMLFilter
             }
             m.appendTail(buf);
             return buf.toString();
-        }
-        else
-        {
+        } else {
             return s;
         }
     }
 
-    private String checkEntity(final String preamble, final String term)
-    {
+    private String checkEntity(final String preamble, final String term) {
 
         return ";".equals(term) && isValidEntity(preamble) ? '&' + preamble : "&amp;" + preamble;
     }
 
-    private boolean isValidEntity(final String entity)
-    {
+    private boolean isValidEntity(final String entity) {
         return inArray(entity, vAllowedEntities);
     }
 
-    private static boolean inArray(final String s, final String[] array)
-    {
-        for (String item : array)
-        {
-            if (item != null && item.equals(s))
-            {
+    private static boolean inArray(final String s, final String[] array) {
+        for (String item : array) {
+            if (item != null && item.equals(s)) {
                 return true;
             }
         }
         return false;
     }
 
-    private boolean allowed(final String name)
-    {
+    private boolean allowed(final String name) {
         return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed);
     }
 
-    private boolean allowedAttribute(final String name, final String paramName)
-    {
+    private boolean allowedAttribute(final String name, final String paramName) {
         return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName));
     }
 }

+ 11 - 22
ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java

@@ -6,46 +6,35 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.nio.charset.StandardCharsets;
 import javax.servlet.ServletRequest;
+
 import org.apache.commons.lang3.exception.ExceptionUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * 通用http工具封装
- * 
+ *
  * @author ruoyi
  */
-public class HttpHelper
-{
+public class HttpHelper {
     private static final Logger LOGGER = LoggerFactory.getLogger(HttpHelper.class);
 
-    public static String getBodyString(ServletRequest request)
-    {
+    public static String getBodyString(ServletRequest request) {
         StringBuilder sb = new StringBuilder();
         BufferedReader reader = null;
-        try (InputStream inputStream = request.getInputStream())
-        {
+        try (InputStream inputStream = request.getInputStream()) {
             reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8));
             String line = "";
-            while ((line = reader.readLine()) != null)
-            {
+            while ((line = reader.readLine()) != null) {
                 sb.append(line);
             }
-        }
-        catch (IOException e)
-        {
+        } catch (IOException e) {
             LOGGER.warn("getBodyString出现问题!");
-        }
-        finally
-        {
-            if (reader != null)
-            {
-                try
-                {
+        } finally {
+            if (reader != null) {
+                try {
                     reader.close();
-                }
-                catch (IOException e)
-                {
+                } catch (IOException e) {
                     LOGGER.error(ExceptionUtils.getMessage(e));
                 }
             }

+ 54 - 118
ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java

@@ -1,34 +1,25 @@
 package com.ruoyi.common.utils.http;
 
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.common.utils.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import javax.net.ssl.*;
+import java.io.*;
 import java.net.ConnectException;
 import java.net.SocketTimeoutException;
 import java.net.URL;
 import java.net.URLConnection;
 import java.nio.charset.StandardCharsets;
 import java.security.cert.X509Certificate;
-import javax.net.ssl.HostnameVerifier;
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSession;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import com.ruoyi.common.constant.Constants;
-import com.ruoyi.common.utils.StringUtils;
 
 /**
  * 通用http发送方法
- * 
+ *
  * @author ruoyi
  */
-public class HttpUtils
-{
+public class HttpUtils {
     private static final Logger log = LoggerFactory.getLogger(HttpUtils.class);
 
     /**
@@ -37,37 +28,33 @@ public class HttpUtils
      * @param url 发送请求的 URL
      * @return 所代表远程资源的响应结果
      */
-    public static String sendGet(String url)
-    {
+    public static String sendGet(String url) {
         return sendGet(url, StringUtils.EMPTY);
     }
 
     /**
      * 向指定 URL 发送GET方法的请求
      *
-     * @param url 发送请求的 URL
+     * @param url   发送请求的 URL
      * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
      * @return 所代表远程资源的响应结果
      */
-    public static String sendGet(String url, String param)
-    {
+    public static String sendGet(String url, String param) {
         return sendGet(url, param, Constants.UTF8);
     }
 
     /**
      * 向指定 URL 发送GET方法的请求
      *
-     * @param url 发送请求的 URL
-     * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
+     * @param url         发送请求的 URL
+     * @param param       请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
      * @param contentType 编码类型
      * @return 所代表远程资源的响应结果
      */
-    public static String sendGet(String url, String param, String contentType)
-    {
+    public static String sendGet(String url, String param, String contentType) {
         StringBuilder result = new StringBuilder();
         BufferedReader in = null;
-        try
-        {
+        try {
             String urlNameString = StringUtils.isNotBlank(param) ? url + "?" + param : url;
             log.info("sendGet - {}", urlNameString);
             URL realUrl = new URL(urlNameString);
@@ -78,39 +65,24 @@ public class HttpUtils
             connection.connect();
             in = new BufferedReader(new InputStreamReader(connection.getInputStream(), contentType));
             String line;
-            while ((line = in.readLine()) != null)
-            {
+            while ((line = in.readLine()) != null) {
                 result.append(line);
             }
             log.info("recv - {}", result);
-        }
-        catch (ConnectException e)
-        {
+        } catch (ConnectException e) {
             log.error("调用HttpUtils.sendGet ConnectException, url=" + url + ",param=" + param, e);
-        }
-        catch (SocketTimeoutException e)
-        {
+        } catch (SocketTimeoutException e) {
             log.error("调用HttpUtils.sendGet SocketTimeoutException, url=" + url + ",param=" + param, e);
-        }
-        catch (IOException e)
-        {
+        } catch (IOException e) {
             log.error("调用HttpUtils.sendGet IOException, url=" + url + ",param=" + param, e);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("调用HttpsUtil.sendGet Exception, url=" + url + ",param=" + param, e);
-        }
-        finally
-        {
-            try
-            {
-                if (in != null)
-                {
+        } finally {
+            try {
+                if (in != null) {
                     in.close();
                 }
-            }
-            catch (Exception ex)
-            {
+            } catch (Exception ex) {
                 log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
             }
         }
@@ -120,17 +92,15 @@ public class HttpUtils
     /**
      * 向指定 URL 发送POST方法的请求
      *
-     * @param url 发送请求的 URL
+     * @param url   发送请求的 URL
      * @param param 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。
      * @return 所代表远程资源的响应结果
      */
-    public static String sendPost(String url, String param)
-    {
+    public static String sendPost(String url, String param) {
         PrintWriter out = null;
         BufferedReader in = null;
         StringBuilder result = new StringBuilder();
-        try
-        {
+        try {
             log.info("sendPost - {}", url);
             URL realUrl = new URL(url);
             URLConnection conn = realUrl.openConnection();
@@ -146,58 +116,40 @@ public class HttpUtils
             out.flush();
             in = new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8));
             String line;
-            while ((line = in.readLine()) != null)
-            {
+            while ((line = in.readLine()) != null) {
                 result.append(line);
             }
             log.info("recv - {}", result);
-        }
-        catch (ConnectException e)
-        {
+        } catch (ConnectException e) {
             log.error("调用HttpUtils.sendPost ConnectException, url=" + url + ",param=" + param, e);
-        }
-        catch (SocketTimeoutException e)
-        {
+        } catch (SocketTimeoutException e) {
             log.error("调用HttpUtils.sendPost SocketTimeoutException, url=" + url + ",param=" + param, e);
-        }
-        catch (IOException e)
-        {
+        } catch (IOException e) {
             log.error("调用HttpUtils.sendPost IOException, url=" + url + ",param=" + param, e);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("调用HttpsUtil.sendPost Exception, url=" + url + ",param=" + param, e);
-        }
-        finally
-        {
-            try
-            {
-                if (out != null)
-                {
+        } finally {
+            try {
+                if (out != null) {
                     out.close();
                 }
-                if (in != null)
-                {
+                if (in != null) {
                     in.close();
                 }
-            }
-            catch (IOException ex)
-            {
+            } catch (IOException ex) {
                 log.error("调用in.close Exception, url=" + url + ",param=" + param, ex);
             }
         }
         return result.toString();
     }
 
-    public static String sendSSLPost(String url, String param)
-    {
+    public static String sendSSLPost(String url, String param) {
         StringBuilder result = new StringBuilder();
         String urlNameString = url + "?" + param;
-        try
-        {
+        try {
             log.info("sendSSLPost - {}", urlNameString);
             SSLContext sc = SSLContext.getInstance("SSL");
-            sc.init(null, new TrustManager[] { new TrustAnyTrustManager() }, new java.security.SecureRandom());
+            sc.init(null, new TrustManager[]{new TrustAnyTrustManager()}, new java.security.SecureRandom());
             URL console = new URL(urlNameString);
             HttpsURLConnection conn = (HttpsURLConnection) console.openConnection();
             conn.setRequestProperty("accept", "*/*");
@@ -214,60 +166,44 @@ public class HttpUtils
             InputStream is = conn.getInputStream();
             BufferedReader br = new BufferedReader(new InputStreamReader(is));
             String ret = "";
-            while ((ret = br.readLine()) != null)
-            {
-                if (ret != null && !"".equals(ret.trim()))
-                {
+            while ((ret = br.readLine()) != null) {
+                if (ret != null && !"".equals(ret.trim())) {
                     result.append(new String(ret.getBytes(StandardCharsets.ISO_8859_1), StandardCharsets.UTF_8));
                 }
             }
             log.info("recv - {}", result);
             conn.disconnect();
             br.close();
-        }
-        catch (ConnectException e)
-        {
+        } catch (ConnectException e) {
             log.error("调用HttpUtils.sendSSLPost ConnectException, url=" + url + ",param=" + param, e);
-        }
-        catch (SocketTimeoutException e)
-        {
+        } catch (SocketTimeoutException e) {
             log.error("调用HttpUtils.sendSSLPost SocketTimeoutException, url=" + url + ",param=" + param, e);
-        }
-        catch (IOException e)
-        {
+        } catch (IOException e) {
             log.error("调用HttpUtils.sendSSLPost IOException, url=" + url + ",param=" + param, e);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("调用HttpsUtil.sendSSLPost Exception, url=" + url + ",param=" + param, e);
         }
         return result.toString();
     }
 
-    private static class TrustAnyTrustManager implements X509TrustManager
-    {
+    private static class TrustAnyTrustManager implements X509TrustManager {
         @Override
-        public void checkClientTrusted(X509Certificate[] chain, String authType)
-        {
+        public void checkClientTrusted(X509Certificate[] chain, String authType) {
         }
 
         @Override
-        public void checkServerTrusted(X509Certificate[] chain, String authType)
-        {
+        public void checkServerTrusted(X509Certificate[] chain, String authType) {
         }
 
         @Override
-        public X509Certificate[] getAcceptedIssuers()
-        {
-            return new X509Certificate[] {};
+        public X509Certificate[] getAcceptedIssuers() {
+            return new X509Certificate[]{};
         }
     }
 
-    private static class TrustAnyHostnameVerifier implements HostnameVerifier
-    {
+    private static class TrustAnyHostnameVerifier implements HostnameVerifier {
         @Override
-        public boolean verify(String hostname, SSLSession session)
-        {
+        public boolean verify(String hostname, SSLSession session) {
             return true;
         }
     }

+ 68 - 126
ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/IpUtils.java

@@ -1,18 +1,18 @@
 package com.ruoyi.common.utils.ip;
 
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import javax.servlet.http.HttpServletRequest;
 import com.ruoyi.common.utils.ServletUtils;
 import com.ruoyi.common.utils.StringUtils;
 
+import javax.servlet.http.HttpServletRequest;
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
 /**
  * 获取IP方法
- * 
+ *
  * @author ruoyi
  */
-public class IpUtils
-{
+public class IpUtils {
     public final static String REGX_0_255 = "(25[0-5]|2[0-4]\\d|1\\d{2}|[1-9]\\d|\\d)";
     // 匹配 ip
     public final static String REGX_IP = "((" + REGX_0_255 + "\\.){3}" + REGX_0_255 + ")";
@@ -22,46 +22,38 @@ public class IpUtils
 
     /**
      * 获取客户端IP
-     * 
+     *
      * @return IP地址
      */
-    public static String getIpAddr()
-    {
+    public static String getIpAddr() {
         return getIpAddr(ServletUtils.getRequest());
     }
 
     /**
      * 获取客户端IP
-     * 
+     *
      * @param request 请求对象
      * @return IP地址
      */
-    public static String getIpAddr(HttpServletRequest request)
-    {
-        if (request == null)
-        {
+    public static String getIpAddr(HttpServletRequest request) {
+        if (request == null) {
             return "unknown";
         }
         String ip = request.getHeader("x-forwarded-for");
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
-        {
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
             ip = request.getHeader("Proxy-Client-IP");
         }
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
-        {
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
             ip = request.getHeader("X-Forwarded-For");
         }
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(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))
-        {
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
             ip = request.getHeader("X-Real-IP");
         }
 
-        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip))
-        {
+        if (ip == null || ip.length() == 0 || "unknown".equalsIgnoreCase(ip)) {
             ip = request.getRemoteAddr();
         }
 
@@ -70,26 +62,23 @@ public class IpUtils
 
     /**
      * 检查是否为内部IP地址
-     * 
+     *
      * @param ip IP地址
      * @return 结果
      */
-    public static boolean internalIp(String ip)
-    {
+    public static boolean internalIp(String ip) {
         byte[] addr = textToNumericFormatV4(ip);
         return internalIp(addr) || "127.0.0.1".equals(ip);
     }
 
     /**
      * 检查是否为内部IP地址
-     * 
+     *
      * @param addr byte地址
      * @return 结果
      */
-    private static boolean internalIp(byte[] addr)
-    {
-        if (StringUtils.isNull(addr) || addr.length < 2)
-        {
+    private static boolean internalIp(byte[] addr) {
+        if (StringUtils.isNull(addr) || addr.length < 2) {
             return true;
         }
         final byte b0 = addr[0];
@@ -103,18 +92,15 @@ public class IpUtils
         // 192.168.x.x/16
         final byte SECTION_5 = (byte) 0xC0;
         final byte SECTION_6 = (byte) 0xA8;
-        switch (b0)
-        {
+        switch (b0) {
             case SECTION_1:
                 return true;
             case SECTION_2:
-                if (b1 >= SECTION_3 && b1 <= SECTION_4)
-                {
+                if (b1 >= SECTION_3 && b1 <= SECTION_4) {
                     return true;
                 }
             case SECTION_5:
-                switch (b1)
-                {
+                switch (b1) {
                     case SECTION_6:
                         return true;
                 }
@@ -125,29 +111,24 @@ public class IpUtils
 
     /**
      * 将IPv4地址转换成字节
-     * 
+     *
      * @param text IPv4地址
      * @return byte 字节
      */
-    public static byte[] textToNumericFormatV4(String text)
-    {
-        if (text.length() == 0)
-        {
+    public static byte[] textToNumericFormatV4(String text) {
+        if (text.length() == 0) {
             return null;
         }
 
         byte[] bytes = new byte[4];
         String[] elements = text.split("\\.", -1);
-        try
-        {
+        try {
             long l;
             int i;
-            switch (elements.length)
-            {
+            switch (elements.length) {
                 case 1:
                     l = Long.parseLong(elements[0]);
-                    if ((l < 0L) || (l > 4294967295L))
-                    {
+                    if ((l < 0L) || (l > 4294967295L)) {
                         return null;
                     }
                     bytes[0] = (byte) (int) (l >> 24 & 0xFF);
@@ -157,14 +138,12 @@ public class IpUtils
                     break;
                 case 2:
                     l = Integer.parseInt(elements[0]);
-                    if ((l < 0L) || (l > 255L))
-                    {
+                    if ((l < 0L) || (l > 255L)) {
                         return null;
                     }
                     bytes[0] = (byte) (int) (l & 0xFF);
                     l = Integer.parseInt(elements[1]);
-                    if ((l < 0L) || (l > 16777215L))
-                    {
+                    if ((l < 0L) || (l > 16777215L)) {
                         return null;
                     }
                     bytes[1] = (byte) (int) (l >> 16 & 0xFF);
@@ -172,29 +151,24 @@ public class IpUtils
                     bytes[3] = (byte) (int) (l & 0xFF);
                     break;
                 case 3:
-                    for (i = 0; i < 2; ++i)
-                    {
+                    for (i = 0; i < 2; ++i) {
                         l = Integer.parseInt(elements[i]);
-                        if ((l < 0L) || (l > 255L))
-                        {
+                        if ((l < 0L) || (l > 255L)) {
                             return null;
                         }
                         bytes[i] = (byte) (int) (l & 0xFF);
                     }
                     l = Integer.parseInt(elements[2]);
-                    if ((l < 0L) || (l > 65535L))
-                    {
+                    if ((l < 0L) || (l > 65535L)) {
                         return null;
                     }
                     bytes[2] = (byte) (int) (l >> 8 & 0xFF);
                     bytes[3] = (byte) (int) (l & 0xFF);
                     break;
                 case 4:
-                    for (i = 0; i < 4; ++i)
-                    {
+                    for (i = 0; i < 4; ++i) {
                         l = Integer.parseInt(elements[i]);
-                        if ((l < 0L) || (l > 255L))
-                        {
+                        if ((l < 0L) || (l > 255L)) {
                             return null;
                         }
                         bytes[i] = (byte) (int) (l & 0xFF);
@@ -203,9 +177,7 @@ public class IpUtils
                 default:
                     return null;
             }
-        }
-        catch (NumberFormatException e)
-        {
+        } catch (NumberFormatException e) {
             return null;
         }
         return bytes;
@@ -213,34 +185,26 @@ public class IpUtils
 
     /**
      * 获取IP地址
-     * 
+     *
      * @return 本地IP地址
      */
-    public static String getHostIp()
-    {
-        try
-        {
+    public static String getHostIp() {
+        try {
             return InetAddress.getLocalHost().getHostAddress();
-        }
-        catch (UnknownHostException e)
-        {
+        } catch (UnknownHostException e) {
         }
         return "127.0.0.1";
     }
 
     /**
      * 获取主机名
-     * 
+     *
      * @return 本地主机名
      */
-    public static String getHostName()
-    {
-        try
-        {
+    public static String getHostName() {
+        try {
             return InetAddress.getLocalHost().getHostName();
-        }
-        catch (UnknownHostException e)
-        {
+        } catch (UnknownHostException e) {
         }
         return "未知";
     }
@@ -251,16 +215,12 @@ public class IpUtils
      * @param ip 获得的IP地址
      * @return 第一个非unknown IP地址
      */
-    public static String getMultistageReverseProxyIp(String ip)
-    {
+    public static String getMultistageReverseProxyIp(String ip) {
         // 多级反向代理检测
-        if (ip != null && ip.indexOf(",") > 0)
-        {
+        if (ip != null && ip.indexOf(",") > 0) {
             final String[] ips = ip.trim().split(",");
-            for (String subIp : ips)
-            {
-                if (false == isUnknown(subIp))
-                {
+            for (String subIp : ips) {
+                if (false == isUnknown(subIp)) {
                     ip = subIp;
                     break;
                 }
@@ -275,39 +235,33 @@ public class IpUtils
      * @param checkString 被检测的字符串
      * @return 是否未知
      */
-    public static boolean isUnknown(String checkString)
-    {
+    public static boolean isUnknown(String checkString) {
         return StringUtils.isBlank(checkString) || "unknown".equalsIgnoreCase(checkString);
     }
 
     /**
      * 是否为IP
      */
-    public static boolean isIP(String ip)
-    {
+    public static boolean isIP(String ip) {
         return StringUtils.isNotBlank(ip) && ip.matches(REGX_IP);
     }
 
     /**
      * 是否为IP,或 *为间隔的通配符地址
      */
-    public static boolean isIpWildCard(String ip)
-    {
+    public static boolean isIpWildCard(String ip) {
         return StringUtils.isNotBlank(ip) && ip.matches(REGX_IP_WILDCARD);
     }
 
     /**
      * 检测参数是否在ip通配符里
      */
-    public static boolean ipIsInWildCardNoCheck(String ipWildCard, String ip)
-    {
+    public static boolean ipIsInWildCardNoCheck(String ipWildCard, String ip) {
         String[] s1 = ipWildCard.split("\\.");
         String[] s2 = ip.split("\\.");
         boolean isMatchedSeg = true;
-        for (int i = 0; i < s1.length && !s1[i].equals("*"); i++)
-        {
-            if (!s1[i].equals(s2[i]))
-            {
+        for (int i = 0; i < s1.length && !s1[i].equals("*"); i++) {
+            if (!s1[i].equals(s2[i])) {
                 isMatchedSeg = false;
                 break;
             }
@@ -318,29 +272,25 @@ public class IpUtils
     /**
      * 是否为特定格式如:“10.10.10.1-10.10.10.99”的ip段字符串
      */
-    public static boolean isIPSegment(String ipSeg)
-    {
+    public static boolean isIPSegment(String ipSeg) {
         return StringUtils.isNotBlank(ipSeg) && ipSeg.matches(REGX_IP_SEG);
     }
 
     /**
      * 判断ip是否在指定网段中
      */
-    public static boolean ipIsInNetNoCheck(String iparea, String ip)
-    {
+    public static boolean ipIsInNetNoCheck(String iparea, String ip) {
         int idx = iparea.indexOf('-');
         String[] sips = iparea.substring(0, idx).split("\\.");
         String[] sipe = iparea.substring(idx + 1).split("\\.");
         String[] sipt = ip.split("\\.");
         long ips = 0L, ipe = 0L, ipt = 0L;
-        for (int i = 0; i < 4; ++i)
-        {
+        for (int i = 0; i < 4; ++i) {
             ips = ips << 8 | Integer.parseInt(sips[i]);
             ipe = ipe << 8 | Integer.parseInt(sipe[i]);
             ipt = ipt << 8 | Integer.parseInt(sipt[i]);
         }
-        if (ips > ipe)
-        {
+        if (ips > ipe) {
             long t = ips;
             ips = ipe;
             ipe = t;
@@ -350,30 +300,22 @@ public class IpUtils
 
     /**
      * 校验ip是否符合过滤串规则
-     * 
+     *
      * @param filter 过滤IP列表,支持后缀'*'通配,支持网段如:`10.10.10.1-10.10.10.99`
-     * @param ip 校验IP地址
+     * @param ip     校验IP地址
      * @return boolean 结果
      */
-    public static boolean isMatchedIp(String filter, String ip)
-    {
-        if (StringUtils.isEmpty(filter) || StringUtils.isEmpty(ip))
-        {
+    public static boolean isMatchedIp(String filter, String ip) {
+        if (StringUtils.isEmpty(filter) || StringUtils.isEmpty(ip)) {
             return false;
         }
         String[] ips = filter.split(";");
-        for (String iStr : ips)
-        {
-            if (isIP(iStr) && iStr.equals(ip))
-            {
+        for (String iStr : ips) {
+            if (isIP(iStr) && iStr.equals(ip)) {
                 return true;
-            }
-            else if (isIpWildCard(iStr) && ipIsInWildCardNoCheck(iStr, ip))
-            {
+            } else if (isIpWildCard(iStr) && ipIsInWildCardNoCheck(iStr, ip)) {
                 return true;
-            }
-            else if (isIPSegment(iStr) && ipIsInNetNoCheck(iStr, ip))
-            {
+            } else if (isIPSegment(iStr) && ipIsInNetNoCheck(iStr, ip)) {
                 return true;
             }
         }

+ 76 - 162
ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java

@@ -1,28 +1,23 @@
 package com.ruoyi.common.utils.reflect;
 
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Date;
+import com.ruoyi.common.core.text.Convert;
+import com.ruoyi.common.utils.DateUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.Validate;
 import org.apache.poi.ss.usermodel.DateUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import com.ruoyi.common.core.text.Convert;
-import com.ruoyi.common.utils.DateUtils;
+
+import java.lang.reflect.*;
+import java.util.Date;
 
 /**
  * 反射工具类. 提供调用getter/setter方法, 访问私有变量, 调用私有方法, 获取泛型类型Class, 被AOP过的真实类等工具函数.
- * 
+ *
  * @author ruoyi
  */
 @SuppressWarnings("rawtypes")
-public class ReflectUtils
-{
+public class ReflectUtils {
     private static final String SETTER_PREFIX = "set";
 
     private static final String GETTER_PREFIX = "get";
@@ -36,13 +31,11 @@ public class ReflectUtils
      * 支持多级,如:对象名.对象名.方法
      */
     @SuppressWarnings("unchecked")
-    public static <E> E invokeGetter(Object obj, String propertyName)
-    {
+    public static <E> E invokeGetter(Object obj, String propertyName) {
         Object object = obj;
-        for (String name : StringUtils.split(propertyName, "."))
-        {
+        for (String name : StringUtils.split(propertyName, ".")) {
             String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name);
-            object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
+            object = invokeMethod(object, getterMethodName, new Class[]{}, new Object[]{});
         }
         return (E) object;
     }
@@ -51,21 +44,16 @@ public class ReflectUtils
      * 调用Setter方法, 仅匹配方法名。
      * 支持多级,如:对象名.对象名.方法
      */
-    public static <E> void invokeSetter(Object obj, String propertyName, E value)
-    {
+    public static <E> void invokeSetter(Object obj, String propertyName, E value) {
         Object object = obj;
         String[] names = StringUtils.split(propertyName, ".");
-        for (int i = 0; i < names.length; i++)
-        {
-            if (i < names.length - 1)
-            {
+        for (int i = 0; i < names.length; i++) {
+            if (i < names.length - 1) {
                 String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]);
-                object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {});
-            }
-            else
-            {
+                object = invokeMethod(object, getterMethodName, new Class[]{}, new Object[]{});
+            } else {
                 String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]);
-                invokeMethodByName(object, setterMethodName, new Object[] { value });
+                invokeMethodByName(object, setterMethodName, new Object[]{value});
             }
         }
     }
@@ -74,21 +62,16 @@ public class ReflectUtils
      * 直接读取对象属性值, 无视private/protected修饰符, 不经过getter函数.
      */
     @SuppressWarnings("unchecked")
-    public static <E> E getFieldValue(final Object obj, final String fieldName)
-    {
+    public static <E> E getFieldValue(final Object obj, final String fieldName) {
         Field field = getAccessibleField(obj, fieldName);
-        if (field == null)
-        {
+        if (field == null) {
             logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
             return null;
         }
         E result = null;
-        try
-        {
+        try {
             result = (E) field.get(obj);
-        }
-        catch (IllegalAccessException e)
-        {
+        } catch (IllegalAccessException e) {
             logger.error("不可能抛出的异常{}", e.getMessage());
         }
         return result;
@@ -97,21 +80,16 @@ public class ReflectUtils
     /**
      * 直接设置对象属性值, 无视private/protected修饰符, 不经过setter函数.
      */
-    public static <E> void setFieldValue(final Object obj, final String fieldName, final E value)
-    {
+    public static <E> void setFieldValue(final Object obj, final String fieldName, final E value) {
         Field field = getAccessibleField(obj, fieldName);
-        if (field == null)
-        {
+        if (field == null) {
             // throw new IllegalArgumentException("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
             logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + fieldName + "] 字段 ");
             return;
         }
-        try
-        {
+        try {
             field.set(obj, value);
-        }
-        catch (IllegalAccessException e)
-        {
+        } catch (IllegalAccessException e) {
             logger.error("不可能抛出的异常: {}", e.getMessage());
         }
     }
@@ -123,24 +101,18 @@ public class ReflectUtils
      */
     @SuppressWarnings("unchecked")
     public static <E> E invokeMethod(final Object obj, final String methodName, final Class<?>[] parameterTypes,
-            final Object[] args)
-    {
-        if (obj == null || methodName == null)
-        {
+                                     final Object[] args) {
+        if (obj == null || methodName == null) {
             return null;
         }
         Method method = getAccessibleMethod(obj, methodName, parameterTypes);
-        if (method == null)
-        {
+        if (method == null) {
             logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
             return null;
         }
-        try
-        {
+        try {
             return (E) method.invoke(obj, args);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             String msg = "method: " + method + ", obj: " + obj + ", args: " + args + "";
             throw convertReflectionExceptionToUnchecked(msg, e);
         }
@@ -152,68 +124,44 @@ public class ReflectUtils
      * 只匹配函数名,如果有多个同名函数调用第一个。
      */
     @SuppressWarnings("unchecked")
-    public static <E> E invokeMethodByName(final Object obj, final String methodName, final Object[] args)
-    {
+    public static <E> E invokeMethodByName(final Object obj, final String methodName, final Object[] args) {
         Method method = getAccessibleMethodByName(obj, methodName, args.length);
-        if (method == null)
-        {
+        if (method == null) {
             // 如果为空不报错,直接返回空。
             logger.debug("在 [" + obj.getClass() + "] 中,没有找到 [" + methodName + "] 方法 ");
             return null;
         }
-        try
-        {
+        try {
             // 类型转换(将参数数据类型转换为目标方法参数类型)
             Class<?>[] cs = method.getParameterTypes();
-            for (int i = 0; i < cs.length; i++)
-            {
-                if (args[i] != null && !args[i].getClass().equals(cs[i]))
-                {
-                    if (cs[i] == String.class)
-                    {
+            for (int i = 0; i < cs.length; i++) {
+                if (args[i] != null && !args[i].getClass().equals(cs[i])) {
+                    if (cs[i] == String.class) {
                         args[i] = Convert.toStr(args[i]);
-                        if (StringUtils.endsWith((String) args[i], ".0"))
-                        {
+                        if (StringUtils.endsWith((String) args[i], ".0")) {
                             args[i] = StringUtils.substringBefore((String) args[i], ".0");
                         }
-                    }
-                    else if (cs[i] == Integer.class)
-                    {
+                    } else if (cs[i] == Integer.class) {
                         args[i] = Convert.toInt(args[i]);
-                    }
-                    else if (cs[i] == Long.class)
-                    {
+                    } else if (cs[i] == Long.class) {
                         args[i] = Convert.toLong(args[i]);
-                    }
-                    else if (cs[i] == Double.class)
-                    {
+                    } else if (cs[i] == Double.class) {
                         args[i] = Convert.toDouble(args[i]);
-                    }
-                    else if (cs[i] == Float.class)
-                    {
+                    } else if (cs[i] == Float.class) {
                         args[i] = Convert.toFloat(args[i]);
-                    }
-                    else if (cs[i] == Date.class)
-                    {
-                        if (args[i] instanceof String)
-                        {
+                    } else if (cs[i] == Date.class) {
+                        if (args[i] instanceof String) {
                             args[i] = DateUtils.parseDate(args[i]);
-                        }
-                        else
-                        {
+                        } else {
                             args[i] = DateUtil.getJavaDate((Double) args[i]);
                         }
-                    }
-                    else if (cs[i] == boolean.class || cs[i] == Boolean.class)
-                    {
+                    } else if (cs[i] == boolean.class || cs[i] == Boolean.class) {
                         args[i] = Convert.toBool(args[i]);
                     }
                 }
             }
             return (E) method.invoke(obj, args);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             String msg = "method: " + method + ", obj: " + obj + ", args: " + args + "";
             throw convertReflectionExceptionToUnchecked(msg, e);
         }
@@ -223,24 +171,18 @@ public class ReflectUtils
      * 循环向上转型, 获取对象的DeclaredField, 并强制设置为可访问.
      * 如向上转型到Object仍无法找到, 返回null.
      */
-    public static Field getAccessibleField(final Object obj, final String fieldName)
-    {
+    public static Field getAccessibleField(final Object obj, final String fieldName) {
         // 为空不报错。直接返回 null
-        if (obj == null)
-        {
+        if (obj == null) {
             return null;
         }
         Validate.notBlank(fieldName, "fieldName can't be blank");
-        for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass())
-        {
-            try
-            {
+        for (Class<?> superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) {
+            try {
                 Field field = superClass.getDeclaredField(fieldName);
                 makeAccessible(field);
                 return field;
-            }
-            catch (NoSuchFieldException e)
-            {
+            } catch (NoSuchFieldException e) {
                 continue;
             }
         }
@@ -254,24 +196,18 @@ public class ReflectUtils
      * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args)
      */
     public static Method getAccessibleMethod(final Object obj, final String methodName,
-            final Class<?>... parameterTypes)
-    {
+                                             final Class<?>... parameterTypes) {
         // 为空不报错。直接返回 null
-        if (obj == null)
-        {
+        if (obj == null) {
             return null;
         }
         Validate.notBlank(methodName, "methodName can't be blank");
-        for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass())
-        {
-            try
-            {
+        for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
+            try {
                 Method method = searchType.getDeclaredMethod(methodName, parameterTypes);
                 makeAccessible(method);
                 return method;
-            }
-            catch (NoSuchMethodException e)
-            {
+            } catch (NoSuchMethodException e) {
                 continue;
             }
         }
@@ -284,21 +220,16 @@ public class ReflectUtils
      * 只匹配函数名。
      * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args)
      */
-    public static Method getAccessibleMethodByName(final Object obj, final String methodName, int argsNum)
-    {
+    public static Method getAccessibleMethodByName(final Object obj, final String methodName, int argsNum) {
         // 为空不报错。直接返回 null
-        if (obj == null)
-        {
+        if (obj == null) {
             return null;
         }
         Validate.notBlank(methodName, "methodName can't be blank");
-        for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass())
-        {
+        for (Class<?> searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) {
             Method[] methods = searchType.getDeclaredMethods();
-            for (Method method : methods)
-            {
-                if (method.getName().equals(methodName) && method.getParameterTypes().length == argsNum)
-                {
+            for (Method method : methods) {
+                if (method.getName().equals(methodName) && method.getParameterTypes().length == argsNum) {
                     makeAccessible(method);
                     return method;
                 }
@@ -310,11 +241,9 @@ public class ReflectUtils
     /**
      * 改变private/protected的方法为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。
      */
-    public static void makeAccessible(Method method)
-    {
+    public static void makeAccessible(Method method) {
         if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers()))
-                && !method.isAccessible())
-        {
+                && !method.isAccessible()) {
             method.setAccessible(true);
         }
     }
@@ -322,11 +251,9 @@ public class ReflectUtils
     /**
      * 改变private/protected的成员变量为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。
      */
-    public static void makeAccessible(Field field)
-    {
+    public static void makeAccessible(Field field) {
         if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())
-                || Modifier.isFinal(field.getModifiers())) && !field.isAccessible())
-        {
+                || Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) {
             field.setAccessible(true);
         }
     }
@@ -336,8 +263,7 @@ public class ReflectUtils
      * 如无法找到, 返回Object.class.
      */
     @SuppressWarnings("unchecked")
-    public static <T> Class<T> getClassGenricType(final Class clazz)
-    {
+    public static <T> Class<T> getClassGenricType(final Class clazz) {
         return getClassGenricType(clazz, 0);
     }
 
@@ -345,26 +271,22 @@ public class ReflectUtils
      * 通过反射, 获得Class定义中声明的父类的泛型参数的类型.
      * 如无法找到, 返回Object.class.
      */
-    public static Class getClassGenricType(final Class clazz, final int index)
-    {
+    public static Class getClassGenricType(final Class clazz, final int index) {
         Type genType = clazz.getGenericSuperclass();
 
-        if (!(genType instanceof ParameterizedType))
-        {
+        if (!(genType instanceof ParameterizedType)) {
             logger.debug(clazz.getSimpleName() + "'s superclass not ParameterizedType");
             return Object.class;
         }
 
         Type[] params = ((ParameterizedType) genType).getActualTypeArguments();
 
-        if (index >= params.length || index < 0)
-        {
+        if (index >= params.length || index < 0) {
             logger.debug("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: "
                     + params.length);
             return Object.class;
         }
-        if (!(params[index] instanceof Class))
-        {
+        if (!(params[index] instanceof Class)) {
             logger.debug(clazz.getSimpleName() + " not set the actual class on superclass generic parameter");
             return Object.class;
         }
@@ -372,18 +294,14 @@ public class ReflectUtils
         return (Class) params[index];
     }
 
-    public static Class<?> getUserClass(Object instance)
-    {
-        if (instance == null)
-        {
+    public static Class<?> getUserClass(Object instance) {
+        if (instance == null) {
             throw new RuntimeException("Instance must not be null");
         }
         Class clazz = instance.getClass();
-        if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR))
-        {
+        if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
             Class<?> superClass = clazz.getSuperclass();
-            if (superClass != null && !Object.class.equals(superClass))
-            {
+            if (superClass != null && !Object.class.equals(superClass)) {
                 return superClass;
             }
         }
@@ -394,15 +312,11 @@ public class ReflectUtils
     /**
      * 将反射时的checked exception转换为unchecked exception.
      */
-    public static RuntimeException convertReflectionExceptionToUnchecked(String msg, Exception e)
-    {
+    public static RuntimeException convertReflectionExceptionToUnchecked(String msg, Exception e) {
         if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException
-                || e instanceof NoSuchMethodException)
-        {
+                || e instanceof NoSuchMethodException) {
             return new IllegalArgumentException(msg, e);
-        }
-        else if (e instanceof InvocationTargetException)
-        {
+        } else if (e instanceof InvocationTargetException) {
             return new RuntimeException(msg, ((InvocationTargetException) e).getTargetException());
         }
         return new RuntimeException(msg, e);

+ 13 - 25
ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Md5Utils.java

@@ -2,49 +2,41 @@ package com.ruoyi.common.utils.sign;
 
 import java.nio.charset.StandardCharsets;
 import java.security.MessageDigest;
+
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
  * Md5加密方法
- * 
+ *
  * @author ruoyi
  */
-public class Md5Utils
-{
+public class Md5Utils {
     private static final Logger log = LoggerFactory.getLogger(Md5Utils.class);
 
-    private static byte[] md5(String s)
-    {
+    private static byte[] md5(String s) {
         MessageDigest algorithm;
-        try
-        {
+        try {
             algorithm = MessageDigest.getInstance("MD5");
             algorithm.reset();
             algorithm.update(s.getBytes("UTF-8"));
             byte[] messageDigest = algorithm.digest();
             return messageDigest;
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("MD5 Error...", e);
         }
         return null;
     }
 
-    private static final String toHex(byte hash[])
-    {
-        if (hash == null)
-        {
+    private static final String toHex(byte hash[]) {
+        if (hash == null) {
             return null;
         }
         StringBuffer buf = new StringBuffer(hash.length * 2);
         int i;
 
-        for (i = 0; i < hash.length; i++)
-        {
-            if ((hash[i] & 0xff) < 0x10)
-            {
+        for (i = 0; i < hash.length; i++) {
+            if ((hash[i] & 0xff) < 0x10) {
                 buf.append("0");
             }
             buf.append(Long.toString(hash[i] & 0xff, 16));
@@ -52,14 +44,10 @@ public class Md5Utils
         return buf.toString();
     }
 
-    public static String hash(String s)
-    {
-        try
-        {
+    public static String hash(String s) {
+        try {
             return new String(toHex(md5(s)).getBytes(StandardCharsets.UTF_8), StandardCharsets.UTF_8);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("not supported charset...{}", e);
             return s;
         }

+ 19 - 36
ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java

@@ -1,5 +1,6 @@
 package com.ruoyi.common.utils.spring;
 
+import com.ruoyi.common.utils.StringUtils;
 import org.springframework.aop.framework.AopContext;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.NoSuchBeanDefinitionException;
@@ -8,30 +9,28 @@ import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.stereotype.Component;
-import com.ruoyi.common.utils.StringUtils;
 
 /**
  * spring工具类 方便在非spring管理环境中获取bean
- * 
+ *
  * @author ruoyi
  */
 @Component
-public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware 
-{
-    /** Spring应用上下文环境 */
+public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationContextAware {
+    /**
+     * Spring应用上下文环境
+     */
     private static ConfigurableListableBeanFactory beanFactory;
 
     private static ApplicationContext applicationContext;
 
     @Override
-    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException 
-    {
+    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
         SpringUtils.beanFactory = beanFactory;
     }
 
     @Override
-    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException 
-    {
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
         SpringUtils.applicationContext = applicationContext;
     }
 
@@ -41,11 +40,9 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC
      * @param name
      * @return Object 一个以所给名字注册的bean的实例
      * @throws org.springframework.beans.BeansException
-     *
      */
     @SuppressWarnings("unchecked")
-    public static <T> T getBean(String name) throws BeansException
-    {
+    public static <T> T getBean(String name) throws BeansException {
         return (T) beanFactory.getBean(name);
     }
 
@@ -55,10 +52,8 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC
      * @param clz
      * @return
      * @throws org.springframework.beans.BeansException
-     *
      */
-    public static <T> T getBean(Class<T> clz) throws BeansException
-    {
+    public static <T> T getBean(Class<T> clz) throws BeansException {
         T result = (T) beanFactory.getBean(clz);
         return result;
     }
@@ -69,8 +64,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC
      * @param name
      * @return boolean
      */
-    public static boolean containsBean(String name)
-    {
+    public static boolean containsBean(String name) {
         return beanFactory.containsBean(name);
     }
 
@@ -80,10 +74,8 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC
      * @param name
      * @return boolean
      * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
-     *
      */
-    public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException
-    {
+    public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
         return beanFactory.isSingleton(name);
     }
 
@@ -91,10 +83,8 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC
      * @param name
      * @return Class 注册对象的类型
      * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
-     *
      */
-    public static Class<?> getType(String name) throws NoSuchBeanDefinitionException
-    {
+    public static Class<?> getType(String name) throws NoSuchBeanDefinitionException {
         return beanFactory.getType(name);
     }
 
@@ -104,22 +94,19 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC
      * @param name
      * @return
      * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
-     *
      */
-    public static String[] getAliases(String name) throws NoSuchBeanDefinitionException
-    {
+    public static String[] getAliases(String name) throws NoSuchBeanDefinitionException {
         return beanFactory.getAliases(name);
     }
 
     /**
      * 获取aop代理对象
-     * 
+     *
      * @param invoker
      * @return
      */
     @SuppressWarnings("unchecked")
-    public static <T> T getAopProxy(T invoker)
-    {
+    public static <T> T getAopProxy(T invoker) {
         return (T) AopContext.currentProxy();
     }
 
@@ -128,8 +115,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC
      *
      * @return 当前的环境配置
      */
-    public static String[] getActiveProfiles()
-    {
+    public static String[] getActiveProfiles() {
         return applicationContext.getEnvironment().getActiveProfiles();
     }
 
@@ -138,8 +124,7 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC
      *
      * @return 当前的环境配置
      */
-    public static String getActiveProfile()
-    {
+    public static String getActiveProfile() {
         final String[] activeProfiles = getActiveProfiles();
         return StringUtils.isNotEmpty(activeProfiles) ? activeProfiles[0] : null;
     }
@@ -149,10 +134,8 @@ public final class SpringUtils implements BeanFactoryPostProcessor, ApplicationC
      *
      * @param key 配置文件的key
      * @return 当前的配置文件的值
-     *
      */
-    public static String getRequiredProperty(String key)
-    {
+    public static String getRequiredProperty(String key) {
         return applicationContext.getEnvironment().getRequiredProperty(key);
     }
 }

+ 9 - 17
ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java

@@ -5,11 +5,10 @@ import com.ruoyi.common.utils.StringUtils;
 
 /**
  * sql操作工具类
- * 
+ *
  * @author ruoyi
  */
-public class SqlUtil
-{
+public class SqlUtil {
     /**
      * 定义常用的 sql关键字
      */
@@ -23,10 +22,8 @@ public class SqlUtil
     /**
      * 检查字符,防止注入绕过
      */
-    public static String escapeOrderBySql(String value)
-    {
-        if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value))
-        {
+    public static String escapeOrderBySql(String value) {
+        if (StringUtils.isNotEmpty(value) && !isValidOrderBySql(value)) {
             throw new UtilException("参数不符合规范,不能进行查询");
         }
         return value;
@@ -35,25 +32,20 @@ public class SqlUtil
     /**
      * 验证 order by 语法是否符合规范
      */
-    public static boolean isValidOrderBySql(String value)
-    {
+    public static boolean isValidOrderBySql(String value) {
         return value.matches(SQL_PATTERN);
     }
 
     /**
      * SQL关键字检查
      */
-    public static void filterKeyword(String value)
-    {
-        if (StringUtils.isEmpty(value))
-        {
+    public static void filterKeyword(String value) {
+        if (StringUtils.isEmpty(value)) {
             return;
         }
         String[] sqlKeywords = StringUtils.split(SQL_REGEX, "\\|");
-        for (String sqlKeyword : sqlKeywords)
-        {
-            if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1)
-            {
+        for (String sqlKeyword : sqlKeywords) {
+            if (StringUtils.indexOfIgnoreCase(value, sqlKeyword) > -1) {
                 throw new UtilException("参数存在SQL注入风险");
             }
         }

+ 10 - 15
ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/IdUtils.java

@@ -2,48 +2,43 @@ package com.ruoyi.common.utils.uuid;
 
 /**
  * ID生成器工具类
- * 
+ *
  * @author ruoyi
  */
-public class IdUtils
-{
+public class IdUtils {
     /**
      * 获取随机UUID
-     * 
+     *
      * @return 随机UUID
      */
-    public static String randomUUID()
-    {
+    public static String randomUUID() {
         return UUID.randomUUID().toString();
     }
 
     /**
      * 简化的UUID,去掉了横线
-     * 
+     *
      * @return 简化的UUID,去掉了横线
      */
-    public static String simpleUUID()
-    {
+    public static String simpleUUID() {
         return UUID.randomUUID().toString(true);
     }
 
     /**
      * 获取随机UUID,使用性能更好的ThreadLocalRandom生成UUID
-     * 
+     *
      * @return 随机UUID
      */
-    public static String fastUUID()
-    {
+    public static String fastUUID() {
         return UUID.fastUUID().toString();
     }
 
     /**
      * 简化的UUID,去掉了横线,使用性能更好的ThreadLocalRandom生成UUID
-     * 
+     *
      * @return 简化的UUID,去掉了横线
      */
-    public static String fastSimpleUUID()
-    {
+    public static String fastSimpleUUID() {
         return UUID.fastUUID().toString(true);
     }
 }

+ 14 - 20
ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/Seq.java

@@ -1,14 +1,14 @@
 package com.ruoyi.common.utils.uuid;
 
 import java.util.concurrent.atomic.AtomicInteger;
+
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
 
 /**
  * @author ruoyi 序列生成类
  */
-public class Seq
-{
+public class Seq {
     // 通用序列类型
     public static final String commSeqType = "COMMON";
 
@@ -26,24 +26,21 @@ public class Seq
 
     /**
      * 获取通用序列号
-     * 
+     *
      * @return 序列值
      */
-    public static String getId()
-    {
+    public static String getId() {
         return getId(commSeqType);
     }
-    
+
     /**
      * 默认16位序列号 yyMMddHHmmss + 一位机器标识 + 3长度循环递增字符串
-     * 
+     *
      * @return 序列值
      */
-    public static String getId(String type)
-    {
+    public static String getId(String type) {
         AtomicInteger atomicInt = commSeq;
-        if (uploadSeqType.equals(type))
-        {
+        if (uploadSeqType.equals(type)) {
             atomicInt = uploadSeq;
         }
         return getId(atomicInt, 3);
@@ -51,13 +48,12 @@ public class Seq
 
     /**
      * 通用接口序列号 yyMMddHHmmss + 一位机器标识 + length长度循环递增字符串
-     * 
+     *
      * @param atomicInt 序列数
-     * @param length 数值长度
+     * @param length    数值长度
      * @return 序列值
      */
-    public static String getId(AtomicInteger atomicInt, int length)
-    {
+    public static String getId(AtomicInteger atomicInt, int length) {
         String result = DateUtils.dateTimeNow();
         result += machineCode;
         result += getSeq(atomicInt, length);
@@ -66,18 +62,16 @@ public class Seq
 
     /**
      * 序列循环递增字符串[1, 10 的 (length)幂次方), 用0左补齐length位数
-     * 
+     *
      * @return 序列值
      */
-    private synchronized static String getSeq(AtomicInteger atomicInt, int length)
-    {
+    private synchronized static String getSeq(AtomicInteger atomicInt, int length) {
         // 先取值再+1
         int value = atomicInt.getAndIncrement();
 
         // 如果更新后值>=10 的 (length)幂次方则重置为1
         int maxSeq = (int) Math.pow(10, length);
-        if (atomicInt.get() >= maxSeq)
-        {
+        if (atomicInt.get() >= maxSeq) {
             atomicInt.set(1);
         }
         // 转字符串,用0左补齐

+ 60 - 103
ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/UUID.java

@@ -5,6 +5,7 @@ import java.security.NoSuchAlgorithmException;
 import java.security.SecureRandom;
 import java.util.Random;
 import java.util.concurrent.ThreadLocalRandom;
+
 import com.ruoyi.common.exception.UtilException;
 
 /**
@@ -12,41 +13,39 @@ import com.ruoyi.common.exception.UtilException;
  *
  * @author ruoyi
  */
-public final class UUID implements java.io.Serializable, Comparable<UUID>
-{
+public final class UUID implements java.io.Serializable, Comparable<UUID> {
     private static final long serialVersionUID = -1185015143654744140L;
 
     /**
      * SecureRandom 的单例
-     *
      */
-    private static class Holder
-    {
+    private static class Holder {
         static final SecureRandom numberGenerator = getSecureRandom();
     }
 
-    /** 此UUID的最高64有效位 */
+    /**
+     * 此UUID的最高64有效位
+     */
     private final long mostSigBits;
 
-    /** 此UUID的最低64有效位 */
+    /**
+     * 此UUID的最低64有效位
+     */
     private final long leastSigBits;
 
     /**
      * 私有构造
-     * 
+     *
      * @param data 数据
      */
-    private UUID(byte[] data)
-    {
+    private UUID(byte[] data) {
         long msb = 0;
         long lsb = 0;
         assert data.length == 16 : "data must be 16 bytes in length";
-        for (int i = 0; i < 8; i++)
-        {
+        for (int i = 0; i < 8; i++) {
             msb = (msb << 8) | (data[i] & 0xff);
         }
-        for (int i = 8; i < 16; i++)
-        {
+        for (int i = 8; i < 16; i++) {
             lsb = (lsb << 8) | (data[i] & 0xff);
         }
         this.mostSigBits = msb;
@@ -56,43 +55,39 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
     /**
      * 使用指定的数据构造新的 UUID。
      *
-     * @param mostSigBits 用于 {@code UUID} 的最高有效 64 位
+     * @param mostSigBits  用于 {@code UUID} 的最高有效 64 位
      * @param leastSigBits 用于 {@code UUID} 的最低有效 64 位
      */
-    public UUID(long mostSigBits, long leastSigBits)
-    {
+    public UUID(long mostSigBits, long leastSigBits) {
         this.mostSigBits = mostSigBits;
         this.leastSigBits = leastSigBits;
     }
 
     /**
      * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的本地线程伪随机数生成器生成该 UUID。
-     * 
+     *
      * @return 随机生成的 {@code UUID}
      */
-    public static UUID fastUUID()
-    {
+    public static UUID fastUUID() {
         return randomUUID(false);
     }
 
     /**
      * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。
-     * 
+     *
      * @return 随机生成的 {@code UUID}
      */
-    public static UUID randomUUID()
-    {
+    public static UUID randomUUID() {
         return randomUUID(true);
     }
 
     /**
      * 获取类型 4(伪随机生成的)UUID 的静态工厂。 使用加密的强伪随机数生成器生成该 UUID。
-     * 
+     *
      * @param isSecure 是否使用{@link SecureRandom}如果是可以获得更安全的随机码,否则可以得到更好的性能
      * @return 随机生成的 {@code UUID}
      */
-    public static UUID randomUUID(boolean isSecure)
-    {
+    public static UUID randomUUID(boolean isSecure) {
         final Random ng = isSecure ? Holder.numberGenerator : getRandom();
 
         byte[] randomBytes = new byte[16];
@@ -108,18 +103,13 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      * 根据指定的字节数组获取类型 3(基于名称的)UUID 的静态工厂。
      *
      * @param name 用于构造 UUID 的字节数组。
-     *
      * @return 根据指定数组生成的 {@code UUID}
      */
-    public static UUID nameUUIDFromBytes(byte[] name)
-    {
+    public static UUID nameUUIDFromBytes(byte[] name) {
         MessageDigest md;
-        try
-        {
+        try {
             md = MessageDigest.getInstance("MD5");
-        }
-        catch (NoSuchAlgorithmException nsae)
-        {
+        } catch (NoSuchAlgorithmException nsae) {
             throw new InternalError("MD5 not supported");
         }
         byte[] md5Bytes = md.digest(name);
@@ -136,17 +126,13 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      * @param name 指定 {@code UUID} 字符串
      * @return 具有指定值的 {@code UUID}
      * @throws IllegalArgumentException 如果 name 与 {@link #toString} 中描述的字符串表示形式不符抛出此异常
-     *
      */
-    public static UUID fromString(String name)
-    {
+    public static UUID fromString(String name) {
         String[] components = name.split("-");
-        if (components.length != 5)
-        {
+        if (components.length != 5) {
             throw new IllegalArgumentException("Invalid UUID string: " + name);
         }
-        for (int i = 0; i < 5; i++)
-        {
+        for (int i = 0; i < 5; i++) {
             components[i] = "0x" + components[i];
         }
 
@@ -168,8 +154,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      *
      * @return 此 UUID 的 128 位值中的最低有效 64 位。
      */
-    public long getLeastSignificantBits()
-    {
+    public long getLeastSignificantBits() {
         return leastSigBits;
     }
 
@@ -178,8 +163,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      *
      * @return 此 UUID 的 128 位值中最高有效 64 位。
      */
-    public long getMostSignificantBits()
-    {
+    public long getMostSignificantBits() {
         return mostSigBits;
     }
 
@@ -196,8 +180,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      *
      * @return 此 {@code UUID} 的版本号
      */
-    public int version()
-    {
+    public int version() {
         // Version is bits masked by 0x000000000000F000 in MS long
         return (int) ((mostSigBits >> 12) & 0x0f);
     }
@@ -215,8 +198,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      *
      * @return 此 {@code UUID} 相关联的变体号
      */
-    public int variant()
-    {
+    public int variant() {
         // This field is composed of a varying number of bits.
         // 0 - - Reserved for NCS backward compatibility
         // 1 0 - The IETF aka Leach-Salz variant (used by this class)
@@ -238,8 +220,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      *
      * @throws UnsupportedOperationException 如果此 {@code UUID} 不是 version 为 1 的 UUID。
      */
-    public long timestamp() throws UnsupportedOperationException
-    {
+    public long timestamp() throws UnsupportedOperationException {
         checkTimeBase();
         return (mostSigBits & 0x0FFFL) << 48//
                 | ((mostSigBits >> 16) & 0x0FFFFL) << 32//
@@ -256,11 +237,9 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      * UnsupportedOperationException。
      *
      * @return 此 {@code UUID} 的时钟序列
-     *
      * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1
      */
-    public int clockSequence() throws UnsupportedOperationException
-    {
+    public int clockSequence() throws UnsupportedOperationException {
         checkTimeBase();
         return (int) ((leastSigBits & 0x3FFF000000000000L) >>> 48);
     }
@@ -275,11 +254,9 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      * 如果此 UUID 不是基于时间的 UUID,则此方法抛出 UnsupportedOperationException。
      *
      * @return 此 {@code UUID} 的节点值
-     *
      * @throws UnsupportedOperationException 如果此 UUID 的 version 不为 1
      */
-    public long node() throws UnsupportedOperationException
-    {
+    public long node() throws UnsupportedOperationException {
         checkTimeBase();
         return leastSigBits & 0x0000FFFFFFFFFFFFL;
     }
@@ -289,7 +266,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      *
      * <p>
      * UUID 的字符串表示形式由此 BNF 描述:
-     * 
+     *
      * <pre>
      * {@code
      * UUID                   = <time_low>-<time_mid>-<time_high_and_version>-<variant_and_sequence>-<node>
@@ -302,15 +279,14 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      * hexDigit               = [0-9a-fA-F]
      * }
      * </pre>
-     * 
+     *
      * </blockquote>
      *
      * @return 此{@code UUID} 的字符串表现形式
      * @see #toString(boolean)
      */
     @Override
-    public String toString()
-    {
+    public String toString() {
         return toString(false);
     }
 
@@ -319,7 +295,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      *
      * <p>
      * UUID 的字符串表示形式由此 BNF 描述:
-     * 
+     *
      * <pre>
      * {@code
      * UUID                   = <time_low>-<time_mid>-<time_high_and_version>-<variant_and_sequence>-<node>
@@ -332,37 +308,32 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      * hexDigit               = [0-9a-fA-F]
      * }
      * </pre>
-     * 
+     *
      * </blockquote>
      *
      * @param isSimple 是否简单模式,简单模式为不带'-'的UUID字符串
      * @return 此{@code UUID} 的字符串表现形式
      */
-    public String toString(boolean isSimple)
-    {
+    public String toString(boolean isSimple) {
         final StringBuilder builder = new StringBuilder(isSimple ? 32 : 36);
         // time_low
         builder.append(digits(mostSigBits >> 32, 8));
-        if (!isSimple)
-        {
+        if (!isSimple) {
             builder.append('-');
         }
         // time_mid
         builder.append(digits(mostSigBits >> 16, 4));
-        if (!isSimple)
-        {
+        if (!isSimple) {
             builder.append('-');
         }
         // time_high_and_version
         builder.append(digits(mostSigBits, 4));
-        if (!isSimple)
-        {
+        if (!isSimple) {
             builder.append('-');
         }
         // variant_and_sequence
         builder.append(digits(leastSigBits >> 48, 4));
-        if (!isSimple)
-        {
+        if (!isSimple) {
             builder.append('-');
         }
         // node
@@ -377,8 +348,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      * @return UUID 的哈希码值。
      */
     @Override
-    public int hashCode()
-    {
+    public int hashCode() {
         long hilo = mostSigBits ^ leastSigBits;
         return ((int) (hilo >> 32)) ^ (int) hilo;
     }
@@ -389,14 +359,11 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      * 当且仅当参数不为 {@code null}、而是一个 UUID 对象、具有与此 UUID 相同的 varriant、包含相同的值(每一位均相同)时,结果才为 {@code true}。
      *
      * @param obj 要与之比较的对象
-     *
      * @return 如果对象相同,则返回 {@code true};否则返回 {@code false}
      */
     @Override
-    public boolean equals(Object obj)
-    {
-        if ((null == obj) || (obj.getClass() != UUID.class))
-        {
+    public boolean equals(Object obj) {
+        if ((null == obj) || (obj.getClass() != UUID.class)) {
             return false;
         }
         UUID id = (UUID) obj;
@@ -412,13 +379,10 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
      * 如果两个 UUID 不同,且第一个 UUID 的最高有效字段大于第二个 UUID 的对应字段,则第一个 UUID 大于第二个 UUID。
      *
      * @param val 与此 UUID 比较的 UUID
-     *
      * @return 在此 UUID 小于、等于或大于 val 时,分别返回 -1、0 或 1。
-     *
      */
     @Override
-    public int compareTo(UUID val)
-    {
+    public int compareTo(UUID val) {
         // The ordering is intentionally set up so that the UUIDs
         // can simply be numerically compared as two numbers
         return (this.mostSigBits < val.mostSigBits ? -1 : //
@@ -430,15 +394,15 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
 
     // -------------------------------------------------------------------------------------------------------------------
     // Private method start
+
     /**
      * 返回指定数字对应的hex值
-     * 
-     * @param val 值
+     *
+     * @param val    
      * @param digits 位
      * @return 值
      */
-    private static String digits(long val, int digits)
-    {
+    private static String digits(long val, int digits) {
         long hi = 1L << (digits * 4);
         return Long.toHexString(hi | (val & (hi - 1))).substring(1);
     }
@@ -446,27 +410,21 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
     /**
      * 检查是否为time-based版本UUID
      */
-    private void checkTimeBase()
-    {
-        if (version() != 1)
-        {
+    private void checkTimeBase() {
+        if (version() != 1) {
             throw new UnsupportedOperationException("Not a time-based UUID");
         }
     }
 
     /**
      * 获取{@link SecureRandom},类提供加密的强随机数生成器 (RNG)
-     * 
+     *
      * @return {@link SecureRandom}
      */
-    public static SecureRandom getSecureRandom()
-    {
-        try
-        {
+    public static SecureRandom getSecureRandom() {
+        try {
             return SecureRandom.getInstance("SHA1PRNG");
-        }
-        catch (NoSuchAlgorithmException e)
-        {
+        } catch (NoSuchAlgorithmException e) {
             throw new UtilException(e);
         }
     }
@@ -474,11 +432,10 @@ public final class UUID implements java.io.Serializable, Comparable<UUID>
     /**
      * 获取随机数生成器对象<br>
      * ThreadLocalRandom是JDK 7之后提供并发产生随机数,能够解决多个线程发生的竞争争夺。
-     * 
+     *
      * @return {@link ThreadLocalRandom}
      */
-    public static ThreadLocalRandom getRandom()
-    {
+    public static ThreadLocalRandom getRandom() {
         return ThreadLocalRandom.current();
     }
 }

+ 5 - 6
ruoyi-common/src/main/java/com/ruoyi/common/xss/Xss.java

@@ -9,17 +9,16 @@ import java.lang.annotation.Target;
 
 /**
  * 自定义xss校验注解
- * 
+ *
  * @author ruoyi
  */
 @Retention(RetentionPolicy.RUNTIME)
-@Target(value = { ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER })
-@Constraint(validatedBy = { XssValidator.class })
-public @interface Xss
-{
+@Target(value = {ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER})
+@Constraint(validatedBy = {XssValidator.class})
+public @interface Xss {
     String message()
 
-    default "不允许任何脚本运行";
+            default "不允许任何脚本运行";
 
     Class<?>[] groups() default {};
 

+ 6 - 9
ruoyi-common/src/main/java/com/ruoyi/common/xss/XssValidator.java

@@ -1,6 +1,7 @@
 package com.ruoyi.common.xss;
 
 import com.ruoyi.common.utils.StringUtils;
+
 import javax.validation.ConstraintValidator;
 import javax.validation.ConstraintValidatorContext;
 import java.util.regex.Matcher;
@@ -8,25 +9,21 @@ import java.util.regex.Pattern;
 
 /**
  * 自定义xss校验注解实现
- * 
+ *
  * @author ruoyi
  */
-public class XssValidator implements ConstraintValidator<Xss, String>
-{
+public class XssValidator implements ConstraintValidator<Xss, String> {
     private static final String HTML_PATTERN = "<(\\S*?)[^>]*>.*?|<.*? />";
 
     @Override
-    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext)
-    {
-        if (StringUtils.isBlank(value))
-        {
+    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext) {
+        if (StringUtils.isBlank(value)) {
             return true;
         }
         return !containsHtml(value);
     }
 
-    public static boolean containsHtml(String value)
-    {
+    public static boolean containsHtml(String value) {
         Pattern pattern = Pattern.compile(HTML_PATTERN);
         Matcher matcher = pattern.matcher(value);
         return matcher.matches();

+ 1 - 1
ruoyi-framework/pom.xml

@@ -18,7 +18,7 @@
     <dependencies>
 
         <!-- SpringBoot Web容器 -->
-         <dependency>
+        <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-web</artifactId>
         </dependency>

+ 60 - 90
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java

@@ -1,21 +1,5 @@
 package com.ruoyi.framework.aspectj;
 
-import java.util.Collection;
-import java.util.Map;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.lang3.ArrayUtils;
-import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.annotation.AfterReturning;
-import org.aspectj.lang.annotation.AfterThrowing;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Before;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.core.NamedThreadLocal;
-import org.springframework.stereotype.Component;
-import org.springframework.validation.BindingResult;
-import org.springframework.web.multipart.MultipartFile;
 import com.alibaba.fastjson2.JSON;
 import com.ruoyi.common.annotation.Log;
 import com.ruoyi.common.core.domain.model.LoginUser;
@@ -29,30 +13,49 @@ import com.ruoyi.common.utils.ip.IpUtils;
 import com.ruoyi.framework.manager.AsyncManager;
 import com.ruoyi.framework.manager.factory.AsyncFactory;
 import com.ruoyi.system.domain.SysOperLog;
+import org.apache.commons.lang3.ArrayUtils;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.AfterReturning;
+import org.aspectj.lang.annotation.AfterThrowing;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.core.NamedThreadLocal;
+import org.springframework.stereotype.Component;
+import org.springframework.validation.BindingResult;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Collection;
+import java.util.Map;
 
 /**
  * 操作日志记录处理
- * 
+ *
  * @author ruoyi
  */
 @Aspect
 @Component
-public class LogAspect
-{
+public class LogAspect {
     private static final Logger log = LoggerFactory.getLogger(LogAspect.class);
 
-    /** 排除敏感属性字段 */
-    public static final String[] EXCLUDE_PROPERTIES = { "password", "oldPassword", "newPassword", "confirmPassword" };
+    /**
+     * 排除敏感属性字段
+     */
+    public static final String[] EXCLUDE_PROPERTIES = {"password", "oldPassword", "newPassword", "confirmPassword"};
 
-    /** 计算操作消耗时间 */
+    /**
+     * 计算操作消耗时间
+     */
     private static final ThreadLocal<Long> TIME_THREADLOCAL = new NamedThreadLocal<Long>("Cost Time");
 
     /**
      * 处理请求前执行
      */
     @Before(value = "@annotation(controllerLog)")
-    public void boBefore(JoinPoint joinPoint, Log controllerLog)
-    {
+    public void boBefore(JoinPoint joinPoint, Log controllerLog) {
         TIME_THREADLOCAL.set(System.currentTimeMillis());
     }
 
@@ -62,27 +65,23 @@ public class LogAspect
      * @param joinPoint 切点
      */
     @AfterReturning(pointcut = "@annotation(controllerLog)", returning = "jsonResult")
-    public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult)
-    {
+    public void doAfterReturning(JoinPoint joinPoint, Log controllerLog, Object jsonResult) {
         handleLog(joinPoint, controllerLog, null, jsonResult);
     }
 
     /**
      * 拦截异常操作
-     * 
+     *
      * @param joinPoint 切点
-     * @param e 异常
+     * @param e         异常
      */
     @AfterThrowing(value = "@annotation(controllerLog)", throwing = "e")
-    public void doAfterThrowing(JoinPoint joinPoint, Log controllerLog, Exception e)
-    {
+    public void doAfterThrowing(JoinPoint joinPoint, Log controllerLog, Exception e) {
         handleLog(joinPoint, controllerLog, e, null);
     }
 
-    protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult)
-    {
-        try
-        {
+    protected void handleLog(final JoinPoint joinPoint, Log controllerLog, final Exception e, Object jsonResult) {
+        try {
             // 获取当前的用户
             LoginUser loginUser = SecurityUtils.getLoginUser();
 
@@ -93,13 +92,11 @@ public class LogAspect
             String ip = IpUtils.getIpAddr();
             operLog.setOperIp(ip);
             operLog.setOperUrl(StringUtils.substring(ServletUtils.getRequest().getRequestURI(), 0, 255));
-            if (loginUser != null)
-            {
+            if (loginUser != null) {
                 operLog.setOperName(loginUser.getUsername());
             }
 
-            if (e != null)
-            {
+            if (e != null) {
                 operLog.setStatus(BusinessStatus.FAIL.ordinal());
                 operLog.setErrorMsg(StringUtils.substring(e.getMessage(), 0, 2000));
             }
@@ -115,28 +112,23 @@ public class LogAspect
             operLog.setCostTime(System.currentTimeMillis() - TIME_THREADLOCAL.get());
             // 保存数据库
             AsyncManager.me().execute(AsyncFactory.recordOper(operLog));
-        }
-        catch (Exception exp)
-        {
+        } catch (Exception exp) {
             // 记录本地异常日志
             log.error("异常信息:{}", exp.getMessage());
             exp.printStackTrace();
-        }
-        finally
-        {
+        } finally {
             TIME_THREADLOCAL.remove();
         }
     }
 
     /**
      * 获取注解中对方法的描述信息 用于Controller层注解
-     * 
-     * @param log 日志
+     *
+     * @param log     日志
      * @param operLog 操作日志
      * @throws Exception
      */
-    public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog, Object jsonResult) throws Exception
-    {
+    public void getControllerMethodDescription(JoinPoint joinPoint, Log log, SysOperLog operLog, Object jsonResult) throws Exception {
         // 设置action动作
         operLog.setBusinessType(log.businessType().ordinal());
         // 设置标题
@@ -144,36 +136,30 @@ public class LogAspect
         // 设置操作人类别
         operLog.setOperatorType(log.operatorType().ordinal());
         // 是否需要保存request,参数和值
-        if (log.isSaveRequestData())
-        {
+        if (log.isSaveRequestData()) {
             // 获取参数的信息,传入到数据库中。
             setRequestValue(joinPoint, operLog, log.excludeParamNames());
         }
         // 是否需要保存response,参数和值
-        if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult))
-        {
+        if (log.isSaveResponseData() && StringUtils.isNotNull(jsonResult)) {
             operLog.setJsonResult(StringUtils.substring(JSON.toJSONString(jsonResult), 0, 2000));
         }
     }
 
     /**
      * 获取请求的参数,放到log中
-     * 
+     *
      * @param operLog 操作日志
      * @throws Exception 异常
      */
-    private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog, String[] excludeParamNames) throws Exception
-    {
+    private void setRequestValue(JoinPoint joinPoint, SysOperLog operLog, String[] excludeParamNames) throws Exception {
         Map<?, ?> paramsMap = ServletUtils.getParamMap(ServletUtils.getRequest());
         String requestMethod = operLog.getRequestMethod();
         if (StringUtils.isEmpty(paramsMap)
-                && (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod)))
-        {
+                && (HttpMethod.PUT.name().equals(requestMethod) || HttpMethod.POST.name().equals(requestMethod))) {
             String params = argsArrayToString(joinPoint.getArgs(), excludeParamNames);
             operLog.setOperParam(StringUtils.substring(params, 0, 2000));
-        }
-        else
-        {
+        } else {
             operLog.setOperParam(StringUtils.substring(JSON.toJSONString(paramsMap, excludePropertyPreFilter(excludeParamNames)), 0, 2000));
         }
     }
@@ -181,22 +167,15 @@ public class LogAspect
     /**
      * 参数拼装
      */
-    private String argsArrayToString(Object[] paramsArray, String[] excludeParamNames)
-    {
+    private String argsArrayToString(Object[] paramsArray, String[] excludeParamNames) {
         String params = "";
-        if (paramsArray != null && paramsArray.length > 0)
-        {
-            for (Object o : paramsArray)
-            {
-                if (StringUtils.isNotNull(o) && !isFilterObject(o))
-                {
-                    try
-                    {
+        if (paramsArray != null && paramsArray.length > 0) {
+            for (Object o : paramsArray) {
+                if (StringUtils.isNotNull(o) && !isFilterObject(o)) {
+                    try {
                         String jsonObj = JSON.toJSONString(o, excludePropertyPreFilter(excludeParamNames));
                         params += jsonObj.toString() + " ";
-                    }
-                    catch (Exception e)
-                    {
+                    } catch (Exception e) {
                     }
                 }
             }
@@ -207,38 +186,29 @@ public class LogAspect
     /**
      * 忽略敏感属性
      */
-    public PropertyPreExcludeFilter excludePropertyPreFilter(String[] excludeParamNames)
-    {
+    public PropertyPreExcludeFilter excludePropertyPreFilter(String[] excludeParamNames) {
         return new PropertyPreExcludeFilter().addExcludes(ArrayUtils.addAll(EXCLUDE_PROPERTIES, excludeParamNames));
     }
 
     /**
      * 判断是否需要过滤的对象。
-     * 
+     *
      * @param o 对象信息。
      * @return 如果是需要过滤的对象,则返回true;否则返回false。
      */
     @SuppressWarnings("rawtypes")
-    public boolean isFilterObject(final Object o)
-    {
+    public boolean isFilterObject(final Object o) {
         Class<?> clazz = o.getClass();
-        if (clazz.isArray())
-        {
+        if (clazz.isArray()) {
             return clazz.getComponentType().isAssignableFrom(MultipartFile.class);
-        }
-        else if (Collection.class.isAssignableFrom(clazz))
-        {
+        } else if (Collection.class.isAssignableFrom(clazz)) {
             Collection collection = (Collection) o;
-            for (Object value : collection)
-            {
+            for (Object value : collection) {
                 return value instanceof MultipartFile;
             }
-        }
-        else if (Map.class.isAssignableFrom(clazz))
-        {
+        } else if (Map.class.isAssignableFrom(clazz)) {
             Map map = (Map) o;
-            for (Object value : map.entrySet())
-            {
+            for (Object value : map.entrySet()) {
                 Map.Entry entry = (Map.Entry) value;
                 return entry.getValue() instanceof MultipartFile;
             }

+ 19 - 30
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/RateLimiterAspect.java

@@ -1,8 +1,10 @@
 package com.ruoyi.framework.aspectj;
 
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.List;
+import com.ruoyi.common.annotation.RateLimiter;
+import com.ruoyi.common.enums.LimitType;
+import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.common.utils.ip.IpUtils;
 import org.aspectj.lang.JoinPoint;
 import org.aspectj.lang.annotation.Aspect;
 import org.aspectj.lang.annotation.Before;
@@ -13,11 +15,10 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.data.redis.core.script.RedisScript;
 import org.springframework.stereotype.Component;
-import com.ruoyi.common.annotation.RateLimiter;
-import com.ruoyi.common.enums.LimitType;
-import com.ruoyi.common.exception.ServiceException;
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.common.utils.ip.IpUtils;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.List;
 
 /**
  * 限流处理
@@ -26,8 +27,7 @@ import com.ruoyi.common.utils.ip.IpUtils;
  */
 @Aspect
 @Component
-public class RateLimiterAspect
-{
+public class RateLimiterAspect {
     private static final Logger log = LoggerFactory.getLogger(RateLimiterAspect.class);
 
     private RedisTemplate<Object, Object> redisTemplate;
@@ -35,49 +35,38 @@ public class RateLimiterAspect
     private RedisScript<Long> limitScript;
 
     @Autowired
-    public void setRedisTemplate1(RedisTemplate<Object, Object> redisTemplate)
-    {
+    public void setRedisTemplate1(RedisTemplate<Object, Object> redisTemplate) {
         this.redisTemplate = redisTemplate;
     }
 
     @Autowired
-    public void setLimitScript(RedisScript<Long> limitScript)
-    {
+    public void setLimitScript(RedisScript<Long> limitScript) {
         this.limitScript = limitScript;
     }
 
     @Before("@annotation(rateLimiter)")
-    public void doBefore(JoinPoint point, RateLimiter rateLimiter) throws Throwable
-    {
+    public void doBefore(JoinPoint point, RateLimiter rateLimiter) throws Throwable {
         int time = rateLimiter.time();
         int count = rateLimiter.count();
 
         String combineKey = getCombineKey(rateLimiter, point);
         List<Object> keys = Collections.singletonList(combineKey);
-        try
-        {
+        try {
             Long number = redisTemplate.execute(limitScript, keys, count, time);
-            if (StringUtils.isNull(number) || number.intValue() > count)
-            {
+            if (StringUtils.isNull(number) || number.intValue() > count) {
                 throw new ServiceException("访问过于频繁,请稍候再试");
             }
             log.info("限制请求'{}',当前请求'{}',缓存key'{}'", count, number.intValue(), combineKey);
-        }
-        catch (ServiceException e)
-        {
+        } catch (ServiceException e) {
             throw e;
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             throw new RuntimeException("服务器限流异常,请稍候再试");
         }
     }
 
-    public String getCombineKey(RateLimiter rateLimiter, JoinPoint point)
-    {
+    public String getCombineKey(RateLimiter rateLimiter, JoinPoint point) {
         StringBuffer stringBuffer = new StringBuffer(rateLimiter.key());
-        if (rateLimiter.limitType() == LimitType.IP)
-        {
+        if (rateLimiter.limitType() == LimitType.IP) {
             stringBuffer.append(IpUtils.getIpAddr()).append("-");
         }
         MethodSignature signature = (MethodSignature) point.getSignature();

+ 11 - 23
ruoyi-framework/src/main/java/com/ruoyi/framework/config/KaptchaTextCreator.java

@@ -1,61 +1,49 @@
 package com.ruoyi.framework.config;
 
-import java.util.Random;
 import com.google.code.kaptcha.text.impl.DefaultTextCreator;
 
+import java.util.Random;
+
 /**
  * 验证码文本生成器
  *
  * @author ruoyi
  */
-public class KaptchaTextCreator extends DefaultTextCreator
-{
+public class KaptchaTextCreator extends DefaultTextCreator {
     private static final String[] CNUMBERS = "0,1,2,3,4,5,6,7,8,9,10".split(",");
 
     @Override
-    public String getText()
-    {
+    public String getText() {
         Integer result = 0;
         Random random = new Random();
         int x = random.nextInt(10);
         int y = random.nextInt(10);
         StringBuilder suChinese = new StringBuilder();
         int randomoperands = random.nextInt(3);
-        if (randomoperands == 0)
-        {
+        if (randomoperands == 0) {
             result = x * y;
             suChinese.append(CNUMBERS[x]);
             suChinese.append("*");
             suChinese.append(CNUMBERS[y]);
-        }
-        else if (randomoperands == 1)
-        {
-            if ((x != 0) && y % x == 0)
-            {
+        } else if (randomoperands == 1) {
+            if ((x != 0) && y % x == 0) {
                 result = y / x;
                 suChinese.append(CNUMBERS[y]);
                 suChinese.append("/");
                 suChinese.append(CNUMBERS[x]);
-            }
-            else
-            {
+            } else {
                 result = x + y;
                 suChinese.append(CNUMBERS[x]);
                 suChinese.append("+");
                 suChinese.append(CNUMBERS[y]);
             }
-        }
-        else
-        {
-            if (x >= y)
-            {
+        } else {
+            if (x >= y) {
                 result = x - y;
                 suChinese.append(CNUMBERS[x]);
                 suChinese.append("-");
                 suChinese.append(CNUMBERS[y]);
-            }
-            else
-            {
+            } else {
                 result = y - x;
                 suChinese.append(CNUMBERS[y]);
                 suChinese.append("-");

+ 6 - 10
ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java

@@ -11,17 +11,15 @@ import org.springframework.data.redis.serializer.StringRedisSerializer;
 
 /**
  * redis配置
- * 
+ *
  * @author ruoyi
  */
 @Configuration
 @EnableCaching
-public class RedisConfig extends CachingConfigurerSupport
-{
+public class RedisConfig extends CachingConfigurerSupport {
     @Bean
-    @SuppressWarnings(value = { "unchecked", "rawtypes" })
-    public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory)
-    {
+    @SuppressWarnings(value = {"unchecked", "rawtypes"})
+    public RedisTemplate<Object, Object> redisTemplate(RedisConnectionFactory connectionFactory) {
         RedisTemplate<Object, Object> template = new RedisTemplate<>();
         template.setConnectionFactory(connectionFactory);
 
@@ -40,8 +38,7 @@ public class RedisConfig extends CachingConfigurerSupport
     }
 
     @Bean
-    public DefaultRedisScript<Long> limitScript()
-    {
+    public DefaultRedisScript<Long> limitScript() {
         DefaultRedisScript<Long> redisScript = new DefaultRedisScript<>();
         redisScript.setScriptText(limitScriptText());
         redisScript.setResultType(Long.class);
@@ -51,8 +48,7 @@ public class RedisConfig extends CachingConfigurerSupport
     /**
      * 限流脚本
      */
-    private String limitScriptText()
-    {
+    private String limitScriptText() {
         return "local key = KEYS[1]\n" +
                 "local count = tonumber(ARGV[1])\n" +
                 "local time = tonumber(ARGV[2])\n" +

+ 12 - 14
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java

@@ -1,6 +1,8 @@
 package com.ruoyi.framework.config;
 
-import java.util.concurrent.TimeUnit;
+import com.ruoyi.common.config.RuoYiConfig;
+import com.ruoyi.common.constant.Constants;
+import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
@@ -11,24 +13,21 @@ import org.springframework.web.filter.CorsFilter;
 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
 import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
-import com.ruoyi.common.config.RuoYiConfig;
-import com.ruoyi.common.constant.Constants;
-import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor;
+
+import java.util.concurrent.TimeUnit;
 
 /**
  * 通用配置
- * 
+ *
  * @author ruoyi
  */
 @Configuration
-public class ResourcesConfig implements WebMvcConfigurer
-{
+public class ResourcesConfig implements WebMvcConfigurer {
     @Autowired
     private RepeatSubmitInterceptor repeatSubmitInterceptor;
 
     @Override
-    public void addResourceHandlers(ResourceHandlerRegistry registry)
-    {
+    public void addResourceHandlers(ResourceHandlerRegistry registry) {
         /** 本地文件上传路径 */
         registry.addResourceHandler(Constants.RESOURCE_PREFIX + "/**")
                 .addResourceLocations("file:" + RuoYiConfig.getProfile() + "/");
@@ -36,15 +35,15 @@ public class ResourcesConfig implements WebMvcConfigurer
         /** swagger配置 */
         registry.addResourceHandler("/swagger-ui/**")
                 .addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/")
-                .setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic());;
+                .setCacheControl(CacheControl.maxAge(5, TimeUnit.HOURS).cachePublic());
+        ;
     }
 
     /**
      * 自定义拦截规则
      */
     @Override
-    public void addInterceptors(InterceptorRegistry registry)
-    {
+    public void addInterceptors(InterceptorRegistry registry) {
         registry.addInterceptor(repeatSubmitInterceptor).addPathPatterns("/**");
     }
 
@@ -52,8 +51,7 @@ public class ResourcesConfig implements WebMvcConfigurer
      * 跨域配置
      */
     @Bean
-    public CorsFilter corsFilter()
-    {
+    public CorsFilter corsFilter() {
         CorsConfiguration config = new CorsConfiguration();
         config.setAllowCredentials(true);
         // 设置访问源地址

+ 12 - 17
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java

@@ -1,5 +1,9 @@
 package com.ruoyi.framework.config;
 
+import com.ruoyi.framework.config.properties.PermitAllUrlProperties;
+import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter;
+import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl;
+import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Bean;
 import org.springframework.http.HttpMethod;
@@ -15,25 +19,20 @@ import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
 import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter;
 import org.springframework.security.web.authentication.logout.LogoutFilter;
 import org.springframework.web.filter.CorsFilter;
-import com.ruoyi.framework.config.properties.PermitAllUrlProperties;
-import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter;
-import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl;
-import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
 
 /**
  * spring security配置
- * 
+ *
  * @author ruoyi
  */
 @EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
-public class SecurityConfig extends WebSecurityConfigurerAdapter
-{
+public class SecurityConfig extends WebSecurityConfigurerAdapter {
     /**
      * 自定义用户认证逻辑
      */
     @Autowired
     private UserDetailsService userDetailsService;
-    
+
     /**
      * 认证失败处理类
      */
@@ -51,7 +50,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
      */
     @Autowired
     private JwtAuthenticationTokenFilter authenticationTokenFilter;
-    
+
     /**
      * 跨域过滤器
      */
@@ -72,8 +71,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
      */
     @Bean
     @Override
-    public AuthenticationManager authenticationManagerBean() throws Exception
-    {
+    public AuthenticationManager authenticationManagerBean() throws Exception {
         return super.authenticationManagerBean();
     }
 
@@ -93,8 +91,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
      * authenticated       |   用户登录后可访问
      */
     @Override
-    protected void configure(HttpSecurity httpSecurity) throws Exception
-    {
+    protected void configure(HttpSecurity httpSecurity) throws Exception {
         // 注解标记允许匿名访问的url
         ExpressionUrlAuthorizationConfigurer<HttpSecurity>.ExpressionInterceptUrlRegistry registry = httpSecurity.authorizeRequests();
         permitAllUrl.getUrls().forEach(url -> registry.antMatchers(url).permitAll());
@@ -132,8 +129,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
      * 强散列哈希加密实现
      */
     @Bean
-    public BCryptPasswordEncoder bCryptPasswordEncoder()
-    {
+    public BCryptPasswordEncoder bCryptPasswordEncoder() {
         return new BCryptPasswordEncoder();
     }
 
@@ -141,8 +137,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
      * 身份认证接口
      */
     @Override
-    protected void configure(AuthenticationManagerBuilder auth) throws Exception
-    {
+    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
         auth.userDetailsService(userDetailsService).passwordEncoder(bCryptPasswordEncoder());
     }
 }

+ 8 - 10
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java

@@ -1,30 +1,28 @@
 package com.ruoyi.framework.config;
 
-import javax.servlet.http.HttpServletRequest;
-import org.springframework.stereotype.Component;
 import com.ruoyi.common.utils.ServletUtils;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
 
 /**
  * 服务相关配置
- * 
+ *
  * @author ruoyi
  */
 @Component
-public class ServerConfig
-{
+public class ServerConfig {
     /**
      * 获取完整的请求路径,包括:域名,端口,上下文访问路径
-     * 
+     *
      * @return 服务地址
      */
-    public String getUrl()
-    {
+    public String getUrl() {
         HttpServletRequest request = ServletUtils.getRequest();
         return getDomain(request);
     }
 
-    public static String getDomain(HttpServletRequest request)
-    {
+    public static String getDomain(HttpServletRequest request) {
         StringBuffer url = request.getRequestURL();
         String contextPath = request.getServletContext().getContextPath();
         return url.delete(url.length() - request.getRequestURI().length(), url.length()).append(contextPath).toString();

+ 6 - 10
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ThreadPoolConfig.java

@@ -5,6 +5,7 @@ import org.apache.commons.lang3.concurrent.BasicThreadFactory;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.ScheduledThreadPoolExecutor;
 import java.util.concurrent.ThreadPoolExecutor;
@@ -15,8 +16,7 @@ import java.util.concurrent.ThreadPoolExecutor;
  * @author ruoyi
  **/
 @Configuration
-public class ThreadPoolConfig
-{
+public class ThreadPoolConfig {
     // 核心线程池大小
     private int corePoolSize = 50;
 
@@ -30,8 +30,7 @@ public class ThreadPoolConfig
     private int keepAliveSeconds = 300;
 
     @Bean(name = "threadPoolTaskExecutor")
-    public ThreadPoolTaskExecutor threadPoolTaskExecutor()
-    {
+    public ThreadPoolTaskExecutor threadPoolTaskExecutor() {
         ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
         executor.setMaxPoolSize(maxPoolSize);
         executor.setCorePoolSize(corePoolSize);
@@ -46,15 +45,12 @@ public class ThreadPoolConfig
      * 执行周期性或定时任务
      */
     @Bean(name = "scheduledExecutorService")
-    protected ScheduledExecutorService scheduledExecutorService()
-    {
+    protected ScheduledExecutorService scheduledExecutorService() {
         return new ScheduledThreadPoolExecutor(corePoolSize,
                 new BasicThreadFactory.Builder().namingPattern("schedule-pool-%d").daemon(true).build(),
-                new ThreadPoolExecutor.CallerRunsPolicy())
-        {
+                new ThreadPoolExecutor.CallerRunsPolicy()) {
             @Override
-            protected void afterExecute(Runnable r, Throwable t)
-            {
+            protected void afterExecute(Runnable r, Throwable t) {
                 super.afterExecute(r, t);
                 Threads.printException(r, t);
             }

+ 10 - 18
ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/PermitAllUrlProperties.java

@@ -1,11 +1,6 @@
 package com.ruoyi.framework.config.properties;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Optional;
-import java.util.regex.Pattern;
+import com.ruoyi.common.annotation.Anonymous;
 import org.apache.commons.lang3.RegExUtils;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.InitializingBean;
@@ -16,16 +11,17 @@ import org.springframework.core.annotation.AnnotationUtils;
 import org.springframework.web.method.HandlerMethod;
 import org.springframework.web.servlet.mvc.method.RequestMappingInfo;
 import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;
-import com.ruoyi.common.annotation.Anonymous;
+
+import java.util.*;
+import java.util.regex.Pattern;
 
 /**
  * 设置Anonymous注解允许匿名访问的url
- * 
+ *
  * @author ruoyi
  */
 @Configuration
-public class PermitAllUrlProperties implements InitializingBean, ApplicationContextAware
-{
+public class PermitAllUrlProperties implements InitializingBean, ApplicationContextAware {
     private static final Pattern PATTERN = Pattern.compile("\\{(.*?)\\}");
 
     private ApplicationContext applicationContext;
@@ -35,8 +31,7 @@ public class PermitAllUrlProperties implements InitializingBean, ApplicationCont
     public String ASTERISK = "*";
 
     @Override
-    public void afterPropertiesSet()
-    {
+    public void afterPropertiesSet() {
         RequestMappingHandlerMapping mapping = applicationContext.getBean(RequestMappingHandlerMapping.class);
         Map<RequestMappingInfo, HandlerMethod> map = mapping.getHandlerMethods();
 
@@ -56,18 +51,15 @@ public class PermitAllUrlProperties implements InitializingBean, ApplicationCont
     }
 
     @Override
-    public void setApplicationContext(ApplicationContext context) throws BeansException
-    {
+    public void setApplicationContext(ApplicationContext context) throws BeansException {
         this.applicationContext = context;
     }
 
-    public List<String> getUrls()
-    {
+    public List<String> getUrls() {
         return urls;
     }
 
-    public void setUrls(List<String> urls)
-    {
+    public void setUrls(List<String> urls) {
         this.urls = urls;
     }
 }

+ 13 - 19
ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java

@@ -1,15 +1,16 @@
 package com.ruoyi.framework.interceptor;
 
-import java.lang.reflect.Method;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.springframework.stereotype.Component;
-import org.springframework.web.method.HandlerMethod;
-import org.springframework.web.servlet.HandlerInterceptor;
 import com.alibaba.fastjson2.JSON;
 import com.ruoyi.common.annotation.RepeatSubmit;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.ServletUtils;
+import org.springframework.stereotype.Component;
+import org.springframework.web.method.HandlerMethod;
+import org.springframework.web.servlet.HandlerInterceptor;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.lang.reflect.Method;
 
 /**
  * 防止重复提交拦截器
@@ -17,29 +18,22 @@ import com.ruoyi.common.utils.ServletUtils;
  * @author ruoyi
  */
 @Component
-public abstract class RepeatSubmitInterceptor implements HandlerInterceptor
-{
+public abstract class RepeatSubmitInterceptor implements HandlerInterceptor {
     @Override
-    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception
-    {
-        if (handler instanceof HandlerMethod)
-        {
+    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
+        if (handler instanceof HandlerMethod) {
             HandlerMethod handlerMethod = (HandlerMethod) handler;
             Method method = handlerMethod.getMethod();
             RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class);
-            if (annotation != null)
-            {
-                if (this.isRepeatSubmit(request, annotation))
-                {
+            if (annotation != null) {
+                if (this.isRepeatSubmit(request, annotation)) {
                     AjaxResult ajaxResult = AjaxResult.error(annotation.message());
                     ServletUtils.renderString(response, JSON.toJSONString(ajaxResult));
                     return false;
                 }
             }
             return true;
-        }
-        else
-        {
+        } else {
             return true;
         }
     }

+ 19 - 28
ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java

@@ -1,12 +1,5 @@
 package com.ruoyi.framework.interceptor.impl;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import javax.servlet.http.HttpServletRequest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
 import com.alibaba.fastjson2.JSON;
 import com.ruoyi.common.annotation.RepeatSubmit;
 import com.ruoyi.common.constant.CacheConstants;
@@ -15,16 +8,23 @@ import com.ruoyi.common.filter.RepeatedlyRequestWrapper;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.http.HttpHelper;
 import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 /**
  * 判断请求url和数据是否和上一次相同,
  * 如果和上次相同,则是重复提交表单。 有效时间为10秒内。
- * 
+ *
  * @author ruoyi
  */
 @Component
-public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
-{
+public class SameUrlDataInterceptor extends RepeatSubmitInterceptor {
     public final String REPEAT_PARAMS = "repeatParams";
 
     public final String REPEAT_TIME = "repeatTime";
@@ -38,18 +38,15 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
 
     @SuppressWarnings("unchecked")
     @Override
-    public boolean isRepeatSubmit(HttpServletRequest request, RepeatSubmit annotation)
-    {
+    public boolean isRepeatSubmit(HttpServletRequest request, RepeatSubmit annotation) {
         String nowParams = "";
-        if (request instanceof RepeatedlyRequestWrapper)
-        {
+        if (request instanceof RepeatedlyRequestWrapper) {
             RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request;
             nowParams = HttpHelper.getBodyString(repeatedlyRequest);
         }
 
         // body参数为空,获取Parameter的数据
-        if (StringUtils.isEmpty(nowParams))
-        {
+        if (StringUtils.isEmpty(nowParams)) {
             nowParams = JSON.toJSONString(request.getParameterMap());
         }
         Map<String, Object> nowDataMap = new HashMap<String, Object>();
@@ -66,14 +63,11 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
         String cacheRepeatKey = CacheConstants.REPEAT_SUBMIT_KEY + url + submitKey;
 
         Object sessionObj = redisCache.getCacheObject(cacheRepeatKey);
-        if (sessionObj != null)
-        {
+        if (sessionObj != null) {
             Map<String, Object> sessionMap = (Map<String, Object>) sessionObj;
-            if (sessionMap.containsKey(url))
-            {
+            if (sessionMap.containsKey(url)) {
                 Map<String, Object> preDataMap = (Map<String, Object>) sessionMap.get(url);
-                if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap, annotation.interval()))
-                {
+                if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap, annotation.interval())) {
                     return true;
                 }
             }
@@ -87,8 +81,7 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
     /**
      * 判断参数是否相同
      */
-    private boolean compareParams(Map<String, Object> nowMap, Map<String, Object> preMap)
-    {
+    private boolean compareParams(Map<String, Object> nowMap, Map<String, Object> preMap) {
         String nowParams = (String) nowMap.get(REPEAT_PARAMS);
         String preParams = (String) preMap.get(REPEAT_PARAMS);
         return nowParams.equals(preParams);
@@ -97,12 +90,10 @@ public class SameUrlDataInterceptor extends RepeatSubmitInterceptor
     /**
      * 判断两次间隔时间
      */
-    private boolean compareTime(Map<String, Object> nowMap, Map<String, Object> preMap, int interval)
-    {
+    private boolean compareTime(Map<String, Object> nowMap, Map<String, Object> preMap, int interval) {
         long time1 = (Long) nowMap.get(REPEAT_TIME);
         long time2 = (Long) preMap.get(REPEAT_TIME);
-        if ((time1 - time2) < interval)
-        {
+        if ((time1 - time2) < interval) {
             return true;
         }
         return false;

+ 6 - 11
ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java

@@ -3,6 +3,7 @@ package com.ruoyi.framework.manager;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
+
 import javax.annotation.PreDestroy;
 
 /**
@@ -11,28 +12,22 @@ import javax.annotation.PreDestroy;
  * @author ruoyi
  */
 @Component
-public class ShutdownManager
-{
+public class ShutdownManager {
     private static final Logger logger = LoggerFactory.getLogger("sys-user");
 
     @PreDestroy
-    public void destroy()
-    {
+    public void destroy() {
         shutdownAsyncManager();
     }
 
     /**
      * 停止异步执行任务
      */
-    private void shutdownAsyncManager()
-    {
-        try
-        {
+    private void shutdownAsyncManager() {
+        try {
             logger.info("====关闭后台任务任务线程池====");
             AsyncManager.me().shutdown();
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             logger.error(e.getMessage(), e);
         }
     }

+ 5 - 8
ruoyi-framework/src/main/java/com/ruoyi/framework/security/context/PermissionContextHolder.java

@@ -1,26 +1,23 @@
 package com.ruoyi.framework.security.context;
 
+import com.ruoyi.common.core.text.Convert;
 import org.springframework.web.context.request.RequestAttributes;
 import org.springframework.web.context.request.RequestContextHolder;
-import com.ruoyi.common.core.text.Convert;
 
 /**
  * 权限信息
- * 
+ *
  * @author ruoyi
  */
-public class PermissionContextHolder
-{
+public class PermissionContextHolder {
     private static final String PERMISSION_CONTEXT_ATTRIBUTES = "PERMISSION_CONTEXT";
 
-    public static void setContext(String permission)
-    {
+    public static void setContext(String permission) {
         RequestContextHolder.currentRequestAttributes().setAttribute(PERMISSION_CONTEXT_ATTRIBUTES, permission,
                 RequestAttributes.SCOPE_REQUEST);
     }
 
-    public static String getContext()
-    {
+    public static String getContext() {
         return Convert.toStr(RequestContextHolder.currentRequestAttributes().getAttribute(PERMISSION_CONTEXT_ATTRIBUTES,
                 RequestAttributes.SCOPE_REQUEST));
     }

+ 14 - 16
ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java

@@ -1,39 +1,37 @@
 package com.ruoyi.framework.security.filter;
 
-import java.io.IOException;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
+import com.ruoyi.common.core.domain.model.LoginUser;
+import com.ruoyi.common.utils.SecurityUtils;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.framework.web.service.TokenService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
 import org.springframework.security.core.context.SecurityContextHolder;
 import org.springframework.security.web.authentication.WebAuthenticationDetailsSource;
 import org.springframework.stereotype.Component;
 import org.springframework.web.filter.OncePerRequestFilter;
-import com.ruoyi.common.core.domain.model.LoginUser;
-import com.ruoyi.common.utils.SecurityUtils;
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.framework.web.service.TokenService;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 
 /**
  * token过滤器 验证token有效性
- * 
+ *
  * @author ruoyi
  */
 @Component
-public class JwtAuthenticationTokenFilter extends OncePerRequestFilter
-{
+public class JwtAuthenticationTokenFilter extends OncePerRequestFilter {
     @Autowired
     private TokenService tokenService;
 
     @Override
     protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain)
-            throws ServletException, IOException
-    {
+            throws ServletException, IOException {
         LoginUser loginUser = tokenService.getLoginUser(request);
-        if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication()))
-        {
+        if (StringUtils.isNotNull(loginUser) && StringUtils.isNull(SecurityUtils.getAuthentication())) {
             tokenService.verifyToken(loginUser);
             UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginUser, null, loginUser.getAuthorities());
             authenticationToken.setDetails(new WebAuthenticationDetailsSource().buildDetails(request));

+ 14 - 16
ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java

@@ -1,13 +1,5 @@
 package com.ruoyi.framework.security.handle;
 
-import java.io.IOException;
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.security.core.Authentication;
-import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
 import com.alibaba.fastjson2.JSON;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.AjaxResult;
@@ -17,30 +9,36 @@ import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.framework.manager.AsyncManager;
 import com.ruoyi.framework.manager.factory.AsyncFactory;
 import com.ruoyi.framework.web.service.TokenService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.core.Authentication;
+import org.springframework.security.web.authentication.logout.LogoutSuccessHandler;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 
 /**
  * 自定义退出处理类 返回成功
- * 
+ *
  * @author ruoyi
  */
 @Configuration
-public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler
-{
+public class LogoutSuccessHandlerImpl implements LogoutSuccessHandler {
     @Autowired
     private TokenService tokenService;
 
     /**
      * 退出处理
-     * 
+     *
      * @return
      */
     @Override
     public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
-            throws IOException, ServletException
-    {
+            throws IOException, ServletException {
         LoginUser loginUser = tokenService.getLoginUser(request);
-        if (StringUtils.isNotNull(loginUser))
-        {
+        if (StringUtils.isNotNull(loginUser)) {
             String userName = loginUser.getUsername();
             // 删除用户缓存记录
             tokenService.delLoginUser(loginUser.getToken());

+ 32 - 61
ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java

@@ -1,16 +1,8 @@
 package com.ruoyi.framework.web.domain;
 
-import java.net.UnknownHostException;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
 import com.ruoyi.common.utils.Arith;
 import com.ruoyi.common.utils.ip.IpUtils;
-import com.ruoyi.framework.web.domain.server.Cpu;
-import com.ruoyi.framework.web.domain.server.Jvm;
-import com.ruoyi.framework.web.domain.server.Mem;
-import com.ruoyi.framework.web.domain.server.Sys;
-import com.ruoyi.framework.web.domain.server.SysFile;
+import com.ruoyi.framework.web.domain.server.*;
 import oshi.SystemInfo;
 import oshi.hardware.CentralProcessor;
 import oshi.hardware.CentralProcessor.TickType;
@@ -21,15 +13,19 @@ import oshi.software.os.OSFileStore;
 import oshi.software.os.OperatingSystem;
 import oshi.util.Util;
 
+import java.net.UnknownHostException;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+
 /**
  * 服务器相关信息
- * 
+ *
  * @author ruoyi
  */
-public class Server
-{
+public class Server {
     private static final int OSHI_WAIT_SECOND = 1000;
-    
+
     /**
      * CPU相关信息
      */
@@ -55,58 +51,47 @@ public class Server
      */
     private List<SysFile> sysFiles = new LinkedList<SysFile>();
 
-    public Cpu getCpu()
-    {
+    public Cpu getCpu() {
         return cpu;
     }
 
-    public void setCpu(Cpu cpu)
-    {
+    public void setCpu(Cpu cpu) {
         this.cpu = cpu;
     }
 
-    public Mem getMem()
-    {
+    public Mem getMem() {
         return mem;
     }
 
-    public void setMem(Mem mem)
-    {
+    public void setMem(Mem mem) {
         this.mem = mem;
     }
 
-    public Jvm getJvm()
-    {
+    public Jvm getJvm() {
         return jvm;
     }
 
-    public void setJvm(Jvm jvm)
-    {
+    public void setJvm(Jvm jvm) {
         this.jvm = jvm;
     }
 
-    public Sys getSys()
-    {
+    public Sys getSys() {
         return sys;
     }
 
-    public void setSys(Sys sys)
-    {
+    public void setSys(Sys sys) {
         this.sys = sys;
     }
 
-    public List<SysFile> getSysFiles()
-    {
+    public List<SysFile> getSysFiles() {
         return sysFiles;
     }
 
-    public void setSysFiles(List<SysFile> sysFiles)
-    {
+    public void setSysFiles(List<SysFile> sysFiles) {
         this.sysFiles = sysFiles;
     }
 
-    public void copyTo() throws Exception
-    {
+    public void copyTo() throws Exception {
         SystemInfo si = new SystemInfo();
         HardwareAbstractionLayer hal = si.getHardware();
 
@@ -124,8 +109,7 @@ public class Server
     /**
      * 设置CPU信息
      */
-    private void setCpuInfo(CentralProcessor processor)
-    {
+    private void setCpuInfo(CentralProcessor processor) {
         // CPU信息
         long[] prevTicks = processor.getSystemCpuLoadTicks();
         Util.sleep(OSHI_WAIT_SECOND);
@@ -150,8 +134,7 @@ public class Server
     /**
      * 设置内存信息
      */
-    private void setMemInfo(GlobalMemory memory)
-    {
+    private void setMemInfo(GlobalMemory memory) {
         mem.setTotal(memory.getTotal());
         mem.setUsed(memory.getTotal() - memory.getAvailable());
         mem.setFree(memory.getAvailable());
@@ -160,8 +143,7 @@ public class Server
     /**
      * 设置服务器信息
      */
-    private void setSysInfo()
-    {
+    private void setSysInfo() {
         Properties props = System.getProperties();
         sys.setComputerName(IpUtils.getHostName());
         sys.setComputerIp(IpUtils.getHostIp());
@@ -173,8 +155,7 @@ public class Server
     /**
      * 设置Java虚拟机
      */
-    private void setJvmInfo() throws UnknownHostException
-    {
+    private void setJvmInfo() throws UnknownHostException {
         Properties props = System.getProperties();
         jvm.setTotal(Runtime.getRuntime().totalMemory());
         jvm.setMax(Runtime.getRuntime().maxMemory());
@@ -186,12 +167,10 @@ public class Server
     /**
      * 设置磁盘信息
      */
-    private void setSysFiles(OperatingSystem os)
-    {
+    private void setSysFiles(OperatingSystem os) {
         FileSystem fileSystem = os.getFileSystem();
         List<OSFileStore> fsArray = fileSystem.getFileStores();
-        for (OSFileStore fs : fsArray)
-        {
+        for (OSFileStore fs : fsArray) {
             long free = fs.getUsableSpace();
             long total = fs.getTotalSpace();
             long used = total - free;
@@ -209,31 +188,23 @@ public class Server
 
     /**
      * 字节转换
-     * 
+     *
      * @param size 字节大小
      * @return 转换后值
      */
-    public String convertFileSize(long size)
-    {
+    public String convertFileSize(long size) {
         long kb = 1024;
         long mb = kb * 1024;
         long gb = mb * 1024;
-        if (size >= gb)
-        {
+        if (size >= gb) {
             return String.format("%.1f GB", (float) size / gb);
-        }
-        else if (size >= mb)
-        {
+        } else if (size >= mb) {
             float f = (float) size / mb;
             return String.format(f > 100 ? "%.0f MB" : "%.1f MB", f);
-        }
-        else if (size >= kb)
-        {
+        } else if (size >= kb) {
             float f = (float) size / kb;
             return String.format(f > 100 ? "%.0f KB" : "%.1f KB", f);
-        }
-        else
-        {
+        } else {
             return String.format("%d B", size);
         }
     }

+ 20 - 36
ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java

@@ -1,16 +1,16 @@
 package com.ruoyi.framework.web.domain.server;
 
-import java.lang.management.ManagementFactory;
 import com.ruoyi.common.utils.Arith;
 import com.ruoyi.common.utils.DateUtils;
 
+import java.lang.management.ManagementFactory;
+
 /**
  * JVM相关信息
- * 
+ *
  * @author ruoyi
  */
-public class Jvm
-{
+public class Jvm {
     /**
      * 当前JVM占用的内存总数(M)
      */
@@ -36,95 +36,79 @@ public class Jvm
      */
     private String home;
 
-    public double getTotal()
-    {
+    public double getTotal() {
         return Arith.div(total, (1024 * 1024), 2);
     }
 
-    public void setTotal(double total)
-    {
+    public void setTotal(double total) {
         this.total = total;
     }
 
-    public double getMax()
-    {
+    public double getMax() {
         return Arith.div(max, (1024 * 1024), 2);
     }
 
-    public void setMax(double max)
-    {
+    public void setMax(double max) {
         this.max = max;
     }
 
-    public double getFree()
-    {
+    public double getFree() {
         return Arith.div(free, (1024 * 1024), 2);
     }
 
-    public void setFree(double free)
-    {
+    public void setFree(double free) {
         this.free = free;
     }
 
-    public double getUsed()
-    {
+    public double getUsed() {
         return Arith.div(total - free, (1024 * 1024), 2);
     }
 
-    public double getUsage()
-    {
+    public double getUsage() {
         return Arith.mul(Arith.div(total - free, total, 4), 100);
     }
 
     /**
      * 获取JDK名称
      */
-    public String getName()
-    {
+    public String getName() {
         return ManagementFactory.getRuntimeMXBean().getVmName();
     }
 
-    public String getVersion()
-    {
+    public String getVersion() {
         return version;
     }
 
-    public void setVersion(String version)
-    {
+    public void setVersion(String version) {
         this.version = version;
     }
 
-    public String getHome()
-    {
+    public String getHome() {
         return home;
     }
 
-    public void setHome(String home)
-    {
+    public void setHome(String home) {
         this.home = home;
     }
 
     /**
      * JDK启动时间
      */
-    public String getStartTime()
-    {
+    public String getStartTime() {
         return DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS, DateUtils.getServerStartDate());
     }
 
     /**
      * JDK运行时间
      */
-    public String getRunTime()
-    {
+    public String getRunTime() {
         return DateUtils.timeDistance(DateUtils.getNowDate(), DateUtils.getServerStartDate());
     }
 
     /**
      * 运行参数
      */
-    public String getInputArgs()
-    {
+    public String getInputArgs() {
         return ManagementFactory.getRuntimeMXBean().getInputArguments().toString();
     }
 }

+ 9 - 17
ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java

@@ -4,11 +4,10 @@ import com.ruoyi.common.utils.Arith;
 
 /**
  * 內存相关信息
- * 
+ *
  * @author ruoyi
  */
-public class Mem
-{
+public class Mem {
     /**
      * 内存总量
      */
@@ -24,38 +23,31 @@ public class Mem
      */
     private double free;
 
-    public double getTotal()
-    {
+    public double getTotal() {
         return Arith.div(total, (1024 * 1024 * 1024), 2);
     }
 
-    public void setTotal(long total)
-    {
+    public void setTotal(long total) {
         this.total = total;
     }
 
-    public double getUsed()
-    {
+    public double getUsed() {
         return Arith.div(used, (1024 * 1024 * 1024), 2);
     }
 
-    public void setUsed(long used)
-    {
+    public void setUsed(long used) {
         this.used = used;
     }
 
-    public double getFree()
-    {
+    public double getFree() {
         return Arith.div(free, (1024 * 1024 * 1024), 2);
     }
 
-    public void setFree(long free)
-    {
+    public void setFree(long free) {
         this.free = free;
     }
 
-    public double getUsage()
-    {
+    public double getUsage() {
         return Arith.mul(Arith.div(used, total, 4), 100);
     }
 }

+ 12 - 23
ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java

@@ -2,11 +2,10 @@ package com.ruoyi.framework.web.domain.server;
 
 /**
  * 系统相关信息
- * 
+ *
  * @author ruoyi
  */
-public class Sys
-{
+public class Sys {
     /**
      * 服务器名称
      */
@@ -32,53 +31,43 @@ public class Sys
      */
     private String osArch;
 
-    public String getComputerName()
-    {
+    public String getComputerName() {
         return computerName;
     }
 
-    public void setComputerName(String computerName)
-    {
+    public void setComputerName(String computerName) {
         this.computerName = computerName;
     }
 
-    public String getComputerIp()
-    {
+    public String getComputerIp() {
         return computerIp;
     }
 
-    public void setComputerIp(String computerIp)
-    {
+    public void setComputerIp(String computerIp) {
         this.computerIp = computerIp;
     }
 
-    public String getUserDir()
-    {
+    public String getUserDir() {
         return userDir;
     }
 
-    public void setUserDir(String userDir)
-    {
+    public void setUserDir(String userDir) {
         this.userDir = userDir;
     }
 
-    public String getOsName()
-    {
+    public String getOsName() {
         return osName;
     }
 
-    public void setOsName(String osName)
-    {
+    public void setOsName(String osName) {
         this.osName = osName;
     }
 
-    public String getOsArch()
-    {
+    public String getOsArch() {
         return osArch;
     }
 
-    public void setOsArch(String osArch)
-    {
+    public void setOsArch(String osArch) {
         this.osArch = osArch;
     }
 }

+ 16 - 31
ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java

@@ -2,11 +2,10 @@ package com.ruoyi.framework.web.domain.server;
 
 /**
  * 系统文件相关信息
- * 
+ *
  * @author ruoyi
  */
-public class SysFile
-{
+public class SysFile {
     /**
      * 盘符路径
      */
@@ -42,73 +41,59 @@ public class SysFile
      */
     private double usage;
 
-    public String getDirName()
-    {
+    public String getDirName() {
         return dirName;
     }
 
-    public void setDirName(String dirName)
-    {
+    public void setDirName(String dirName) {
         this.dirName = dirName;
     }
 
-    public String getSysTypeName()
-    {
+    public String getSysTypeName() {
         return sysTypeName;
     }
 
-    public void setSysTypeName(String sysTypeName)
-    {
+    public void setSysTypeName(String sysTypeName) {
         this.sysTypeName = sysTypeName;
     }
 
-    public String getTypeName()
-    {
+    public String getTypeName() {
         return typeName;
     }
 
-    public void setTypeName(String typeName)
-    {
+    public void setTypeName(String typeName) {
         this.typeName = typeName;
     }
 
-    public String getTotal()
-    {
+    public String getTotal() {
         return total;
     }
 
-    public void setTotal(String total)
-    {
+    public void setTotal(String total) {
         this.total = total;
     }
 
-    public String getFree()
-    {
+    public String getFree() {
         return free;
     }
 
-    public void setFree(String free)
-    {
+    public void setFree(String free) {
         this.free = free;
     }
 
-    public String getUsed()
-    {
+    public String getUsed() {
         return used;
     }
 
-    public void setUsed(String used)
-    {
+    public void setUsed(String used) {
         this.used = used;
     }
 
-    public double getUsage()
-    {
+    public double getUsage() {
         return usage;
     }
 
-    public void setUsage(double usage)
-    {
+    public void setUsage(double usage) {
         this.usage = usage;
     }
 }

+ 37 - 54
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java

@@ -1,26 +1,30 @@
 package com.ruoyi.framework.web.service;
 
-import java.util.Set;
-import org.springframework.stereotype.Service;
-import org.springframework.util.CollectionUtils;
 import com.ruoyi.common.core.domain.entity.SysRole;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.framework.security.context.PermissionContextHolder;
+import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Set;
 
 /**
  * RuoYi首创 自定义权限实现,ss取自SpringSecurity首字母
- * 
+ *
  * @author ruoyi
  */
 @Service("ss")
-public class PermissionService
-{
-    /** 所有权限标识 */
+public class PermissionService {
+    /**
+     * 所有权限标识
+     */
     private static final String ALL_PERMISSION = "*:*:*";
 
-    /** 管理员角色权限标识 */
+    /**
+     * 管理员角色权限标识
+     */
     private static final String SUPER_ADMIN = "admin";
 
     private static final String ROLE_DELIMETER = ",";
@@ -29,19 +33,16 @@ public class PermissionService
 
     /**
      * 验证用户是否具备某权限
-     * 
+     *
      * @param permission 权限字符串
      * @return 用户是否具备某权限
      */
-    public boolean hasPermi(String permission)
-    {
-        if (StringUtils.isEmpty(permission))
-        {
+    public boolean hasPermi(String permission) {
+        if (StringUtils.isEmpty(permission)) {
             return false;
         }
         LoginUser loginUser = SecurityUtils.getLoginUser();
-        if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions()))
-        {
+        if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) {
             return false;
         }
         PermissionContextHolder.setContext(permission);
@@ -54,8 +55,7 @@ public class PermissionService
      * @param permission 权限字符串
      * @return 用户是否不具备某权限
      */
-    public boolean lacksPermi(String permission)
-    {
+    public boolean lacksPermi(String permission) {
         return hasPermi(permission) != true;
     }
 
@@ -65,23 +65,18 @@ public class PermissionService
      * @param permissions 以 PERMISSION_NAMES_DELIMETER 为分隔符的权限列表
      * @return 用户是否具有以下任意一个权限
      */
-    public boolean hasAnyPermi(String permissions)
-    {
-        if (StringUtils.isEmpty(permissions))
-        {
+    public boolean hasAnyPermi(String permissions) {
+        if (StringUtils.isEmpty(permissions)) {
             return false;
         }
         LoginUser loginUser = SecurityUtils.getLoginUser();
-        if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions()))
-        {
+        if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getPermissions())) {
             return false;
         }
         PermissionContextHolder.setContext(permissions);
         Set<String> authorities = loginUser.getPermissions();
-        for (String permission : permissions.split(PERMISSION_DELIMETER))
-        {
-            if (permission != null && hasPermissions(authorities, permission))
-            {
+        for (String permission : permissions.split(PERMISSION_DELIMETER)) {
+            if (permission != null && hasPermissions(authorities, permission)) {
                 return true;
             }
         }
@@ -90,26 +85,21 @@ public class PermissionService
 
     /**
      * 判断用户是否拥有某个角色
-     * 
+     *
      * @param role 角色字符串
      * @return 用户是否具备某角色
      */
-    public boolean hasRole(String role)
-    {
-        if (StringUtils.isEmpty(role))
-        {
+    public boolean hasRole(String role) {
+        if (StringUtils.isEmpty(role)) {
             return false;
         }
         LoginUser loginUser = SecurityUtils.getLoginUser();
-        if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles()))
-        {
+        if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) {
             return false;
         }
-        for (SysRole sysRole : loginUser.getUser().getRoles())
-        {
+        for (SysRole sysRole : loginUser.getUser().getRoles()) {
             String roleKey = sysRole.getRoleKey();
-            if (SUPER_ADMIN.equals(roleKey) || roleKey.equals(StringUtils.trim(role)))
-            {
+            if (SUPER_ADMIN.equals(roleKey) || roleKey.equals(StringUtils.trim(role))) {
                 return true;
             }
         }
@@ -122,8 +112,7 @@ public class PermissionService
      * @param role 角色名称
      * @return 用户是否不具备某角色
      */
-    public boolean lacksRole(String role)
-    {
+    public boolean lacksRole(String role) {
         return hasRole(role) != true;
     }
 
@@ -133,21 +122,16 @@ public class PermissionService
      * @param roles 以 ROLE_NAMES_DELIMETER 为分隔符的角色列表
      * @return 用户是否具有以下任意一个角色
      */
-    public boolean hasAnyRoles(String roles)
-    {
-        if (StringUtils.isEmpty(roles))
-        {
+    public boolean hasAnyRoles(String roles) {
+        if (StringUtils.isEmpty(roles)) {
             return false;
         }
         LoginUser loginUser = SecurityUtils.getLoginUser();
-        if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles()))
-        {
+        if (StringUtils.isNull(loginUser) || CollectionUtils.isEmpty(loginUser.getUser().getRoles())) {
             return false;
         }
-        for (String role : roles.split(ROLE_DELIMETER))
-        {
-            if (hasRole(role))
-            {
+        for (String role : roles.split(ROLE_DELIMETER)) {
+            if (hasRole(role)) {
                 return true;
             }
         }
@@ -156,13 +140,12 @@ public class PermissionService
 
     /**
      * 判断是否包含权限
-     * 
+     *
      * @param permissions 权限列表
-     * @param permission 权限字符串
+     * @param permission  权限字符串
      * @return 用户是否具备某权限
      */
-    private boolean hasPermissions(Set<String> permissions, String permission)
-    {
+    private boolean hasPermissions(Set<String> permissions, String permission) {
         return permissions.contains(ALL_PERMISSION) || permissions.contains(StringUtils.trim(permission));
     }
 }

+ 35 - 57
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java

@@ -1,12 +1,5 @@
 package com.ruoyi.framework.web.service;
 
-import javax.annotation.Resource;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.security.authentication.AuthenticationManager;
-import org.springframework.security.authentication.BadCredentialsException;
-import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
-import org.springframework.security.core.Authentication;
-import org.springframework.stereotype.Component;
 import com.ruoyi.common.constant.CacheConstants;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.constant.UserConstants;
@@ -14,11 +7,7 @@ import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.exception.ServiceException;
-import com.ruoyi.common.exception.user.BlackListException;
-import com.ruoyi.common.exception.user.CaptchaException;
-import com.ruoyi.common.exception.user.CaptchaExpireException;
-import com.ruoyi.common.exception.user.UserNotExistsException;
-import com.ruoyi.common.exception.user.UserPasswordNotMatchException;
+import com.ruoyi.common.exception.user.*;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.MessageUtils;
 import com.ruoyi.common.utils.StringUtils;
@@ -28,15 +17,22 @@ import com.ruoyi.framework.manager.factory.AsyncFactory;
 import com.ruoyi.framework.security.context.AuthenticationContextHolder;
 import com.ruoyi.system.service.ISysConfigService;
 import com.ruoyi.system.service.ISysUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.authentication.AuthenticationManager;
+import org.springframework.security.authentication.BadCredentialsException;
+import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
+import org.springframework.security.core.Authentication;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
 
 /**
  * 登录校验方法
- * 
+ *
  * @author ruoyi
  */
 @Component
-public class SysLoginService
-{
+public class SysLoginService {
     @Autowired
     private TokenService tokenService;
 
@@ -45,7 +41,7 @@ public class SysLoginService
 
     @Autowired
     private RedisCache redisCache;
-    
+
     @Autowired
     private ISysUserService userService;
 
@@ -54,43 +50,34 @@ public class SysLoginService
 
     /**
      * 登录验证
-     * 
+     *
      * @param username 用户名
      * @param password 密码
-     * @param code 验证码
-     * @param uuid 唯一标识
+     * @param code     验证码
+     * @param uuid     唯一标识
      * @return 结果
      */
-    public String login(String username, String password, String code, String uuid)
-    {
+    public String login(String username, String password, String code, String uuid) {
         // 验证码校验
         validateCaptcha(username, code, uuid);
         // 登录前置校验
         loginPreCheck(username, password);
         // 用户验证
         Authentication authentication = null;
-        try
-        {
+        try {
             UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(username, password);
             AuthenticationContextHolder.setContext(authenticationToken);
             // 该方法会去调用UserDetailsServiceImpl.loadUserByUsername
             authentication = authenticationManager.authenticate(authenticationToken);
-        }
-        catch (Exception e)
-        {
-            if (e instanceof BadCredentialsException)
-            {
+        } catch (Exception e) {
+            if (e instanceof BadCredentialsException) {
                 AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
                 throw new UserPasswordNotMatchException();
-            }
-            else
-            {
+            } else {
                 AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, e.getMessage()));
                 throw new ServiceException(e.getMessage());
             }
-        }
-        finally
-        {
+        } finally {
             AuthenticationContextHolder.clearContext();
         }
         AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_SUCCESS, MessageUtils.message("user.login.success")));
@@ -102,27 +89,23 @@ public class SysLoginService
 
     /**
      * 校验验证码
-     * 
+     *
      * @param username 用户名
-     * @param code 验证码
-     * @param uuid 唯一标识
+     * @param code     验证码
+     * @param uuid     唯一标识
      * @return 结果
      */
-    public void validateCaptcha(String username, String code, String uuid)
-    {
+    public void validateCaptcha(String username, String code, String uuid) {
         boolean captchaEnabled = configService.selectCaptchaEnabled();
-        if (captchaEnabled)
-        {
+        if (captchaEnabled) {
             String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
             String captcha = redisCache.getCacheObject(verifyKey);
             redisCache.deleteObject(verifyKey);
-            if (captcha == null)
-            {
+            if (captcha == null) {
                 AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.expire")));
                 throw new CaptchaExpireException();
             }
-            if (!code.equalsIgnoreCase(captcha))
-            {
+            if (!code.equalsIgnoreCase(captcha)) {
                 AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.jcaptcha.error")));
                 throw new CaptchaException();
             }
@@ -131,35 +114,31 @@ public class SysLoginService
 
     /**
      * 登录前置校验
+     *
      * @param username 用户名
      * @param password 用户密码
      */
-    public void loginPreCheck(String username, String password)
-    {
+    public void loginPreCheck(String username, String password) {
         // 用户名或密码为空 错误
-        if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password))
-        {
+        if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
             AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("not.null")));
             throw new UserNotExistsException();
         }
         // 密码如果不在指定范围内 错误
         if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
-                || password.length() > UserConstants.PASSWORD_MAX_LENGTH)
-        {
+                || password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
             AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
             throw new UserPasswordNotMatchException();
         }
         // 用户名不在指定范围内 错误
         if (username.length() < UserConstants.USERNAME_MIN_LENGTH
-                || username.length() > UserConstants.USERNAME_MAX_LENGTH)
-        {
+                || username.length() > UserConstants.USERNAME_MAX_LENGTH) {
             AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("user.password.not.match")));
             throw new UserPasswordNotMatchException();
         }
         // IP黑名单校验
         String blackStr = configService.selectConfigByKey("sys.login.blackIPList");
-        if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr()))
-        {
+        if (IpUtils.isMatchedIp(blackStr, IpUtils.getIpAddr())) {
             AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL, MessageUtils.message("login.blocked")));
             throw new BlackListException();
         }
@@ -170,8 +149,7 @@ public class SysLoginService
      *
      * @param userId 用户ID
      */
-    public void recordLoginInfo(Long userId)
-    {
+    public void recordLoginInfo(Long userId) {
         SysUser sysUser = new SysUser();
         sysUser.setUserId(userId);
         sysUser.setLoginIp(IpUtils.getIpAddr());

+ 18 - 28
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPasswordService.java

@@ -1,10 +1,5 @@
 package com.ruoyi.framework.web.service;
 
-import java.util.concurrent.TimeUnit;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.security.core.Authentication;
-import org.springframework.stereotype.Component;
 import com.ruoyi.common.constant.CacheConstants;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.entity.SysUser;
@@ -16,15 +11,20 @@ import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.framework.manager.AsyncManager;
 import com.ruoyi.framework.manager.factory.AsyncFactory;
 import com.ruoyi.framework.security.context.AuthenticationContextHolder;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.security.core.Authentication;
+import org.springframework.stereotype.Component;
+
+import java.util.concurrent.TimeUnit;
 
 /**
  * 登录密码方法
- * 
+ *
  * @author ruoyi
  */
 @Component
-public class SysPasswordService
-{
+public class SysPasswordService {
     @Autowired
     private RedisCache redisCache;
 
@@ -36,58 +36,48 @@ public class SysPasswordService
 
     /**
      * 登录账户密码错误次数缓存键名
-     * 
+     *
      * @param username 用户名
      * @return 缓存键key
      */
-    private String getCacheKey(String username)
-    {
+    private String getCacheKey(String username) {
         return CacheConstants.PWD_ERR_CNT_KEY + username;
     }
 
-    public void validate(SysUser user)
-    {
+    public void validate(SysUser user) {
         Authentication usernamePasswordAuthenticationToken = AuthenticationContextHolder.getContext();
         String username = usernamePasswordAuthenticationToken.getName();
         String password = usernamePasswordAuthenticationToken.getCredentials().toString();
 
         Integer retryCount = redisCache.getCacheObject(getCacheKey(username));
 
-        if (retryCount == null)
-        {
+        if (retryCount == null) {
             retryCount = 0;
         }
 
-        if (retryCount >= Integer.valueOf(maxRetryCount).intValue())
-        {
+        if (retryCount >= Integer.valueOf(maxRetryCount).intValue()) {
             AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL,
                     MessageUtils.message("user.password.retry.limit.exceed", maxRetryCount, lockTime)));
             throw new UserPasswordRetryLimitExceedException(maxRetryCount, lockTime);
         }
 
-        if (!matches(user, password))
-        {
+        if (!matches(user, password)) {
             retryCount = retryCount + 1;
             AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.LOGIN_FAIL,
                     MessageUtils.message("user.password.retry.limit.count", retryCount)));
             redisCache.setCacheObject(getCacheKey(username), retryCount, lockTime, TimeUnit.MINUTES);
             throw new UserPasswordNotMatchException();
-        }
-        else
-        {
+        } else {
             clearLoginRecordCache(username);
         }
     }
 
-    public boolean matches(SysUser user, String rawPassword)
-    {
+    public boolean matches(SysUser user, String rawPassword) {
         return SecurityUtils.matchesPassword(rawPassword, user.getPassword());
     }
 
-    public void clearLoginRecordCache(String loginName)
-    {
-        if (redisCache.hasKey(getCacheKey(loginName)))
-        {
+    public void clearLoginRecordCache(String loginName) {
+        if (redisCache.hasKey(getCacheKey(loginName))) {
             redisCache.deleteObject(getCacheKey(loginName));
         }
     }

+ 19 - 31
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPermissionService.java

@@ -1,23 +1,23 @@
 package com.ruoyi.framework.web.service;
 
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
 import com.ruoyi.common.core.domain.entity.SysRole;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.system.service.ISysMenuService;
 import com.ruoyi.system.service.ISysRoleService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
 
 /**
  * 用户权限处理
- * 
+ *
  * @author ruoyi
  */
 @Component
-public class SysPermissionService
-{
+public class SysPermissionService {
     @Autowired
     private ISysRoleService roleService;
 
@@ -26,20 +26,16 @@ public class SysPermissionService
 
     /**
      * 获取角色数据权限
-     * 
+     *
      * @param user 用户信息
      * @return 角色权限信息
      */
-    public Set<String> getRolePermission(SysUser user)
-    {
+    public Set<String> getRolePermission(SysUser user) {
         Set<String> roles = new HashSet<String>();
         // 管理员拥有所有权限
-        if (user.isAdmin())
-        {
+        if (user.isAdmin()) {
             roles.add("admin");
-        }
-        else
-        {
+        } else {
             roles.addAll(roleService.selectRolePermissionByUserId(user.getUserId()));
         }
         return roles;
@@ -47,33 +43,25 @@ public class SysPermissionService
 
     /**
      * 获取菜单数据权限
-     * 
+     *
      * @param user 用户信息
      * @return 菜单权限信息
      */
-    public Set<String> getMenuPermission(SysUser user)
-    {
+    public Set<String> getMenuPermission(SysUser user) {
         Set<String> perms = new HashSet<String>();
         // 管理员拥有所有权限
-        if (user.isAdmin())
-        {
+        if (user.isAdmin()) {
             perms.add("*:*:*");
-        }
-        else
-        {
+        } else {
             List<SysRole> roles = user.getRoles();
-            if (!roles.isEmpty() && roles.size() > 1)
-            {
+            if (!roles.isEmpty() && roles.size() > 1) {
                 // 多角色设置permissions属性,以便数据权限匹配权限
-                for (SysRole role : roles)
-                {
+                for (SysRole role : roles) {
                     Set<String> rolePerms = menuService.selectMenuPermsByRoleId(role.getRoleId());
                     role.setPermissions(rolePerms);
                     perms.addAll(rolePerms);
                 }
-            }
-            else
-            {
+            } else {
                 perms.addAll(menuService.selectMenuPermsByUserId(user.getUserId()));
             }
         }

+ 22 - 42
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysRegisterService.java

@@ -1,7 +1,5 @@
 package com.ruoyi.framework.web.service;
 
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
 import com.ruoyi.common.constant.CacheConstants;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.constant.UserConstants;
@@ -17,15 +15,16 @@ import com.ruoyi.framework.manager.AsyncManager;
 import com.ruoyi.framework.manager.factory.AsyncFactory;
 import com.ruoyi.system.service.ISysConfigService;
 import com.ruoyi.system.service.ISysUserService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
 
 /**
  * 注册校验方法
- * 
+ *
  * @author ruoyi
  */
 @Component
-public class SysRegisterService
-{
+public class SysRegisterService {
     @Autowired
     private ISysUserService userService;
 
@@ -38,52 +37,36 @@ public class SysRegisterService
     /**
      * 注册
      */
-    public String register(RegisterBody registerBody)
-    {
+    public String register(RegisterBody registerBody) {
         String msg = "", username = registerBody.getUsername(), password = registerBody.getPassword();
         SysUser sysUser = new SysUser();
         sysUser.setUserName(username);
 
         // 验证码开关
         boolean captchaEnabled = configService.selectCaptchaEnabled();
-        if (captchaEnabled)
-        {
+        if (captchaEnabled) {
             validateCaptcha(username, registerBody.getCode(), registerBody.getUuid());
         }
 
-        if (StringUtils.isEmpty(username))
-        {
+        if (StringUtils.isEmpty(username)) {
             msg = "用户名不能为空";
-        }
-        else if (StringUtils.isEmpty(password))
-        {
+        } else if (StringUtils.isEmpty(password)) {
             msg = "用户密码不能为空";
-        }
-        else if (username.length() < UserConstants.USERNAME_MIN_LENGTH
-                || username.length() > UserConstants.USERNAME_MAX_LENGTH)
-        {
+        } else if (username.length() < UserConstants.USERNAME_MIN_LENGTH
+                || username.length() > UserConstants.USERNAME_MAX_LENGTH) {
             msg = "账户长度必须在2到20个字符之间";
-        }
-        else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
-                || password.length() > UserConstants.PASSWORD_MAX_LENGTH)
-        {
+        } else if (password.length() < UserConstants.PASSWORD_MIN_LENGTH
+                || password.length() > UserConstants.PASSWORD_MAX_LENGTH) {
             msg = "密码长度必须在5到20个字符之间";
-        }
-        else if (!userService.checkUserNameUnique(sysUser))
-        {
+        } else if (!userService.checkUserNameUnique(sysUser)) {
             msg = "保存用户'" + username + "'失败,注册账号已存在";
-        }
-        else
-        {
+        } else {
             sysUser.setNickName(username);
             sysUser.setPassword(SecurityUtils.encryptPassword(password));
             boolean regFlag = userService.registerUser(sysUser);
-            if (!regFlag)
-            {
+            if (!regFlag) {
                 msg = "注册失败,请联系系统管理人员";
-            }
-            else
-            {
+            } else {
                 AsyncManager.me().execute(AsyncFactory.recordLogininfor(username, Constants.REGISTER, MessageUtils.message("user.register.success")));
             }
         }
@@ -92,23 +75,20 @@ public class SysRegisterService
 
     /**
      * 校验验证码
-     * 
+     *
      * @param username 用户名
-     * @param code 验证码
-     * @param uuid 唯一标识
+     * @param code     验证码
+     * @param uuid     唯一标识
      * @return 结果
      */
-    public void validateCaptcha(String username, String code, String uuid)
-    {
+    public void validateCaptcha(String username, String code, String uuid) {
         String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + StringUtils.nvl(uuid, "");
         String captcha = redisCache.getCacheObject(verifyKey);
         redisCache.deleteObject(verifyKey);
-        if (captcha == null)
-        {
+        if (captcha == null) {
             throw new CaptchaExpireException();
         }
-        if (!code.equalsIgnoreCase(captcha))
-        {
+        if (!code.equalsIgnoreCase(captcha)) {
             throw new CaptchaException();
         }
     }

+ 28 - 48
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java

@@ -1,12 +1,5 @@
 package com.ruoyi.framework.web.service;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import javax.servlet.http.HttpServletRequest;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Component;
 import com.ruoyi.common.constant.CacheConstants;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.model.LoginUser;
@@ -20,6 +13,14 @@ import eu.bitwalker.useragentutils.UserAgent;
 import io.jsonwebtoken.Claims;
 import io.jsonwebtoken.Jwts;
 import io.jsonwebtoken.SignatureAlgorithm;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
 
 /**
  * token验证处理
@@ -27,8 +28,7 @@ import io.jsonwebtoken.SignatureAlgorithm;
  * @author ruoyi
  */
 @Component
-public class TokenService
-{
+public class TokenService {
     // 令牌自定义标识
     @Value("${token.header:''}")
     private String header;
@@ -55,23 +55,18 @@ public class TokenService
      *
      * @return 用户信息
      */
-    public LoginUser getLoginUser(HttpServletRequest request)
-    {
+    public LoginUser getLoginUser(HttpServletRequest request) {
         // 获取请求携带的令牌
         String token = getToken(request);
-        if (StringUtils.isNotEmpty(token))
-        {
-            try
-            {
+        if (StringUtils.isNotEmpty(token)) {
+            try {
                 Claims claims = parseToken(token);
                 // 解析对应的权限以及用户信息
                 String uuid = (String) claims.get(Constants.LOGIN_USER_KEY);
                 String userKey = getTokenKey(uuid);
                 LoginUser user = redisCache.getCacheObject(userKey);
                 return user;
-            }
-            catch (Exception e)
-            {
+            } catch (Exception e) {
             }
         }
         return null;
@@ -80,10 +75,8 @@ public class TokenService
     /**
      * 设置用户身份信息
      */
-    public void setLoginUser(LoginUser loginUser)
-    {
-        if (StringUtils.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken()))
-        {
+    public void setLoginUser(LoginUser loginUser) {
+        if (StringUtils.isNotNull(loginUser) && StringUtils.isNotEmpty(loginUser.getToken())) {
             refreshToken(loginUser);
         }
     }
@@ -91,10 +84,8 @@ public class TokenService
     /**
      * 删除用户身份信息
      */
-    public void delLoginUser(String token)
-    {
-        if (StringUtils.isNotEmpty(token))
-        {
+    public void delLoginUser(String token) {
+        if (StringUtils.isNotEmpty(token)) {
             String userKey = getTokenKey(token);
             redisCache.deleteObject(userKey);
         }
@@ -106,8 +97,7 @@ public class TokenService
      * @param loginUser 用户信息
      * @return 令牌
      */
-    public String createToken(LoginUser loginUser)
-    {
+    public String createToken(LoginUser loginUser) {
         String token = IdUtils.fastUUID();
         loginUser.setToken(token);
         setUserAgent(loginUser);
@@ -124,12 +114,10 @@ public class TokenService
      * @param loginUser
      * @return 令牌
      */
-    public void verifyToken(LoginUser loginUser)
-    {
+    public void verifyToken(LoginUser loginUser) {
         long expireTime = loginUser.getExpireTime();
         long currentTime = System.currentTimeMillis();
-        if (expireTime - currentTime <= MILLIS_MINUTE_TEN)
-        {
+        if (expireTime - currentTime <= MILLIS_MINUTE_TEN) {
             refreshToken(loginUser);
         }
     }
@@ -139,8 +127,7 @@ public class TokenService
      *
      * @param loginUser 登录信息
      */
-    public void refreshToken(LoginUser loginUser)
-    {
+    public void refreshToken(LoginUser loginUser) {
         loginUser.setLoginTime(System.currentTimeMillis());
         loginUser.setExpireTime(loginUser.getLoginTime() + expireTime * MILLIS_MINUTE);
         // 根据uuid将loginUser缓存
@@ -153,8 +140,7 @@ public class TokenService
      *
      * @param loginUser 登录信息
      */
-    public void setUserAgent(LoginUser loginUser)
-    {
+    public void setUserAgent(LoginUser loginUser) {
         UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent"));
         String ip = IpUtils.getIpAddr();
         loginUser.setIpaddr(ip);
@@ -169,8 +155,7 @@ public class TokenService
      * @param claims 数据声明
      * @return 令牌
      */
-    private String createToken(Map<String, Object> claims)
-    {
+    private String createToken(Map<String, Object> claims) {
         String token = Jwts.builder()
                 .setClaims(claims)
                 .signWith(SignatureAlgorithm.HS512, secret).compact();
@@ -183,8 +168,7 @@ public class TokenService
      * @param token 令牌
      * @return 数据声明
      */
-    private Claims parseToken(String token)
-    {
+    private Claims parseToken(String token) {
         return Jwts.parser()
                 .setSigningKey(secret)
                 .parseClaimsJws(token)
@@ -197,8 +181,7 @@ public class TokenService
      * @param token 令牌
      * @return 用户名
      */
-    public String getUsernameFromToken(String token)
-    {
+    public String getUsernameFromToken(String token) {
         Claims claims = parseToken(token);
         return claims.getSubject();
     }
@@ -209,18 +192,15 @@ public class TokenService
      * @param request
      * @return token
      */
-    private String getToken(HttpServletRequest request)
-    {
+    private String getToken(HttpServletRequest request) {
         String token = request.getHeader(header);
-        if (StringUtils.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX))
-        {
+        if (StringUtils.isNotEmpty(token) && token.startsWith(Constants.TOKEN_PREFIX)) {
             token = token.replace(Constants.TOKEN_PREFIX, "");
         }
         return token;
     }
 
-    private String getTokenKey(String uuid)
-    {
+    private String getTokenKey(String uuid) {
         return CacheConstants.LOGIN_TOKEN_KEY + uuid;
     }
 }

+ 0 - 0
ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java


Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor