xushili 8 månader sedan
förälder
incheckning
2b2a416612
100 ändrade filer med 2463 tillägg och 3166 borttagningar
  1. 0 3
      ruoyi-admin/src/main/java/com/ruoyi/web/controller/FrontController.java
  2. 1 13
      ruoyi-admin/src/main/resources/FunctionTemplate.java
  3. 4 9
      ruoyi-common/src/main/java/com/ruoyi/common/annotation/Anonymous.java
  4. 3 8
      ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java
  5. 5 10
      ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java
  6. 12 18
      ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java
  7. 2 3
      ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excels.java
  8. 2 3
      ruoyi-common/src/main/java/com/ruoyi/common/constant/CacheConstants.java
  9. 6 7
      ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java
  10. 128 59
      ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java
  11. 38 63
      ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java
  12. 45 54
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java
  13. 42 43
      ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java
  14. 36 31
      ruoyi-common/src/main/java/com/ruoyi/common/core/text/CharsetKit.java
  15. 170 321
      ruoyi-common/src/main/java/com/ruoyi/common/core/text/Convert.java
  16. 2 4
      ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessStatus.java
  17. 3 4
      ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java
  18. 2 3
      ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java
  19. 3 5
      ruoyi-common/src/main/java/com/ruoyi/common/exception/DemoModeException.java
  20. 9 16
      ruoyi-common/src/main/java/com/ruoyi/common/exception/GlobalException.java
  21. 14 27
      ruoyi-common/src/main/java/com/ruoyi/common/exception/base/BaseException.java
  22. 3 5
      ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileException.java
  23. 4 6
      ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java
  24. 4 6
      ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java
  25. 10 19
      ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileUploadException.java
  26. 3 5
      ruoyi-common/src/main/java/com/ruoyi/common/exception/user/BlackListException.java
  27. 3 5
      ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java
  28. 3 5
      ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaExpireException.java
  29. 27 28
      ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java
  30. 30 57
      ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java
  31. 43 70
      ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java
  32. 7 11
      ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java
  33. 26 32
      ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java
  34. 5 8
      ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanValidators.java
  35. 14 26
      ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileTypeUtils.java
  36. 42 76
      ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java
  37. 54 101
      ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java
  38. 30 57
      ruoyi-common/src/main/java/com/ruoyi/common/utils/html/EscapeUtil.java
  39. 10 18
      ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java
  40. 4 6
      ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelHandlerAdapter.java
  41. 334 658
      ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java
  42. 46 84
      ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Base64.java
  43. 32 57
      ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java
  44. 14 22
      ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java
  45. 4 5
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java
  46. 9 10
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java
  47. 32 46
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java
  48. 11 16
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java
  49. 12 14
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/FilterConfig.java
  50. 6 8
      ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/DruidProperties.java
  51. 0 1
      ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java
  52. 6 10
      ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSourceContextHolder.java
  53. 11 13
      ruoyi-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java
  54. 19 28
      ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java
  55. 5 9
      ruoyi-framework/src/main/java/com/ruoyi/framework/security/context/AuthenticationContextHolder.java
  56. 11 12
      ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java
  57. 14 27
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java
  58. 17 25
      ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java
  59. 23 24
      ruoyi-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java
  60. 16 29
      ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java
  61. 131 140
      ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java
  62. 118 143
      ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java
  63. 30 34
      ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableColumnServiceImpl.java
  64. 80 146
      ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java
  65. 1 1
      ruoyi-generator/src/main/resources/generator.yml
  66. 276 161
      ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml
  67. 23 30
      ruoyi-generator/src/main/resources/vm/java/controller.java.vm
  68. 63 67
      ruoyi-generator/src/main/resources/vm/java/domain.java.vm
  69. 23 23
      ruoyi-generator/src/main/resources/vm/js/api.js.vm
  70. 19 29
      ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java
  71. 11 21
      ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java
  72. 4 1
      ruoyi-ui/src/assets/icons/svg/404.svg
  73. 4 1
      ruoyi-ui/src/assets/icons/svg/bug.svg
  74. 11 1
      ruoyi-ui/src/assets/icons/svg/build.svg
  75. 10 1
      ruoyi-ui/src/assets/icons/svg/button.svg
  76. 11 1
      ruoyi-ui/src/assets/icons/svg/cascader.svg
  77. 3 1
      ruoyi-ui/src/assets/icons/svg/chart.svg
  78. 14 1
      ruoyi-ui/src/assets/icons/svg/checkbox.svg
  79. 4 1
      ruoyi-ui/src/assets/icons/svg/clipboard.svg
  80. 11 1
      ruoyi-ui/src/assets/icons/svg/code.svg
  81. 14 1
      ruoyi-ui/src/assets/icons/svg/color.svg
  82. 11 1
      ruoyi-ui/src/assets/icons/svg/component.svg
  83. 4 1
      ruoyi-ui/src/assets/icons/svg/dashboard.svg
  84. 14 1
      ruoyi-ui/src/assets/icons/svg/date-range.svg
  85. 11 1
      ruoyi-ui/src/assets/icons/svg/date.svg
  86. 14 1
      ruoyi-ui/src/assets/icons/svg/dict.svg
  87. 4 1
      ruoyi-ui/src/assets/icons/svg/documentation.svg
  88. 14 1
      ruoyi-ui/src/assets/icons/svg/download.svg
  89. 4 1
      ruoyi-ui/src/assets/icons/svg/drag.svg
  90. 11 1
      ruoyi-ui/src/assets/icons/svg/druid.svg
  91. 6 1
      ruoyi-ui/src/assets/icons/svg/edit.svg
  92. 4 1
      ruoyi-ui/src/assets/icons/svg/education.svg
  93. 5 1
      ruoyi-ui/src/assets/icons/svg/email.svg
  94. 4 1
      ruoyi-ui/src/assets/icons/svg/example.svg
  95. 6 1
      ruoyi-ui/src/assets/icons/svg/excel.svg
  96. 4 1
      ruoyi-ui/src/assets/icons/svg/exit-fullscreen.svg
  97. 7 1
      ruoyi-ui/src/assets/icons/svg/eye-open.svg
  98. 4 1
      ruoyi-ui/src/assets/icons/svg/eye.svg
  99. 4 1
      ruoyi-ui/src/assets/icons/svg/form.svg
  100. 0 0
      ruoyi-ui/src/assets/icons/svg/fullscreen.svg

+ 0 - 3
ruoyi-admin/src/main/java/com/ruoyi/web/controller/FrontController.java

@@ -1,8 +1,5 @@
 package com.ruoyi.web.controller;
 
-import org.springframework.stereotype.Controller;
-import org.springframework.web.bind.annotation.GetMapping;
-
 //@Controller
 public class FrontController {
     //@GetMapping("/one")

+ 1 - 13
ruoyi-admin/src/main/resources/FunctionTemplate.java

@@ -1,23 +1,11 @@
 package com.ruoyi;
 
-import cn.hutool.core.collection.CollUtil;
-import cn.hutool.core.date.DateTime;
-import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.util.NumberUtil;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.ruoyi.quartz.handler.IJobHandler;
-import com.ruoyi.quartz.task.ChangedSave;
-import com.ruoyi.ucp.entity.*;
 import com.ruoyi.ucp.feign.AdapterApi;
 import com.ruoyi.ucp.service.*;
-import com.ruoyi.ucp.util.CalcCache;
 import org.springframework.data.redis.core.RedisTemplate;
 
 import javax.annotation.Resource;
-import java.net.URI;
-import java.util.*;
-import java.util.function.Function;
-import java.util.stream.Collectors;
 
 public class JavaFunctionJobHandler extends IJobHandler {
 
@@ -56,5 +44,5 @@ public class JavaFunctionJobHandler extends IJobHandler {
     public void setFunctionHandler(IJobHandler jobHandler) {
 
     }
-//此处加公式
+    //此处加公式
 }

+ 4 - 9
ruoyi-common/src/main/java/com/ruoyi/common/annotation/Anonymous.java

@@ -1,19 +1,14 @@
 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 java.lang.annotation.*;
 
 /**
  * 匿名访问不鉴权注解
- * 
+ *
  * @author ruoyi
  */
-@Target({ ElementType.METHOD, ElementType.TYPE })
+@Target({ElementType.METHOD, ElementType.TYPE})
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
-public @interface Anonymous
-{
+public @interface Anonymous {
 }

+ 3 - 8
ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java

@@ -1,21 +1,16 @@
 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 java.lang.annotation.*;
 
 /**
  * 数据权限过滤注解
- * 
+ *
  * @author ruoyi
  */
 @Target(ElementType.METHOD)
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
-public @interface DataScope
-{
+public @interface DataScope {
     /**
      * 部门表的别名
      */

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

@@ -1,26 +1,21 @@
 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 com.ruoyi.common.enums.DataSourceType;
 
+import java.lang.annotation.*;
+
 /**
  * 自定义多数据源切换注解
- *
+ * <p>
  * 优先级:先方法,后类,如果方法覆盖了类上的数据源类型,以方法的为准,否则以类上的为准
  *
  * @author ruoyi
  */
-@Target({ ElementType.METHOD, ElementType.TYPE })
+@Target({ElementType.METHOD, ElementType.TYPE})
 @Retention(RetentionPolicy.RUNTIME)
 @Documented
 @Inherited
-public @interface DataSource
-{
+public @interface DataSource {
     /**
      * 切换数据源名称
      */

+ 12 - 18
ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java

@@ -1,23 +1,23 @@
 package com.ruoyi.common.annotation;
 
+import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
+import org.apache.poi.ss.usermodel.HorizontalAlignment;
+import org.apache.poi.ss.usermodel.IndexedColors;
+
 import java.lang.annotation.ElementType;
 import java.lang.annotation.Retention;
 import java.lang.annotation.RetentionPolicy;
 import java.lang.annotation.Target;
 import java.math.BigDecimal;
-import org.apache.poi.ss.usermodel.HorizontalAlignment;
-import org.apache.poi.ss.usermodel.IndexedColors;
-import com.ruoyi.common.utils.poi.ExcelHandlerAdapter;
 
 /**
  * 自定义导出Excel数据注解
- * 
+ *
  * @author ruoyi
  */
 @Retention(RetentionPolicy.RUNTIME)
 @Target(ElementType.FIELD)
-public @interface Excel
-{
+public @interface Excel {
     /**
      * 导出时在excel中排序
      */
@@ -153,34 +153,28 @@ public @interface Excel
      */
     Type type() default Type.ALL;
 
-    public enum Type
-    {
+    public enum Type {
         ALL(0), EXPORT(1), IMPORT(2);
         private final int value;
 
-        Type(int value)
-        {
+        Type(int value) {
             this.value = value;
         }
 
-        public int value()
-        {
+        public int value() {
             return this.value;
         }
     }
 
-    public enum ColumnType
-    {
+    public enum ColumnType {
         NUMERIC(0), STRING(1), IMAGE(2);
         private final int value;
 
-        ColumnType(int value)
-        {
+        ColumnType(int value) {
             this.value = value;
         }
 
-        public int value()
-        {
+        public int value() {
             return this.value;
         }
     }

+ 2 - 3
ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excels.java

@@ -7,12 +7,11 @@ import java.lang.annotation.Target;
 
 /**
  * Excel注解集
- * 
+ *
  * @author ruoyi
  */
 @Target(ElementType.FIELD)
 @Retention(RetentionPolicy.RUNTIME)
-public @interface Excels
-{
+public @interface Excels {
     public Excel[] value();
 }

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

@@ -2,11 +2,10 @@ package com.ruoyi.common.constant;
 
 /**
  * 缓存的key 常量
- * 
+ *
  * @author ruoyi
  */
-public class CacheConstants
-{
+public class CacheConstants {
     /**
      * 登录用户 redis key
      */

+ 6 - 7
ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java

@@ -4,11 +4,10 @@ import io.jsonwebtoken.Claims;
 
 /**
  * 通用常量信息
- * 
+ *
  * @author ruoyi
  */
-public class Constants
-{
+public class Constants {
     /**
      * UTF-8 字符集
      */
@@ -63,7 +62,7 @@ public class Constants
      * 登录失败
      */
     public static final String LOGIN_FAIL = "Error";
- 
+
     /**
      * 验证码有效期(分钟)
      */
@@ -132,11 +131,11 @@ public class Constants
     /**
      * 定时任务白名单配置(仅允许访问的包名,如其他需要可以自行添加)
      */
-    public static final String[] JOB_WHITELIST_STR = { "com.ruoyi" };
+    public static final String[] JOB_WHITELIST_STR = {"com.ruoyi"};
 
     /**
      * 定时任务违规的字符
      */
-    public static final String[] JOB_ERROR_STR = { "java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
-            "org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config" };
+    public static final String[] JOB_ERROR_STR = {"java.net.URL", "javax.naming.InitialContext", "org.yaml.snakeyaml",
+            "org.springframework", "org.apache", "com.ruoyi.common.utils.file", "com.ruoyi.common.config"};
 }

+ 128 - 59
ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java

@@ -2,116 +2,185 @@ package com.ruoyi.common.constant;
 
 /**
  * 代码生成通用常量
- * 
+ *
  * @author ruoyi
  */
-public class GenConstants
-{
-    /** 单表(增删改查) */
+public class GenConstants {
+    /**
+     * 单表(增删改查)
+     */
     public static final String TPL_CRUD = "crud";
 
-    /** 树表(增删改查) */
+    /**
+     * 树表(增删改查)
+     */
     public static final String TPL_TREE = "tree";
 
-    /** 主子表(增删改查) */
+    /**
+     * 主子表(增删改查)
+     */
     public static final String TPL_SUB = "sub";
 
-    /** 树编码字段 */
+    /**
+     * 树编码字段
+     */
     public static final String TREE_CODE = "treeCode";
 
-    /** 树父编码字段 */
+    /**
+     * 树父编码字段
+     */
     public static final String TREE_PARENT_CODE = "treeParentCode";
 
-    /** 树名称字段 */
+    /**
+     * 树名称字段
+     */
     public static final String TREE_NAME = "treeName";
 
-    /** 上级菜单ID字段 */
+    /**
+     * 上级菜单ID字段
+     */
     public static final String PARENT_MENU_ID = "parentMenuId";
 
-    /** 上级菜单名称字段 */
+    /**
+     * 上级菜单名称字段
+     */
     public static final String PARENT_MENU_NAME = "parentMenuName";
 
-    /** 数据库字符串类型 */
-    public static final String[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" };
-
-    /** 数据库文本类型 */
-    public static final String[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" };
-
-    /** 数据库时间类型 */
-    public static final String[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
-
-    /** 数据库数字类型 */
-    public static final String[] COLUMNTYPE_NUMBER = { "tinyint", "smallint", "mediumint", "int", "number", "integer",
-            "bit", "bigint", "float", "double", "decimal" };
-
-    /** 页面不需要编辑字段 */
-    public static final String[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "del_flag" };
-
-    /** 页面不需要显示的列表字段 */
-    public static final String[] COLUMNNAME_NOT_LIST = { "id", "create_by", "create_time", "del_flag", "update_by",
-            "update_time" };
-
-    /** 页面不需要查询字段 */
-    public static final String[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "del_flag", "update_by",
-            "update_time", "remark" };
-
-    /** Entity基类字段 */
-    public static final String[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" };
-
-    /** Tree基类字段 */
-    public static final String[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors", "children" };
-
-    /** 文本框 */
+    /**
+     * 数据库字符串类型
+     */
+    public static final String[] COLUMNTYPE_STR = {"char", "varchar", "nvarchar", "varchar2"};
+
+    /**
+     * 数据库文本类型
+     */
+    public static final String[] COLUMNTYPE_TEXT = {"tinytext", "text", "mediumtext", "longtext"};
+
+    /**
+     * 数据库时间类型
+     */
+    public static final String[] COLUMNTYPE_TIME = {"datetime", "time", "date", "timestamp"};
+
+    /**
+     * 数据库数字类型
+     */
+    public static final String[] COLUMNTYPE_NUMBER = {"tinyint", "smallint", "mediumint", "int", "number", "integer",
+            "bit", "bigint", "float", "double", "decimal"};
+
+    /**
+     * 页面不需要编辑字段
+     */
+    public static final String[] COLUMNNAME_NOT_EDIT = {"id", "create_by", "create_time", "del_flag"};
+
+    /**
+     * 页面不需要显示的列表字段
+     */
+    public static final String[] COLUMNNAME_NOT_LIST = {"id", "create_by", "create_time", "del_flag", "update_by",
+            "update_time"};
+
+    /**
+     * 页面不需要查询字段
+     */
+    public static final String[] COLUMNNAME_NOT_QUERY = {"id", "create_by", "create_time", "del_flag", "update_by",
+            "update_time", "remark"};
+
+    /**
+     * Entity基类字段
+     */
+    public static final String[] BASE_ENTITY = {"createBy", "createTime", "updateBy", "updateTime", "remark"};
+
+    /**
+     * Tree基类字段
+     */
+    public static final String[] TREE_ENTITY = {"parentName", "parentId", "orderNum", "ancestors", "children"};
+
+    /**
+     * 文本框
+     */
     public static final String HTML_INPUT = "input";
 
-    /** 文本域 */
+    /**
+     * 文本域
+     */
     public static final String HTML_TEXTAREA = "textarea";
 
-    /** 下拉框 */
+    /**
+     * 下拉框
+     */
     public static final String HTML_SELECT = "select";
 
-    /** 单选框 */
+    /**
+     * 单选框
+     */
     public static final String HTML_RADIO = "radio";
 
-    /** 复选框 */
+    /**
+     * 复选框
+     */
     public static final String HTML_CHECKBOX = "checkbox";
 
-    /** 日期控件 */
+    /**
+     * 日期控件
+     */
     public static final String HTML_DATETIME = "datetime";
 
-    /** 图片上传控件 */
+    /**
+     * 图片上传控件
+     */
     public static final String HTML_IMAGE_UPLOAD = "imageUpload";
 
-    /** 文件上传控件 */
+    /**
+     * 文件上传控件
+     */
     public static final String HTML_FILE_UPLOAD = "fileUpload";
 
-    /** 富文本控件 */
+    /**
+     * 富文本控件
+     */
     public static final String HTML_EDITOR = "editor";
 
-    /** 字符串类型 */
+    /**
+     * 字符串类型
+     */
     public static final String TYPE_STRING = "String";
 
-    /** 整型 */
+    /**
+     * 整型
+     */
     public static final String TYPE_INTEGER = "Integer";
 
-    /** 长整型 */
+    /**
+     * 长整型
+     */
     public static final String TYPE_LONG = "Long";
 
-    /** 浮点型 */
+    /**
+     * 浮点型
+     */
     public static final String TYPE_DOUBLE = "Double";
 
-    /** 高精度计算类型 */
+    /**
+     * 高精度计算类型
+     */
     public static final String TYPE_BIGDECIMAL = "BigDecimal";
 
-    /** 时间类型 */
+    /**
+     * 时间类型
+     */
     public static final String TYPE_DATE = "Date";
 
-    /** 模糊查询 */
+    /**
+     * 模糊查询
+     */
     public static final String QUERY_LIKE = "LIKE";
 
-    /** 相等查询 */
+    /**
+     * 相等查询
+     */
     public static final String QUERY_EQ = "EQ";
 
-    /** 需要 */
+    /**
+     * 需要
+     */
     public static final String REQUIRE = "1";
 }

+ 38 - 63
ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java

@@ -1,15 +1,6 @@
 package com.ruoyi.common.core.controller;
 
-import java.beans.PropertyEditorSupport;
-import java.util.Date;
-import java.util.List;
-
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import org.apache.poi.ss.formula.functions.T;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.web.bind.WebDataBinder;
-import org.springframework.web.bind.annotation.InitBinder;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
 import com.ruoyi.common.constant.HttpStatus;
@@ -23,28 +14,32 @@ import com.ruoyi.common.utils.PageUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.sql.SqlUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.WebDataBinder;
+import org.springframework.web.bind.annotation.InitBinder;
+
+import java.beans.PropertyEditorSupport;
+import java.util.Date;
+import java.util.List;
 
 /**
  * web层通用数据处理
- * 
+ *
  * @author ruoyi
  */
-public class BaseController
-{
+public class BaseController {
     protected final Logger logger = LoggerFactory.getLogger(this.getClass());
 
     /**
      * 将前台传递过来的日期格式的字符串,自动转化为Date类型
      */
     @InitBinder
-    public void initBinder(WebDataBinder binder)
-    {
+    public void initBinder(WebDataBinder binder) {
         // Date 类型转换
-        binder.registerCustomEditor(Date.class, new PropertyEditorSupport()
-        {
+        binder.registerCustomEditor(Date.class, new PropertyEditorSupport() {
             @Override
-            public void setAsText(String text)
-            {
+            public void setAsText(String text) {
                 setValue(DateUtils.parseDate(text));
             }
         });
@@ -53,27 +48,23 @@ public class BaseController
     /**
      * 设置请求分页数据
      */
-    protected void startPage()
-    {
+    protected void startPage() {
         PageUtils.startPage();
     }
 
     /**
      * 设置请求分页数据
      */
-    protected <T> Page<T> startPage2()
-    {
+    protected <T> Page<T> startPage2() {
         return PageUtils.startPage2();
     }
 
     /**
      * 设置请求排序数据
      */
-    protected void startOrderBy()
-    {
+    protected void startOrderBy() {
         PageDomain pageDomain = TableSupport.buildPageRequest();
-        if (StringUtils.isNotEmpty(pageDomain.getOrderBy()))
-        {
+        if (StringUtils.isNotEmpty(pageDomain.getOrderBy())) {
             String orderBy = SqlUtil.escapeOrderBySql(pageDomain.getOrderBy());
             PageHelper.orderBy(orderBy);
         }
@@ -82,17 +73,15 @@ public class BaseController
     /**
      * 清理分页的线程变量
      */
-    protected void clearPage()
-    {
+    protected void clearPage() {
         PageUtils.clearPage();
     }
 
     /**
      * 响应请求分页数据
      */
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    protected TableDataInfo getDataTable(Page<?> page)
-    {
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    protected TableDataInfo getDataTable(Page<?> page) {
         TableDataInfo rspData = new TableDataInfo();
         rspData.setCode(HttpStatus.SUCCESS);
         rspData.setMsg("查询成功");
@@ -104,9 +93,8 @@ public class BaseController
     /**
      * 响应请求分页数据
      */
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    protected TableDataInfo getDataTable(List<?> list)
-    {
+    @SuppressWarnings({"rawtypes", "unchecked"})
+    protected TableDataInfo getDataTable(List<?> list) {
         TableDataInfo rspData = new TableDataInfo();
         rspData.setCode(HttpStatus.SUCCESS);
         rspData.setMsg("查询成功");
@@ -118,110 +106,97 @@ public class BaseController
     /**
      * 返回成功
      */
-    public AjaxResult success()
-    {
+    public AjaxResult success() {
         return AjaxResult.success();
     }
 
     /**
      * 返回失败消息
      */
-    public AjaxResult error()
-    {
+    public AjaxResult error() {
         return AjaxResult.error();
     }
 
     /**
      * 返回成功消息
      */
-    public AjaxResult success(String message)
-    {
+    public AjaxResult success(String message) {
         return AjaxResult.success(message);
     }
-    
+
     /**
      * 返回成功消息
      */
-    public AjaxResult success(Object data)
-    {
+    public AjaxResult success(Object data) {
         return AjaxResult.success(data);
     }
 
     /**
      * 返回失败消息
      */
-    public AjaxResult error(String message)
-    {
+    public AjaxResult error(String message) {
         return AjaxResult.error(message);
     }
 
     /**
      * 返回警告消息
      */
-    public AjaxResult warn(String message)
-    {
+    public AjaxResult warn(String message) {
         return AjaxResult.warn(message);
     }
 
     /**
      * 响应返回结果
-     * 
+     *
      * @param rows 影响行数
      * @return 操作结果
      */
-    protected AjaxResult toAjax(int rows)
-    {
+    protected AjaxResult toAjax(int rows) {
         return rows > 0 ? AjaxResult.success() : AjaxResult.error();
     }
 
     /**
      * 响应返回结果
-     * 
+     *
      * @param result 结果
      * @return 操作结果
      */
-    protected AjaxResult toAjax(boolean result)
-    {
+    protected AjaxResult toAjax(boolean result) {
         return result ? success() : error();
     }
 
     /**
      * 页面跳转
      */
-    public String redirect(String url)
-    {
+    public String redirect(String url) {
         return StringUtils.format("redirect:{}", url);
     }
 
     /**
      * 获取用户缓存信息
      */
-    public LoginUser getLoginUser()
-    {
+    public LoginUser getLoginUser() {
         return SecurityUtils.getLoginUser();
     }
 
     /**
      * 获取登录用户id
      */
-    public Long getUserId()
-    {
+    public Long getUserId() {
         return getLoginUser().getUserId();
     }
 
     /**
      * 获取登录部门id
      */
-    public Long getDeptId()
-    {
+    public Long getDeptId() {
         return getLoginUser().getDeptId();
     }
 
     /**
      * 获取登录用户名
      */
-    public String getUsername()
-    {
+    public String getUsername() {
         return getLoginUser().getUsername();
     }
 }

+ 45 - 54
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java

@@ -1,103 +1,101 @@
 package com.ruoyi.common.core.domain;
 
-import java.util.HashMap;
 import com.ruoyi.common.constant.HttpStatus;
 import com.ruoyi.common.utils.StringUtils;
 
+import java.util.HashMap;
+
 /**
  * 操作消息提醒
- * 
+ *
  * @author ruoyi
  */
-public class AjaxResult extends HashMap<String, Object>
-{
+public class AjaxResult extends HashMap<String, Object> {
     private static final long serialVersionUID = 1L;
 
-    /** 状态码 */
+    /**
+     * 状态码
+     */
     public static final String CODE_TAG = "code";
 
-    /** 返回内容 */
+    /**
+     * 返回内容
+     */
     public static final String MSG_TAG = "msg";
 
-    /** 数据对象 */
+    /**
+     * 数据对象
+     */
     public static final String DATA_TAG = "data";
 
     /**
      * 初始化一个新创建的 AjaxResult 对象,使其表示一个空消息。
      */
-    public AjaxResult()
-    {
+    public AjaxResult() {
     }
 
     /**
      * 初始化一个新创建的 AjaxResult 对象
-     * 
+     *
      * @param code 状态码
-     * @param msg 返回内容
+     * @param msg  返回内容
      */
-    public AjaxResult(int code, String msg)
-    {
+    public AjaxResult(int code, String msg) {
         super.put(CODE_TAG, code);
         super.put(MSG_TAG, msg);
     }
 
     /**
      * 初始化一个新创建的 AjaxResult 对象
-     * 
+     *
      * @param code 状态码
-     * @param msg 返回内容
+     * @param msg  返回内容
      * @param data 数据对象
      */
-    public AjaxResult(int code, String msg, Object data)
-    {
+    public AjaxResult(int code, String msg, Object data) {
         super.put(CODE_TAG, code);
         super.put(MSG_TAG, msg);
-        if (StringUtils.isNotNull(data))
-        {
+        if (StringUtils.isNotNull(data)) {
             super.put(DATA_TAG, data);
         }
     }
 
     /**
      * 返回成功消息
-     * 
+     *
      * @return 成功消息
      */
-    public static AjaxResult success()
-    {
+    public static AjaxResult success() {
         return AjaxResult.success("操作成功");
     }
 
     /**
      * 返回成功数据
-     * 
+     *
      * @return 成功消息
      */
-    public static AjaxResult success(Object data)
-    {
+    public static AjaxResult success(Object data) {
         return AjaxResult.success("操作成功", data);
     }
 
     /**
      * 返回成功消息
-     * 
+     *
      * @param msg 返回内容
      * @return 成功消息
      */
-    public static AjaxResult success(String msg)
-    {
+    public static AjaxResult success(String msg) {
         return AjaxResult.success(msg, null);
     }
 
     /**
      * 返回成功消息
-     * 
-     * @param msg 返回内容
+     *
+     * @param msg  返回内容
      * @param data 数据对象
      * @return 成功消息
      */
-    public static AjaxResult success(String msg, Object data)
-    {
+    public static AjaxResult success(String msg, Object data) {
         return new AjaxResult(HttpStatus.SUCCESS, msg, data);
     }
 
@@ -107,78 +105,71 @@ public class AjaxResult extends HashMap<String, Object>
      * @param msg 返回内容
      * @return 警告消息
      */
-    public static AjaxResult warn(String msg)
-    {
+    public static AjaxResult warn(String msg) {
         return AjaxResult.warn(msg, null);
     }
 
     /**
      * 返回警告消息
      *
-     * @param msg 返回内容
+     * @param msg  返回内容
      * @param data 数据对象
      * @return 警告消息
      */
-    public static AjaxResult warn(String msg, Object data)
-    {
+    public static AjaxResult warn(String msg, Object data) {
         return new AjaxResult(HttpStatus.WARN, msg, data);
     }
 
     /**
      * 返回错误消息
-     * 
+     *
      * @return 错误消息
      */
-    public static AjaxResult error()
-    {
+    public static AjaxResult error() {
         return AjaxResult.error("操作失败");
     }
 
     /**
      * 返回错误消息
-     * 
+     *
      * @param msg 返回内容
      * @return 错误消息
      */
-    public static AjaxResult error(String msg)
-    {
+    public static AjaxResult error(String msg) {
         return AjaxResult.error(msg, null);
     }
 
     /**
      * 返回错误消息
-     * 
-     * @param msg 返回内容
+     *
+     * @param msg  返回内容
      * @param data 数据对象
      * @return 错误消息
      */
-    public static AjaxResult error(String msg, Object data)
-    {
+    public static AjaxResult error(String msg, Object data) {
         return new AjaxResult(HttpStatus.ERROR, msg, data);
     }
 
     /**
      * 返回错误消息
-     * 
+     *
      * @param code 状态码
-     * @param msg 返回内容
+     * @param msg  返回内容
      * @return 错误消息
      */
-    public static AjaxResult error(int code, String msg)
-    {
+    public static AjaxResult error(int code, String msg) {
         return new AjaxResult(code, msg, null);
     }
 
     /**
      * 方便链式调用
      *
-     * @param key 键
+     * @param key   
      * @param value 值
      * @return 数据对象
      */
     @Override
-    public AjaxResult put(String key, Object value)
-    {
+    public AjaxResult put(String key, Object value) {
         super.put(key, value);
         return this;
     }

+ 42 - 43
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java

@@ -1,118 +1,117 @@
 package com.ruoyi.common.core.domain;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonInclude;
+
 import java.io.Serializable;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonInclude;
 
 /**
  * Entity基类
- * 
+ *
  * @author ruoyi
  */
-public class BaseEntity implements Serializable
-{
+public class BaseEntity implements Serializable {
     private static final long serialVersionUID = 1L;
 
-    /** 搜索值 */
+    /**
+     * 搜索值
+     */
     @JsonIgnore
     private String searchValue;
 
-    /** 创建者 */
+    /**
+     * 创建者
+     */
     private String createBy;
 
-    /** 创建时间 */
+    /**
+     * 创建时间
+     */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date createTime;
 
-    /** 更新者 */
+    /**
+     * 更新者
+     */
     private String updateBy;
 
-    /** 更新时间 */
+    /**
+     * 更新时间
+     */
     @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
     private Date updateTime;
 
-    /** 备注 */
+    /**
+     * 备注
+     */
     private String remark;
 
-    /** 请求参数 */
+    /**
+     * 请求参数
+     */
     @JsonInclude(JsonInclude.Include.NON_EMPTY)
     private Map<String, Object> params;
 
-    public String getSearchValue()
-    {
+    public String getSearchValue() {
         return searchValue;
     }
 
-    public void setSearchValue(String searchValue)
-    {
+    public void setSearchValue(String searchValue) {
         this.searchValue = searchValue;
     }
 
-    public String getCreateBy()
-    {
+    public String getCreateBy() {
         return createBy;
     }
 
-    public void setCreateBy(String createBy)
-    {
+    public void setCreateBy(String createBy) {
         this.createBy = createBy;
     }
 
-    public Date getCreateTime()
-    {
+    public Date getCreateTime() {
         return createTime;
     }
 
-    public void setCreateTime(Date createTime)
-    {
+    public void setCreateTime(Date createTime) {
         this.createTime = createTime;
     }
 
-    public String getUpdateBy()
-    {
+    public String getUpdateBy() {
         return updateBy;
     }
 
-    public void setUpdateBy(String updateBy)
-    {
+    public void setUpdateBy(String updateBy) {
         this.updateBy = updateBy;
     }
 
-    public Date getUpdateTime()
-    {
+    public Date getUpdateTime() {
         return updateTime;
     }
 
-    public void setUpdateTime(Date updateTime)
-    {
+    public void setUpdateTime(Date updateTime) {
         this.updateTime = updateTime;
     }
 
-    public String getRemark()
-    {
+    public String getRemark() {
         return remark;
     }
 
-    public void setRemark(String remark)
-    {
+    public void setRemark(String remark) {
         this.remark = remark;
     }
 
-    public Map<String, Object> getParams()
-    {
-        if (params == null)
-        {
+    public Map<String, Object> getParams() {
+        if (params == null) {
             params = new HashMap<>();
         }
         return params;
     }
 
-    public void setParams(Map<String, Object> params)
-    {
+    public void setParams(Map<String, Object> params) {
         this.params = params;
     }
 }

+ 36 - 31
ruoyi-common/src/main/java/com/ruoyi/common/core/text/CharsetKit.java

@@ -1,76 +1,82 @@
 package com.ruoyi.common.core.text;
 
+import com.ruoyi.common.utils.StringUtils;
+
 import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
-import com.ruoyi.common.utils.StringUtils;
 
 /**
  * 字符集工具类
- * 
+ *
  * @author ruoyi
  */
-public class CharsetKit
-{
-    /** ISO-8859-1 */
+public class CharsetKit {
+    /**
+     * ISO-8859-1
+     */
     public static final String ISO_8859_1 = "ISO-8859-1";
-    /** UTF-8 */
+    /**
+     * UTF-8
+     */
     public static final String UTF_8 = "UTF-8";
-    /** GBK */
+    /**
+     * GBK
+     */
     public static final String GBK = "GBK";
 
-    /** ISO-8859-1 */
+    /**
+     * ISO-8859-1
+     */
     public static final Charset CHARSET_ISO_8859_1 = Charset.forName(ISO_8859_1);
-    /** UTF-8 */
+    /**
+     * UTF-8
+     */
     public static final Charset CHARSET_UTF_8 = Charset.forName(UTF_8);
-    /** GBK */
+    /**
+     * GBK
+     */
     public static final Charset CHARSET_GBK = Charset.forName(GBK);
 
     /**
      * 转换为Charset对象
-     * 
+     *
      * @param charset 字符集,为空则返回默认字符集
      * @return Charset
      */
-    public static Charset charset(String charset)
-    {
+    public static Charset charset(String charset) {
         return StringUtils.isEmpty(charset) ? Charset.defaultCharset() : Charset.forName(charset);
     }
 
     /**
      * 转换字符串的字符集编码
-     * 
-     * @param source 字符串
-     * @param srcCharset 源字符集,默认ISO-8859-1
+     *
+     * @param source      字符串
+     * @param srcCharset  源字符集,默认ISO-8859-1
      * @param destCharset 目标字符集,默认UTF-8
      * @return 转换后的字符集
      */
-    public static String convert(String source, String srcCharset, String destCharset)
-    {
+    public static String convert(String source, String srcCharset, String destCharset) {
         return convert(source, Charset.forName(srcCharset), Charset.forName(destCharset));
     }
 
     /**
      * 转换字符串的字符集编码
-     * 
-     * @param source 字符串
-     * @param srcCharset 源字符集,默认ISO-8859-1
+     *
+     * @param source      字符串
+     * @param srcCharset  源字符集,默认ISO-8859-1
      * @param destCharset 目标字符集,默认UTF-8
      * @return 转换后的字符集
      */
-    public static String convert(String source, Charset srcCharset, Charset destCharset)
-    {
-        if (null == srcCharset)
-        {
+    public static String convert(String source, Charset srcCharset, Charset destCharset) {
+        if (null == srcCharset) {
             srcCharset = StandardCharsets.ISO_8859_1;
         }
 
-        if (null == destCharset)
-        {
+        if (null == destCharset) {
             destCharset = StandardCharsets.UTF_8;
         }
 
-        if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset))
-        {
+        if (StringUtils.isEmpty(source) || srcCharset.equals(destCharset)) {
             return source;
         }
         return new String(source.getBytes(srcCharset), destCharset);
@@ -79,8 +85,7 @@ public class CharsetKit
     /**
      * @return 系统字符集编码
      */
-    public static String systemCharset()
-    {
+    public static String systemCharset() {
         return Charset.defaultCharset().name();
     }
 }

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 170 - 321
ruoyi-common/src/main/java/com/ruoyi/common/core/text/Convert.java


+ 2 - 4
ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessStatus.java

@@ -2,12 +2,10 @@ package com.ruoyi.common.enums;
 
 /**
  * 操作状态
- * 
- * @author ruoyi
  *
+ * @author ruoyi
  */
-public enum BusinessStatus
-{
+public enum BusinessStatus {
     /**
      * 成功
      */

+ 3 - 4
ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java

@@ -2,11 +2,10 @@ package com.ruoyi.common.enums;
 
 /**
  * 业务操作类型
- * 
+ *
  * @author ruoyi
  */
-public enum BusinessType
-{
+public enum BusinessType {
     /**
      * 其它
      */
@@ -51,7 +50,7 @@ public enum BusinessType
      * 生成代码
      */
     GENCODE,
-    
+
     /**
      * 清空数据
      */

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

@@ -2,11 +2,10 @@ package com.ruoyi.common.enums;
 
 /**
  * 数据源
- * 
+ *
  * @author ruoyi
  */
-public enum DataSourceType
-{
+public enum DataSourceType {
     /**
      * 主库
      */

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

@@ -2,14 +2,12 @@ package com.ruoyi.common.exception;
 
 /**
  * 演示模式异常
- * 
+ *
  * @author ruoyi
  */
-public class DemoModeException extends RuntimeException
-{
+public class DemoModeException extends RuntimeException {
     private static final long serialVersionUID = 1L;
 
-    public DemoModeException()
-    {
+    public DemoModeException() {
     }
 }

+ 9 - 16
ruoyi-common/src/main/java/com/ruoyi/common/exception/GlobalException.java

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

+ 14 - 27
ruoyi-common/src/main/java/com/ruoyi/common/exception/base/BaseException.java

@@ -5,11 +5,10 @@ import com.ruoyi.common.utils.StringUtils;
 
 /**
  * 基础异常
- * 
+ *
  * @author ruoyi
  */
-public class BaseException extends RuntimeException
-{
+public class BaseException extends RuntimeException {
     private static final long serialVersionUID = 1L;
 
     /**
@@ -32,66 +31,54 @@ public class BaseException extends RuntimeException
      */
     private String defaultMessage;
 
-    public BaseException(String module, String code, Object[] args, String defaultMessage)
-    {
+    public BaseException(String module, String code, Object[] args, String defaultMessage) {
         this.module = module;
         this.code = code;
         this.args = args;
         this.defaultMessage = defaultMessage;
     }
 
-    public BaseException(String module, String code, Object[] args)
-    {
+    public BaseException(String module, String code, Object[] args) {
         this(module, code, args, null);
     }
 
-    public BaseException(String module, String defaultMessage)
-    {
+    public BaseException(String module, String defaultMessage) {
         this(module, null, null, defaultMessage);
     }
 
-    public BaseException(String code, Object[] args)
-    {
+    public BaseException(String code, Object[] args) {
         this(null, code, args, null);
     }
 
-    public BaseException(String defaultMessage)
-    {
+    public BaseException(String defaultMessage) {
         this(null, null, null, defaultMessage);
     }
 
     @Override
-    public String getMessage()
-    {
+    public String getMessage() {
         String message = null;
-        if (!StringUtils.isEmpty(code))
-        {
+        if (!StringUtils.isEmpty(code)) {
             message = MessageUtils.message(code, args);
         }
-        if (message == null)
-        {
+        if (message == null) {
             message = defaultMessage;
         }
         return message;
     }
 
-    public String getModule()
-    {
+    public String getModule() {
         return module;
     }
 
-    public String getCode()
-    {
+    public String getCode() {
         return code;
     }
 
-    public Object[] getArgs()
-    {
+    public Object[] getArgs() {
         return args;
     }
 
-    public String getDefaultMessage()
-    {
+    public String getDefaultMessage() {
         return defaultMessage;
     }
 }

+ 3 - 5
ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileException.java

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

+ 4 - 6
ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java

@@ -2,15 +2,13 @@ package com.ruoyi.common.exception.file;
 
 /**
  * 文件名称超长限制异常类
- * 
+ *
  * @author ruoyi
  */
-public class FileNameLengthLimitExceededException extends FileException
-{
+public class FileNameLengthLimitExceededException extends FileException {
     private static final long serialVersionUID = 1L;
 
-    public FileNameLengthLimitExceededException(int defaultFileNameLength)
-    {
-        super("upload.filename.exceed.length", new Object[] { defaultFileNameLength });
+    public FileNameLengthLimitExceededException(int defaultFileNameLength) {
+        super("upload.filename.exceed.length", new Object[]{defaultFileNameLength});
     }
 }

+ 4 - 6
ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java

@@ -2,15 +2,13 @@ package com.ruoyi.common.exception.file;
 
 /**
  * 文件名大小限制异常类
- * 
+ *
  * @author ruoyi
  */
-public class FileSizeLimitExceededException extends FileException
-{
+public class FileSizeLimitExceededException extends FileException {
     private static final long serialVersionUID = 1L;
 
-    public FileSizeLimitExceededException(long defaultMaxSize)
-    {
-        super("upload.exceed.maxSize", new Object[] { defaultMaxSize });
+    public FileSizeLimitExceededException(long defaultMaxSize) {
+        super("upload.exceed.maxSize", new Object[]{defaultMaxSize});
     }
 }

+ 10 - 19
ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileUploadException.java

@@ -5,57 +5,48 @@ import java.io.PrintWriter;
 
 /**
  * 文件上传异常类
- * 
+ *
  * @author ruoyi
  */
-public class FileUploadException extends Exception
-{
+public class FileUploadException extends Exception {
 
     private static final long serialVersionUID = 1L;
 
     private final Throwable cause;
 
-    public FileUploadException()
-    {
+    public FileUploadException() {
         this(null, null);
     }
 
-    public FileUploadException(final String msg)
-    {
+    public FileUploadException(final String msg) {
         this(msg, null);
     }
 
-    public FileUploadException(String msg, Throwable cause)
-    {
+    public FileUploadException(String msg, Throwable cause) {
         super(msg);
         this.cause = cause;
     }
 
     @Override
-    public void printStackTrace(PrintStream stream)
-    {
+    public void printStackTrace(PrintStream stream) {
         super.printStackTrace(stream);
-        if (cause != null)
-        {
+        if (cause != null) {
             stream.println("Caused by:");
             cause.printStackTrace(stream);
         }
     }
 
     @Override
-    public void printStackTrace(PrintWriter writer)
-    {
+    public void printStackTrace(PrintWriter writer) {
         super.printStackTrace(writer);
-        if (cause != null)
-        {
+        if (cause != null) {
             writer.println("Caused by:");
             cause.printStackTrace(writer);
         }
     }
 
     @Override
-    public Throwable getCause()
-    {
+    public Throwable getCause() {
         return cause;
     }
 }

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

@@ -2,15 +2,13 @@ package com.ruoyi.common.exception.user;
 
 /**
  * 黑名单IP异常类
- * 
+ *
  * @author ruoyi
  */
-public class BlackListException extends UserException
-{
+public class BlackListException extends UserException {
     private static final long serialVersionUID = 1L;
 
-    public BlackListException()
-    {
+    public BlackListException() {
         super("login.blocked", null);
     }
 }

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

@@ -2,15 +2,13 @@ package com.ruoyi.common.exception.user;
 
 /**
  * 验证码错误异常类
- * 
+ *
  * @author ruoyi
  */
-public class CaptchaException extends UserException
-{
+public class CaptchaException extends UserException {
     private static final long serialVersionUID = 1L;
 
-    public CaptchaException()
-    {
+    public CaptchaException() {
         super("user.jcaptcha.error", null);
     }
 }

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

@@ -2,15 +2,13 @@ package com.ruoyi.common.exception.user;
 
 /**
  * 验证码失效异常类
- * 
+ *
  * @author ruoyi
  */
-public class CaptchaExpireException extends UserException
-{
+public class CaptchaExpireException extends UserException {
     private static final long serialVersionUID = 1L;
 
-    public CaptchaExpireException()
-    {
+    public CaptchaExpireException() {
         super("user.jcaptcha.expire", null);
     }
 }

+ 27 - 28
ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java

@@ -5,28 +5,30 @@ import java.math.RoundingMode;
 
 /**
  * 精确的浮点数运算
- * 
+ *
  * @author ruoyi
  */
-public class Arith
-{
+public class Arith {
 
-    /** 默认除法运算精度 */
+    /**
+     * 默认除法运算精度
+     */
     private static final int DEF_DIV_SCALE = 10;
 
-    /** 这个类不能实例化 */
-    private Arith()
-    {
+    /**
+     * 这个类不能实例化
+     */
+    private Arith() {
     }
 
     /**
      * 提供精确的加法运算。
+     *
      * @param v1 被加数
      * @param v2 加数
      * @return 两个参数的和
      */
-    public static double add(double v1, double v2)
-    {
+    public static double add(double v1, double v2) {
         BigDecimal b1 = new BigDecimal(Double.toString(v1));
         BigDecimal b2 = new BigDecimal(Double.toString(v2));
         return b1.add(b2).doubleValue();
@@ -34,12 +36,12 @@ public class Arith
 
     /**
      * 提供精确的减法运算。
+     *
      * @param v1 被减数
      * @param v2 减数
      * @return 两个参数的差
      */
-    public static double sub(double v1, double v2)
-    {
+    public static double sub(double v1, double v2) {
         BigDecimal b1 = new BigDecimal(Double.toString(v1));
         BigDecimal b2 = new BigDecimal(Double.toString(v2));
         return b1.subtract(b2).doubleValue();
@@ -47,12 +49,12 @@ public class Arith
 
     /**
      * 提供精确的乘法运算。
+     *
      * @param v1 被乘数
      * @param v2 乘数
      * @return 两个参数的积
      */
-    public static double mul(double v1, double v2)
-    {
+    public static double mul(double v1, double v2) {
         BigDecimal b1 = new BigDecimal(Double.toString(v1));
         BigDecimal b2 = new BigDecimal(Double.toString(v2));
         return b1.multiply(b2).doubleValue();
@@ -61,34 +63,32 @@ public class Arith
     /**
      * 提供(相对)精确的除法运算,当发生除不尽的情况时,精确到
      * 小数点以后10位,以后的数字四舍五入。
+     *
      * @param v1 被除数
      * @param v2 除数
      * @return 两个参数的商
      */
-    public static double div(double v1, double v2)
-    {
+    public static double div(double v1, double v2) {
         return div(v1, v2, DEF_DIV_SCALE);
     }
 
     /**
      * 提供(相对)精确的除法运算。当发生除不尽的情况时,由scale参数指
      * 定精度,以后的数字四舍五入。
-     * @param v1 被除数
-     * @param v2 除数
+     *
+     * @param v1    被除数
+     * @param v2    除数
      * @param scale 表示表示需要精确到小数点以后几位。
      * @return 两个参数的商
      */
-    public static double div(double v1, double v2, int scale)
-    {
-        if (scale < 0)
-        {
+    public static double div(double v1, double v2, int scale) {
+        if (scale < 0) {
             throw new IllegalArgumentException(
                     "The scale must be a positive integer or zero");
         }
         BigDecimal b1 = new BigDecimal(Double.toString(v1));
         BigDecimal b2 = new BigDecimal(Double.toString(v2));
-        if (b1.compareTo(BigDecimal.ZERO) == 0)
-        {
+        if (b1.compareTo(BigDecimal.ZERO) == 0) {
             return BigDecimal.ZERO.doubleValue();
         }
         return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue();
@@ -96,14 +96,13 @@ public class Arith
 
     /**
      * 提供精确的小数位四舍五入处理。
-     * @param v 需要四舍五入的数字
+     *
+     * @param v     需要四舍五入的数字
      * @param scale 小数点后保留几位
      * @return 四舍五入后的结果
      */
-    public static double round(double v, int scale)
-    {
-        if (scale < 0)
-        {
+    public static double round(double v, int scale) {
+        if (scale < 0) {
             throw new IllegalArgumentException(
                     "The scale must be a positive integer or zero");
         }

+ 30 - 57
ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java

@@ -1,23 +1,19 @@
 package com.ruoyi.common.utils;
 
+import org.apache.commons.lang3.time.DateFormatUtils;
+
 import java.lang.management.ManagementFactory;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.LocalTime;
-import java.time.ZoneId;
-import java.time.ZonedDateTime;
+import java.time.*;
 import java.util.Date;
-import org.apache.commons.lang3.time.DateFormatUtils;
 
 /**
  * 时间工具类
- * 
+ *
  * @author ruoyi
  */
-public class DateUtils extends org.apache.commons.lang3.time.DateUtils
-{
+public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
     public static String YYYY = "yyyy";
 
     public static String YYYY_MM = "yyyy-MM";
@@ -29,63 +25,52 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
 
     private static String[] parsePatterns = {
-            "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", 
+            "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
             "yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
             "yyyy.MM.dd", "yyyy.MM.dd HH:mm:ss", "yyyy.MM.dd HH:mm", "yyyy.MM"};
 
     /**
      * 获取当前Date型日期
-     * 
+     *
      * @return Date() 当前日期
      */
-    public static Date getNowDate()
-    {
+    public static Date getNowDate() {
         return new Date();
     }
 
     /**
      * 获取当前日期, 默认格式为yyyy-MM-dd
-     * 
+     *
      * @return String
      */
-    public static String getDate()
-    {
+    public static String getDate() {
         return dateTimeNow(YYYY_MM_DD);
     }
 
-    public static final String getTime()
-    {
+    public static final String getTime() {
         return dateTimeNow(YYYY_MM_DD_HH_MM_SS);
     }
 
-    public static final String dateTimeNow()
-    {
+    public static final String dateTimeNow() {
         return dateTimeNow(YYYYMMDDHHMMSS);
     }
 
-    public static final String dateTimeNow(final String format)
-    {
+    public static final String dateTimeNow(final String format) {
         return parseDateToStr(format, new Date());
     }
 
-    public static final String dateTime(final Date date)
-    {
+    public static final String dateTime(final Date date) {
         return parseDateToStr(YYYY_MM_DD, date);
     }
 
-    public static final String parseDateToStr(final String format, final Date date)
-    {
+    public static final String parseDateToStr(final String format, final Date date) {
         return new SimpleDateFormat(format).format(date);
     }
 
-    public static final Date dateTime(final String format, final String ts)
-    {
-        try
-        {
+    public static final Date dateTime(final String format, final String ts) {
+        try {
             return new SimpleDateFormat(format).parse(ts);
-        }
-        catch (ParseException e)
-        {
+        } catch (ParseException e) {
             throw new RuntimeException(e);
         }
     }
@@ -93,8 +78,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 日期路径 即年/月/日 如2018/08/08
      */
-    public static final String datePath()
-    {
+    public static final String datePath() {
         Date now = new Date();
         return DateFormatUtils.format(now, "yyyy/MM/dd");
     }
@@ -102,8 +86,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 日期路径 即年/月/日 如20180808
      */
-    public static final String dateTime()
-    {
+    public static final String dateTime() {
         Date now = new Date();
         return DateFormatUtils.format(now, "yyyyMMdd");
     }
@@ -111,18 +94,13 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 日期型字符串转化为日期 格式
      */
-    public static Date parseDate(Object str)
-    {
-        if (str == null)
-        {
+    public static Date parseDate(Object str) {
+        if (str == null) {
             return null;
         }
-        try
-        {
+        try {
             return parseDate(str.toString(), parsePatterns);
-        }
-        catch (ParseException e)
-        {
+        } catch (ParseException e) {
             return null;
         }
     }
@@ -130,8 +108,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 获取服务器启动时间
      */
-    public static Date getServerStartDate()
-    {
+    public static Date getServerStartDate() {
         long time = ManagementFactory.getRuntimeMXBean().getStartTime();
         return new Date(time);
     }
@@ -139,20 +116,18 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 计算相差天数
      */
-    public static int differentDaysByMillisecond(Date date1, Date date2)
-    {
+    public static int differentDaysByMillisecond(Date date1, Date date2) {
         return Math.abs((int) ((date2.getTime() - date1.getTime()) / (1000 * 3600 * 24)));
     }
 
     /**
      * 计算时间差
      *
-     * @param endTime 最后时间
+     * @param endTime   最后时间
      * @param startTime 开始时间
      * @return 时间差(天/小时/分钟)
      */
-    public static String timeDistance(Date endDate, Date startTime)
-    {
+    public static String timeDistance(Date endDate, Date startTime) {
         long nd = 1000 * 24 * 60 * 60;
         long nh = 1000 * 60 * 60;
         long nm = 1000 * 60;
@@ -173,8 +148,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 增加 LocalDateTime ==> Date
      */
-    public static Date toDate(LocalDateTime temporalAccessor)
-    {
+    public static Date toDate(LocalDateTime temporalAccessor) {
         ZonedDateTime zdt = temporalAccessor.atZone(ZoneId.systemDefault());
         return Date.from(zdt.toInstant());
     }
@@ -182,8 +156,7 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
     /**
      * 增加 LocalDate ==> Date
      */
-    public static Date toDate(LocalDate temporalAccessor)
-    {
+    public static Date toDate(LocalDate temporalAccessor) {
         LocalDateTime localDateTime = LocalDateTime.of(temporalAccessor, LocalTime.of(0, 0, 0));
         ZonedDateTime zdt = localDateTime.atZone(ZoneId.systemDefault());
         return Date.from(zdt.toInstant());

+ 43 - 70
ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java

@@ -1,20 +1,20 @@
 package com.ruoyi.common.utils;
 
-import java.util.Collection;
-import java.util.List;
 import com.alibaba.fastjson2.JSONArray;
 import com.ruoyi.common.constant.CacheConstants;
 import com.ruoyi.common.core.domain.entity.SysDictData;
 import com.ruoyi.common.core.redis.RedisCache;
 import com.ruoyi.common.utils.spring.SpringUtils;
 
+import java.util.Collection;
+import java.util.List;
+
 /**
  * 字典工具类
- * 
+ *
  * @author ruoyi
  */
-public class DictUtils
-{
+public class DictUtils {
     /**
      * 分隔符
      */
@@ -22,26 +22,23 @@ public class DictUtils
 
     /**
      * 设置字典缓存
-     * 
-     * @param key 参数键
+     *
+     * @param key       参数键
      * @param dictDatas 字典数据列表
      */
-    public static void setDictCache(String key, List<SysDictData> dictDatas)
-    {
+    public static void setDictCache(String key, List<SysDictData> dictDatas) {
         SpringUtils.getBean(RedisCache.class).setCacheObject(getCacheKey(key), dictDatas);
     }
 
     /**
      * 获取字典缓存
-     * 
+     *
      * @param key 参数键
      * @return dictDatas 字典数据列表
      */
-    public static List<SysDictData> getDictCache(String key)
-    {
+    public static List<SysDictData> getDictCache(String key) {
         JSONArray arrayCache = SpringUtils.getBean(RedisCache.class).getCacheObject(getCacheKey(key));
-        if (StringUtils.isNotNull(arrayCache))
-        {
+        if (StringUtils.isNotNull(arrayCache)) {
             return arrayCache.toList(SysDictData.class);
         }
         return null;
@@ -49,63 +46,51 @@ public class DictUtils
 
     /**
      * 根据字典类型和字典值获取字典标签
-     * 
-     * @param dictType 字典类型
+     *
+     * @param dictType  字典类型
      * @param dictValue 字典值
      * @return 字典标签
      */
-    public static String getDictLabel(String dictType, String dictValue)
-    {
+    public static String getDictLabel(String dictType, String dictValue) {
         return getDictLabel(dictType, dictValue, SEPARATOR);
     }
 
     /**
      * 根据字典类型和字典标签获取字典值
-     * 
-     * @param dictType 字典类型
+     *
+     * @param dictType  字典类型
      * @param dictLabel 字典标签
      * @return 字典值
      */
-    public static String getDictValue(String dictType, String dictLabel)
-    {
+    public static String getDictValue(String dictType, String dictLabel) {
         return getDictValue(dictType, dictLabel, SEPARATOR);
     }
 
     /**
      * 根据字典类型和字典值获取字典标签
-     * 
-     * @param dictType 字典类型
+     *
+     * @param dictType  字典类型
      * @param dictValue 字典值
      * @param separator 分隔符
      * @return 字典标签
      */
-    public static String getDictLabel(String dictType, String dictValue, String separator)
-    {
+    public static String getDictLabel(String dictType, String dictValue, String separator) {
         StringBuilder propertyString = new StringBuilder();
         List<SysDictData> datas = getDictCache(dictType);
 
-        if (StringUtils.isNotNull(datas))
-        {
-            if (StringUtils.containsAny(separator, dictValue))
-            {
-                for (SysDictData dict : datas)
-                {
-                    for (String value : dictValue.split(separator))
-                    {
-                        if (value.equals(dict.getDictValue()))
-                        {
+        if (StringUtils.isNotNull(datas)) {
+            if (StringUtils.containsAny(separator, dictValue)) {
+                for (SysDictData dict : datas) {
+                    for (String value : dictValue.split(separator)) {
+                        if (value.equals(dict.getDictValue())) {
                             propertyString.append(dict.getDictLabel()).append(separator);
                             break;
                         }
                     }
                 }
-            }
-            else
-            {
-                for (SysDictData dict : datas)
-                {
-                    if (dictValue.equals(dict.getDictValue()))
-                    {
+            } else {
+                for (SysDictData dict : datas) {
+                    if (dictValue.equals(dict.getDictValue())) {
                         return dict.getDictLabel();
                     }
                 }
@@ -116,37 +101,28 @@ public class DictUtils
 
     /**
      * 根据字典类型和字典标签获取字典值
-     * 
-     * @param dictType 字典类型
+     *
+     * @param dictType  字典类型
      * @param dictLabel 字典标签
      * @param separator 分隔符
      * @return 字典值
      */
-    public static String getDictValue(String dictType, String dictLabel, String separator)
-    {
+    public static String getDictValue(String dictType, String dictLabel, String separator) {
         StringBuilder propertyString = new StringBuilder();
         List<SysDictData> datas = getDictCache(dictType);
 
-        if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas))
-        {
-            for (SysDictData dict : datas)
-            {
-                for (String label : dictLabel.split(separator))
-                {
-                    if (label.equals(dict.getDictLabel()))
-                    {
+        if (StringUtils.containsAny(separator, dictLabel) && StringUtils.isNotEmpty(datas)) {
+            for (SysDictData dict : datas) {
+                for (String label : dictLabel.split(separator)) {
+                    if (label.equals(dict.getDictLabel())) {
                         propertyString.append(dict.getDictValue()).append(separator);
                         break;
                     }
                 }
             }
-        }
-        else
-        {
-            for (SysDictData dict : datas)
-            {
-                if (dictLabel.equals(dict.getDictLabel()))
-                {
+        } else {
+            for (SysDictData dict : datas) {
+                if (dictLabel.equals(dict.getDictLabel())) {
                     return dict.getDictValue();
                 }
             }
@@ -156,31 +132,28 @@ public class DictUtils
 
     /**
      * 删除指定字典缓存
-     * 
+     *
      * @param key 字典键
      */
-    public static void removeDictCache(String key)
-    {
+    public static void removeDictCache(String key) {
         SpringUtils.getBean(RedisCache.class).deleteObject(getCacheKey(key));
     }
 
     /**
      * 清空字典缓存
      */
-    public static void clearDictCache()
-    {
+    public static void clearDictCache() {
         Collection<String> keys = SpringUtils.getBean(RedisCache.class).keys(CacheConstants.SYS_DICT_KEY + "*");
         SpringUtils.getBean(RedisCache.class).deleteObject(keys);
     }
 
     /**
      * 设置cache key
-     * 
+     *
      * @param configKey 参数键
      * @return 缓存键key
      */
-    public static String getCacheKey(String configKey)
-    {
+    public static String getCacheKey(String configKey) {
         return CacheConstants.SYS_DICT_KEY + configKey;
     }
 }

+ 7 - 11
ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java

@@ -1,37 +1,33 @@
 package com.ruoyi.common.utils;
 
+import org.apache.commons.lang3.exception.ExceptionUtils;
+
 import java.io.PrintWriter;
 import java.io.StringWriter;
-import org.apache.commons.lang3.exception.ExceptionUtils;
 
 /**
  * 错误信息处理类。
  *
  * @author ruoyi
  */
-public class ExceptionUtil
-{
+public class ExceptionUtil {
     /**
      * 获取exception的详细错误信息。
      */
-    public static String getExceptionMessage(Throwable e)
-    {
+    public static String getExceptionMessage(Throwable e) {
         StringWriter sw = new StringWriter();
         e.printStackTrace(new PrintWriter(sw, true));
         return sw.toString();
     }
 
-    public static String getRootErrorMessage(Exception e)
-    {
+    public static String getRootErrorMessage(Exception e) {
         Throwable root = ExceptionUtils.getRootCause(e);
         root = (root == null ? e : root);
-        if (root == null)
-        {
+        if (root == null) {
             return "";
         }
         String msg = root.getMessage();
-        if (msg == null)
-        {
+        if (msg == null) {
             return "null";
         }
         return StringUtils.defaultString(msg);

+ 26 - 32
ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java

@@ -8,46 +8,46 @@ import java.util.regex.Pattern;
 
 /**
  * Bean 工具类
- * 
+ *
  * @author ruoyi
  */
-public class BeanUtils extends org.springframework.beans.BeanUtils
-{
-    /** Bean方法名中属性名开始的下标 */
+public class BeanUtils extends org.springframework.beans.BeanUtils {
+    /**
+     * Bean方法名中属性名开始的下标
+     */
     private static final int BEAN_METHOD_PROP_INDEX = 3;
 
-    /** * 匹配getter方法的正则表达式 */
+    /**
+     * 匹配getter方法的正则表达式
+     */
     private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)");
 
-    /** * 匹配setter方法的正则表达式 */
+    /**
+     * 匹配setter方法的正则表达式
+     */
     private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)");
 
     /**
      * Bean属性复制工具方法。
-     * 
+     *
      * @param dest 目标对象
-     * @param src 源对象
+     * @param src  源对象
      */
-    public static void copyBeanProp(Object dest, Object src)
-    {
-        try
-        {
+    public static void copyBeanProp(Object dest, Object src) {
+        try {
             copyProperties(src, dest);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }
 
     /**
      * 获取对象的setter方法。
-     * 
+     *
      * @param obj 对象
      * @return 对象的setter方法列表
      */
-    public static List<Method> getSetterMethods(Object obj)
-    {
+    public static List<Method> getSetterMethods(Object obj) {
         // setter方法列表
         List<Method> setterMethods = new ArrayList<Method>();
 
@@ -56,11 +56,9 @@ public class BeanUtils extends org.springframework.beans.BeanUtils
 
         // 查找setter方法
 
-        for (Method method : methods)
-        {
+        for (Method method : methods) {
             Matcher m = SET_PATTERN.matcher(method.getName());
-            if (m.matches() && (method.getParameterTypes().length == 1))
-            {
+            if (m.matches() && (method.getParameterTypes().length == 1)) {
                 setterMethods.add(method);
             }
         }
@@ -70,23 +68,20 @@ public class BeanUtils extends org.springframework.beans.BeanUtils
 
     /**
      * 获取对象的getter方法。
-     * 
+     *
      * @param obj 对象
      * @return 对象的getter方法列表
      */
 
-    public static List<Method> getGetterMethods(Object obj)
-    {
+    public static List<Method> getGetterMethods(Object obj) {
         // getter方法列表
         List<Method> getterMethods = new ArrayList<Method>();
         // 获取所有方法
         Method[] methods = obj.getClass().getMethods();
         // 查找getter方法
-        for (Method method : methods)
-        {
+        for (Method method : methods) {
             Matcher m = GET_PATTERN.matcher(method.getName());
-            if (m.matches() && (method.getParameterTypes().length == 0))
-            {
+            if (m.matches() && (method.getParameterTypes().length == 0)) {
                 getterMethods.add(method);
             }
         }
@@ -97,14 +92,13 @@ public class BeanUtils extends org.springframework.beans.BeanUtils
     /**
      * 检查Bean方法名中的属性名是否相等。<br>
      * 如getName()和setName()属性名一样,getName()和setAge()属性名不一样。
-     * 
+     *
      * @param m1 方法名1
      * @param m2 方法名2
      * @return 属性名一样返回true,否则返回false
      */
 
-    public static boolean isMethodPropEquals(String m1, String m2)
-    {
+    public static boolean isMethodPropEquals(String m1, String m2) {
         return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX));
     }
 }

+ 5 - 8
ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanValidators.java

@@ -1,23 +1,20 @@
 package com.ruoyi.common.utils.bean;
 
-import java.util.Set;
 import javax.validation.ConstraintViolation;
 import javax.validation.ConstraintViolationException;
 import javax.validation.Validator;
+import java.util.Set;
 
 /**
  * bean对象属性验证
- * 
+ *
  * @author ruoyi
  */
-public class BeanValidators
-{
+public class BeanValidators {
     public static void validateWithException(Validator validator, Object object, Class<?>... groups)
-            throws ConstraintViolationException
-    {
+            throws ConstraintViolationException {
         Set<ConstraintViolation<Object>> constraintViolations = validator.validate(object, groups);
-        if (!constraintViolations.isEmpty())
-        {
+        if (!constraintViolations.isEmpty()) {
             throw new ConstraintViolationException(constraintViolations);
         }
     }

+ 14 - 26
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileTypeUtils.java

@@ -1,27 +1,25 @@
 package com.ruoyi.common.utils.file;
 
-import java.io.File;
 import org.apache.commons.lang3.StringUtils;
 
+import java.io.File;
+
 /**
  * 文件类型工具类
  *
  * @author ruoyi
  */
-public class FileTypeUtils
-{
+public class FileTypeUtils {
     /**
      * 获取文件类型
      * <p>
      * 例如: ruoyi.txt, 返回: txt
-     * 
+     *
      * @param file 文件名
      * @return 后缀(不含".")
      */
-    public static String getFileType(File file)
-    {
-        if (null == file)
-        {
+    public static String getFileType(File file) {
+        if (null == file) {
             return StringUtils.EMPTY;
         }
         return getFileType(file.getName());
@@ -35,11 +33,9 @@ public class FileTypeUtils
      * @param fileName 文件名
      * @return 后缀(不含".")
      */
-    public static String getFileType(String fileName)
-    {
+    public static String getFileType(String fileName) {
         int separatorIndex = fileName.lastIndexOf(".");
-        if (separatorIndex < 0)
-        {
+        if (separatorIndex < 0) {
             return "";
         }
         return fileName.substring(separatorIndex + 1).toLowerCase();
@@ -47,28 +43,20 @@ public class FileTypeUtils
 
     /**
      * 获取文件类型
-     * 
+     *
      * @param photoByte 文件字节码
      * @return 后缀(不含".")
      */
-    public static String getFileExtendName(byte[] photoByte)
-    {
+    public static String getFileExtendName(byte[] photoByte) {
         String strFileExtendName = "JPG";
         if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
-                && ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97))
-        {
+                && ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97)) {
             strFileExtendName = "GIF";
-        }
-        else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70))
-        {
+        } else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70)) {
             strFileExtendName = "JPG";
-        }
-        else if ((photoByte[0] == 66) && (photoByte[1] == 77))
-        {
+        } else if ((photoByte[0] == 66) && (photoByte[1] == 77)) {
             strFileExtendName = "BMP";
-        }
-        else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71))
-        {
+        } else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71)) {
             strFileExtendName = "PNG";
         }
         return strFileExtendName;

+ 42 - 76
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java

@@ -1,11 +1,5 @@
 package com.ruoyi.common.utils.file;
 
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Paths;
-import java.util.Objects;
-import org.apache.commons.io.FilenameUtils;
-import org.springframework.web.multipart.MultipartFile;
 import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.exception.file.FileNameLengthLimitExceededException;
@@ -14,14 +8,20 @@ import com.ruoyi.common.exception.file.InvalidExtensionException;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.uuid.Seq;
+import org.apache.commons.io.FilenameUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Paths;
+import java.util.Objects;
 
 /**
  * 文件上传工具类
  *
  * @author ruoyi
  */
-public class FileUploadUtils
-{
+public class FileUploadUtils {
     /**
      * 默认大小 50M
      */
@@ -37,13 +37,11 @@ public class FileUploadUtils
      */
     private static String defaultBaseDir = RuoYiConfig.getProfile();
 
-    public static void setDefaultBaseDir(String defaultBaseDir)
-    {
+    public static void setDefaultBaseDir(String defaultBaseDir) {
         FileUploadUtils.defaultBaseDir = defaultBaseDir;
     }
 
-    public static String getDefaultBaseDir()
-    {
+    public static String getDefaultBaseDir() {
         return defaultBaseDir;
     }
 
@@ -54,14 +52,10 @@ public class FileUploadUtils
      * @return 文件名称
      * @throws Exception
      */
-    public static final String upload(MultipartFile file) throws IOException
-    {
-        try
-        {
+    public static final String upload(MultipartFile file) throws IOException {
+        try {
             return upload(getDefaultBaseDir(), file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             throw new IOException(e.getMessage(), e);
         }
     }
@@ -70,18 +64,14 @@ public class FileUploadUtils
      * 根据文件路径上传
      *
      * @param baseDir 相对应用的基目录
-     * @param file 上传的文件
+     * @param file    上传的文件
      * @return 文件名称
      * @throws IOException
      */
-    public static final String upload(String baseDir, MultipartFile file) throws IOException
-    {
-        try
-        {
+    public static final String upload(String baseDir, MultipartFile file) throws IOException {
+        try {
             return upload(baseDir, file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             throw new IOException(e.getMessage(), e);
         }
     }
@@ -89,22 +79,20 @@ public class FileUploadUtils
     /**
      * 文件上传
      *
-     * @param baseDir 相对应用的基目录
-     * @param file 上传的文件
+     * @param baseDir          相对应用的基目录
+     * @param file             上传的文件
      * @param allowedExtension 上传文件类型
      * @return 返回上传成功的文件名
-     * @throws FileSizeLimitExceededException 如果超出最大大小
+     * @throws FileSizeLimitExceededException       如果超出最大大小
      * @throws FileNameLengthLimitExceededException 文件名太长
-     * @throws IOException 比如读写文件出错时
-     * @throws InvalidExtensionException 文件校验异常
+     * @throws IOException                          比如读写文件出错时
+     * @throws InvalidExtensionException            文件校验异常
      */
     public static final String upload(String baseDir, MultipartFile file, String[] allowedExtension)
             throws FileSizeLimitExceededException, IOException, FileNameLengthLimitExceededException,
-            InvalidExtensionException
-    {
+            InvalidExtensionException {
         int fileNamelength = Objects.requireNonNull(file.getOriginalFilename()).length();
-        if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH)
-        {
+        if (fileNamelength > FileUploadUtils.DEFAULT_FILE_NAME_LENGTH) {
             throw new FileNameLengthLimitExceededException(FileUploadUtils.DEFAULT_FILE_NAME_LENGTH);
         }
 
@@ -120,28 +108,23 @@ public class FileUploadUtils
     /**
      * 编码文件名
      */
-    public static final String extractFilename(MultipartFile file)
-    {
+    public static final String extractFilename(MultipartFile file) {
         return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
                 FilenameUtils.getBaseName(file.getOriginalFilename()), Seq.getId(Seq.uploadSeqType), getExtension(file));
     }
 
-    public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException
-    {
+    public static final File getAbsoluteFile(String uploadDir, String fileName) throws IOException {
         File desc = new File(uploadDir + File.separator + fileName);
 
-        if (!desc.exists())
-        {
-            if (!desc.getParentFile().exists())
-            {
+        if (!desc.exists()) {
+            if (!desc.getParentFile().exists()) {
                 desc.getParentFile().mkdirs();
             }
         }
         return desc;
     }
 
-    public static final String getPathFileName(String uploadDir, String fileName) throws IOException
-    {
+    public static final String getPathFileName(String uploadDir, String fileName) throws IOException {
         int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
         String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
         return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
@@ -156,40 +139,28 @@ public class FileUploadUtils
      * @throws InvalidExtensionException
      */
     public static final void assertAllowed(MultipartFile file, String[] allowedExtension)
-            throws FileSizeLimitExceededException, InvalidExtensionException
-    {
+            throws FileSizeLimitExceededException, InvalidExtensionException {
         long size = file.getSize();
-        if (size > DEFAULT_MAX_SIZE)
-        {
+        if (size > DEFAULT_MAX_SIZE) {
             throw new FileSizeLimitExceededException(DEFAULT_MAX_SIZE / 1024 / 1024);
         }
 
         String fileName = file.getOriginalFilename();
         String extension = getExtension(file);
-        if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension))
-        {
-            if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION)
-            {
+        if (allowedExtension != null && !isAllowedExtension(extension, allowedExtension)) {
+            if (allowedExtension == MimeTypeUtils.IMAGE_EXTENSION) {
                 throw new InvalidExtensionException.InvalidImageExtensionException(allowedExtension, extension,
                         fileName);
-            }
-            else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION)
-            {
+            } else if (allowedExtension == MimeTypeUtils.FLASH_EXTENSION) {
                 throw new InvalidExtensionException.InvalidFlashExtensionException(allowedExtension, extension,
                         fileName);
-            }
-            else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION)
-            {
+            } else if (allowedExtension == MimeTypeUtils.MEDIA_EXTENSION) {
                 throw new InvalidExtensionException.InvalidMediaExtensionException(allowedExtension, extension,
                         fileName);
-            }
-            else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION)
-            {
+            } else if (allowedExtension == MimeTypeUtils.VIDEO_EXTENSION) {
                 throw new InvalidExtensionException.InvalidVideoExtensionException(allowedExtension, extension,
                         fileName);
-            }
-            else
-            {
+            } else {
                 throw new InvalidExtensionException(allowedExtension, extension, fileName);
             }
         }
@@ -202,12 +173,9 @@ public class FileUploadUtils
      * @param allowedExtension
      * @return
      */
-    public static final boolean isAllowedExtension(String extension, String[] allowedExtension)
-    {
-        for (String str : allowedExtension)
-        {
-            if (str.equalsIgnoreCase(extension))
-            {
+    public static final boolean isAllowedExtension(String extension, String[] allowedExtension) {
+        for (String str : allowedExtension) {
+            if (str.equalsIgnoreCase(extension)) {
                 return true;
             }
         }
@@ -220,11 +188,9 @@ public class FileUploadUtils
      * @param file 表单文件
      * @return 后缀名
      */
-    public static final String getExtension(MultipartFile file)
-    {
+    public static final String getExtension(MultipartFile file) {
         String extension = FilenameUtils.getExtension(file.getOriginalFilename());
-        if (StringUtils.isEmpty(extension))
-        {
+        if (StringUtils.isEmpty(extension)) {
             extension = MimeTypeUtils.getExtension(Objects.requireNonNull(file.getContentType()));
         }
         return extension;

+ 54 - 101
ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java

@@ -1,64 +1,50 @@
 package com.ruoyi.common.utils.file;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.apache.commons.io.IOUtils;
-import org.apache.commons.lang3.ArrayUtils;
 import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.utils.DateUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.uuid.IdUtils;
 import org.apache.commons.io.FilenameUtils;
+import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.ArrayUtils;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
+import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
 
 /**
  * 文件处理工具类
- * 
+ *
  * @author ruoyi
  */
-public class FileUtils
-{
+public class FileUtils {
     public static String FILENAME_PATTERN = "[a-zA-Z0-9_\\-\\|\\.\\u4e00-\\u9fa5]+";
 
     /**
      * 输出指定文件的byte数组
-     * 
+     *
      * @param filePath 文件路径
-     * @param os 输出流
+     * @param os       输出流
      * @return
      */
-    public static void writeBytes(String filePath, OutputStream os) throws IOException
-    {
+    public static void writeBytes(String filePath, OutputStream os) throws IOException {
         FileInputStream fis = null;
-        try
-        {
+        try {
             File file = new File(filePath);
-            if (!file.exists())
-            {
+            if (!file.exists()) {
                 throw new FileNotFoundException(filePath);
             }
             fis = new FileInputStream(file);
             byte[] b = new byte[1024];
             int length;
-            while ((length = fis.read(b)) > 0)
-            {
+            while ((length = fis.read(b)) > 0) {
                 os.write(b, 0, length);
             }
-        }
-        catch (IOException e)
-        {
+        } catch (IOException e) {
             throw e;
-        }
-        finally
-        {
+        } finally {
             IOUtils.close(os);
             IOUtils.close(fis);
         }
@@ -71,33 +57,28 @@ public class FileUtils
      * @return 目标文件
      * @throws IOException IO异常
      */
-    public static String writeImportBytes(byte[] data) throws IOException
-    {
+    public static String writeImportBytes(byte[] data) throws IOException {
         return writeBytes(data, RuoYiConfig.getImportPath());
     }
 
     /**
      * 写数据到文件中
      *
-     * @param data 数据
+     * @param data      数据
      * @param uploadDir 目标文件
      * @return 目标文件
      * @throws IOException IO异常
      */
-    public static String writeBytes(byte[] data, String uploadDir) throws IOException
-    {
+    public static String writeBytes(byte[] data, String uploadDir) throws IOException {
         FileOutputStream fos = null;
         String pathName = "";
-        try
-        {
+        try {
             String extension = getFileExtendName(data);
             pathName = DateUtils.datePath() + "/" + IdUtils.fastUUID() + "." + extension;
             File file = FileUploadUtils.getAbsoluteFile(uploadDir, pathName);
             fos = new FileOutputStream(file);
             fos.write(data);
-        }
-        finally
-        {
+        } finally {
             IOUtils.close(fos);
         }
         return FileUploadUtils.getPathFileName(uploadDir, pathName);
@@ -105,17 +86,15 @@ public class FileUtils
 
     /**
      * 删除文件
-     * 
+     *
      * @param filePath 文件
      * @return
      */
-    public static boolean deleteFile(String filePath)
-    {
+    public static boolean deleteFile(String filePath) {
         boolean flag = false;
         File file = new File(filePath);
         // 路径为文件且不为空则进行删除
-        if (file.isFile() && file.exists())
-        {
+        if (file.isFile() && file.exists()) {
             flag = file.delete();
         }
         return flag;
@@ -123,32 +102,28 @@ public class FileUtils
 
     /**
      * 文件名称验证
-     * 
+     *
      * @param filename 文件名称
      * @return true 正常 false 非法
      */
-    public static boolean isValidFilename(String filename)
-    {
+    public static boolean isValidFilename(String filename) {
         return filename.matches(FILENAME_PATTERN);
     }
 
     /**
      * 检查文件是否可下载
-     * 
+     *
      * @param resource 需要下载的文件
      * @return true 正常 false 非法
      */
-    public static boolean checkAllowDownload(String resource)
-    {
+    public static boolean checkAllowDownload(String resource) {
         // 禁止目录上跳级别
-        if (StringUtils.contains(resource, ".."))
-        {
+        if (StringUtils.contains(resource, "..")) {
             return false;
         }
 
         // 检查允许下载的文件规则
-        if (ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource)))
-        {
+        if (ArrayUtils.contains(MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION, FileTypeUtils.getFileType(resource))) {
             return true;
         }
 
@@ -158,33 +133,25 @@ public class FileUtils
 
     /**
      * 下载文件名重新编码
-     * 
-     * @param request 请求对象
+     *
+     * @param request  请求对象
      * @param fileName 文件名
      * @return 编码后的文件名
      */
-    public static String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException
-    {
+    public static String setFileDownloadHeader(HttpServletRequest request, String fileName) throws UnsupportedEncodingException {
         final String agent = request.getHeader("USER-AGENT");
         String filename = fileName;
-        if (agent.contains("MSIE"))
-        {
+        if (agent.contains("MSIE")) {
             // IE浏览器
             filename = URLEncoder.encode(filename, "utf-8");
             filename = filename.replace("+", " ");
-        }
-        else if (agent.contains("Firefox"))
-        {
+        } else if (agent.contains("Firefox")) {
             // 火狐浏览器
             filename = new String(fileName.getBytes(), "ISO8859-1");
-        }
-        else if (agent.contains("Chrome"))
-        {
+        } else if (agent.contains("Chrome")) {
             // google浏览器
             filename = URLEncoder.encode(filename, "utf-8");
-        }
-        else
-        {
+        } else {
             // 其它浏览器
             filename = URLEncoder.encode(filename, "utf-8");
         }
@@ -194,11 +161,10 @@ public class FileUtils
     /**
      * 下载文件名重新编码
      *
-     * @param response 响应对象
+     * @param response     响应对象
      * @param realFileName 真实文件名
      */
-    public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException
-    {
+    public static void setAttachmentResponseHeader(HttpServletResponse response, String realFileName) throws UnsupportedEncodingException {
         String percentEncodedFileName = percentEncode(realFileName);
 
         StringBuilder contentDispositionValue = new StringBuilder();
@@ -220,36 +186,27 @@ public class FileUtils
      * @param s 需要百分号编码的字符串
      * @return 百分号编码后的字符串
      */
-    public static String percentEncode(String s) throws UnsupportedEncodingException
-    {
+    public static String percentEncode(String s) throws UnsupportedEncodingException {
         String encode = URLEncoder.encode(s, StandardCharsets.UTF_8.toString());
         return encode.replaceAll("\\+", "%20");
     }
 
     /**
      * 获取图像后缀
-     * 
+     *
      * @param photoByte 图像数据
      * @return 后缀名
      */
-    public static String getFileExtendName(byte[] photoByte)
-    {
+    public static String getFileExtendName(byte[] photoByte) {
         String strFileExtendName = "jpg";
         if ((photoByte[0] == 71) && (photoByte[1] == 73) && (photoByte[2] == 70) && (photoByte[3] == 56)
-                && ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97))
-        {
+                && ((photoByte[4] == 55) || (photoByte[4] == 57)) && (photoByte[5] == 97)) {
             strFileExtendName = "gif";
-        }
-        else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70))
-        {
+        } else if ((photoByte[6] == 74) && (photoByte[7] == 70) && (photoByte[8] == 73) && (photoByte[9] == 70)) {
             strFileExtendName = "jpg";
-        }
-        else if ((photoByte[0] == 66) && (photoByte[1] == 77))
-        {
+        } else if ((photoByte[0] == 66) && (photoByte[1] == 77)) {
             strFileExtendName = "bmp";
-        }
-        else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71))
-        {
+        } else if ((photoByte[1] == 80) && (photoByte[2] == 78) && (photoByte[3] == 71)) {
             strFileExtendName = "png";
         }
         return strFileExtendName;
@@ -257,14 +214,12 @@ public class FileUtils
 
     /**
      * 获取文件名称 /profile/upload/2022/04/16/ruoyi.png -- ruoyi.png
-     * 
+     *
      * @param fileName 路径名称
      * @return 没有文件路径的名称
      */
-    public static String getName(String fileName)
-    {
-        if (fileName == null)
-        {
+    public static String getName(String fileName) {
+        if (fileName == null) {
             return null;
         }
         int lastUnixPos = fileName.lastIndexOf('/');
@@ -275,14 +230,12 @@ public class FileUtils
 
     /**
      * 获取不带后缀文件名称 /profile/upload/2022/04/16/ruoyi.png -- ruoyi
-     * 
+     *
      * @param fileName 路径名称
      * @return 没有文件路径和后缀的名称
      */
-    public static String getNameNotSuffix(String fileName)
-    {
-        if (fileName == null)
-        {
+    public static String getNameNotSuffix(String fileName) {
+        if (fileName == null) {
             return null;
         }
         String baseName = FilenameUtils.getBaseName(fileName);

+ 30 - 57
ruoyi-common/src/main/java/com/ruoyi/common/utils/html/EscapeUtil.java

@@ -4,20 +4,17 @@ import com.ruoyi.common.utils.StringUtils;
 
 /**
  * 转义和反转义工具类
- * 
+ *
  * @author ruoyi
  */
-public class EscapeUtil
-{
+public class EscapeUtil {
     public static final String RE_HTML_MARK = "(<[^<]*?>)|(<[\\s]*?/[^<]*?>)|(<[^<]*?/[\\s]*?>)";
 
     private static final char[][] TEXT = new char[64][];
 
-    static
-    {
-        for (int i = 0; i < 64; i++)
-        {
-            TEXT[i] = new char[] { (char) i };
+    static {
+        for (int i = 0; i < 64; i++) {
+            TEXT[i] = new char[]{(char) i};
         }
 
         // special HTML characters
@@ -30,69 +27,58 @@ public class EscapeUtil
 
     /**
      * 转义文本中的HTML字符为安全的字符
-     * 
+     *
      * @param text 被转义的文本
      * @return 转义后的文本
      */
-    public static String escape(String text)
-    {
+    public static String escape(String text) {
         return encode(text);
     }
 
     /**
      * 还原被转义的HTML特殊字符
-     * 
+     *
      * @param content 包含转义符的HTML内容
      * @return 转换后的字符串
      */
-    public static String unescape(String content)
-    {
+    public static String unescape(String content) {
         return decode(content);
     }
 
     /**
      * 清除所有HTML标签,但是不删除标签内的内容
-     * 
+     *
      * @param content 文本
      * @return 清除标签后的文本
      */
-    public static String clean(String content)
-    {
+    public static String clean(String content) {
         return new HTMLFilter().filter(content);
     }
 
     /**
      * Escape编码
-     * 
+     *
      * @param text 被编码的文本
      * @return 编码后的字符
      */
-    private static String encode(String text)
-    {
-        if (StringUtils.isEmpty(text))
-        {
+    private static String encode(String text) {
+        if (StringUtils.isEmpty(text)) {
             return StringUtils.EMPTY;
         }
 
         final StringBuilder tmp = new StringBuilder(text.length() * 6);
         char c;
-        for (int i = 0; i < text.length(); i++)
-        {
+        for (int i = 0; i < text.length(); i++) {
             c = text.charAt(i);
-            if (c < 256)
-            {
+            if (c < 256) {
                 tmp.append("%");
-                if (c < 16)
-                {
+                if (c < 16) {
                     tmp.append("0");
                 }
                 tmp.append(Integer.toString(c, 16));
-            }
-            else
-            {
+            } else {
                 tmp.append("%u");
-                if (c <= 0xfff)
-                {
+                if (c <= 0xfff) {
                     // issue#I49JU8@Gitee
                     tmp.append("0");
                 }
@@ -104,47 +90,35 @@ public class EscapeUtil
 
     /**
      * Escape解码
-     * 
+     *
      * @param content 被转义的内容
      * @return 解码后的字符串
      */
-    public static String decode(String content)
-    {
-        if (StringUtils.isEmpty(content))
-        {
+    public static String decode(String content) {
+        if (StringUtils.isEmpty(content)) {
             return content;
         }
 
         StringBuilder tmp = new StringBuilder(content.length());
         int lastPos = 0, pos = 0;
         char ch;
-        while (lastPos < content.length())
-        {
+        while (lastPos < content.length()) {
             pos = content.indexOf("%", lastPos);
-            if (pos == lastPos)
-            {
-                if (content.charAt(pos + 1) == 'u')
-                {
+            if (pos == lastPos) {
+                if (content.charAt(pos + 1) == 'u') {
                     ch = (char) Integer.parseInt(content.substring(pos + 2, pos + 6), 16);
                     tmp.append(ch);
                     lastPos = pos + 6;
-                }
-                else
-                {
+                } else {
                     ch = (char) Integer.parseInt(content.substring(pos + 1, pos + 3), 16);
                     tmp.append(ch);
                     lastPos = pos + 3;
                 }
-            }
-            else
-            {
-                if (pos == -1)
-                {
+            } else {
+                if (pos == -1) {
                     tmp.append(content.substring(lastPos));
                     lastPos = content.length();
-                }
-                else
-                {
+                } else {
                     tmp.append(content.substring(lastPos, pos));
                     lastPos = pos;
                 }
@@ -153,8 +127,7 @@ public class EscapeUtil
         return tmp.toString();
     }
 
-    public static void main(String[] args)
-    {
+    public static void main(String[] args) {
         String html = "<script>alert(1);</script>";
         String escape = EscapeUtil.escape(html);
         // String html = "<scr<script>ipt>alert(\"XSS\")</scr<script>ipt>";

+ 10 - 18
ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java

@@ -1,21 +1,20 @@
 package com.ruoyi.common.utils.ip;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONObject;
 import com.ruoyi.common.config.RuoYiConfig;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.common.utils.http.HttpUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * 获取地址类
- * 
+ *
  * @author ruoyi
  */
-public class AddressUtils
-{
+public class AddressUtils {
     private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
 
     // IP地址查询
@@ -24,20 +23,15 @@ public class AddressUtils
     // 未知地址
     public static final String UNKNOWN = "XX XX";
 
-    public static String getRealAddressByIP(String ip)
-    {
+    public static String getRealAddressByIP(String ip) {
         // 内网不查询
-        if (IpUtils.internalIp(ip))
-        {
+        if (IpUtils.internalIp(ip)) {
             return "内网IP";
         }
-        if (RuoYiConfig.isAddressEnabled())
-        {
-            try
-            {
+        if (RuoYiConfig.isAddressEnabled()) {
+            try {
                 String rspStr = HttpUtils.sendGet(IP_URL, "ip=" + ip + "&json=true", Constants.GBK);
-                if (StringUtils.isEmpty(rspStr))
-                {
+                if (StringUtils.isEmpty(rspStr)) {
                     log.error("获取地理位置异常 {}", ip);
                     return UNKNOWN;
                 }
@@ -45,9 +39,7 @@ public class AddressUtils
                 String region = obj.getString("pro");
                 String city = obj.getString("city");
                 return String.format("%s %s", region, city);
-            }
-            catch (Exception e)
-            {
+            } catch (Exception e) {
                 log.error("获取地理位置异常 {}", ip);
             }
         }

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

@@ -2,17 +2,15 @@ package com.ruoyi.common.utils.poi;
 
 /**
  * Excel数据格式处理适配器
- * 
+ *
  * @author ruoyi
  */
-public interface ExcelHandlerAdapter
-{
+public interface ExcelHandlerAdapter {
     /**
      * 格式化
-     * 
-     * @param value 单元格数据值
-     * @param args excel注解args参数组
      *
+     * @param value 单元格数据值
+     * @param args  excel注解args参数组
      * @return 处理后的值
      */
     Object format(Object value, String[] args);

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 334 - 658
ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java


+ 46 - 84
ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Base64.java

@@ -2,75 +2,63 @@ package com.ruoyi.common.utils.sign;
 
 /**
  * Base64工具类
- * 
+ *
  * @author ruoyi
  */
-public final class Base64
-{
-    static private final int     BASELENGTH           = 128;
-    static private final int     LOOKUPLENGTH         = 64;
-    static private final int     TWENTYFOURBITGROUP   = 24;
-    static private final int     EIGHTBIT             = 8;
-    static private final int     SIXTEENBIT           = 16;
-    static private final int     FOURBYTE             = 4;
-    static private final int     SIGN                 = -128;
-    static private final char    PAD                  = '=';
-    static final private byte[]  base64Alphabet       = new byte[BASELENGTH];
-    static final private char[]  lookUpBase64Alphabet = new char[LOOKUPLENGTH];
-
-    static
-    {
-        for (int i = 0; i < BASELENGTH; ++i)
-        {
+public final class Base64 {
+    static private final int BASELENGTH = 128;
+    static private final int LOOKUPLENGTH = 64;
+    static private final int TWENTYFOURBITGROUP = 24;
+    static private final int EIGHTBIT = 8;
+    static private final int SIXTEENBIT = 16;
+    static private final int FOURBYTE = 4;
+    static private final int SIGN = -128;
+    static private final char PAD = '=';
+    static final private byte[] base64Alphabet = new byte[BASELENGTH];
+    static final private char[] lookUpBase64Alphabet = new char[LOOKUPLENGTH];
+
+    static {
+        for (int i = 0; i < BASELENGTH; ++i) {
             base64Alphabet[i] = -1;
         }
-        for (int i = 'Z'; i >= 'A'; i--)
-        {
+        for (int i = 'Z'; i >= 'A'; i--) {
             base64Alphabet[i] = (byte) (i - 'A');
         }
-        for (int i = 'z'; i >= 'a'; i--)
-        {
+        for (int i = 'z'; i >= 'a'; i--) {
             base64Alphabet[i] = (byte) (i - 'a' + 26);
         }
 
-        for (int i = '9'; i >= '0'; i--)
-        {
+        for (int i = '9'; i >= '0'; i--) {
             base64Alphabet[i] = (byte) (i - '0' + 52);
         }
 
         base64Alphabet['+'] = 62;
         base64Alphabet['/'] = 63;
 
-        for (int i = 0; i <= 25; i++)
-        {
+        for (int i = 0; i <= 25; i++) {
             lookUpBase64Alphabet[i] = (char) ('A' + i);
         }
 
-        for (int i = 26, j = 0; i <= 51; i++, j++)
-        {
+        for (int i = 26, j = 0; i <= 51; i++, j++) {
             lookUpBase64Alphabet[i] = (char) ('a' + j);
         }
 
-        for (int i = 52, j = 0; i <= 61; i++, j++)
-        {
+        for (int i = 52, j = 0; i <= 61; i++, j++) {
             lookUpBase64Alphabet[i] = (char) ('0' + j);
         }
         lookUpBase64Alphabet[62] = (char) '+';
         lookUpBase64Alphabet[63] = (char) '/';
     }
 
-    private static boolean isWhiteSpace(char octect)
-    {
+    private static boolean isWhiteSpace(char octect) {
         return (octect == 0x20 || octect == 0xd || octect == 0xa || octect == 0x9);
     }
 
-    private static boolean isPad(char octect)
-    {
+    private static boolean isPad(char octect) {
         return (octect == PAD);
     }
 
-    private static boolean isData(char octect)
-    {
+    private static boolean isData(char octect) {
         return (octect < BASELENGTH && base64Alphabet[octect] != -1);
     }
 
@@ -80,16 +68,13 @@ public final class Base64
      * @param binaryData Array containing binaryData
      * @return Encoded Base64 array
      */
-    public static String encode(byte[] binaryData)
-    {
-        if (binaryData == null)
-        {
+    public static String encode(byte[] binaryData) {
+        if (binaryData == null) {
             return null;
         }
 
         int lengthDataBits = binaryData.length * EIGHTBIT;
-        if (lengthDataBits == 0)
-        {
+        if (lengthDataBits == 0) {
             return "";
         }
 
@@ -105,8 +90,7 @@ public final class Base64
         int encodedIndex = 0;
         int dataIndex = 0;
 
-        for (int i = 0; i < numberTriplets; i++)
-        {
+        for (int i = 0; i < numberTriplets; i++) {
             b1 = binaryData[dataIndex++];
             b2 = binaryData[dataIndex++];
             b3 = binaryData[dataIndex++];
@@ -125,8 +109,7 @@ public final class Base64
         }
 
         // form integral number of 6-bit groups
-        if (fewerThan24bits == EIGHTBIT)
-        {
+        if (fewerThan24bits == EIGHTBIT) {
             b1 = binaryData[dataIndex];
             k = (byte) (b1 & 0x03);
             byte val1 = ((b1 & SIGN) == 0) ? (byte) (b1 >> 2) : (byte) ((b1) >> 2 ^ 0xc0);
@@ -134,9 +117,7 @@ public final class Base64
             encodedData[encodedIndex++] = lookUpBase64Alphabet[k << 4];
             encodedData[encodedIndex++] = PAD;
             encodedData[encodedIndex++] = PAD;
-        }
-        else if (fewerThan24bits == SIXTEENBIT)
-        {
+        } else if (fewerThan24bits == SIXTEENBIT) {
             b1 = binaryData[dataIndex];
             b2 = binaryData[dataIndex + 1];
             l = (byte) (b2 & 0x0f);
@@ -159,10 +140,8 @@ public final class Base64
      * @param encoded string containing Base64 data
      * @return Array containind decoded data.
      */
-    public static byte[] decode(String encoded)
-    {
-        if (encoded == null)
-        {
+    public static byte[] decode(String encoded) {
+        if (encoded == null) {
             return null;
         }
 
@@ -170,15 +149,13 @@ public final class Base64
         // remove white spaces
         int len = removeWhiteSpace(base64Data);
 
-        if (len % FOURBYTE != 0)
-        {
+        if (len % FOURBYTE != 0) {
             return null;// should be divisible by four
         }
 
         int numberQuadruple = (len / FOURBYTE);
 
-        if (numberQuadruple == 0)
-        {
+        if (numberQuadruple == 0) {
             return new byte[0];
         }
 
@@ -191,12 +168,10 @@ public final class Base64
         int dataIndex = 0;
         decodedData = new byte[(numberQuadruple) * 3];
 
-        for (; i < numberQuadruple - 1; i++)
-        {
+        for (; i < numberQuadruple - 1; i++) {
 
             if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))
-                    || !isData((d3 = base64Data[dataIndex++])) || !isData((d4 = base64Data[dataIndex++])))
-            {
+                    || !isData((d3 = base64Data[dataIndex++])) || !isData((d4 = base64Data[dataIndex++]))) {
                 return null;
             } // if found "no data" just return null
 
@@ -210,8 +185,7 @@ public final class Base64
             decodedData[encodedIndex++] = (byte) (b3 << 6 | b4);
         }
 
-        if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++])))
-        {
+        if (!isData((d1 = base64Data[dataIndex++])) || !isData((d2 = base64Data[dataIndex++]))) {
             return null;// if found "no data" just return null
         }
 
@@ -220,10 +194,8 @@ public final class Base64
 
         d3 = base64Data[dataIndex++];
         d4 = base64Data[dataIndex++];
-        if (!isData((d3)) || !isData((d4)))
-        {// Check if they are PAD characters
-            if (isPad(d3) && isPad(d4))
-            {
+        if (!isData((d3)) || !isData((d4))) {// Check if they are PAD characters
+            if (isPad(d3) && isPad(d4)) {
                 if ((b2 & 0xf) != 0)// last 4 bits should be zero
                 {
                     return null;
@@ -232,9 +204,7 @@ public final class Base64
                 System.arraycopy(decodedData, 0, tmp, 0, i * 3);
                 tmp[encodedIndex] = (byte) (b1 << 2 | b2 >> 4);
                 return tmp;
-            }
-            else if (!isPad(d3) && isPad(d4))
-            {
+            } else if (!isPad(d3) && isPad(d4)) {
                 b3 = base64Alphabet[d3];
                 if ((b3 & 0x3) != 0)// last 2 bits should be zero
                 {
@@ -245,14 +215,10 @@ public final class Base64
                 tmp[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
                 tmp[encodedIndex] = (byte) (((b2 & 0xf) << 4) | ((b3 >> 2) & 0xf));
                 return tmp;
-            }
-            else
-            {
+            } else {
                 return null;
             }
-        }
-        else
-        { // No PAD e.g 3cQl
+        } else { // No PAD e.g 3cQl
             b3 = base64Alphabet[d3];
             b4 = base64Alphabet[d4];
             decodedData[encodedIndex++] = (byte) (b1 << 2 | b2 >> 4);
@@ -269,20 +235,16 @@ public final class Base64
      * @param data the byte array of base64 data (with WS)
      * @return the new length
      */
-    private static int removeWhiteSpace(char[] data)
-    {
-        if (data == null)
-        {
+    private static int removeWhiteSpace(char[] data) {
+        if (data == null) {
             return 0;
         }
 
         // count characters that's not whitespace
         int newSize = 0;
         int len = data.length;
-        for (int i = 0; i < len; i++)
-        {
-            if (!isWhiteSpace(data[i]))
-            {
+        for (int i = 0; i < len; i++) {
+            if (!isWhiteSpace(data[i])) {
                 data[newSize++] = data[i];
             }
         }

+ 32 - 57
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java

@@ -1,11 +1,5 @@
 package com.ruoyi.framework.aspectj;
 
-import java.util.ArrayList;
-import java.util.List;
-import org.aspectj.lang.JoinPoint;
-import org.aspectj.lang.annotation.Aspect;
-import org.aspectj.lang.annotation.Before;
-import org.springframework.stereotype.Component;
 import com.ruoyi.common.annotation.DataScope;
 import com.ruoyi.common.core.domain.BaseEntity;
 import com.ruoyi.common.core.domain.entity.SysRole;
@@ -15,6 +9,13 @@ import com.ruoyi.common.core.text.Convert;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
 import com.ruoyi.framework.security.context.PermissionContextHolder;
+import org.aspectj.lang.JoinPoint;
+import org.aspectj.lang.annotation.Aspect;
+import org.aspectj.lang.annotation.Before;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * 数据过滤处理
@@ -23,8 +24,7 @@ import com.ruoyi.framework.security.context.PermissionContextHolder;
  */
 @Aspect
 @Component
-public class DataScopeAspect
-{
+public class DataScopeAspect {
     /**
      * 全部数据权限
      */
@@ -56,22 +56,18 @@ public class DataScopeAspect
     public static final String DATA_SCOPE = "dataScope";
 
     @Before("@annotation(controllerDataScope)")
-    public void doBefore(JoinPoint point, DataScope controllerDataScope) throws Throwable
-    {
+    public void doBefore(JoinPoint point, DataScope controllerDataScope) throws Throwable {
         clearDataScope(point);
         handleDataScope(point, controllerDataScope);
     }
 
-    protected void handleDataScope(final JoinPoint joinPoint, DataScope controllerDataScope)
-    {
+    protected void handleDataScope(final JoinPoint joinPoint, DataScope controllerDataScope) {
         // 获取当前的用户
         LoginUser loginUser = SecurityUtils.getLoginUser();
-        if (StringUtils.isNotNull(loginUser))
-        {
+        if (StringUtils.isNotNull(loginUser)) {
             SysUser currentUser = loginUser.getUser();
             // 如果是超级管理员,则不过滤数据
-            if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin())
-            {
+            if (StringUtils.isNotNull(currentUser) && !currentUser.isAdmin()) {
                 String permission = StringUtils.defaultIfEmpty(controllerDataScope.permission(), PermissionContextHolder.getContext());
                 dataScopeFilter(joinPoint, currentUser, controllerDataScope.deptAlias(),
                         controllerDataScope.userAlias(), permission);
@@ -82,59 +78,43 @@ public class DataScopeAspect
     /**
      * 数据范围过滤
      *
-     * @param joinPoint 切点
-     * @param user 用户
-     * @param deptAlias 部门别名
-     * @param userAlias 用户别名
+     * @param joinPoint  切点
+     * @param user       用户
+     * @param deptAlias  部门别名
+     * @param userAlias  用户别名
      * @param permission 权限字符
      */
-    public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias, String permission)
-    {
+    public static void dataScopeFilter(JoinPoint joinPoint, SysUser user, String deptAlias, String userAlias, String permission) {
         StringBuilder sqlString = new StringBuilder();
         List<String> conditions = new ArrayList<String>();
 
-        for (SysRole role : user.getRoles())
-        {
+        for (SysRole role : user.getRoles()) {
             String dataScope = role.getDataScope();
-            if (!DATA_SCOPE_CUSTOM.equals(dataScope) && conditions.contains(dataScope))
-            {
+            if (!DATA_SCOPE_CUSTOM.equals(dataScope) && conditions.contains(dataScope)) {
                 continue;
             }
             if (StringUtils.isNotEmpty(permission) && StringUtils.isNotEmpty(role.getPermissions())
-                    && !StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission)))
-            {
+                    && !StringUtils.containsAny(role.getPermissions(), Convert.toStrArray(permission))) {
                 continue;
             }
-            if (DATA_SCOPE_ALL.equals(dataScope))
-            {
+            if (DATA_SCOPE_ALL.equals(dataScope)) {
                 sqlString = new StringBuilder();
                 conditions.add(dataScope);
                 break;
-            }
-            else if (DATA_SCOPE_CUSTOM.equals(dataScope))
-            {
+            } else if (DATA_SCOPE_CUSTOM.equals(dataScope)) {
                 sqlString.append(StringUtils.format(
                         " OR {}.dept_id IN ( SELECT dept_id FROM sys_role_dept WHERE role_id = {} ) ", deptAlias,
                         role.getRoleId()));
-            }
-            else if (DATA_SCOPE_DEPT.equals(dataScope))
-            {
+            } else if (DATA_SCOPE_DEPT.equals(dataScope)) {
                 sqlString.append(StringUtils.format(" OR {}.dept_id = {} ", deptAlias, user.getDeptId()));
-            }
-            else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope))
-            {
+            } else if (DATA_SCOPE_DEPT_AND_CHILD.equals(dataScope)) {
                 sqlString.append(StringUtils.format(
                         " OR {}.dept_id IN ( SELECT dept_id FROM sys_dept WHERE dept_id = {} or find_in_set( {} , ancestors ) )",
                         deptAlias, user.getDeptId(), user.getDeptId()));
-            }
-            else if (DATA_SCOPE_SELF.equals(dataScope))
-            {
-                if (StringUtils.isNotBlank(userAlias))
-                {
+            } else if (DATA_SCOPE_SELF.equals(dataScope)) {
+                if (StringUtils.isNotBlank(userAlias)) {
                     sqlString.append(StringUtils.format(" OR {}.user_id = {} ", userAlias, user.getUserId()));
-                }
-                else
-                {
+                } else {
                     // 数据权限为仅本人且没有userAlias别名不查询任何数据
                     sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
                 }
@@ -143,16 +123,13 @@ public class DataScopeAspect
         }
 
         // 多角色情况下,所有角色都不包含传递过来的权限字符,这个时候sqlString也会为空,所以要限制一下,不查询任何数据
-        if (StringUtils.isEmpty(conditions))
-        {
+        if (StringUtils.isEmpty(conditions)) {
             sqlString.append(StringUtils.format(" OR {}.dept_id = 0 ", deptAlias));
         }
 
-        if (StringUtils.isNotBlank(sqlString.toString()))
-        {
+        if (StringUtils.isNotBlank(sqlString.toString())) {
             Object params = joinPoint.getArgs()[0];
-            if (StringUtils.isNotNull(params) && params instanceof BaseEntity)
-            {
+            if (StringUtils.isNotNull(params) && params instanceof BaseEntity) {
                 BaseEntity baseEntity = (BaseEntity) params;
                 baseEntity.getParams().put(DATA_SCOPE, " AND (" + sqlString.substring(4) + ")");
             }
@@ -162,11 +139,9 @@ public class DataScopeAspect
     /**
      * 拼接权限sql前先清空params.dataScope参数防止注入
      */
-    private void clearDataScope(final JoinPoint joinPoint)
-    {
+    private void clearDataScope(final JoinPoint joinPoint) {
         Object params = joinPoint.getArgs()[0];
-        if (StringUtils.isNotNull(params) && params instanceof BaseEntity)
-        {
+        if (StringUtils.isNotNull(params) && params instanceof BaseEntity) {
             BaseEntity baseEntity = (BaseEntity) params;
             baseEntity.getParams().put(DATA_SCOPE, "");
         }

+ 14 - 22
ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java

@@ -1,6 +1,8 @@
 package com.ruoyi.framework.aspectj;
 
-import java.util.Objects;
+import com.ruoyi.common.annotation.DataSource;
+import com.ruoyi.common.utils.StringUtils;
+import com.ruoyi.framework.datasource.DynamicDataSourceContextHolder;
 import org.aspectj.lang.ProceedingJoinPoint;
 import org.aspectj.lang.annotation.Around;
 import org.aspectj.lang.annotation.Aspect;
@@ -11,45 +13,37 @@ import org.slf4j.LoggerFactory;
 import org.springframework.core.annotation.AnnotationUtils;
 import org.springframework.core.annotation.Order;
 import org.springframework.stereotype.Component;
-import com.ruoyi.common.annotation.DataSource;
-import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.framework.datasource.DynamicDataSourceContextHolder;
+
+import java.util.Objects;
 
 /**
  * 多数据源处理
- * 
+ *
  * @author ruoyi
  */
 @Aspect
 @Order(1)
 @Component
-public class DataSourceAspect
-{
+public class DataSourceAspect {
     protected Logger logger = LoggerFactory.getLogger(getClass());
 
     @Pointcut("@annotation(com.ruoyi.common.annotation.DataSource)"
             + "|| @within(com.ruoyi.common.annotation.DataSource)")
-    public void dsPointCut()
-    {
+    public void dsPointCut() {
 
     }
 
     @Around("dsPointCut()")
-    public Object around(ProceedingJoinPoint point) throws Throwable
-    {
+    public Object around(ProceedingJoinPoint point) throws Throwable {
         DataSource dataSource = getDataSource(point);
 
-        if (StringUtils.isNotNull(dataSource))
-        {
+        if (StringUtils.isNotNull(dataSource)) {
             DynamicDataSourceContextHolder.setDataSourceType(dataSource.value().name());
         }
 
-        try
-        {
+        try {
             return point.proceed();
-        }
-        finally
-        {
+        } finally {
             // 销毁数据源 在执行方法之后
             DynamicDataSourceContextHolder.clearDataSourceType();
         }
@@ -58,12 +52,10 @@ public class DataSourceAspect
     /**
      * 获取需要切换的数据源
      */
-    public DataSource getDataSource(ProceedingJoinPoint point)
-    {
+    public DataSource getDataSource(ProceedingJoinPoint point) {
         MethodSignature signature = (MethodSignature) point.getSignature();
         DataSource dataSource = AnnotationUtils.findAnnotation(signature.getMethod(), DataSource.class);
-        if (Objects.nonNull(dataSource))
-        {
+        if (Objects.nonNull(dataSource)) {
             return dataSource;
         }
 

+ 4 - 5
ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java

@@ -1,12 +1,13 @@
 package com.ruoyi.framework.config;
 
-import java.util.TimeZone;
 import org.mybatis.spring.annotation.MapperScan;
 import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.EnableAspectJAutoProxy;
 
+import java.util.TimeZone;
+
 /**
  * 程序注解配置
  *
@@ -17,14 +18,12 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy;
 @EnableAspectJAutoProxy(exposeProxy = true)
 // 指定要扫描的Mapper类的包的路径
 @MapperScan("com.ruoyi.**.mapper")
-public class ApplicationConfig
-{
+public class ApplicationConfig {
     /**
      * 时区配置
      */
     @Bean
-    public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization()
-    {
+    public Jackson2ObjectMapperBuilderCustomizer jacksonObjectMapperCustomization() {
         return jacksonObjectMapperBuilder -> jacksonObjectMapperBuilder.timeZone(TimeZone.getDefault());
     }
 }

+ 9 - 10
ruoyi-framework/src/main/java/com/ruoyi/framework/config/CaptchaConfig.java

@@ -1,23 +1,23 @@
 package com.ruoyi.framework.config;
 
-import java.util.Properties;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
 import com.google.code.kaptcha.impl.DefaultKaptcha;
 import com.google.code.kaptcha.util.Config;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Properties;
+
 import static com.google.code.kaptcha.Constants.*;
 
 /**
  * 验证码配置
- * 
+ *
  * @author ruoyi
  */
 @Configuration
-public class CaptchaConfig
-{
+public class CaptchaConfig {
     @Bean(name = "captchaProducer")
-    public DefaultKaptcha getKaptchaBean()
-    {
+    public DefaultKaptcha getKaptchaBean() {
         DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
         Properties properties = new Properties();
         // 是否有边框 默认为true 我们可以自己设置yes,no
@@ -44,8 +44,7 @@ public class CaptchaConfig
     }
 
     @Bean(name = "captchaProducerMath")
-    public DefaultKaptcha getKaptchaBeanMath()
-    {
+    public DefaultKaptcha getKaptchaBeanMath() {
         DefaultKaptcha defaultKaptcha = new DefaultKaptcha();
         Properties properties = new Properties();
         // 是否有边框 默认为true 我们可以自己设置yes,no

+ 32 - 46
ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java

@@ -1,20 +1,5 @@
 package com.ruoyi.framework.config;
 
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import javax.servlet.Filter;
-import javax.servlet.FilterChain;
-import javax.servlet.ServletException;
-import javax.servlet.ServletRequest;
-import javax.servlet.ServletResponse;
-import javax.sql.DataSource;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.boot.web.servlet.FilterRegistrationBean;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Primary;
 import com.alibaba.druid.pool.DruidDataSource;
 import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder;
 import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties;
@@ -23,19 +8,29 @@ import com.ruoyi.common.enums.DataSourceType;
 import com.ruoyi.common.utils.spring.SpringUtils;
 import com.ruoyi.framework.config.properties.DruidProperties;
 import com.ruoyi.framework.datasource.DynamicDataSource;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Primary;
+
+import javax.servlet.*;
+import javax.sql.DataSource;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * druid 配置多数据源
- * 
+ *
  * @author ruoyi
  */
 @Configuration
-public class DruidConfig
-{
+public class DruidConfig {
     @Bean
     @ConfigurationProperties("spring.datasource.druid.master")
-    public DataSource masterDataSource(DruidProperties druidProperties)
-    {
+    public DataSource masterDataSource(DruidProperties druidProperties) {
         DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
         return druidProperties.dataSource(dataSource);
     }
@@ -43,38 +38,32 @@ public class DruidConfig
     @Bean
     @ConfigurationProperties("spring.datasource.druid.slave")
     @ConditionalOnProperty(prefix = "spring.datasource.druid.slave", name = "enabled", havingValue = "true")
-    public DataSource slaveDataSource(DruidProperties druidProperties)
-    {
+    public DataSource slaveDataSource(DruidProperties druidProperties) {
         DruidDataSource dataSource = DruidDataSourceBuilder.create().build();
         return druidProperties.dataSource(dataSource);
     }
 
     @Bean(name = "dynamicDataSource")
     @Primary
-    public DynamicDataSource dataSource(DataSource masterDataSource)
-    {
+    public DynamicDataSource dataSource(DataSource masterDataSource) {
         Map<Object, Object> targetDataSources = new HashMap<>();
         targetDataSources.put(DataSourceType.MASTER.name(), masterDataSource);
         setDataSource(targetDataSources, DataSourceType.SLAVE.name(), "slaveDataSource");
         return new DynamicDataSource(masterDataSource, targetDataSources);
     }
-    
+
     /**
      * 设置数据源
-     * 
+     *
      * @param targetDataSources 备选数据源集合
-     * @param sourceName 数据源名称
-     * @param beanName bean名称
+     * @param sourceName        数据源名称
+     * @param beanName          bean名称
      */
-    public void setDataSource(Map<Object, Object> targetDataSources, String sourceName, String beanName)
-    {
-        try
-        {
+    public void setDataSource(Map<Object, Object> targetDataSources, String sourceName, String beanName) {
+        try {
             DataSource dataSource = SpringUtils.getBean(beanName);
             targetDataSources.put(sourceName, dataSource);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             e.printStackTrace();
         }
     }
@@ -82,11 +71,10 @@ public class DruidConfig
     /**
      * 去除监控页面底部的广告
      */
-    @SuppressWarnings({ "rawtypes", "unchecked" })
+    @SuppressWarnings({"rawtypes", "unchecked"})
     @Bean
     @ConditionalOnProperty(name = "spring.datasource.druid.statViewServlet.enabled", havingValue = "true")
-    public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties)
-    {
+    public FilterRegistrationBean removeDruidFilterRegistrationBean(DruidStatProperties properties) {
         // 获取web监控页面的参数
         DruidStatProperties.StatViewServlet config = properties.getStatViewServlet();
         // 提取common.js的配置路径
@@ -94,16 +82,14 @@ public class DruidConfig
         String commonJsPattern = pattern.replaceAll("\\*", "js/common.js");
         final String filePath = "support/http/resources/js/common.js";
         // 创建filter进行过滤
-        Filter filter = new Filter()
-        {
+        Filter filter = new Filter() {
             @Override
-            public void init(javax.servlet.FilterConfig filterConfig) throws ServletException
-            {
+            public void init(javax.servlet.FilterConfig filterConfig) throws ServletException {
             }
+
             @Override
             public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
-                    throws IOException, ServletException
-            {
+                    throws IOException, ServletException {
                 chain.doFilter(request, response);
                 // 重置缓冲区,响应头不会被重置
                 response.resetBuffer();
@@ -114,9 +100,9 @@ public class DruidConfig
                 text = text.replaceAll("powered.*?shrek.wang</a>", "");
                 response.getWriter().write(text);
             }
+
             @Override
-            public void destroy()
-            {
+            public void destroy() {
             }
         };
         FilterRegistrationBean registrationBean = new FilterRegistrationBean();

+ 11 - 16
ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java

@@ -1,44 +1,39 @@
 package com.ruoyi.framework.config;
 
-import java.nio.charset.Charset;
-import org.springframework.data.redis.serializer.RedisSerializer;
-import org.springframework.data.redis.serializer.SerializationException;
 import com.alibaba.fastjson2.JSON;
 import com.alibaba.fastjson2.JSONReader;
 import com.alibaba.fastjson2.JSONWriter;
+import org.springframework.data.redis.serializer.RedisSerializer;
+import org.springframework.data.redis.serializer.SerializationException;
+
+import java.nio.charset.Charset;
 
 /**
  * Redis使用FastJson序列化
- * 
+ *
  * @author ruoyi
  */
-public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T>
-{
+public class FastJson2JsonRedisSerializer<T> implements RedisSerializer<T> {
     public static final Charset DEFAULT_CHARSET = Charset.forName("UTF-8");
 
     private Class<T> clazz;
 
-    public FastJson2JsonRedisSerializer(Class<T> clazz)
-    {
+    public FastJson2JsonRedisSerializer(Class<T> clazz) {
         super();
         this.clazz = clazz;
     }
 
     @Override
-    public byte[] serialize(T t) throws SerializationException
-    {
-        if (t == null)
-        {
+    public byte[] serialize(T t) throws SerializationException {
+        if (t == null) {
             return new byte[0];
         }
         return JSON.toJSONString(t, JSONWriter.Feature.WriteClassName).getBytes(DEFAULT_CHARSET);
     }
 
     @Override
-    public T deserialize(byte[] bytes) throws SerializationException
-    {
-        if (bytes == null || bytes.length <= 0)
-        {
+    public T deserialize(byte[] bytes) throws SerializationException {
+        if (bytes == null || bytes.length <= 0) {
             return null;
         }
         String str = new String(bytes, DEFAULT_CHARSET);

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

@@ -1,16 +1,17 @@
 package com.ruoyi.framework.config;
 
-import java.util.HashMap;
-import java.util.Map;
-import javax.servlet.DispatcherType;
+import com.ruoyi.common.filter.RepeatableFilter;
+import com.ruoyi.common.filter.XssFilter;
+import com.ruoyi.common.utils.StringUtils;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.boot.web.servlet.FilterRegistrationBean;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
-import com.ruoyi.common.filter.RepeatableFilter;
-import com.ruoyi.common.filter.XssFilter;
-import com.ruoyi.common.utils.StringUtils;
+
+import javax.servlet.DispatcherType;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * Filter配置
@@ -18,19 +19,17 @@ import com.ruoyi.common.utils.StringUtils;
  * @author ruoyi
  */
 @Configuration
-public class FilterConfig
-{
+public class FilterConfig {
     @Value("${xss.excludes:''}")
     private String excludes;
 
     @Value("${xss.urlPatterns:''}")
     private String urlPatterns;
 
-    @SuppressWarnings({ "rawtypes", "unchecked" })
+    @SuppressWarnings({"rawtypes", "unchecked"})
     @Bean
     @ConditionalOnProperty(value = "xss.enabled", havingValue = "true")
-    public FilterRegistrationBean xssFilterRegistration()
-    {
+    public FilterRegistrationBean xssFilterRegistration() {
         FilterRegistrationBean registration = new FilterRegistrationBean();
         registration.setDispatcherTypes(DispatcherType.REQUEST);
         registration.setFilter(new XssFilter());
@@ -43,10 +42,9 @@ public class FilterConfig
         return registration;
     }
 
-    @SuppressWarnings({ "rawtypes", "unchecked" })
+    @SuppressWarnings({"rawtypes", "unchecked"})
     @Bean
-    public FilterRegistrationBean someFilterRegistration()
-    {
+    public FilterRegistrationBean someFilterRegistration() {
         FilterRegistrationBean registration = new FilterRegistrationBean();
         registration.setFilter(new RepeatableFilter());
         registration.addUrlPatterns("/*");

+ 6 - 8
ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/DruidProperties.java

@@ -1,17 +1,16 @@
 package com.ruoyi.framework.config.properties;
 
+import com.alibaba.druid.pool.DruidDataSource;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Configuration;
-import com.alibaba.druid.pool.DruidDataSource;
 
 /**
  * druid 配置属性
- * 
+ *
  * @author ruoyi
  */
 @Configuration
-public class DruidProperties
-{
+public class DruidProperties {
     @Value("${spring.datasource.druid.initialSize}")
     private int initialSize;
 
@@ -51,8 +50,7 @@ public class DruidProperties
     @Value("${spring.datasource.druid.testOnReturn}")
     private boolean testOnReturn;
 
-    public DruidDataSource dataSource(DruidDataSource datasource)
-    {
+    public DruidDataSource dataSource(DruidDataSource datasource) {
         /** 配置初始化大小、最小、最大 */
         datasource.setInitialSize(initialSize);
         datasource.setMaxActive(maxActive);
@@ -60,10 +58,10 @@ public class DruidProperties
 
         /** 配置获取连接等待超时的时间 */
         datasource.setMaxWait(maxWait);
-        
+
         /** 配置驱动连接超时时间,检测数据库建立连接的超时时间,单位是毫秒 */
         datasource.setConnectTimeout(connectTimeout);
-        
+
         /** 配置网络超时时间,等待数据库操作完成的网络超时时间,单位是毫秒 */
         datasource.setSocketTimeout(socketTimeout);
 

+ 0 - 1
ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java

@@ -7,7 +7,6 @@ import org.springframework.util.CollectionUtils;
 
 import javax.sql.DataSource;
 import java.sql.DriverManager;
-import java.sql.SQLException;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;

+ 6 - 10
ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSourceContextHolder.java

@@ -5,24 +5,22 @@ import org.slf4j.LoggerFactory;
 
 /**
  * 数据源切换处理
- * 
+ *
  * @author ruoyi
  */
-public class DynamicDataSourceContextHolder
-{
+public class DynamicDataSourceContextHolder {
     public static final Logger log = LoggerFactory.getLogger(DynamicDataSourceContextHolder.class);
 
     /**
      * 使用ThreadLocal维护变量,ThreadLocal为每个使用该变量的线程提供独立的变量副本,
-     *  所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。
+     * 所以每一个线程都可以独立地改变自己的副本,而不会影响其它线程所对应的副本。
      */
     private static final ThreadLocal<String> CONTEXT_HOLDER = new ThreadLocal<>();
 
     /**
      * 设置数据源的变量
      */
-    public static void setDataSourceType(String dsType)
-    {
+    public static void setDataSourceType(String dsType) {
         log.info("切换到{}数据源", dsType);
         CONTEXT_HOLDER.set(dsType);
     }
@@ -30,16 +28,14 @@ public class DynamicDataSourceContextHolder
     /**
      * 获得数据源的变量
      */
-    public static String getDataSourceType()
-    {
+    public static String getDataSourceType() {
         return CONTEXT_HOLDER.get();
     }
 
     /**
      * 清空数据源变量
      */
-    public static void clearDataSourceType()
-    {
+    public static void clearDataSourceType() {
         CONTEXT_HOLDER.remove();
     }
 }

+ 11 - 13
ruoyi-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java

@@ -1,18 +1,18 @@
 package com.ruoyi.framework.manager;
 
+import com.ruoyi.common.utils.Threads;
+import com.ruoyi.common.utils.spring.SpringUtils;
+
 import java.util.TimerTask;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
-import com.ruoyi.common.utils.Threads;
-import com.ruoyi.common.utils.spring.SpringUtils;
 
 /**
  * 异步任务管理器
- * 
+ *
  * @author ruoyi
  */
-public class AsyncManager
-{
+public class AsyncManager {
     /**
      * 操作延迟10毫秒
      */
@@ -26,30 +26,28 @@ public class AsyncManager
     /**
      * 单例模式
      */
-    private AsyncManager(){}
+    private AsyncManager() {
+    }
 
     private static AsyncManager me = new AsyncManager();
 
-    public static AsyncManager me()
-    {
+    public static AsyncManager me() {
         return me;
     }
 
     /**
      * 执行任务
-     * 
+     *
      * @param task 任务
      */
-    public void execute(TimerTask task)
-    {
+    public void execute(TimerTask task) {
         executor.schedule(task, OPERATE_DELAY_TIME, TimeUnit.MILLISECONDS);
     }
 
     /**
      * 停止任务线程池
      */
-    public void shutdown()
-    {
+    public void shutdown() {
         Threads.shutdownAndAwaitTermination(executor);
     }
 }

+ 19 - 28
ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java

@@ -1,8 +1,5 @@
 package com.ruoyi.framework.manager.factory;
 
-import java.util.TimerTask;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.utils.LogUtils;
 import com.ruoyi.common.utils.ServletUtils;
@@ -15,35 +12,35 @@ import com.ruoyi.system.domain.SysOperLog;
 import com.ruoyi.system.service.ISysLogininforService;
 import com.ruoyi.system.service.ISysOperLogService;
 import eu.bitwalker.useragentutils.UserAgent;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.TimerTask;
 
 /**
  * 异步工厂(产生任务用)
- * 
+ *
  * @author ruoyi
  */
-public class AsyncFactory
-{
+public class AsyncFactory {
     private static final Logger sys_user_logger = LoggerFactory.getLogger("sys-user");
 
     /**
      * 记录登录信息
-     * 
+     *
      * @param username 用户名
-     * @param status 状态
-     * @param message 消息
-     * @param args 列表
+     * @param status   状态
+     * @param message  消息
+     * @param args     列表
      * @return 任务task
      */
     public static TimerTask recordLogininfor(final String username, final String status, final String message,
-            final Object... args)
-    {
+                                             final Object... args) {
         final UserAgent userAgent = UserAgent.parseUserAgentString(ServletUtils.getRequest().getHeader("User-Agent"));
         final String ip = IpUtils.getIpAddr();
-        return new TimerTask()
-        {
+        return new TimerTask() {
             @Override
-            public void run()
-            {
+            public void run() {
                 String address = AddressUtils.getRealAddressByIP(ip);
                 StringBuilder s = new StringBuilder();
                 s.append(LogUtils.getBlock(ip));
@@ -66,12 +63,9 @@ public class AsyncFactory
                 logininfor.setOs(os);
                 logininfor.setMsg(message);
                 // 日志状态
-                if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER))
-                {
+                if (StringUtils.equalsAny(status, Constants.LOGIN_SUCCESS, Constants.LOGOUT, Constants.REGISTER)) {
                     logininfor.setStatus(Constants.SUCCESS);
-                }
-                else if (Constants.LOGIN_FAIL.equals(status))
-                {
+                } else if (Constants.LOGIN_FAIL.equals(status)) {
                     logininfor.setStatus(Constants.FAIL);
                 }
                 // 插入数据
@@ -82,17 +76,14 @@ public class AsyncFactory
 
     /**
      * 操作日志记录
-     * 
+     *
      * @param operLog 操作日志信息
      * @return 任务task
      */
-    public static TimerTask recordOper(final SysOperLog operLog)
-    {
-        return new TimerTask()
-        {
+    public static TimerTask recordOper(final SysOperLog operLog) {
+        return new TimerTask() {
             @Override
-            public void run()
-            {
+            public void run() {
                 // 远程查询操作地点
                 operLog.setOperLocation(AddressUtils.getRealAddressByIP(operLog.getOperIp()));
                 SpringUtils.getBean(ISysOperLogService.class).insertOperlog(operLog);

+ 5 - 9
ruoyi-framework/src/main/java/com/ruoyi/framework/security/context/AuthenticationContextHolder.java

@@ -4,25 +4,21 @@ import org.springframework.security.core.Authentication;
 
 /**
  * 身份验证信息
- * 
+ *
  * @author ruoyi
  */
-public class AuthenticationContextHolder
-{
+public class AuthenticationContextHolder {
     private static final ThreadLocal<Authentication> contextHolder = new ThreadLocal<>();
 
-    public static Authentication getContext()
-    {
+    public static Authentication getContext() {
         return contextHolder.get();
     }
 
-    public static void setContext(Authentication context)
-    {
+    public static void setContext(Authentication context) {
         contextHolder.set(context);
     }
 
-    public static void clearContext()
-    {
+    public static void clearContext() {
         contextHolder.remove();
     }
 }

+ 11 - 12
ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java

@@ -1,32 +1,31 @@
 package com.ruoyi.framework.security.handle;
 
-import java.io.IOException;
-import java.io.Serializable;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import org.springframework.security.core.AuthenticationException;
-import org.springframework.security.web.AuthenticationEntryPoint;
-import org.springframework.stereotype.Component;
 import com.alibaba.fastjson2.JSON;
 import com.ruoyi.common.constant.HttpStatus;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.utils.ServletUtils;
 import com.ruoyi.common.utils.StringUtils;
+import org.springframework.security.core.AuthenticationException;
+import org.springframework.security.web.AuthenticationEntryPoint;
+import org.springframework.stereotype.Component;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.Serializable;
 
 /**
  * 认证失败处理类 返回未授权
- * 
+ *
  * @author ruoyi
  */
 @Component
-public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, Serializable
-{
+public class AuthenticationEntryPointImpl implements AuthenticationEntryPoint, Serializable {
     private static final long serialVersionUID = -8970718410437077606L;
 
     @Override
     public void commence(HttpServletRequest request, HttpServletResponse response, AuthenticationException e)
-            throws IOException
-    {
+            throws IOException {
         int code = HttpStatus.UNAUTHORIZED;
         String msg = StringUtils.format("请求访问:{},认证失败,无法访问系统资源", request.getRequestURI());
         ServletUtils.renderString(response, JSON.toJSONString(AjaxResult.error(code, msg)));

+ 14 - 27
ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java

@@ -4,11 +4,10 @@ import com.ruoyi.common.utils.Arith;
 
 /**
  * CPU相关信息
- * 
+ *
  * @author ruoyi
  */
-public class Cpu
-{
+public class Cpu {
     /**
      * 核心数
      */
@@ -39,63 +38,51 @@ public class Cpu
      */
     private double free;
 
-    public int getCpuNum()
-    {
+    public int getCpuNum() {
         return cpuNum;
     }
 
-    public void setCpuNum(int cpuNum)
-    {
+    public void setCpuNum(int cpuNum) {
         this.cpuNum = cpuNum;
     }
 
-    public double getTotal()
-    {
+    public double getTotal() {
         return Arith.round(Arith.mul(total, 100), 2);
     }
 
-    public void setTotal(double total)
-    {
+    public void setTotal(double total) {
         this.total = total;
     }
 
-    public double getSys()
-    {
+    public double getSys() {
         return Arith.round(Arith.mul(sys / total, 100), 2);
     }
 
-    public void setSys(double sys)
-    {
+    public void setSys(double sys) {
         this.sys = sys;
     }
 
-    public double getUsed()
-    {
+    public double getUsed() {
         return Arith.round(Arith.mul(used / total, 100), 2);
     }
 
-    public void setUsed(double used)
-    {
+    public void setUsed(double used) {
         this.used = used;
     }
 
-    public double getWait()
-    {
+    public double getWait() {
         return Arith.round(Arith.mul(wait / total, 100), 2);
     }
 
-    public void setWait(double wait)
-    {
+    public void setWait(double wait) {
         this.wait = wait;
     }
 
-    public double getFree()
-    {
+    public double getFree() {
         return Arith.round(Arith.mul(free / total, 100), 2);
     }
 
-    public void setFree(double free)
-    {
+    public void setFree(double free) {
         this.free = free;
     }
 }

+ 17 - 25
ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java

@@ -1,6 +1,10 @@
 package com.ruoyi.framework.web.exception;
 
-import javax.servlet.http.HttpServletRequest;
+import com.ruoyi.common.constant.HttpStatus;
+import com.ruoyi.common.core.domain.AjaxResult;
+import com.ruoyi.common.exception.DemoModeException;
+import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.security.access.AccessDeniedException;
@@ -9,28 +13,23 @@ import org.springframework.web.HttpRequestMethodNotSupportedException;
 import org.springframework.web.bind.MethodArgumentNotValidException;
 import org.springframework.web.bind.annotation.ExceptionHandler;
 import org.springframework.web.bind.annotation.RestControllerAdvice;
-import com.ruoyi.common.constant.HttpStatus;
-import com.ruoyi.common.core.domain.AjaxResult;
-import com.ruoyi.common.exception.DemoModeException;
-import com.ruoyi.common.exception.ServiceException;
-import com.ruoyi.common.utils.StringUtils;
+
+import javax.servlet.http.HttpServletRequest;
 
 /**
  * 全局异常处理器
- * 
+ *
  * @author ruoyi
  */
 @RestControllerAdvice
-public class GlobalExceptionHandler
-{
+public class GlobalExceptionHandler {
     private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
 
     /**
      * 权限校验异常
      */
     @ExceptionHandler(AccessDeniedException.class)
-    public AjaxResult handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request)
-    {
+    public AjaxResult handleAccessDeniedException(AccessDeniedException e, HttpServletRequest request) {
         String requestURI = request.getRequestURI();
         log.error("请求地址'{}',权限校验失败'{}'", requestURI, e.getMessage());
         return AjaxResult.error(HttpStatus.FORBIDDEN, "没有权限,请联系管理员授权");
@@ -41,8 +40,7 @@ public class GlobalExceptionHandler
      */
     @ExceptionHandler(HttpRequestMethodNotSupportedException.class)
     public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e,
-            HttpServletRequest request)
-    {
+                                                          HttpServletRequest request) {
         String requestURI = request.getRequestURI();
         log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
         return AjaxResult.error(e.getMessage());
@@ -52,8 +50,7 @@ public class GlobalExceptionHandler
      * 业务异常
      */
     @ExceptionHandler(ServiceException.class)
-    public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request)
-    {
+    public AjaxResult handleServiceException(ServiceException e, HttpServletRequest request) {
         log.error(e.getMessage(), e);
         Integer code = e.getCode();
         return StringUtils.isNotNull(code) ? AjaxResult.error(code, e.getMessage()) : AjaxResult.error(e.getMessage());
@@ -63,8 +60,7 @@ public class GlobalExceptionHandler
      * 拦截未知的运行时异常
      */
     @ExceptionHandler(RuntimeException.class)
-    public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request)
-    {
+    public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request) {
         String requestURI = request.getRequestURI();
         log.error("请求地址'{}',发生未知异常.", requestURI, e);
         return AjaxResult.error(e.getMessage());
@@ -74,8 +70,7 @@ public class GlobalExceptionHandler
      * 系统异常
      */
     @ExceptionHandler(Exception.class)
-    public AjaxResult handleException(Exception e, HttpServletRequest request)
-    {
+    public AjaxResult handleException(Exception e, HttpServletRequest request) {
         String requestURI = request.getRequestURI();
         log.error("请求地址'{}',发生系统异常.", requestURI, e);
         return AjaxResult.error(e.getMessage());
@@ -85,8 +80,7 @@ public class GlobalExceptionHandler
      * 自定义验证异常
      */
     @ExceptionHandler(BindException.class)
-    public AjaxResult handleBindException(BindException e)
-    {
+    public AjaxResult handleBindException(BindException e) {
         log.error(e.getMessage(), e);
         String message = e.getAllErrors().get(0).getDefaultMessage();
         return AjaxResult.error(message);
@@ -96,8 +90,7 @@ public class GlobalExceptionHandler
      * 自定义验证异常
      */
     @ExceptionHandler(MethodArgumentNotValidException.class)
-    public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e)
-    {
+    public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
         log.error(e.getMessage(), e);
         String message = e.getBindingResult().getFieldError().getDefaultMessage();
         return AjaxResult.error(message);
@@ -107,8 +100,7 @@ public class GlobalExceptionHandler
      * 演示模式异常
      */
     @ExceptionHandler(DemoModeException.class)
-    public AjaxResult handleDemoModeException(DemoModeException e)
-    {
+    public AjaxResult handleDemoModeException(DemoModeException e) {
         return AjaxResult.error("演示模式,不允许操作");
     }
 }

+ 23 - 24
ruoyi-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java

@@ -7,67 +7,66 @@ import org.springframework.stereotype.Component;
 
 /**
  * 读取代码生成相关配置
- * 
+ *
  * @author ruoyi
  */
 @Component
 @ConfigurationProperties(prefix = "gen")
-@PropertySource(value = { "classpath:generator.yml" })
-public class GenConfig
-{
-    /** 作者 */
+@PropertySource(value = {"classpath:generator.yml"})
+public class GenConfig {
+    /**
+     * 作者
+     */
     public static String author;
 
-    /** 生成包路径 */
+    /**
+     * 生成包路径
+     */
     public static String packageName;
 
-    /** 自动去除表前缀,默认是false */
+    /**
+     * 自动去除表前缀,默认是false
+     */
     public static boolean autoRemovePre;
 
-    /** 表前缀(类名不会包含表前缀) */
+    /**
+     * 表前缀(类名不会包含表前缀)
+     */
     public static String tablePrefix;
 
-    public static String getAuthor()
-    {
+    public static String getAuthor() {
         return author;
     }
 
     @Value("${author}")
-    public void setAuthor(String author)
-    {
+    public void setAuthor(String author) {
         GenConfig.author = author;
     }
 
-    public static String getPackageName()
-    {
+    public static String getPackageName() {
         return packageName;
     }
 
     @Value("${packageName}")
-    public void setPackageName(String packageName)
-    {
+    public void setPackageName(String packageName) {
         GenConfig.packageName = packageName;
     }
 
-    public static boolean getAutoRemovePre()
-    {
+    public static boolean getAutoRemovePre() {
         return autoRemovePre;
     }
 
     @Value("${autoRemovePre}")
-    public void setAutoRemovePre(boolean autoRemovePre)
-    {
+    public void setAutoRemovePre(boolean autoRemovePre) {
         GenConfig.autoRemovePre = autoRemovePre;
     }
 
-    public static String getTablePrefix()
-    {
+    public static String getTablePrefix() {
         return tablePrefix;
     }
 
     @Value("${tablePrefix}")
-    public void setTablePrefix(String tablePrefix)
-    {
+    public void setTablePrefix(String tablePrefix) {
         GenConfig.tablePrefix = tablePrefix;
     }
 }

+ 16 - 29
ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java

@@ -5,6 +5,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import javax.servlet.http.HttpServletResponse;
+
 import org.apache.commons.io.IOUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
@@ -30,13 +31,12 @@ import com.ruoyi.generator.service.IGenTableService;
 
 /**
  * 代码生成 操作处理
- * 
+ *
  * @author ruoyi
  */
 @RestController
 @RequestMapping("/tool/gen")
-public class GenController extends BaseController
-{
+public class GenController extends BaseController {
     @Autowired
     private IGenTableService genTableService;
 
@@ -48,8 +48,7 @@ public class GenController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('tool:gen:list')")
     @GetMapping("/list")
-    public TableDataInfo genList(GenTable genTable)
-    {
+    public TableDataInfo genList(GenTable genTable) {
         startPage();
         List<GenTable> list = genTableService.selectGenTableList(genTable);
         return getDataTable(list);
@@ -60,8 +59,7 @@ public class GenController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('tool:gen:query')")
     @GetMapping(value = "/{tableId}")
-    public AjaxResult getInfo(@PathVariable Long tableId)
-    {
+    public AjaxResult getInfo(@PathVariable Long tableId) {
         GenTable table = genTableService.selectGenTableById(tableId);
         List<GenTable> tables = genTableService.selectGenTableAll();
         List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
@@ -77,8 +75,7 @@ public class GenController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('tool:gen:list')")
     @GetMapping("/db/list")
-    public TableDataInfo dataList(GenTable genTable)
-    {
+    public TableDataInfo dataList(GenTable genTable) {
         startPage();
         List<GenTable> list = genTableService.selectDbTableList(genTable);
         return getDataTable(list);
@@ -89,8 +86,7 @@ public class GenController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('tool:gen:list')")
     @GetMapping(value = "/column/{tableId}")
-    public TableDataInfo columnList(Long tableId)
-    {
+    public TableDataInfo columnList(Long tableId) {
         TableDataInfo dataInfo = new TableDataInfo();
         List<GenTableColumn> list = genTableColumnService.selectGenTableColumnListByTableId(tableId);
         dataInfo.setRows(list);
@@ -104,8 +100,7 @@ public class GenController extends BaseController
     @PreAuthorize("@ss.hasPermi('tool:gen:import')")
     @Log(title = "代码生成", businessType = BusinessType.IMPORT)
     @PostMapping("/importTable")
-    public AjaxResult importTableSave(String tables)
-    {
+    public AjaxResult importTableSave(String tables) {
         String[] tableNames = Convert.toStrArray(tables);
         // 查询表信息
         List<GenTable> tableList = genTableService.selectDbTableListByNames(tableNames);
@@ -119,8 +114,7 @@ public class GenController extends BaseController
     @PreAuthorize("@ss.hasPermi('tool:gen:edit')")
     @Log(title = "代码生成", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult editSave(@Validated @RequestBody GenTable genTable)
-    {
+    public AjaxResult editSave(@Validated @RequestBody GenTable genTable) {
         genTableService.validateEdit(genTable);
         genTableService.updateGenTable(genTable);
         return success();
@@ -132,8 +126,7 @@ public class GenController extends BaseController
     @PreAuthorize("@ss.hasPermi('tool:gen:remove')")
     @Log(title = "代码生成", businessType = BusinessType.DELETE)
     @DeleteMapping("/{tableIds}")
-    public AjaxResult remove(@PathVariable Long[] tableIds)
-    {
+    public AjaxResult remove(@PathVariable Long[] tableIds) {
         genTableService.deleteGenTableByIds(tableIds);
         return success();
     }
@@ -143,8 +136,7 @@ public class GenController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('tool:gen:preview')")
     @GetMapping("/preview/{tableId}")
-    public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException
-    {
+    public AjaxResult preview(@PathVariable("tableId") Long tableId) throws IOException {
         Map<String, String> dataMap = genTableService.previewCode(tableId);
         return success(dataMap);
     }
@@ -155,8 +147,7 @@ public class GenController extends BaseController
     @PreAuthorize("@ss.hasPermi('tool:gen:code')")
     @Log(title = "代码生成", businessType = BusinessType.GENCODE)
     @GetMapping("/download/{tableName}")
-    public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException
-    {
+    public void download(HttpServletResponse response, @PathVariable("tableName") String tableName) throws IOException {
         byte[] data = genTableService.downloadCode(tableName);
         genCode(response, data);
     }
@@ -167,8 +158,7 @@ public class GenController extends BaseController
     @PreAuthorize("@ss.hasPermi('tool:gen:code')")
     @Log(title = "代码生成", businessType = BusinessType.GENCODE)
     @GetMapping("/genCode/{tableName}")
-    public AjaxResult genCode(@PathVariable("tableName") String tableName)
-    {
+    public AjaxResult genCode(@PathVariable("tableName") String tableName) {
         genTableService.generatorCode(tableName);
         return success();
     }
@@ -179,8 +169,7 @@ public class GenController extends BaseController
     @PreAuthorize("@ss.hasPermi('tool:gen:edit')")
     @Log(title = "代码生成", businessType = BusinessType.UPDATE)
     @GetMapping("/synchDb/{tableName}")
-    public AjaxResult synchDb(@PathVariable("tableName") String tableName)
-    {
+    public AjaxResult synchDb(@PathVariable("tableName") String tableName) {
         genTableService.synchDb(tableName);
         return success();
     }
@@ -191,8 +180,7 @@ public class GenController extends BaseController
     @PreAuthorize("@ss.hasPermi('tool:gen:code')")
     @Log(title = "代码生成", businessType = BusinessType.GENCODE)
     @GetMapping("/batchGenCode")
-    public void batchGenCode(HttpServletResponse response, String tables) throws IOException
-    {
+    public void batchGenCode(HttpServletResponse response, String tables) throws IOException {
         String[] tableNames = Convert.toStrArray(tables);
         byte[] data = genTableService.downloadCode(tableNames);
         genCode(response, data);
@@ -201,8 +189,7 @@ public class GenController extends BaseController
     /**
      * 生成zip文件
      */
-    private void genCode(HttpServletResponse response, byte[] data) throws IOException
-    {
+    private void genCode(HttpServletResponse response, byte[] data) throws IOException {
         response.reset();
         response.addHeader("Access-Control-Allow-Origin", "*");
         response.addHeader("Access-Control-Expose-Headers", "Content-Disposition");

+ 131 - 140
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java

@@ -1,369 +1,360 @@
 package com.ruoyi.generator.domain;
 
-import java.util.List;
-import javax.validation.Valid;
-import javax.validation.constraints.NotBlank;
-import org.apache.commons.lang3.ArrayUtils;
 import com.ruoyi.common.constant.GenConstants;
 import com.ruoyi.common.core.domain.BaseEntity;
 import com.ruoyi.common.utils.StringUtils;
+import org.apache.commons.lang3.ArrayUtils;
+
+import javax.validation.Valid;
+import javax.validation.constraints.NotBlank;
+import java.util.List;
 
 /**
  * 业务表 gen_table
- * 
+ *
  * @author ruoyi
  */
-public class GenTable extends BaseEntity
-{
+public class GenTable extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 编号 */
+    /**
+     * 编号
+     */
     private Long tableId;
 
-    /** 表名称 */
+    /**
+     * 表名称
+     */
     @NotBlank(message = "表名称不能为空")
     private String tableName;
 
-    /** 表描述 */
+    /**
+     * 表描述
+     */
     @NotBlank(message = "表描述不能为空")
     private String tableComment;
 
-    /** 关联父表的表名 */
+    /**
+     * 关联父表的表名
+     */
     private String subTableName;
 
-    /** 本表关联父表的外键名 */
+    /**
+     * 本表关联父表的外键名
+     */
     private String subTableFkName;
 
-    /** 实体类名称(首字母大写) */
+    /**
+     * 实体类名称(首字母大写)
+     */
     @NotBlank(message = "实体类名称不能为空")
     private String className;
 
-    /** 使用的模板(crud单表操作 tree树表操作 sub主子表操作) */
+    /**
+     * 使用的模板(crud单表操作 tree树表操作 sub主子表操作)
+     */
     private String tplCategory;
 
-    /** 生成包路径 */
+    /**
+     * 生成包路径
+     */
     @NotBlank(message = "生成包路径不能为空")
     private String packageName;
 
-    /** 生成模块名 */
+    /**
+     * 生成模块名
+     */
     @NotBlank(message = "生成模块名不能为空")
     private String moduleName;
 
-    /** 生成业务名 */
+    /**
+     * 生成业务名
+     */
     @NotBlank(message = "生成业务名不能为空")
     private String businessName;
 
-    /** 生成功能名 */
+    /**
+     * 生成功能名
+     */
     @NotBlank(message = "生成功能名不能为空")
     private String functionName;
 
-    /** 生成作者 */
+    /**
+     * 生成作者
+     */
     @NotBlank(message = "作者不能为空")
     private String functionAuthor;
 
-    /** 生成代码方式(0zip压缩包 1自定义路径) */
+    /**
+     * 生成代码方式(0zip压缩包 1自定义路径)
+     */
     private String genType;
 
-    /** 生成路径(不填默认项目路径) */
+    /**
+     * 生成路径(不填默认项目路径)
+     */
     private String genPath;
 
-    /** 主键信息 */
+    /**
+     * 主键信息
+     */
     private GenTableColumn pkColumn;
 
-    /** 子表信息 */
+    /**
+     * 子表信息
+     */
     private GenTable subTable;
 
-    /** 表列信息 */
+    /**
+     * 表列信息
+     */
     @Valid
     private List<GenTableColumn> columns;
 
-    /** 其它生成选项 */
+    /**
+     * 其它生成选项
+     */
     private String options;
 
-    /** 树编码字段 */
+    /**
+     * 树编码字段
+     */
     private String treeCode;
 
-    /** 树父编码字段 */
+    /**
+     * 树父编码字段
+     */
     private String treeParentCode;
 
-    /** 树名称字段 */
+    /**
+     * 树名称字段
+     */
     private String treeName;
 
-    /** 上级菜单ID字段 */
+    /**
+     * 上级菜单ID字段
+     */
     private String parentMenuId;
 
-    /** 上级菜单名称字段 */
+    /**
+     * 上级菜单名称字段
+     */
     private String parentMenuName;
 
-    public Long getTableId()
-    {
+    public Long getTableId() {
         return tableId;
     }
 
-    public void setTableId(Long tableId)
-    {
+    public void setTableId(Long tableId) {
         this.tableId = tableId;
     }
 
-    public String getTableName()
-    {
+    public String getTableName() {
         return tableName;
     }
 
-    public void setTableName(String tableName)
-    {
+    public void setTableName(String tableName) {
         this.tableName = tableName;
     }
 
-    public String getTableComment()
-    {
+    public String getTableComment() {
         return tableComment;
     }
 
-    public void setTableComment(String tableComment)
-    {
+    public void setTableComment(String tableComment) {
         this.tableComment = tableComment;
     }
 
-    public String getSubTableName()
-    {
+    public String getSubTableName() {
         return subTableName;
     }
 
-    public void setSubTableName(String subTableName)
-    {
+    public void setSubTableName(String subTableName) {
         this.subTableName = subTableName;
     }
 
-    public String getSubTableFkName()
-    {
+    public String getSubTableFkName() {
         return subTableFkName;
     }
 
-    public void setSubTableFkName(String subTableFkName)
-    {
+    public void setSubTableFkName(String subTableFkName) {
         this.subTableFkName = subTableFkName;
     }
 
-    public String getClassName()
-    {
+    public String getClassName() {
         return className;
     }
 
-    public void setClassName(String className)
-    {
+    public void setClassName(String className) {
         this.className = className;
     }
 
-    public String getTplCategory()
-    {
+    public String getTplCategory() {
         return tplCategory;
     }
 
-    public void setTplCategory(String tplCategory)
-    {
+    public void setTplCategory(String tplCategory) {
         this.tplCategory = tplCategory;
     }
 
-    public String getPackageName()
-    {
+    public String getPackageName() {
         return packageName;
     }
 
-    public void setPackageName(String packageName)
-    {
+    public void setPackageName(String packageName) {
         this.packageName = packageName;
     }
 
-    public String getModuleName()
-    {
+    public String getModuleName() {
         return moduleName;
     }
 
-    public void setModuleName(String moduleName)
-    {
+    public void setModuleName(String moduleName) {
         this.moduleName = moduleName;
     }
 
-    public String getBusinessName()
-    {
+    public String getBusinessName() {
         return businessName;
     }
 
-    public void setBusinessName(String businessName)
-    {
+    public void setBusinessName(String businessName) {
         this.businessName = businessName;
     }
 
-    public String getFunctionName()
-    {
+    public String getFunctionName() {
         return functionName;
     }
 
-    public void setFunctionName(String functionName)
-    {
+    public void setFunctionName(String functionName) {
         this.functionName = functionName;
     }
 
-    public String getFunctionAuthor()
-    {
+    public String getFunctionAuthor() {
         return functionAuthor;
     }
 
-    public void setFunctionAuthor(String functionAuthor)
-    {
+    public void setFunctionAuthor(String functionAuthor) {
         this.functionAuthor = functionAuthor;
     }
 
-    public String getGenType()
-    {
+    public String getGenType() {
         return genType;
     }
 
-    public void setGenType(String genType)
-    {
+    public void setGenType(String genType) {
         this.genType = genType;
     }
 
-    public String getGenPath()
-    {
+    public String getGenPath() {
         return genPath;
     }
 
-    public void setGenPath(String genPath)
-    {
+    public void setGenPath(String genPath) {
         this.genPath = genPath;
     }
 
-    public GenTableColumn getPkColumn()
-    {
+    public GenTableColumn getPkColumn() {
         return pkColumn;
     }
 
-    public void setPkColumn(GenTableColumn pkColumn)
-    {
+    public void setPkColumn(GenTableColumn pkColumn) {
         this.pkColumn = pkColumn;
     }
 
-    public GenTable getSubTable()
-    {
+    public GenTable getSubTable() {
         return subTable;
     }
 
-    public void setSubTable(GenTable subTable)
-    {
+    public void setSubTable(GenTable subTable) {
         this.subTable = subTable;
     }
 
-    public List<GenTableColumn> getColumns()
-    {
+    public List<GenTableColumn> getColumns() {
         return columns;
     }
 
-    public void setColumns(List<GenTableColumn> columns)
-    {
+    public void setColumns(List<GenTableColumn> columns) {
         this.columns = columns;
     }
 
-    public String getOptions()
-    {
+    public String getOptions() {
         return options;
     }
 
-    public void setOptions(String options)
-    {
+    public void setOptions(String options) {
         this.options = options;
     }
 
-    public String getTreeCode()
-    {
+    public String getTreeCode() {
         return treeCode;
     }
 
-    public void setTreeCode(String treeCode)
-    {
+    public void setTreeCode(String treeCode) {
         this.treeCode = treeCode;
     }
 
-    public String getTreeParentCode()
-    {
+    public String getTreeParentCode() {
         return treeParentCode;
     }
 
-    public void setTreeParentCode(String treeParentCode)
-    {
+    public void setTreeParentCode(String treeParentCode) {
         this.treeParentCode = treeParentCode;
     }
 
-    public String getTreeName()
-    {
+    public String getTreeName() {
         return treeName;
     }
 
-    public void setTreeName(String treeName)
-    {
+    public void setTreeName(String treeName) {
         this.treeName = treeName;
     }
 
-    public String getParentMenuId()
-    {
+    public String getParentMenuId() {
         return parentMenuId;
     }
 
-    public void setParentMenuId(String parentMenuId)
-    {
+    public void setParentMenuId(String parentMenuId) {
         this.parentMenuId = parentMenuId;
     }
 
-    public String getParentMenuName()
-    {
+    public String getParentMenuName() {
         return parentMenuName;
     }
 
-    public void setParentMenuName(String parentMenuName)
-    {
+    public void setParentMenuName(String parentMenuName) {
         this.parentMenuName = parentMenuName;
     }
 
-    public boolean isSub()
-    {
+    public boolean isSub() {
         return isSub(this.tplCategory);
     }
 
-    public static boolean isSub(String tplCategory)
-    {
+    public static boolean isSub(String tplCategory) {
         return tplCategory != null && StringUtils.equals(GenConstants.TPL_SUB, tplCategory);
     }
 
-    public boolean isTree()
-    {
+    public boolean isTree() {
         return isTree(this.tplCategory);
     }
 
-    public static boolean isTree(String tplCategory)
-    {
+    public static boolean isTree(String tplCategory) {
         return tplCategory != null && StringUtils.equals(GenConstants.TPL_TREE, tplCategory);
     }
 
-    public boolean isCrud()
-    {
+    public boolean isCrud() {
         return isCrud(this.tplCategory);
     }
 
-    public static boolean isCrud(String tplCategory)
-    {
+    public static boolean isCrud(String tplCategory) {
         return tplCategory != null && StringUtils.equals(GenConstants.TPL_CRUD, tplCategory);
     }
 
-    public boolean isSuperColumn(String javaField)
-    {
+    public boolean isSuperColumn(String javaField) {
         return isSuperColumn(this.tplCategory, javaField);
     }
 
-    public static boolean isSuperColumn(String tplCategory, String javaField)
-    {
-        if (isTree(tplCategory))
-        {
+    public static boolean isSuperColumn(String tplCategory, String javaField) {
+        if (isTree(tplCategory)) {
             return StringUtils.equalsAnyIgnoreCase(javaField,
                     ArrayUtils.addAll(GenConstants.TREE_ENTITY, GenConstants.BASE_ENTITY));
         }

+ 118 - 143
ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java

@@ -1,335 +1,318 @@
 package com.ruoyi.generator.domain;
 
-import javax.validation.constraints.NotBlank;
 import com.ruoyi.common.core.domain.BaseEntity;
 import com.ruoyi.common.utils.StringUtils;
 
+import javax.validation.constraints.NotBlank;
+
 /**
  * 代码生成业务字段表 gen_table_column
- * 
+ *
  * @author ruoyi
  */
-public class GenTableColumn extends BaseEntity
-{
+public class GenTableColumn extends BaseEntity {
     private static final long serialVersionUID = 1L;
 
-    /** 编号 */
+    /**
+     * 编号
+     */
     private Long columnId;
 
-    /** 归属表编号 */
+    /**
+     * 归属表编号
+     */
     private Long tableId;
 
-    /** 列名称 */
+    /**
+     * 列名称
+     */
     private String columnName;
 
-    /** 列描述 */
+    /**
+     * 列描述
+     */
     private String columnComment;
 
-    /** 列类型 */
+    /**
+     * 列类型
+     */
     private String columnType;
 
-    /** JAVA类型 */
+    /**
+     * JAVA类型
+     */
     private String javaType;
 
-    /** JAVA字段名 */
+    /**
+     * JAVA字段名
+     */
     @NotBlank(message = "Java属性不能为空")
     private String javaField;
 
-    /** 是否主键(1是) */
+    /**
+     * 是否主键(1是)
+     */
     private String isPk;
 
-    /** 是否自增(1是) */
+    /**
+     * 是否自增(1是)
+     */
     private String isIncrement;
 
-    /** 是否必填(1是) */
+    /**
+     * 是否必填(1是)
+     */
     private String isRequired;
 
-    /** 是否为插入字段(1是) */
+    /**
+     * 是否为插入字段(1是)
+     */
     private String isInsert;
 
-    /** 是否编辑字段(1是) */
+    /**
+     * 是否编辑字段(1是)
+     */
     private String isEdit;
 
-    /** 是否列表字段(1是) */
+    /**
+     * 是否列表字段(1是)
+     */
     private String isList;
 
-    /** 是否查询字段(1是) */
+    /**
+     * 是否查询字段(1是)
+     */
     private String isQuery;
 
-    /** 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围) */
+    /**
+     * 查询方式(EQ等于、NE不等于、GT大于、LT小于、LIKE模糊、BETWEEN范围)
+     */
     private String queryType;
 
-    /** 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件) */
+    /**
+     * 显示类型(input文本框、textarea文本域、select下拉框、checkbox复选框、radio单选框、datetime日期控件、image图片上传控件、upload文件上传控件、editor富文本控件)
+     */
     private String htmlType;
 
-    /** 字典类型 */
+    /**
+     * 字典类型
+     */
     private String dictType;
 
-    /** 排序 */
+    /**
+     * 排序
+     */
     private Integer sort;
 
-    public void setColumnId(Long columnId)
-    {
+    public void setColumnId(Long columnId) {
         this.columnId = columnId;
     }
 
-    public Long getColumnId()
-    {
+    public Long getColumnId() {
         return columnId;
     }
 
-    public void setTableId(Long tableId)
-    {
+    public void setTableId(Long tableId) {
         this.tableId = tableId;
     }
 
-    public Long getTableId()
-    {
+    public Long getTableId() {
         return tableId;
     }
 
-    public void setColumnName(String columnName)
-    {
+    public void setColumnName(String columnName) {
         this.columnName = columnName;
     }
 
-    public String getColumnName()
-    {
+    public String getColumnName() {
         return columnName;
     }
 
-    public void setColumnComment(String columnComment)
-    {
+    public void setColumnComment(String columnComment) {
         this.columnComment = columnComment;
     }
 
-    public String getColumnComment()
-    {
+    public String getColumnComment() {
         return columnComment;
     }
 
-    public void setColumnType(String columnType)
-    {
+    public void setColumnType(String columnType) {
         this.columnType = columnType;
     }
 
-    public String getColumnType()
-    {
+    public String getColumnType() {
         return columnType;
     }
 
-    public void setJavaType(String javaType)
-    {
+    public void setJavaType(String javaType) {
         this.javaType = javaType;
     }
 
-    public String getJavaType()
-    {
+    public String getJavaType() {
         return javaType;
     }
 
-    public void setJavaField(String javaField)
-    {
+    public void setJavaField(String javaField) {
         this.javaField = javaField;
     }
 
-    public String getJavaField()
-    {
+    public String getJavaField() {
         return javaField;
     }
 
-    public String getCapJavaField()
-    {
+    public String getCapJavaField() {
         return StringUtils.capitalize(javaField);
     }
 
-    public void setIsPk(String isPk)
-    {
+    public void setIsPk(String isPk) {
         this.isPk = isPk;
     }
 
-    public String getIsPk()
-    {
+    public String getIsPk() {
         return isPk;
     }
 
-    public boolean isPk()
-    {
+    public boolean isPk() {
         return isPk(this.isPk);
     }
 
-    public boolean isPk(String isPk)
-    {
+    public boolean isPk(String isPk) {
         return isPk != null && StringUtils.equals("1", isPk);
     }
 
-    public String getIsIncrement()
-    {
+    public String getIsIncrement() {
         return isIncrement;
     }
 
-    public void setIsIncrement(String isIncrement)
-    {
+    public void setIsIncrement(String isIncrement) {
         this.isIncrement = isIncrement;
     }
 
-    public boolean isIncrement()
-    {
+    public boolean isIncrement() {
         return isIncrement(this.isIncrement);
     }
 
-    public boolean isIncrement(String isIncrement)
-    {
+    public boolean isIncrement(String isIncrement) {
         return isIncrement != null && StringUtils.equals("1", isIncrement);
     }
 
-    public void setIsRequired(String isRequired)
-    {
+    public void setIsRequired(String isRequired) {
         this.isRequired = isRequired;
     }
 
-    public String getIsRequired()
-    {
+    public String getIsRequired() {
         return isRequired;
     }
 
-    public boolean isRequired()
-    {
+    public boolean isRequired() {
         return isRequired(this.isRequired);
     }
 
-    public boolean isRequired(String isRequired)
-    {
+    public boolean isRequired(String isRequired) {
         return isRequired != null && StringUtils.equals("1", isRequired);
     }
 
-    public void setIsInsert(String isInsert)
-    {
+    public void setIsInsert(String isInsert) {
         this.isInsert = isInsert;
     }
 
-    public String getIsInsert()
-    {
+    public String getIsInsert() {
         return isInsert;
     }
 
-    public boolean isInsert()
-    {
+    public boolean isInsert() {
         return isInsert(this.isInsert);
     }
 
-    public boolean isInsert(String isInsert)
-    {
+    public boolean isInsert(String isInsert) {
         return isInsert != null && StringUtils.equals("1", isInsert);
     }
 
-    public void setIsEdit(String isEdit)
-    {
+    public void setIsEdit(String isEdit) {
         this.isEdit = isEdit;
     }
 
-    public String getIsEdit()
-    {
+    public String getIsEdit() {
         return isEdit;
     }
 
-    public boolean isEdit()
-    {
+    public boolean isEdit() {
         return isInsert(this.isEdit);
     }
 
-    public boolean isEdit(String isEdit)
-    {
+    public boolean isEdit(String isEdit) {
         return isEdit != null && StringUtils.equals("1", isEdit);
     }
 
-    public void setIsList(String isList)
-    {
+    public void setIsList(String isList) {
         this.isList = isList;
     }
 
-    public String getIsList()
-    {
+    public String getIsList() {
         return isList;
     }
 
-    public boolean isList()
-    {
+    public boolean isList() {
         return isList(this.isList);
     }
 
-    public boolean isList(String isList)
-    {
+    public boolean isList(String isList) {
         return isList != null && StringUtils.equals("1", isList);
     }
 
-    public void setIsQuery(String isQuery)
-    {
+    public void setIsQuery(String isQuery) {
         this.isQuery = isQuery;
     }
 
-    public String getIsQuery()
-    {
+    public String getIsQuery() {
         return isQuery;
     }
 
-    public boolean isQuery()
-    {
+    public boolean isQuery() {
         return isQuery(this.isQuery);
     }
 
-    public boolean isQuery(String isQuery)
-    {
+    public boolean isQuery(String isQuery) {
         return isQuery != null && StringUtils.equals("1", isQuery);
     }
 
-    public void setQueryType(String queryType)
-    {
+    public void setQueryType(String queryType) {
         this.queryType = queryType;
     }
 
-    public String getQueryType()
-    {
+    public String getQueryType() {
         return queryType;
     }
 
-    public String getHtmlType()
-    {
+    public String getHtmlType() {
         return htmlType;
     }
 
-    public void setHtmlType(String htmlType)
-    {
+    public void setHtmlType(String htmlType) {
         this.htmlType = htmlType;
     }
 
-    public void setDictType(String dictType)
-    {
+    public void setDictType(String dictType) {
         this.dictType = dictType;
     }
 
-    public String getDictType()
-    {
+    public String getDictType() {
         return dictType;
     }
 
-    public void setSort(Integer sort)
-    {
+    public void setSort(Integer sort) {
         this.sort = sort;
     }
 
-    public Integer getSort()
-    {
+    public Integer getSort() {
         return sort;
     }
 
-    public boolean isSuperColumn()
-    {
+    public boolean isSuperColumn() {
         return isSuperColumn(this.javaField);
     }
 
-    public static boolean isSuperColumn(String javaField)
-    {
+    public static boolean isSuperColumn(String javaField) {
         return StringUtils.equalsAnyIgnoreCase(javaField,
                 // BaseEntity
                 "createBy", "createTime", "updateBy", "updateTime", "remark",
@@ -337,36 +320,28 @@ public class GenTableColumn extends BaseEntity
                 "parentName", "parentId", "orderNum", "ancestors");
     }
 
-    public boolean isUsableColumn()
-    {
+    public boolean isUsableColumn() {
         return isUsableColumn(javaField);
     }
 
-    public static boolean isUsableColumn(String javaField)
-    {
+    public static boolean isUsableColumn(String javaField) {
         // isSuperColumn()中的名单用于避免生成多余Domain属性,若某些属性在生成页面时需要用到不能忽略,则放在此处白名单
         return StringUtils.equalsAnyIgnoreCase(javaField, "parentId", "orderNum", "remark");
     }
 
-    public String readConverterExp()
-    {
+    public String readConverterExp() {
         String remarks = StringUtils.substringBetween(this.columnComment, "(", ")");
         StringBuffer sb = new StringBuffer();
-        if (StringUtils.isNotEmpty(remarks))
-        {
-            for (String value : remarks.split(" "))
-            {
-                if (StringUtils.isNotEmpty(value))
-                {
+        if (StringUtils.isNotEmpty(remarks)) {
+            for (String value : remarks.split(" ")) {
+                if (StringUtils.isNotEmpty(value)) {
                     Object startStr = value.subSequence(0, 1);
                     String endStr = value.substring(1);
                     sb.append("").append(startStr).append("=").append(endStr).append(",");
                 }
             }
             return sb.deleteCharAt(sb.length() - 1).toString();
-        }
-        else
-        {
+        } else {
             return this.columnComment;
         }
     }

+ 30 - 34
ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableColumnServiceImpl.java

@@ -1,6 +1,7 @@
 package com.ruoyi.generator.service;
 
 import java.util.List;
+
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.common.core.text.Convert;
@@ -9,60 +10,55 @@ import com.ruoyi.generator.mapper.GenTableColumnMapper;
 
 /**
  * 业务字段 服务层实现
- * 
+ *
  * @author ruoyi
  */
 @Service
-public class GenTableColumnServiceImpl implements IGenTableColumnService 
-{
-	@Autowired
-	private GenTableColumnMapper genTableColumnMapper;
+public class GenTableColumnServiceImpl implements IGenTableColumnService {
+    @Autowired
+    private GenTableColumnMapper genTableColumnMapper;
 
-	/**
+    /**
      * 查询业务字段列表
-     * 
+     *
      * @param tableId 业务字段编号
      * @return 业务字段集合
      */
-	@Override
-	public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId)
-	{
-	    return genTableColumnMapper.selectGenTableColumnListByTableId(tableId);
-	}
-	
+    @Override
+    public List<GenTableColumn> selectGenTableColumnListByTableId(Long tableId) {
+        return genTableColumnMapper.selectGenTableColumnListByTableId(tableId);
+    }
+
     /**
      * 新增业务字段
-     * 
+     *
      * @param genTableColumn 业务字段信息
      * @return 结果
      */
-	@Override
-	public int insertGenTableColumn(GenTableColumn genTableColumn)
-	{
-	    return genTableColumnMapper.insertGenTableColumn(genTableColumn);
-	}
-	
-	/**
+    @Override
+    public int insertGenTableColumn(GenTableColumn genTableColumn) {
+        return genTableColumnMapper.insertGenTableColumn(genTableColumn);
+    }
+
+    /**
      * 修改业务字段
-     * 
+     *
      * @param genTableColumn 业务字段信息
      * @return 结果
      */
-	@Override
-	public int updateGenTableColumn(GenTableColumn genTableColumn)
-	{
-	    return genTableColumnMapper.updateGenTableColumn(genTableColumn);
-	}
+    @Override
+    public int updateGenTableColumn(GenTableColumn genTableColumn) {
+        return genTableColumnMapper.updateGenTableColumn(genTableColumn);
+    }
 
-	/**
+    /**
      * 删除业务字段对象
-     * 
+     *
      * @param ids 需要删除的数据ID
      * @return 结果
      */
-	@Override
-	public int deleteGenTableColumnByIds(String ids)
-	{
-		return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
-	}
+    @Override
+    public int deleteGenTableColumnByIds(String ids) {
+        return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids));
+    }
 }

+ 80 - 146
ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java

@@ -11,6 +11,7 @@ import java.util.function.Function;
 import java.util.stream.Collectors;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
+
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.velocity.Template;
@@ -39,12 +40,11 @@ import com.ruoyi.generator.util.VelocityUtils;
 
 /**
  * 业务 服务层实现
- * 
+ *
  * @author ruoyi
  */
 @Service
-public class GenTableServiceImpl implements IGenTableService
-{
+public class GenTableServiceImpl implements IGenTableService {
     private static final Logger log = LoggerFactory.getLogger(GenTableServiceImpl.class);
 
     @Autowired
@@ -55,13 +55,12 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 查询业务信息
-     * 
+     *
      * @param id 业务ID
      * @return 业务信息
      */
     @Override
-    public GenTable selectGenTableById(Long id)
-    {
+    public GenTable selectGenTableById(Long id) {
         GenTable genTable = genTableMapper.selectGenTableById(id);
         setTableFromOptions(genTable);
         return genTable;
@@ -69,68 +68,61 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 查询业务列表
-     * 
+     *
      * @param genTable 业务信息
      * @return 业务集合
      */
     @Override
-    public List<GenTable> selectGenTableList(GenTable genTable)
-    {
+    public List<GenTable> selectGenTableList(GenTable genTable) {
         return genTableMapper.selectGenTableList(genTable);
     }
 
     /**
      * 查询据库列表
-     * 
+     *
      * @param genTable 业务信息
      * @return 数据库表集合
      */
     @Override
-    public List<GenTable> selectDbTableList(GenTable genTable)
-    {
+    public List<GenTable> selectDbTableList(GenTable genTable) {
         return genTableMapper.selectDbTableList(genTable);
     }
 
     /**
      * 查询据库列表
-     * 
+     *
      * @param tableNames 表名称组
      * @return 数据库表集合
      */
     @Override
-    public List<GenTable> selectDbTableListByNames(String[] tableNames)
-    {
+    public List<GenTable> selectDbTableListByNames(String[] tableNames) {
         return genTableMapper.selectDbTableListByNames(tableNames);
     }
 
     /**
      * 查询所有表信息
-     * 
+     *
      * @return 表信息集合
      */
     @Override
-    public List<GenTable> selectGenTableAll()
-    {
+    public List<GenTable> selectGenTableAll() {
         return genTableMapper.selectGenTableAll();
     }
 
     /**
      * 修改业务
-     * 
+     *
      * @param genTable 业务信息
      * @return 结果
      */
     @Override
     @Transactional
-    public void updateGenTable(GenTable genTable)
-    {
+    public void updateGenTable(GenTable genTable) {
         String options = JSON.toJSONString(genTable.getParams());
         genTable.setOptions(options);
         int row = genTableMapper.updateGenTable(genTable);
-        if (row > 0)
-        {
-            for (GenTableColumn cenTableColumn : genTable.getColumns())
-            {
+        if (row > 0) {
+            for (GenTableColumn cenTableColumn : genTable.getColumns()) {
                 genTableColumnMapper.updateGenTableColumn(cenTableColumn);
             }
         }
@@ -138,62 +130,53 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 删除业务对象
-     * 
+     *
      * @param tableIds 需要删除的数据ID
      * @return 结果
      */
     @Override
     @Transactional
-    public void deleteGenTableByIds(Long[] tableIds)
-    {
+    public void deleteGenTableByIds(Long[] tableIds) {
         genTableMapper.deleteGenTableByIds(tableIds);
         genTableColumnMapper.deleteGenTableColumnByIds(tableIds);
     }
 
     /**
      * 导入表结构
-     * 
+     *
      * @param tableList 导入表列表
      */
     @Override
     @Transactional
-    public void importGenTable(List<GenTable> tableList)
-    {
+    public void importGenTable(List<GenTable> tableList) {
         String operName = SecurityUtils.getUsername();
-        try
-        {
-            for (GenTable table : tableList)
-            {
+        try {
+            for (GenTable table : tableList) {
                 String tableName = table.getTableName();
                 GenUtils.initTable(table, operName);
                 int row = genTableMapper.insertGenTable(table);
-                if (row > 0)
-                {
+                if (row > 0) {
                     // 保存列信息
                     List<GenTableColumn> genTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
-                    for (GenTableColumn column : genTableColumns)
-                    {
+                    for (GenTableColumn column : genTableColumns) {
                         GenUtils.initColumnField(column, table);
                         genTableColumnMapper.insertGenTableColumn(column);
                     }
                 }
             }
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             throw new ServiceException("导入失败:" + e.getMessage());
         }
     }
 
     /**
      * 预览代码
-     * 
+     *
      * @param tableId 表编号
      * @return 预览数据列表
      */
     @Override
-    public Map<String, String> previewCode(Long tableId)
-    {
+    public Map<String, String> previewCode(Long tableId) {
         Map<String, String> dataMap = new LinkedHashMap<>();
         // 查询表信息
         GenTable table = genTableMapper.selectGenTableById(tableId);
@@ -207,8 +190,7 @@ public class GenTableServiceImpl implements IGenTableService
 
         // 获取模板列表
         List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
-        for (String template : templates)
-        {
+        for (String template : templates) {
             // 渲染模板
             StringWriter sw = new StringWriter();
             Template tpl = Velocity.getTemplate(template, Constants.UTF8);
@@ -220,13 +202,12 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 生成代码(下载方式)
-     * 
+     *
      * @param tableName 表名称
      * @return 数据
      */
     @Override
-    public byte[] downloadCode(String tableName)
-    {
+    public byte[] downloadCode(String tableName) {
         ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
         ZipOutputStream zip = new ZipOutputStream(outputStream);
         generatorCode(tableName, zip);
@@ -236,12 +217,11 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 生成代码(自定义路径)
-     * 
+     *
      * @param tableName 表名称
      */
     @Override
-    public void generatorCode(String tableName)
-    {
+    public void generatorCode(String tableName) {
         // 查询表信息
         GenTable table = genTableMapper.selectGenTableByName(tableName);
         // 设置主子表信息
@@ -255,21 +235,16 @@ public class GenTableServiceImpl implements IGenTableService
 
         // 获取模板列表
         List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
-        for (String template : templates)
-        {
-            if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm"))
-            {
+        for (String template : templates) {
+            if (!StringUtils.containsAny(template, "sql.vm", "api.js.vm", "index.vue.vm", "index-tree.vue.vm")) {
                 // 渲染模板
                 StringWriter sw = new StringWriter();
                 Template tpl = Velocity.getTemplate(template, Constants.UTF8);
                 tpl.merge(context, sw);
-                try
-                {
+                try {
                     String path = getGenPath(table, template);
                     FileUtils.writeStringToFile(new File(path), sw.toString(), CharsetKit.UTF_8);
-                }
-                catch (IOException e)
-                {
+                } catch (IOException e) {
                     throw new ServiceException("渲染模板失败,表名:" + table.getTableName());
                 }
             }
@@ -278,72 +253,62 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 同步数据库
-     * 
+     *
      * @param tableName 表名称
      */
     @Override
     @Transactional
-    public void synchDb(String tableName)
-    {
+    public void synchDb(String tableName) {
         GenTable table = genTableMapper.selectGenTableByName(tableName);
         List<GenTableColumn> tableColumns = table.getColumns();
         Map<String, GenTableColumn> tableColumnMap = tableColumns.stream().collect(Collectors.toMap(GenTableColumn::getColumnName, Function.identity()));
 
         List<GenTableColumn> dbTableColumns = genTableColumnMapper.selectDbTableColumnsByName(tableName);
-        if (StringUtils.isEmpty(dbTableColumns))
-        {
+        if (StringUtils.isEmpty(dbTableColumns)) {
             throw new ServiceException("同步数据失败,原表结构不存在");
         }
         List<String> dbTableColumnNames = dbTableColumns.stream().map(GenTableColumn::getColumnName).collect(Collectors.toList());
 
         dbTableColumns.forEach(column -> {
             GenUtils.initColumnField(column, table);
-            if (tableColumnMap.containsKey(column.getColumnName()))
-            {
+            if (tableColumnMap.containsKey(column.getColumnName())) {
                 GenTableColumn prevColumn = tableColumnMap.get(column.getColumnName());
                 column.setColumnId(prevColumn.getColumnId());
-                if (column.isList())
-                {
+                if (column.isList()) {
                     // 如果是列表,继续保留查询方式/字典类型选项
                     column.setDictType(prevColumn.getDictType());
                     column.setQueryType(prevColumn.getQueryType());
                 }
                 if (StringUtils.isNotEmpty(prevColumn.getIsRequired()) && !column.isPk()
                         && (column.isInsert() || column.isEdit())
-                        && ((column.isUsableColumn()) || (!column.isSuperColumn())))
-                {
+                        && ((column.isUsableColumn()) || (!column.isSuperColumn()))) {
                     // 如果是(新增/修改&非主键/非忽略及父属性),继续保留必填/显示类型选项
                     column.setIsRequired(prevColumn.getIsRequired());
                     column.setHtmlType(prevColumn.getHtmlType());
                 }
                 genTableColumnMapper.updateGenTableColumn(column);
-            }
-            else
-            {
+            } else {
                 genTableColumnMapper.insertGenTableColumn(column);
             }
         });
 
         List<GenTableColumn> delColumns = tableColumns.stream().filter(column -> !dbTableColumnNames.contains(column.getColumnName())).collect(Collectors.toList());
-        if (StringUtils.isNotEmpty(delColumns))
-        {
+        if (StringUtils.isNotEmpty(delColumns)) {
             genTableColumnMapper.deleteGenTableColumns(delColumns);
         }
     }
 
     /**
      * 批量生成代码(下载方式)
-     * 
+     *
      * @param tableNames 表数组
      * @return 数据
      */
     @Override
-    public byte[] downloadCode(String[] tableNames)
-    {
+    public byte[] downloadCode(String[] tableNames) {
         ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
         ZipOutputStream zip = new ZipOutputStream(outputStream);
-        for (String tableName : tableNames)
-        {
+        for (String tableName : tableNames) {
             generatorCode(tableName, zip);
         }
         IOUtils.closeQuietly(zip);
@@ -353,8 +318,7 @@ public class GenTableServiceImpl implements IGenTableService
     /**
      * 查询表信息并生成代码
      */
-    private void generatorCode(String tableName, ZipOutputStream zip)
-    {
+    private void generatorCode(String tableName, ZipOutputStream zip) {
         // 查询表信息
         GenTable table = genTableMapper.selectGenTableByName(tableName);
         // 设置主子表信息
@@ -368,23 +332,19 @@ public class GenTableServiceImpl implements IGenTableService
 
         // 获取模板列表
         List<String> templates = VelocityUtils.getTemplateList(table.getTplCategory());
-        for (String template : templates)
-        {
+        for (String template : templates) {
             // 渲染模板
             StringWriter sw = new StringWriter();
             Template tpl = Velocity.getTemplate(template, Constants.UTF8);
             tpl.merge(context, sw);
-            try
-            {
+            try {
                 // 添加到zip
                 zip.putNextEntry(new ZipEntry(VelocityUtils.getFileName(template, table)));
                 IOUtils.write(sw.toString(), zip, Constants.UTF8);
                 IOUtils.closeQuietly(sw);
                 zip.flush();
                 zip.closeEntry();
-            }
-            catch (IOException e)
-            {
+            } catch (IOException e) {
                 log.error("渲染模板失败,表名:" + table.getTableName(), e);
             }
         }
@@ -392,36 +352,24 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 修改保存参数校验
-     * 
+     *
      * @param genTable 业务信息
      */
     @Override
-    public void validateEdit(GenTable genTable)
-    {
-        if (GenConstants.TPL_TREE.equals(genTable.getTplCategory()))
-        {
+    public void validateEdit(GenTable genTable) {
+        if (GenConstants.TPL_TREE.equals(genTable.getTplCategory())) {
             String options = JSON.toJSONString(genTable.getParams());
             JSONObject paramsObj = JSON.parseObject(options);
-            if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE)))
-            {
+            if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_CODE))) {
                 throw new ServiceException("树编码字段不能为空");
-            }
-            else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE)))
-            {
+            } else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_PARENT_CODE))) {
                 throw new ServiceException("树父编码字段不能为空");
-            }
-            else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME)))
-            {
+            } else if (StringUtils.isEmpty(paramsObj.getString(GenConstants.TREE_NAME))) {
                 throw new ServiceException("树名称字段不能为空");
-            }
-            else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory()))
-            {
-                if (StringUtils.isEmpty(genTable.getSubTableName()))
-                {
+            } else if (GenConstants.TPL_SUB.equals(genTable.getTplCategory())) {
+                if (StringUtils.isEmpty(genTable.getSubTableName())) {
                     throw new ServiceException("关联子表的表名不能为空");
-                }
-                else if (StringUtils.isEmpty(genTable.getSubTableFkName()))
-                {
+                } else if (StringUtils.isEmpty(genTable.getSubTableFkName())) {
                     throw new ServiceException("子表关联的外键名不能为空");
                 }
             }
@@ -430,35 +378,27 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 设置主键列信息
-     * 
+     *
      * @param table 业务表信息
      */
-    public void setPkColumn(GenTable table)
-    {
-        for (GenTableColumn column : table.getColumns())
-        {
-            if (column.isPk())
-            {
+    public void setPkColumn(GenTable table) {
+        for (GenTableColumn column : table.getColumns()) {
+            if (column.isPk()) {
                 table.setPkColumn(column);
                 break;
             }
         }
-        if (StringUtils.isNull(table.getPkColumn()))
-        {
+        if (StringUtils.isNull(table.getPkColumn())) {
             table.setPkColumn(table.getColumns().get(0));
         }
-        if (GenConstants.TPL_SUB.equals(table.getTplCategory()))
-        {
-            for (GenTableColumn column : table.getSubTable().getColumns())
-            {
-                if (column.isPk())
-                {
+        if (GenConstants.TPL_SUB.equals(table.getTplCategory())) {
+            for (GenTableColumn column : table.getSubTable().getColumns()) {
+                if (column.isPk()) {
                     table.getSubTable().setPkColumn(column);
                     break;
                 }
             }
-            if (StringUtils.isNull(table.getSubTable().getPkColumn()))
-            {
+            if (StringUtils.isNull(table.getSubTable().getPkColumn())) {
                 table.getSubTable().setPkColumn(table.getSubTable().getColumns().get(0));
             }
         }
@@ -466,28 +406,24 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 设置主子表信息
-     * 
+     *
      * @param table 业务表信息
      */
-    public void setSubTable(GenTable table)
-    {
+    public void setSubTable(GenTable table) {
         String subTableName = table.getSubTableName();
-        if (StringUtils.isNotEmpty(subTableName))
-        {
+        if (StringUtils.isNotEmpty(subTableName)) {
             table.setSubTable(genTableMapper.selectGenTableByName(subTableName));
         }
     }
 
     /**
      * 设置代码生成其他选项值
-     * 
+     *
      * @param genTable 设置后的生成对象
      */
-    public void setTableFromOptions(GenTable genTable)
-    {
+    public void setTableFromOptions(GenTable genTable) {
         JSONObject paramsObj = JSON.parseObject(genTable.getOptions());
-        if (StringUtils.isNotNull(paramsObj))
-        {
+        if (StringUtils.isNotNull(paramsObj)) {
             String treeCode = paramsObj.getString(GenConstants.TREE_CODE);
             String treeParentCode = paramsObj.getString(GenConstants.TREE_PARENT_CODE);
             String treeName = paramsObj.getString(GenConstants.TREE_NAME);
@@ -504,16 +440,14 @@ public class GenTableServiceImpl implements IGenTableService
 
     /**
      * 获取代码生成地址
-     * 
-     * @param table 业务表信息
+     *
+     * @param table    业务表信息
      * @param template 模板文件路径
      * @return 生成地址
      */
-    public static String getGenPath(GenTable table, String template)
-    {
+    public static String getGenPath(GenTable table, String template) {
         String genPath = table.getGenPath();
-        if (StringUtils.equals(genPath, "/"))
-        {
+        if (StringUtils.equals(genPath, "/")) {
             return System.getProperty("user.dir") + File.separator + "src" + File.separator + VelocityUtils.getFileName(template, table);
         }
         return genPath + File.separator + VelocityUtils.getFileName(template, table);

+ 1 - 1
ruoyi-generator/src/main/resources/generator.yml

@@ -1,5 +1,5 @@
 # 代码生成
-gen: 
+gen:
   # 作者
   author: ruoyi
   # 默认生成包路径 system 需改成自己的模块名称 如 system monitor tool

+ 276 - 161
ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml

@@ -1,173 +1,288 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.generator.mapper.GenTableMapper">
 
-	<resultMap type="GenTable" id="GenTableResult">
-	    <id     property="tableId"        column="table_id"          />
-		<result property="tableName"      column="table_name"        />
-		<result property="tableComment"   column="table_comment"     />
-		<result property="subTableName"   column="sub_table_name"    />
-		<result property="subTableFkName" column="sub_table_fk_name" />
-		<result property="className"      column="class_name"        />
-		<result property="tplCategory"    column="tpl_category"      />
-		<result property="packageName"    column="package_name"      />
-		<result property="moduleName"     column="module_name"       />
-		<result property="businessName"   column="business_name"     />
-		<result property="functionName"   column="function_name"     />
-		<result property="functionAuthor" column="function_author"   />
-		<result property="genType"        column="gen_type"          />
-		<result property="genPath"        column="gen_path"          />
-		<result property="options"        column="options"           />
-		<result property="createBy"       column="create_by"         />
-		<result property="createTime"     column="create_time"       />
-		<result property="updateBy"       column="update_by"         />
-		<result property="updateTime"     column="update_time"       />
-		<result property="remark"         column="remark"            />
-		<collection  property="columns"  javaType="java.util.List"  resultMap="GenTableColumnResult" />
-	</resultMap>
-	
-	<resultMap type="GenTableColumn" id="GenTableColumnResult">
-        <id     property="columnId"       column="column_id"      />
-        <result property="tableId"        column="table_id"       />
-        <result property="columnName"     column="column_name"    />
-        <result property="columnComment"  column="column_comment" />
-        <result property="columnType"     column="column_type"    />
-        <result property="javaType"       column="java_type"      />
-        <result property="javaField"      column="java_field"     />
-        <result property="isPk"           column="is_pk"          />
-        <result property="isIncrement"    column="is_increment"   />
-        <result property="isRequired"     column="is_required"    />
-        <result property="isInsert"       column="is_insert"      />
-        <result property="isEdit"         column="is_edit"        />
-        <result property="isList"         column="is_list"        />
-        <result property="isQuery"        column="is_query"       />
-        <result property="queryType"      column="query_type"     />
-        <result property="htmlType"       column="html_type"      />
-        <result property="dictType"       column="dict_type"      />
-        <result property="sort"           column="sort"           />
-        <result property="createBy"       column="create_by"      />
-        <result property="createTime"     column="create_time"    />
-        <result property="updateBy"       column="update_by"      />
-        <result property="updateTime"     column="update_time"    />
+    <resultMap type="GenTable" id="GenTableResult">
+        <id property="tableId" column="table_id"/>
+        <result property="tableName" column="table_name"/>
+        <result property="tableComment" column="table_comment"/>
+        <result property="subTableName" column="sub_table_name"/>
+        <result property="subTableFkName" column="sub_table_fk_name"/>
+        <result property="className" column="class_name"/>
+        <result property="tplCategory" column="tpl_category"/>
+        <result property="packageName" column="package_name"/>
+        <result property="moduleName" column="module_name"/>
+        <result property="businessName" column="business_name"/>
+        <result property="functionName" column="function_name"/>
+        <result property="functionAuthor" column="function_author"/>
+        <result property="genType" column="gen_type"/>
+        <result property="genPath" column="gen_path"/>
+        <result property="options" column="options"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="remark" column="remark"/>
+        <collection property="columns" javaType="java.util.List" resultMap="GenTableColumnResult"/>
     </resultMap>
-	
-	<sql id="selectGenTableVo">
-        select table_id, table_name, table_comment, sub_table_name, sub_table_fk_name, class_name, tpl_category, package_name, module_name, business_name, function_name, function_author, gen_type, gen_path, options, create_by, create_time, update_by, update_time, remark from gen_table
+
+    <resultMap type="GenTableColumn" id="GenTableColumnResult">
+        <id property="columnId" column="column_id"/>
+        <result property="tableId" column="table_id"/>
+        <result property="columnName" column="column_name"/>
+        <result property="columnComment" column="column_comment"/>
+        <result property="columnType" column="column_type"/>
+        <result property="javaType" column="java_type"/>
+        <result property="javaField" column="java_field"/>
+        <result property="isPk" column="is_pk"/>
+        <result property="isIncrement" column="is_increment"/>
+        <result property="isRequired" column="is_required"/>
+        <result property="isInsert" column="is_insert"/>
+        <result property="isEdit" column="is_edit"/>
+        <result property="isList" column="is_list"/>
+        <result property="isQuery" column="is_query"/>
+        <result property="queryType" column="query_type"/>
+        <result property="htmlType" column="html_type"/>
+        <result property="dictType" column="dict_type"/>
+        <result property="sort" column="sort"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createTime" column="create_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updateTime" column="update_time"/>
+    </resultMap>
+
+    <sql id="selectGenTableVo">
+        select table_id,
+               table_name,
+               table_comment,
+               sub_table_name,
+               sub_table_fk_name,
+               class_name,
+               tpl_category,
+               package_name,
+               module_name,
+               business_name,
+               function_name,
+               function_author,
+               gen_type,
+               gen_path,
+               options,
+               create_by,
+               create_time,
+               update_by,
+               update_time,
+               remark
+        from gen_table
     </sql>
-    
+
     <select id="selectGenTableList" parameterType="GenTable" resultMap="GenTableResult">
-		<include refid="selectGenTableVo"/>
-		<where>
-			<if test="tableName != null and tableName != ''">
-				AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
-			</if>
-			<if test="tableComment != null and tableComment != ''">
-				AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
-			</if>
-			<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
-				AND to_char(create_time, 'YYYYMMDD') &gt;= to_char(#{params.beginTime}, 'YYYYMMDD')
-			</if>
-			<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
-				AND to_char(create_time, 'YYYYMMDD') &lt;= date_format(#{params.endTime},'%y%m%d')
-			</if>
-		</where>
-	</select>
+        <include refid="selectGenTableVo"/>
+        <where>
+            <if test="tableName != null and tableName != ''">
+                AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
+            </if>
+            <if test="tableComment != null and tableComment != ''">
+                AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
+            </if>
+            <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
+                AND to_char(create_time, 'YYYYMMDD') &gt;= to_char(#{params.beginTime}, 'YYYYMMDD')
+            </if>
+            <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
+                AND to_char(create_time, 'YYYYMMDD') &lt;= date_format(#{params.endTime},'%y%m%d')
+            </if>
+        </where>
+    </select>
 
-	<select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
-		select table_name, table_comment, create_time, update_time from information_schema.tables
-		where table_schema = (select database())
-		AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
-		AND table_name NOT IN (select table_name from gen_table)
-		<if test="tableName != null and tableName != ''">
-			AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
-		</if>
-		<if test="tableComment != null and tableComment != ''">
-			AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
-		</if>
-		<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
-			AND to_char(create_time, 'YYYYMMDD') &gt;= to_char(#{params.beginTime}, 'YYYYMMDD')
-		</if>
-		<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
-			AND to_char(create_time, 'YYYYMMDD') &lt;= date_format(#{params.endTime},'%y%m%d')
-		</if>
+    <select id="selectDbTableList" parameterType="GenTable" resultMap="GenTableResult">
+        select table_name, table_comment, create_time, update_time from information_schema.tables
+        where table_schema = (select database())
+        AND table_name NOT LIKE 'qrtz_%' AND table_name NOT LIKE 'gen_%'
+        AND table_name NOT IN (select table_name from gen_table)
+        <if test="tableName != null and tableName != ''">
+            AND lower(table_name) like lower(concat('%', #{tableName}, '%'))
+        </if>
+        <if test="tableComment != null and tableComment != ''">
+            AND lower(table_comment) like lower(concat('%', #{tableComment}, '%'))
+        </if>
+        <if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
+            AND to_char(create_time, 'YYYYMMDD') &gt;= to_char(#{params.beginTime}, 'YYYYMMDD')
+        </if>
+        <if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
+            AND to_char(create_time, 'YYYYMMDD') &lt;= date_format(#{params.endTime},'%y%m%d')
+        </if>
         order by create_time desc
-	</select>
-	
-	<select id="selectDbTableListByNames" resultMap="GenTableResult">
-		select table_name, table_comment, create_time, update_time from information_schema.tables
-		where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
-		and table_name in
-	    <foreach collection="array" item="name" open="(" separator="," close=")">
- 			#{name}
-        </foreach> 
-	</select>
-	
-	<select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
-		select table_name, table_comment, create_time, update_time from information_schema.tables
-		where table_comment <![CDATA[ <> ]]> '' and table_schema = (select database())
-		and table_name = #{tableName}
-	</select>
-	
-	<select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
-	    SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
-			   c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
-		FROM gen_table t
-			 LEFT JOIN gen_table_column c ON t.table_id = c.table_id
-		where t.table_id = #{tableId} order by c.sort
-	</select>
-	
-	<select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
-	    SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.gen_type, t.gen_path, t.options, t.remark,
-			   c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
-		FROM gen_table t
-			 LEFT JOIN gen_table_column c ON t.table_id = c.table_id
-		where t.table_name = #{tableName} order by c.sort
-	</select>
-	
-	<select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
-	    SELECT t.table_id, t.table_name, t.table_comment, t.sub_table_name, t.sub_table_fk_name, t.class_name, t.tpl_category, t.package_name, t.module_name, t.business_name, t.function_name, t.function_author, t.options, t.remark,
-			   c.column_id, c.column_name, c.column_comment, c.column_type, c.java_type, c.java_field, c.is_pk, c.is_increment, c.is_required, c.is_insert, c.is_edit, c.is_list, c.is_query, c.query_type, c.html_type, c.dict_type, c.sort
-		FROM gen_table t
-			 LEFT JOIN gen_table_column c ON t.table_id = c.table_id
-		order by c.sort
-	</select>
-	
-	<insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
+    </select>
+
+    <select id="selectDbTableListByNames" resultMap="GenTableResult">
+        select table_name, table_comment, create_time, update_time from information_schema.tables
+        where table_name NOT LIKE 'qrtz_%' and table_name NOT LIKE 'gen_%' and table_schema = (select database())
+        and table_name in
+        <foreach collection="array" item="name" open="(" separator="," close=")">
+            #{name}
+        </foreach>
+    </select>
+
+    <select id="selectTableByName" parameterType="String" resultMap="GenTableResult">
+        select table_name, table_comment, create_time, update_time
+        from information_schema.tables
+        where table_comment <![CDATA[ <> ]]> ''
+          and table_schema = (select database())
+          and table_name = #{tableName}
+    </select>
+
+    <select id="selectGenTableById" parameterType="Long" resultMap="GenTableResult">
+        SELECT t.table_id,
+               t.table_name,
+               t.table_comment,
+               t.sub_table_name,
+               t.sub_table_fk_name,
+               t.class_name,
+               t.tpl_category,
+               t.package_name,
+               t.module_name,
+               t.business_name,
+               t.function_name,
+               t.function_author,
+               t.gen_type,
+               t.gen_path,
+               t.options,
+               t.remark,
+               c.column_id,
+               c.column_name,
+               c.column_comment,
+               c.column_type,
+               c.java_type,
+               c.java_field,
+               c.is_pk,
+               c.is_increment,
+               c.is_required,
+               c.is_insert,
+               c.is_edit,
+               c.is_list,
+               c.is_query,
+               c.query_type,
+               c.html_type,
+               c.dict_type,
+               c.sort
+        FROM gen_table t
+                 LEFT JOIN gen_table_column c ON t.table_id = c.table_id
+        where t.table_id = #{tableId}
+        order by c.sort
+    </select>
+
+    <select id="selectGenTableByName" parameterType="String" resultMap="GenTableResult">
+        SELECT t.table_id,
+               t.table_name,
+               t.table_comment,
+               t.sub_table_name,
+               t.sub_table_fk_name,
+               t.class_name,
+               t.tpl_category,
+               t.package_name,
+               t.module_name,
+               t.business_name,
+               t.function_name,
+               t.function_author,
+               t.gen_type,
+               t.gen_path,
+               t.options,
+               t.remark,
+               c.column_id,
+               c.column_name,
+               c.column_comment,
+               c.column_type,
+               c.java_type,
+               c.java_field,
+               c.is_pk,
+               c.is_increment,
+               c.is_required,
+               c.is_insert,
+               c.is_edit,
+               c.is_list,
+               c.is_query,
+               c.query_type,
+               c.html_type,
+               c.dict_type,
+               c.sort
+        FROM gen_table t
+                 LEFT JOIN gen_table_column c ON t.table_id = c.table_id
+        where t.table_name = #{tableName}
+        order by c.sort
+    </select>
+
+    <select id="selectGenTableAll" parameterType="String" resultMap="GenTableResult">
+        SELECT t.table_id,
+               t.table_name,
+               t.table_comment,
+               t.sub_table_name,
+               t.sub_table_fk_name,
+               t.class_name,
+               t.tpl_category,
+               t.package_name,
+               t.module_name,
+               t.business_name,
+               t.function_name,
+               t.function_author,
+               t.options,
+               t.remark,
+               c.column_id,
+               c.column_name,
+               c.column_comment,
+               c.column_type,
+               c.java_type,
+               c.java_field,
+               c.is_pk,
+               c.is_increment,
+               c.is_required,
+               c.is_insert,
+               c.is_edit,
+               c.is_list,
+               c.is_query,
+               c.query_type,
+               c.html_type,
+               c.dict_type,
+               c.sort
+        FROM gen_table t
+                 LEFT JOIN gen_table_column c ON t.table_id = c.table_id
+        order by c.sort
+    </select>
+
+    <insert id="insertGenTable" parameterType="GenTable" useGeneratedKeys="true" keyProperty="tableId">
         insert into gen_table (
-			<if test="tableName != null">table_name,</if>
-			<if test="tableComment != null and tableComment != ''">table_comment,</if>
-			<if test="className != null and className != ''">class_name,</if>
-			<if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
-			<if test="packageName != null and packageName != ''">package_name,</if>
-			<if test="moduleName != null and moduleName != ''">module_name,</if>
-			<if test="businessName != null and businessName != ''">business_name,</if>
-			<if test="functionName != null and functionName != ''">function_name,</if>
-			<if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
-			<if test="genType != null and genType != ''">gen_type,</if>
-			<if test="genPath != null and genPath != ''">gen_path,</if>
-			<if test="remark != null and remark != ''">remark,</if>
- 			<if test="createBy != null and createBy != ''">create_by,</if>
-			create_time
-         )values(
-			<if test="tableName != null">#{tableName},</if>
-			<if test="tableComment != null and tableComment != ''">#{tableComment},</if>
-			<if test="className != null and className != ''">#{className},</if>
-			<if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
-			<if test="packageName != null and packageName != ''">#{packageName},</if>
-			<if test="moduleName != null and moduleName != ''">#{moduleName},</if>
-			<if test="businessName != null and businessName != ''">#{businessName},</if>
-			<if test="functionName != null and functionName != ''">#{functionName},</if>
-			<if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
-			<if test="genType != null and genType != ''">#{genType},</if>
-			<if test="genPath != null and genPath != ''">#{genPath},</if>
-			<if test="remark != null and remark != ''">#{remark},</if>
- 			<if test="createBy != null and createBy != ''">#{createBy},</if>
-			CURRENT_TIMESTAMP
-         )
+        <if test="tableName != null">table_name,</if>
+        <if test="tableComment != null and tableComment != ''">table_comment,</if>
+        <if test="className != null and className != ''">class_name,</if>
+        <if test="tplCategory != null and tplCategory != ''">tpl_category,</if>
+        <if test="packageName != null and packageName != ''">package_name,</if>
+        <if test="moduleName != null and moduleName != ''">module_name,</if>
+        <if test="businessName != null and businessName != ''">business_name,</if>
+        <if test="functionName != null and functionName != ''">function_name,</if>
+        <if test="functionAuthor != null and functionAuthor != ''">function_author,</if>
+        <if test="genType != null and genType != ''">gen_type,</if>
+        <if test="genPath != null and genPath != ''">gen_path,</if>
+        <if test="remark != null and remark != ''">remark,</if>
+        <if test="createBy != null and createBy != ''">create_by,</if>
+        create_time
+        )values(
+        <if test="tableName != null">#{tableName},</if>
+        <if test="tableComment != null and tableComment != ''">#{tableComment},</if>
+        <if test="className != null and className != ''">#{className},</if>
+        <if test="tplCategory != null and tplCategory != ''">#{tplCategory},</if>
+        <if test="packageName != null and packageName != ''">#{packageName},</if>
+        <if test="moduleName != null and moduleName != ''">#{moduleName},</if>
+        <if test="businessName != null and businessName != ''">#{businessName},</if>
+        <if test="functionName != null and functionName != ''">#{functionName},</if>
+        <if test="functionAuthor != null and functionAuthor != ''">#{functionAuthor},</if>
+        <if test="genType != null and genType != ''">#{genType},</if>
+        <if test="genPath != null and genPath != ''">#{genPath},</if>
+        <if test="remark != null and remark != ''">#{remark},</if>
+        <if test="createBy != null and createBy != ''">#{createBy},</if>
+        CURRENT_TIMESTAMP
+        )
     </insert>
-    
+
     <update id="updateGenTable" parameterType="GenTable">
         update gen_table
         <set>
@@ -191,9 +306,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </set>
         where table_id = #{tableId}
     </update>
-    
+
     <delete id="deleteGenTableByIds" parameterType="Long">
-        delete from gen_table where table_id in 
+        delete from gen_table where table_id in
         <foreach collection="array" item="tableId" open="(" separator="," close=")">
             #{tableId}
         </foreach>

+ 23 - 30
ruoyi-generator/src/main/resources/vm/java/controller.java.vm

@@ -2,6 +2,7 @@ package ${packageName}.controller;
 
 import java.util.List;
 import javax.servlet.http.HttpServletResponse;
+
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
@@ -26,36 +27,33 @@ import com.ruoyi.common.core.page.TableDataInfo;
 
 /**
  * ${functionName}Controller
- * 
+ *
  * @author ${author}
  * @date ${datetime}
  */
 @RestController
 @RequestMapping("/${moduleName}/${businessName}")
-public class ${ClassName}Controller extends BaseController
-{
+public class ${ClassName}Controller extends BaseController {
     @Autowired
     private I${ClassName}Service ${className}Service;
 
-    /**
-     * 查询${functionName}列表
-     */
-    @PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
-    @GetMapping("/list")
-#if($table.crud || $table.sub)
-    public TableDataInfo list(${ClassName} ${className})
-    {
+/**
+ * 查询${functionName}列表
+ */
+@PreAuthorize("@ss.hasPermi('${permissionPrefix}:list')")
+@GetMapping("/list")
+    #if($table.crud || $table.sub)
+    public TableDataInfo list(${ClassName} ${className}) {
         startPage();
         List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
         return getDataTable(list);
     }
-#elseif($table.tree)
-    public AjaxResult list(${ClassName} ${className})
-    {
-        List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
-        return success(list);
-    }
-#end
+    #elseif($table.tree)
+        public AjaxResult list(${ClassName} ${className}) {
+            List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
+            return success(list);
+        }
+    #end
 
     /**
      * 导出${functionName}列表
@@ -63,10 +61,9 @@ public class ${ClassName}Controller extends BaseController
     @PreAuthorize("@ss.hasPermi('${permissionPrefix}:export')")
     @Log(title = "${functionName}", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public void export(HttpServletResponse response, ${ClassName} ${className})
-    {
+    public void export(HttpServletResponse response, ${ClassName} ${className}) {
         List<${ClassName}> list = ${className}Service.select${ClassName}List(${className});
-        ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}.class);
+        ExcelUtil<${ClassName}> util = new ExcelUtil<${ClassName}>(${ClassName}. class);
         util.exportExcel(response, list, "${functionName}数据");
     }
 
@@ -75,8 +72,7 @@ public class ${ClassName}Controller extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('${permissionPrefix}:query')")
     @GetMapping(value = "/{${pkColumn.javaField}}")
-    public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField})
-    {
+    public AjaxResult getInfo(@PathVariable("${pkColumn.javaField}") ${pkColumn.javaType} ${pkColumn.javaField}) {
         return success(${className}Service.select${ClassName}By${pkColumn.capJavaField}(${pkColumn.javaField}));
     }
 
@@ -86,8 +82,7 @@ public class ${ClassName}Controller extends BaseController
     @PreAuthorize("@ss.hasPermi('${permissionPrefix}:add')")
     @Log(title = "${functionName}", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody ${ClassName} ${className})
-    {
+    public AjaxResult add(@RequestBody ${ClassName} ${className}) {
         return toAjax(${className}Service.insert${ClassName}(${className}));
     }
 
@@ -97,8 +92,7 @@ public class ${ClassName}Controller extends BaseController
     @PreAuthorize("@ss.hasPermi('${permissionPrefix}:edit')")
     @Log(title = "${functionName}", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody ${ClassName} ${className})
-    {
+    public AjaxResult edit(@RequestBody ${ClassName} ${className}) {
         return toAjax(${className}Service.update${ClassName}(${className}));
     }
 
@@ -107,9 +101,8 @@ public class ${ClassName}Controller extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('${permissionPrefix}:remove')")
     @Log(title = "${functionName}", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{${pkColumn.javaField}s}")
-    public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s)
-    {
+    @DeleteMapping("/{${pkColumn.javaField}s}")
+    public AjaxResult remove(@PathVariable ${pkColumn.javaType}[] ${pkColumn.javaField}s) {
         return toAjax(${className}Service.delete${ClassName}By${pkColumn.capJavaField}s(${pkColumn.javaField}s));
     }
 }

+ 63 - 67
ruoyi-generator/src/main/resources/vm/java/domain.java.vm

@@ -14,92 +14,88 @@ import com.ruoyi.common.core.domain.TreeEntity;
 
 /**
  * ${functionName}对象 ${tableName}
- * 
+ *
  * @author ${author}
  * @date ${datetime}
  */
 #if($table.crud || $table.sub)
-#set($Entity="BaseEntity")
+    #set($Entity="BaseEntity")
 #elseif($table.tree)
-#set($Entity="TreeEntity")
+    #set($Entity="TreeEntity")
 #end
 public class ${ClassName} extends ${Entity}
-{
-    private static final long serialVersionUID = 1L;
+        {
+private static final long serialVersionUID = 1L;
 
-#foreach ($column in $columns)
-#if(!$table.isSuperColumn($column.javaField))
-    /** $column.columnComment */
-#if($column.list)
-#set($parentheseIndex=$column.columnComment.indexOf("("))
-#if($parentheseIndex != -1)
-#set($comment=$column.columnComment.substring(0, $parentheseIndex))
-#else
-#set($comment=$column.columnComment)
-#end
-#if($parentheseIndex != -1)
-    @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
-#elseif($column.javaType == 'Date')
-    @JsonFormat(pattern = "yyyy-MM-dd")
-    @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
-#else
-    @Excel(name = "${comment}")
-#end
-#end
-    private $column.javaType $column.javaField;
+    #foreach ($column in $columns)
+        #if(!$table.isSuperColumn($column.javaField))
+        /** $column.columnComment */
+            #if($column.list)
+                #set($parentheseIndex=$column.columnComment.indexOf("("))
+                #if($parentheseIndex != -1)
+                    #set($comment=$column.columnComment.substring(0, $parentheseIndex))
+                #else
+                    #set($comment=$column.columnComment)
+                #end
+                #if($parentheseIndex != -1)
+                @Excel(name = "${comment}", readConverterExp = "$column.readConverterExp()")
+                #elseif($column.javaType == 'Date')
+                @JsonFormat(pattern = "yyyy-MM-dd")
+                @Excel(name = "${comment}", width = 30, dateFormat = "yyyy-MM-dd")
+                #else
+                @Excel(name = "${comment}")
+                #end
+            #end
+        private $column.javaType $column.javaField;
 
-#end
-#end
-#if($table.sub)
+        #end
+    #end
+    #if($table.sub)
     /** $table.subTable.functionName信息 */
     private List<${subClassName}> ${subclassName}List;
 
-#end
-#foreach ($column in $columns)
-#if(!$table.isSuperColumn($column.javaField))
-#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
-#set($AttrName=$column.javaField)
-#else
-#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
-#end
-    public void set${AttrName}($column.javaType $column.javaField) 
-    {
-        this.$column.javaField = $column.javaField;
-    }
+    #end
+    #foreach ($column in $columns)
+        #if(!$table.isSuperColumn($column.javaField))
+            #if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
+                #set($AttrName=$column.javaField)
+            #else
+                #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
+            #end
+        public void set${AttrName}($column.javaType $column.javaField) {
+            this.$column.javaField = $column.javaField;
+        }
 
-    public $column.javaType get${AttrName}() 
-    {
-        return $column.javaField;
-    }
-#end
-#end
+        public $column.javaType get${AttrName}() {
+            return $column.javaField;
+        }
+        #end
+    #end
 
-#if($table.sub)
-    public List<${subClassName}> get${subClassName}List()
-    {
+    #if($table.sub)
+    public List<${subClassName}> get${subClassName}List() {
         return ${subclassName}List;
     }
 
-    public void set${subClassName}List(List<${subClassName}> ${subclassName}List)
-    {
+    public void set${subClassName}List(List<${subClassName}> ${subclassName}List) {
         this.${subclassName}List = ${subclassName}List;
     }
 
-#end
-    @Override
-    public String toString() {
-        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
-#foreach ($column in $columns)
-#if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
-#set($AttrName=$column.javaField)
-#else
-#set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
-#end
-            .append("${column.javaField}", get${AttrName}())
-#end
-#if($table.sub)
-            .append("${subclassName}List", get${subClassName}List())
-#end
+    #end
+@Override
+public String toString() {
+    return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
+        #foreach ($column in $columns)
+            #if($column.javaField.length() > 2 && $column.javaField.substring(1,2).matches("[A-Z]"))
+                #set($AttrName=$column.javaField)
+            #else
+                #set($AttrName=$column.javaField.substring(0,1).toUpperCase() + ${column.javaField.substring(1)})
+            #end
+        .append("${column.javaField}", get${AttrName}())
+        #end
+        #if($table.sub)
+                .append("${subclassName}List", get${subClassName}List())
+                #end
             .toString();
-    }
+}
 }

+ 23 - 23
ruoyi-generator/src/main/resources/vm/js/api.js.vm

@@ -2,43 +2,43 @@ import request from '@/utils/request'
 
 // 查询${functionName}列表
 export function list${BusinessName}(query) {
-  return request({
-    url: '/${moduleName}/${businessName}/list',
-    method: 'get',
-    params: query
-  })
+return request({
+url: '/${moduleName}/${businessName}/list',
+method: 'get',
+params: query
+})
 }
 
 // 查询${functionName}详细
 export function get${BusinessName}(${pkColumn.javaField}) {
-  return request({
-    url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
-    method: 'get'
-  })
+return request({
+url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
+method: 'get'
+})
 }
 
 // 新增${functionName}
 export function add${BusinessName}(data) {
-  return request({
-    url: '/${moduleName}/${businessName}',
-    method: 'post',
-    data: data
-  })
+return request({
+url: '/${moduleName}/${businessName}',
+method: 'post',
+data: data
+})
 }
 
 // 修改${functionName}
 export function update${BusinessName}(data) {
-  return request({
-    url: '/${moduleName}/${businessName}',
-    method: 'put',
-    data: data
-  })
+return request({
+url: '/${moduleName}/${businessName}',
+method: 'put',
+data: data
+})
 }
 
 // 删除${functionName}
 export function del${BusinessName}(${pkColumn.javaField}) {
-  return request({
-    url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
-    method: 'delete'
-  })
+return request({
+url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
+method: 'delete'
+})
 }

+ 19 - 29
ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java

@@ -1,11 +1,5 @@
 package com.ruoyi.quartz.util;
 
-import java.util.Date;
-import org.quartz.Job;
-import org.quartz.JobExecutionContext;
-import org.quartz.JobExecutionException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.constant.ScheduleConstants;
 import com.ruoyi.common.utils.ExceptionUtil;
@@ -15,14 +9,20 @@ import com.ruoyi.common.utils.spring.SpringUtils;
 import com.ruoyi.quartz.domain.SysJob;
 import com.ruoyi.quartz.domain.SysJobLog;
 import com.ruoyi.quartz.service.ISysJobLogService;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Date;
 
 /**
  * 抽象quartz调用
  *
  * @author ruoyi
  */
-public abstract class AbstractQuartzJob implements Job
-{
+public abstract class AbstractQuartzJob implements Job {
     private static final Logger log = LoggerFactory.getLogger(AbstractQuartzJob.class);
 
     /**
@@ -31,21 +31,16 @@ public abstract class AbstractQuartzJob implements Job
     private static ThreadLocal<Date> threadLocal = new ThreadLocal<>();
 
     @Override
-    public void execute(JobExecutionContext context) throws JobExecutionException
-    {
+    public void execute(JobExecutionContext context) throws JobExecutionException {
         SysJob sysJob = new SysJob();
         BeanUtils.copyBeanProp(sysJob, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES));
-        try
-        {
+        try {
             before(context, sysJob);
-            if (sysJob != null)
-            {
+            if (sysJob != null) {
                 doExecute(context, sysJob);
             }
             after(context, sysJob, null);
-        }
-        catch (Exception e)
-        {
+        } catch (Exception e) {
             log.error("任务执行异常  - :", e);
             after(context, sysJob, e);
         }
@@ -55,10 +50,9 @@ public abstract class AbstractQuartzJob implements Job
      * 执行前
      *
      * @param context 工作执行上下文对象
-     * @param sysJob 系统计划任务
+     * @param sysJob  系统计划任务
      */
-    protected void before(JobExecutionContext context, SysJob sysJob)
-    {
+    protected void before(JobExecutionContext context, SysJob sysJob) {
         threadLocal.set(new Date());
     }
 
@@ -66,10 +60,9 @@ public abstract class AbstractQuartzJob implements Job
      * 执行后
      *
      * @param context 工作执行上下文对象
-     * @param sysJob 系统计划任务
+     * @param sysJob  系统计划任务
      */
-    protected void after(JobExecutionContext context, SysJob sysJob, Exception e)
-    {
+    protected void after(JobExecutionContext context, SysJob sysJob, Exception e) {
         Date startTime = threadLocal.get();
         threadLocal.remove();
 
@@ -81,14 +74,11 @@ public abstract class AbstractQuartzJob implements Job
         sysJobLog.setStopTime(new Date());
         long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime();
         sysJobLog.setJobMessage(sysJobLog.getJobName() + " 总共耗时:" + runMs + "毫秒");
-        if (e != null)
-        {
+        if (e != null) {
             sysJobLog.setStatus(Constants.FAIL);
             String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000);
             sysJobLog.setExceptionInfo(errorMsg);
-        }
-        else
-        {
+        } else {
             sysJobLog.setStatus(Constants.SUCCESS);
         }
 
@@ -100,7 +90,7 @@ public abstract class AbstractQuartzJob implements Job
      * 执行方法,由子类重载
      *
      * @param context 工作执行上下文对象
-     * @param sysJob 系统计划任务
+     * @param sysJob  系统计划任务
      * @throws Exception 执行过程中的异常
      */
     protected abstract void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception;

+ 11 - 21
ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java

@@ -1,25 +1,23 @@
 package com.ruoyi.quartz.util;
 
+import org.quartz.CronExpression;
+
 import java.text.ParseException;
 import java.util.Date;
-import org.quartz.CronExpression;
 
 /**
  * cron表达式工具类
- * 
- * @author ruoyi
  *
+ * @author ruoyi
  */
-public class CronUtils
-{
+public class CronUtils {
     /**
      * 返回一个布尔值代表一个给定的Cron表达式的有效性
      *
      * @param cronExpression Cron表达式
      * @return boolean 表达式是否有效
      */
-    public static boolean isValid(String cronExpression)
-    {
+    public static boolean isValid(String cronExpression) {
         return CronExpression.isValidExpression(cronExpression);
     }
 
@@ -29,15 +27,11 @@ public class CronUtils
      * @param cronExpression Cron表达式
      * @return String 无效时返回表达式错误描述,如果有效返回null
      */
-    public static String getInvalidMessage(String cronExpression)
-    {
-        try
-        {
+    public static String getInvalidMessage(String cronExpression) {
+        try {
             new CronExpression(cronExpression);
             return null;
-        }
-        catch (ParseException pe)
-        {
+        } catch (ParseException pe) {
             return pe.getMessage();
         }
     }
@@ -48,15 +42,11 @@ public class CronUtils
      * @param cronExpression Cron表达式
      * @return Date 下次Cron表达式执行时间
      */
-    public static Date getNextExecution(String cronExpression)
-    {
-        try
-        {
+    public static Date getNextExecution(String cronExpression) {
+        try {
             CronExpression cron = new CronExpression(cronExpression);
             return cron.getNextValidTimeAfter(new Date(System.currentTimeMillis()));
-        }
-        catch (ParseException e)
-        {
+        } catch (ParseException e) {
             throw new IllegalArgumentException(e.getMessage());
         }
     }

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 4 - 1
ruoyi-ui/src/assets/icons/svg/404.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 4 - 1
ruoyi-ui/src/assets/icons/svg/bug.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 11 - 1
ruoyi-ui/src/assets/icons/svg/build.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 10 - 1
ruoyi-ui/src/assets/icons/svg/button.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 11 - 1
ruoyi-ui/src/assets/icons/svg/cascader.svg


+ 3 - 1
ruoyi-ui/src/assets/icons/svg/chart.svg

@@ -1 +1,3 @@
-<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg"><path d="M0 54.857h36.571V128H0V54.857zM91.429 27.43H128V128H91.429V27.429zM45.714 0h36.572v128H45.714V0z"/></svg>
+<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg">
+  <path d="M0 54.857h36.571V128H0V54.857zM91.429 27.43H128V128H91.429V27.429zM45.714 0h36.572v128H45.714V0z"/>
+</svg>

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 14 - 1
ruoyi-ui/src/assets/icons/svg/checkbox.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 4 - 1
ruoyi-ui/src/assets/icons/svg/clipboard.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 11 - 1
ruoyi-ui/src/assets/icons/svg/code.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 14 - 1
ruoyi-ui/src/assets/icons/svg/color.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 11 - 1
ruoyi-ui/src/assets/icons/svg/component.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 4 - 1
ruoyi-ui/src/assets/icons/svg/dashboard.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 14 - 1
ruoyi-ui/src/assets/icons/svg/date-range.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 11 - 1
ruoyi-ui/src/assets/icons/svg/date.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 14 - 1
ruoyi-ui/src/assets/icons/svg/dict.svg


+ 4 - 1
ruoyi-ui/src/assets/icons/svg/documentation.svg

@@ -1 +1,4 @@
-<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg"><path d="M71.984 44.815H115.9L71.984 9.642v35.173zM16.094.05h63.875l47.906 38.37v76.74c0 3.392-1.682 6.645-4.677 9.044-2.995 2.399-7.056 3.746-11.292 3.746H16.094c-4.236 0-8.297-1.347-11.292-3.746-2.995-2.399-4.677-5.652-4.677-9.044V12.84C.125 5.742 7.23.05 16.094.05zm71.86 102.32V89.58h-71.86v12.79h71.86zm23.952-25.58V64H16.094v12.79h95.812z"/></svg>
+<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg">
+  <path
+    d="M71.984 44.815H115.9L71.984 9.642v35.173zM16.094.05h63.875l47.906 38.37v76.74c0 3.392-1.682 6.645-4.677 9.044-2.995 2.399-7.056 3.746-11.292 3.746H16.094c-4.236 0-8.297-1.347-11.292-3.746-2.995-2.399-4.677-5.652-4.677-9.044V12.84C.125 5.742 7.23.05 16.094.05zm71.86 102.32V89.58h-71.86v12.79h71.86zm23.952-25.58V64H16.094v12.79h95.812z"/>
+</svg>

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 14 - 1
ruoyi-ui/src/assets/icons/svg/download.svg


+ 4 - 1
ruoyi-ui/src/assets/icons/svg/drag.svg

@@ -1 +1,4 @@
-<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg"><path d="M73.137 29.08h-9.209 29.7L63.886.093 34.373 29.08h20.49v27.035H27.238v17.948h27.625v27.133h18.274V74.063h27.41V56.115h-27.41V29.08zm-9.245 98.827l27.518-26.711H36.59l27.302 26.71zM.042 64.982l27.196 27.029V38.167L.042 64.982zm100.505-26.815V92.01l27.41-27.029-27.41-26.815z"/></svg>
+<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg">
+  <path
+    d="M73.137 29.08h-9.209 29.7L63.886.093 34.373 29.08h20.49v27.035H27.238v17.948h27.625v27.133h18.274V74.063h27.41V56.115h-27.41V29.08zm-9.245 98.827l27.518-26.711H36.59l27.302 26.71zM.042 64.982l27.196 27.029V38.167L.042 64.982zm100.505-26.815V92.01l27.41-27.029-27.41-26.815z"/>
+</svg>

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 11 - 1
ruoyi-ui/src/assets/icons/svg/druid.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 6 - 1
ruoyi-ui/src/assets/icons/svg/edit.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 4 - 1
ruoyi-ui/src/assets/icons/svg/education.svg


+ 5 - 1
ruoyi-ui/src/assets/icons/svg/email.svg

@@ -1 +1,5 @@
-<svg width="128" height="96" xmlns="http://www.w3.org/2000/svg"><path d="M64.125 56.975L120.188.912A12.476 12.476 0 0 0 115.5 0h-103c-1.588 0-3.113.3-4.513.838l56.138 56.137z"/><path d="M64.125 68.287l-62.3-62.3A12.42 12.42 0 0 0 0 12.5v71C0 90.4 5.6 96 12.5 96h103c6.9 0 12.5-5.6 12.5-12.5v-71a12.47 12.47 0 0 0-1.737-6.35L64.125 68.287z"/></svg>
+<svg width="128" height="96" xmlns="http://www.w3.org/2000/svg">
+  <path d="M64.125 56.975L120.188.912A12.476 12.476 0 0 0 115.5 0h-103c-1.588 0-3.113.3-4.513.838l56.138 56.137z"/>
+  <path
+    d="M64.125 68.287l-62.3-62.3A12.42 12.42 0 0 0 0 12.5v71C0 90.4 5.6 96 12.5 96h103c6.9 0 12.5-5.6 12.5-12.5v-71a12.47 12.47 0 0 0-1.737-6.35L64.125 68.287z"/>
+</svg>

+ 4 - 1
ruoyi-ui/src/assets/icons/svg/example.svg

@@ -1 +1,4 @@
-<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg"><path d="M96.258 57.462h31.421C124.794 27.323 100.426 2.956 70.287.07v31.422a32.856 32.856 0 0 1 25.971 25.97zm-38.796-25.97V.07C27.323 2.956 2.956 27.323.07 57.462h31.422a32.856 32.856 0 0 1 25.97-25.97zm12.825 64.766v31.421c30.46-2.885 54.507-27.253 57.713-57.712H96.579c-2.886 13.466-13.146 23.726-26.292 26.291zM31.492 70.287H.07c2.886 30.46 27.253 54.507 57.713 57.713V96.579c-13.466-2.886-23.726-13.146-26.291-26.292z"/></svg>
+<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg">
+  <path
+    d="M96.258 57.462h31.421C124.794 27.323 100.426 2.956 70.287.07v31.422a32.856 32.856 0 0 1 25.971 25.97zm-38.796-25.97V.07C27.323 2.956 2.956 27.323.07 57.462h31.422a32.856 32.856 0 0 1 25.97-25.97zm12.825 64.766v31.421c30.46-2.885 54.507-27.253 57.713-57.712H96.579c-2.886 13.466-13.146 23.726-26.292 26.291zM31.492 70.287H.07c2.886 30.46 27.253 54.507 57.713 57.713V96.579c-13.466-2.886-23.726-13.146-26.291-26.292z"/>
+</svg>

+ 6 - 1
ruoyi-ui/src/assets/icons/svg/excel.svg

@@ -1 +1,6 @@
-<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg"><path d="M78.208 16.576v8.384h38.72v5.376h-38.72v8.704h38.72v5.376h-38.72v8.576h38.72v5.376h-38.72v8.576h38.72v5.376h-38.72v8.576h38.72v5.376h-38.72v8.512h38.72v5.376h-38.72v11.136H128v-94.72H78.208zM0 114.368L72.128 128V0L0 13.632v100.736z"/><path d="M28.672 82.56h-11.2l14.784-23.488-14.08-22.592h11.52l8.192 14.976 8.448-14.976h11.136l-14.08 22.208L58.368 82.56H46.656l-8.768-15.68z"/></svg>
+<svg width="128" height="128" xmlns="http://www.w3.org/2000/svg">
+  <path
+    d="M78.208 16.576v8.384h38.72v5.376h-38.72v8.704h38.72v5.376h-38.72v8.576h38.72v5.376h-38.72v8.576h38.72v5.376h-38.72v8.576h38.72v5.376h-38.72v8.512h38.72v5.376h-38.72v11.136H128v-94.72H78.208zM0 114.368L72.128 128V0L0 13.632v100.736z"/>
+  <path
+    d="M28.672 82.56h-11.2l14.784-23.488-14.08-22.592h11.52l8.192 14.976 8.448-14.976h11.136l-14.08 22.208L58.368 82.56H46.656l-8.768-15.68z"/>
+</svg>

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 4 - 1
ruoyi-ui/src/assets/icons/svg/exit-fullscreen.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 7 - 1
ruoyi-ui/src/assets/icons/svg/eye-open.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 4 - 1
ruoyi-ui/src/assets/icons/svg/eye.svg


Filskillnaden har hållts tillbaka eftersom den är för stor
+ 4 - 1
ruoyi-ui/src/assets/icons/svg/form.svg


+ 0 - 0
ruoyi-ui/src/assets/icons/svg/fullscreen.svg


Vissa filer visades inte eftersom för många filer har ändrats