diff --git a/ruoyi/.gitignore b/.gitignore similarity index 100% rename from ruoyi/.gitignore rename to .gitignore diff --git a/ruoyi/bin/clean.bat b/bin/clean.bat similarity index 100% rename from ruoyi/bin/clean.bat rename to bin/clean.bat diff --git a/ruoyi/bin/package.bat b/bin/package.bat similarity index 100% rename from ruoyi/bin/package.bat rename to bin/package.bat diff --git a/bin/run.bat b/bin/run.bat new file mode 100644 index 000000000..e5fb6a6b2 --- /dev/null +++ b/bin/run.bat @@ -0,0 +1,14 @@ +@echo off +echo. +echo [信息] 运行Web工程。 +echo. + +cd %~dp0 +cd ../ruoyi-admin/target + +set JAVA_OPTS=-Xms256m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m + +java -jar %JAVA_OPTS% ruoyi-admin.jar + +cd bin +pause \ No newline at end of file diff --git a/doc/鑻ヤ緷鐜浣跨敤鎵嬪唽.docx b/doc/鑻ヤ緷鐜浣跨敤鎵嬪唽.docx new file mode 100644 index 000000000..9e4daef4d Binary files /dev/null and b/doc/鑻ヤ緷鐜浣跨敤鎵嬪唽.docx differ diff --git a/pom.xml b/pom.xml new file mode 100644 index 000000000..cb9ecfbb2 --- /dev/null +++ b/pom.xml @@ -0,0 +1,234 @@ + + + 4.0.0 + + com.ruoyi + ruoyi + 3.0.0 + + ruoyi + http://www.ruoyi.vip + 鑻ヤ緷绠$悊绯荤粺 + + + 3.0.0 + UTF-8 + UTF-8 + 1.8 + 1.3.2 + 1.1.14 + 1.19 + 2.9.2 + 1.2.5 + 1.2.70 + 3.9.1 + 2.5 + 1.3.3 + 3.17 + 1.7 + 0.9.0 + + + + + + + + + org.springframework.boot + spring-boot-dependencies + 2.1.1.RELEASE + pom + import + + + + + com.alibaba + druid-spring-boot-starter + ${druid.version} + + + + + eu.bitwalker + UserAgentUtils + ${bitwalker.version} + + + + + com.github.pagehelper + pagehelper-spring-boot-starter + ${pagehelper.boot.version} + + + + + com.github.oshi + oshi-core + ${oshi.version} + + + + + io.springfox + springfox-swagger2 + ${swagger.version} + + + io.swagger + swagger-annotations + + + io.swagger + swagger-models + + + + + + + io.springfox + springfox-swagger-ui + ${swagger.version} + + + + + commons-io + commons-io + ${commons.io.version} + + + + + commons-fileupload + commons-fileupload + ${commons.fileupload.version} + + + + + org.apache.poi + poi-ooxml + ${poi.version} + + + + + org.apache.velocity + velocity + ${velocity.version} + + + + + com.alibaba + fastjson + ${fastjson.version} + + + + + io.jsonwebtoken + jjwt + ${jwt.version} + + + + + com.ruoyi + ruoyi-quartz + ${ruoyi.version} + + + + + com.ruoyi + ruoyi-generator + ${ruoyi.version} + + + + + com.ruoyi + ruoyi-framework + ${ruoyi.version} + + + + + com.ruoyi + ruoyi-system + ${ruoyi.version} + + + + + com.ruoyi + ruoyi-common + ${ruoyi.version} + + + + + + + ruoyi-admin + ruoyi-framework + ruoyi-system + ruoyi-quartz + ruoyi-generator + ruoyi-common + + pom + + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + ${java.version} + ${java.version} + ${project.build.sourceEncoding} + + + + + + + + public + aliyun nexus + http://maven.aliyun.com/nexus/content/groups/public/ + + true + + + + + + + public + aliyun nexus + http://maven.aliyun.com/nexus/content/groups/public/ + + true + + + false + + + + + \ No newline at end of file diff --git a/ruoyi-admin/pom.xml b/ruoyi-admin/pom.xml new file mode 100644 index 000000000..1ed741f4f --- /dev/null +++ b/ruoyi-admin/pom.xml @@ -0,0 +1,108 @@ + + + + ruoyi + com.ruoyi + 3.0.0 + + 4.0.0 + jar + ruoyi-admin + + + web鏈嶅姟鍏ュ彛 + + + + + + + org.springframework.boot + spring-boot-devtools + true + + + + + io.springfox + springfox-swagger2 + + + + + io.swagger + swagger-annotations + 1.5.21 + + + + io.swagger + swagger-models + 1.5.21 + + + + + io.springfox + springfox-swagger-ui + + + + + mysql + mysql-connector-java + + + + + com.ruoyi + ruoyi-framework + + + + + com.ruoyi + ruoyi-quartz + + + + + com.ruoyi + ruoyi-generator + + + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.1.1.RELEASE + + true + + + + + repackage + + + + + + org.apache.maven.plugins + maven-war-plugin + 3.0.0 + + false + ${project.artifactId} + + + + ${project.artifactId} + + + \ No newline at end of file diff --git a/ruoyi/src/main/java/com/ruoyi/RuoYiApplication.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/RuoYiApplication.java rename to ruoyi-admin/src/main/java/com/ruoyi/RuoYiApplication.java diff --git a/ruoyi/src/main/java/com/ruoyi/RuoYiServletInitializer.java b/ruoyi-admin/src/main/java/com/ruoyi/RuoYiServletInitializer.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/RuoYiServletInitializer.java rename to ruoyi-admin/src/main/java/com/ruoyi/RuoYiServletInitializer.java diff --git a/ruoyi/src/main/java/com/ruoyi/project/common/CaptchaController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java similarity index 87% rename from ruoyi/src/main/java/com/ruoyi/project/common/CaptchaController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java index 9a3af208b..a4ee00ff6 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/common/CaptchaController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.common; +package com.ruoyi.web.controller.common; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -8,11 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.constant.Constants; -import com.ruoyi.common.utils.IdUtils; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.utils.VerifyCodeUtils; import com.ruoyi.common.utils.sign.Base64; -import com.ruoyi.framework.redis.RedisCache; -import com.ruoyi.framework.web.domain.AjaxResult; +import com.ruoyi.common.utils.uuid.IdUtils; /** * 楠岃瘉鐮佹搷浣滃鐞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/common/CommonController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/project/common/CommonController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java index b59fb29c0..9cba04dca 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/common/CommonController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CommonController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.common; +package com.ruoyi.web.controller.common; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -9,13 +9,13 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.file.FileUploadUtils; import com.ruoyi.common.utils.file.FileUtils; -import com.ruoyi.framework.config.RuoYiConfig; import com.ruoyi.framework.config.ServerConfig; -import com.ruoyi.framework.web.domain.AjaxResult; /** * 閫氱敤璇锋眰澶勭悊 diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/ServerController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java similarity index 79% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/controller/ServerController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java index a69222615..2f0c86e73 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/ServerController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/ServerController.java @@ -1,11 +1,11 @@ -package com.ruoyi.project.monitor.controller; +package com.ruoyi.web.controller.monitor; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.framework.web.domain.Server; /** diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysLogininforController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java similarity index 80% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysLogininforController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java index ecda07647..560c4b585 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysLogininforController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysLogininforController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.monitor.controller; +package com.ruoyi.web.controller.monitor; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -8,14 +8,14 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.framework.web.page.TableDataInfo; -import com.ruoyi.project.monitor.domain.SysLogininfor; -import com.ruoyi.project.monitor.service.ISysLogininforService; +import com.ruoyi.system.domain.SysLogininfor; +import com.ruoyi.system.service.ISysLogininforService; /** * 绯荤粺璁块棶璁板綍 diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysOperlogController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java similarity index 79% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysOperlogController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java index d0d5c340b..194285613 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysOperlogController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysOperlogController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.monitor.controller; +package com.ruoyi.web.controller.monitor; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -8,14 +8,14 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.framework.web.page.TableDataInfo; -import com.ruoyi.project.monitor.domain.SysOperLog; -import com.ruoyi.project.monitor.service.ISysOperLogService; +import com.ruoyi.system.domain.SysOperLog; +import com.ruoyi.system.service.ISysOperLogService; /** * 鎿嶄綔鏃ュ織璁板綍 diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysUserOnlineController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java similarity index 82% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysUserOnlineController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java index 5a7301912..7f73813a0 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysUserOnlineController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/monitor/SysUserOnlineController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.monitor.controller; +package com.ruoyi.web.controller.monitor; import java.util.ArrayList; import java.util.Collection; @@ -11,17 +11,17 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.redis.RedisCache; -import com.ruoyi.framework.security.LoginUser; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.framework.web.page.TableDataInfo; -import com.ruoyi.project.monitor.domain.SysUserOnline; -import com.ruoyi.project.system.service.ISysUserOnlineService; +import com.ruoyi.system.domain.SysUserOnline; +import com.ruoyi.system.service.ISysUserOnlineService; /** * 鍦ㄧ嚎鐢ㄦ埛鐩戞帶 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysConfigController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java similarity index 88% rename from ruoyi/src/main/java/com/ruoyi/project/system/controller/SysConfigController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java index 9a832cb59..41b82098e 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysConfigController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysConfigController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.controller; +package com.ruoyi.web.controller.system; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -12,16 +12,17 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.annotation.RepeatSubmit; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.framework.web.page.TableDataInfo; -import com.ruoyi.project.system.domain.SysConfig; -import com.ruoyi.project.system.service.ISysConfigService; +import com.ruoyi.system.domain.SysConfig; +import com.ruoyi.system.service.ISysConfigService; /** * 鍙傛暟閰嶇疆 淇℃伅鎿嶄綔澶勭悊 @@ -82,6 +83,7 @@ public class SysConfigController extends BaseController @PreAuthorize("@ss.hasPermi('system:config:add')") @Log(title = "鍙傛暟绠$悊", businessType = BusinessType.INSERT) @PostMapping + @RepeatSubmit public AjaxResult add(@Validated @RequestBody SysConfig config) { if (UserConstants.NOT_UNIQUE.equals(configService.checkConfigKeyUnique(config))) diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java similarity index 90% rename from ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java index e549a4324..60bd1a5b5 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDeptController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDeptController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.controller; +package com.ruoyi.web.controller.system; import java.util.Iterator; import java.util.List; @@ -14,15 +14,15 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.project.system.domain.SysDept; -import com.ruoyi.project.system.service.ISysDeptService; +import com.ruoyi.system.service.ISysDeptService; /** * 閮ㄩ棬淇℃伅 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java similarity index 85% rename from ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java index 8b3b394e5..58cf43d22 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictDataController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.controller; +package com.ruoyi.web.controller.system; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -12,16 +12,16 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.framework.web.page.TableDataInfo; -import com.ruoyi.project.system.domain.SysDictData; -import com.ruoyi.project.system.service.ISysDictDataService; -import com.ruoyi.project.system.service.ISysDictTypeService; +import com.ruoyi.system.service.ISysDictDataService; +import com.ruoyi.system.service.ISysDictTypeService; /** * 鏁版嵁瀛楀吀淇℃伅 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java similarity index 88% rename from ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java index 816d5438a..efde2d49f 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysDictTypeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictTypeController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.controller; +package com.ruoyi.web.controller.system; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -12,16 +12,16 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysDictType; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.framework.web.page.TableDataInfo; -import com.ruoyi.project.system.domain.SysDictType; -import com.ruoyi.project.system.service.ISysDictTypeService; +import com.ruoyi.system.service.ISysDictTypeService; /** * 鏁版嵁瀛楀吀淇℃伅 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysLoginController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java similarity index 79% rename from ruoyi/src/main/java/com/ruoyi/project/system/controller/SysLoginController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java index 73aaa71c4..4ade9f683 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysLoginController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysLoginController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.controller; +package com.ruoyi.web.controller.system; import java.util.List; import java.util.Set; @@ -8,16 +8,16 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RestController; import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysMenu; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.LoginBody; +import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.ServletUtils; -import com.ruoyi.framework.security.LoginBody; -import com.ruoyi.framework.security.LoginUser; -import com.ruoyi.framework.security.service.SysLoginService; -import com.ruoyi.framework.security.service.SysPermissionService; -import com.ruoyi.framework.security.service.TokenService; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.project.system.domain.SysMenu; -import com.ruoyi.project.system.domain.SysUser; -import com.ruoyi.project.system.service.ISysMenuService; +import com.ruoyi.framework.web.service.SysLoginService; +import com.ruoyi.framework.web.service.SysPermissionService; +import com.ruoyi.framework.web.service.TokenService; +import com.ruoyi.system.service.ISysMenuService; /** * 鐧诲綍楠岃瘉 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysMenuController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/system/controller/SysMenuController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java index a958f62c0..8bdfe9169 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysMenuController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysMenuController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.controller; +package com.ruoyi.web.controller.system; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -12,19 +12,19 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysMenu; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.security.LoginUser; -import com.ruoyi.framework.security.service.TokenService; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.project.system.domain.SysMenu; -import com.ruoyi.project.system.service.ISysMenuService; +import com.ruoyi.framework.web.service.TokenService; +import com.ruoyi.system.service.ISysMenuService; /** * 鑿滃崟淇℃伅 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java similarity index 83% rename from ruoyi/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java index 9f003927d..029ee385b 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysNoticeController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysNoticeController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.controller; +package com.ruoyi.web.controller.system; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -12,14 +12,14 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.framework.web.page.TableDataInfo; -import com.ruoyi.project.system.domain.SysNotice; -import com.ruoyi.project.system.service.ISysNoticeService; +import com.ruoyi.system.domain.SysNotice; +import com.ruoyi.system.service.ISysNoticeService; /** * 鍏憡 淇℃伅鎿嶄綔澶勭悊 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysPostController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java similarity index 88% rename from ruoyi/src/main/java/com/ruoyi/project/system/controller/SysPostController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java index 0c30ef798..67d76ee0b 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysPostController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysPostController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.controller; +package com.ruoyi.web.controller.system; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -12,16 +12,16 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.framework.web.page.TableDataInfo; -import com.ruoyi.project.system.domain.SysPost; -import com.ruoyi.project.system.service.ISysPostService; +import com.ruoyi.system.domain.SysPost; +import com.ruoyi.system.service.ISysPostService; /** * 宀椾綅淇℃伅鎿嶄綔澶勭悊 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java similarity index 87% rename from ruoyi/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java index 8b0b38e1a..bfedddfdd 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysProfileController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysProfileController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.controller; +package com.ruoyi.web.controller.system; import java.io.IOException; import org.springframework.beans.factory.annotation.Autowired; @@ -10,18 +10,18 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.file.FileUploadUtils; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.config.RuoYiConfig; -import com.ruoyi.framework.security.LoginUser; -import com.ruoyi.framework.security.service.TokenService; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.project.system.domain.SysUser; -import com.ruoyi.project.system.service.ISysUserService; +import com.ruoyi.framework.web.service.TokenService; +import com.ruoyi.system.service.ISysUserService; /** * 涓汉淇℃伅 涓氬姟澶勭悊 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysRoleController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/system/controller/SysRoleController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java index 62ab85842..927a6c283 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysRoleController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysRoleController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.controller; +package com.ruoyi.web.controller.system; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -12,16 +12,16 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.framework.web.page.TableDataInfo; -import com.ruoyi.project.system.domain.SysRole; -import com.ruoyi.project.system.service.ISysRoleService; +import com.ruoyi.system.service.ISysRoleService; /** * 瑙掕壊淇℃伅 @@ -151,4 +151,4 @@ public class SysRoleController extends BaseController { return AjaxResult.success(roleService.selectRoleAll()); } -} \ No newline at end of file +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysUserController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java similarity index 88% rename from ruoyi/src/main/java/com/ruoyi/project/system/controller/SysUserController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java index 5c6857008..946df4d60 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/controller/SysUserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.controller; +package com.ruoyi.web.controller.system; import java.util.List; import java.util.stream.Collectors; @@ -14,23 +14,23 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.multipart.MultipartFile; +import com.ruoyi.common.annotation.Log; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.security.LoginUser; -import com.ruoyi.framework.security.service.TokenService; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.framework.web.page.TableDataInfo; -import com.ruoyi.project.system.domain.SysRole; -import com.ruoyi.project.system.domain.SysUser; -import com.ruoyi.project.system.service.ISysPostService; -import com.ruoyi.project.system.service.ISysRoleService; -import com.ruoyi.project.system.service.ISysUserService; +import com.ruoyi.framework.web.service.TokenService; +import com.ruoyi.system.service.ISysPostService; +import com.ruoyi.system.service.ISysRoleService; +import com.ruoyi.system.service.ISysUserService; /** * 鐢ㄦ埛淇℃伅 @@ -198,4 +198,4 @@ public class SysUserController extends BaseController user.setUpdateBy(SecurityUtils.getUsername()); return toAjax(userService.updateUserStatus(user)); } -} \ No newline at end of file +} diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/SwaggerController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/SwaggerController.java new file mode 100644 index 000000000..e901fedd7 --- /dev/null +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/SwaggerController.java @@ -0,0 +1,24 @@ +package com.ruoyi.web.controller.tool; + +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import com.ruoyi.common.core.controller.BaseController; + +/** + * swagger 鎺ュ彛 + * + * @author ruoyi + */ +@Controller +@RequestMapping("/tool/swagger") +public class SwaggerController extends BaseController +{ + @PreAuthorize("@ss.hasPermi('tool:swagger:view')") + @GetMapping() + public String index() + { + return redirect("/swagger-ui.html"); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/swagger/TestController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/project/tool/swagger/TestController.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java index 17f4c31e7..2ae0c54ac 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/swagger/TestController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/tool/TestController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.tool.swagger; +package com.ruoyi.web.controller.tool; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -11,9 +11,9 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiModel; diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java similarity index 95% rename from ruoyi/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java rename to ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java index 969268565..86acc3f0b 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/config/SwaggerConfig.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/core/config/SwaggerConfig.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.config; +package com.ruoyi.web.core.config; import java.util.ArrayList; import java.util.List; @@ -6,6 +6,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import com.ruoyi.common.config.RuoYiConfig; import io.swagger.annotations.ApiOperation; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; diff --git a/ruoyi/src/main/resources/META-INF/spring-devtools.properties b/ruoyi-admin/src/main/resources/META-INF/spring-devtools.properties similarity index 100% rename from ruoyi/src/main/resources/META-INF/spring-devtools.properties rename to ruoyi-admin/src/main/resources/META-INF/spring-devtools.properties diff --git a/ruoyi/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml similarity index 100% rename from ruoyi/src/main/resources/application-druid.yml rename to ruoyi-admin/src/main/resources/application-druid.yml diff --git a/ruoyi/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml similarity index 80% rename from ruoyi/src/main/resources/application.yml rename to ruoyi-admin/src/main/resources/application.yml index cf23b8e06..c87725a42 100644 --- a/ruoyi/src/main/resources/application.yml +++ b/ruoyi-admin/src/main/resources/application.yml @@ -3,7 +3,7 @@ ruoyi: # 鍚嶇О name: RuoYi # 鐗堟湰 - version: 2.3.0 + version: 3.0.0 # 鐗堟潈骞翠唤 copyrightYear: 2019 # 瀹炰緥婕旂ず寮鍏 @@ -87,9 +87,9 @@ token: # MyBatis閰嶇疆 mybatis: # 鎼滅储鎸囧畾鍖呭埆鍚 - typeAliasesPackage: com.ruoyi.project.**.domain + typeAliasesPackage: com.ruoyi.**.domain # 閰嶇疆mapper鐨勬壂鎻忥紝鎵惧埌鎵鏈夌殑mapper.xml鏄犲皠鏂囦欢 - mapperLocations: classpath*:mybatis/**/*Mapper.xml + mapperLocations: classpath*:mapper/**/*Mapper.xml # 鍔犺浇鍏ㄥ眬鐨勯厤缃枃浠 configLocation: classpath:mybatis/mybatis-config.xml @@ -115,14 +115,3 @@ xss: excludes: /system/notice/* # 鍖归厤閾炬帴 urlPatterns: /system/*,/monitor/*,/tool/* - -# 浠g爜鐢熸垚 -gen: - # 浣滆 - author: ruoyi - # 榛樿鐢熸垚鍖呰矾寰 system 闇鏀规垚鑷繁鐨勬ā鍧楀悕绉 濡 system monitor tool - packageName: com.ruoyi.project.system - # 鑷姩鍘婚櫎琛ㄥ墠缂锛岄粯璁ゆ槸true - autoRemovePre: false - # 琛ㄥ墠缂锛堢敓鎴愮被鍚嶄笉浼氬寘鍚〃鍓嶇紑锛屽涓敤閫楀彿鍒嗛殧锛 - tablePrefix: sys_ \ No newline at end of file diff --git a/ruoyi/src/main/resources/banner.txt b/ruoyi-admin/src/main/resources/banner.txt similarity index 100% rename from ruoyi/src/main/resources/banner.txt rename to ruoyi-admin/src/main/resources/banner.txt diff --git a/ruoyi/src/main/resources/i18n/messages.properties b/ruoyi-admin/src/main/resources/i18n/messages.properties similarity index 100% rename from ruoyi/src/main/resources/i18n/messages.properties rename to ruoyi-admin/src/main/resources/i18n/messages.properties diff --git a/ruoyi/src/main/resources/logback.xml b/ruoyi-admin/src/main/resources/logback.xml similarity index 100% rename from ruoyi/src/main/resources/logback.xml rename to ruoyi-admin/src/main/resources/logback.xml diff --git a/ruoyi/src/main/resources/mybatis/mybatis-config.xml b/ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml similarity index 100% rename from ruoyi/src/main/resources/mybatis/mybatis-config.xml rename to ruoyi-admin/src/main/resources/mybatis/mybatis-config.xml diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml new file mode 100644 index 000000000..e4c677a2a --- /dev/null +++ b/ruoyi-common/pom.xml @@ -0,0 +1,124 @@ + + + + ruoyi + com.ruoyi + 3.0.0 + + 4.0.0 + + ruoyi-common + + + common閫氱敤宸ュ叿 + + + + + + + org.springframework + spring-context-support + + + + + org.springframework + spring-web + + + + + org.springframework.boot + spring-boot-starter-security + + + + + com.github.pagehelper + pagehelper-spring-boot-starter + + + + + javax.validation + validation-api + + + + + org.apache.commons + commons-lang3 + + + + + com.fasterxml.jackson.core + jackson-databind + + + + + com.alibaba + fastjson + + + + + commons-io + commons-io + + + + + commons-fileupload + commons-fileupload + + + + + org.apache.poi + poi-ooxml + + + + + org.yaml + snakeyaml + + + + + io.jsonwebtoken + jjwt + + + + + org.springframework.boot + spring-boot-starter-data-redis + + + + + org.apache.commons + commons-pool2 + + + + + eu.bitwalker + UserAgentUtils + + + + + javax.servlet + javax.servlet-api + + + + + \ No newline at end of file diff --git a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/DataScope.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java similarity index 86% rename from ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/DataScope.java rename to ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java index 5e4cc9c2d..fe5a01f55 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/DataScope.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataScope.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.aspectj.lang.annotation; +package com.ruoyi.common.annotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/DataSource.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java similarity index 82% rename from ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/DataSource.java rename to ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java index 15a1d82eb..6b41ee739 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/DataSource.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/DataSource.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.aspectj.lang.annotation; +package com.ruoyi.common.annotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; @@ -6,7 +6,7 @@ import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.ruoyi.framework.aspectj.lang.enums.DataSourceType; +import com.ruoyi.common.enums.DataSourceType; /** * 鑷畾涔夊鏁版嵁婧愬垏鎹㈡敞瑙 diff --git a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Excel.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Excel.java rename to ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java index de25b1cf5..351979176 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Excel.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excel.java @@ -1,118 +1,118 @@ -package com.ruoyi.framework.aspectj.lang.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * 鑷畾涔夊鍑篍xcel鏁版嵁娉ㄨВ - * - * @author ruoyi - */ -@Retention(RetentionPolicy.RUNTIME) -@Target(ElementType.FIELD) -public @interface Excel -{ - /** - * 瀵煎嚭鏃跺湪excel涓帓搴 - */ - public int sort() default Integer.MAX_VALUE; - - /** - * 瀵煎嚭鍒癊xcel涓殑鍚嶅瓧. - */ - public String name() default ""; - - /** - * 鏃ユ湡鏍煎紡, 濡: yyyy-MM-dd - */ - public String dateFormat() default ""; - - /** - * 璇诲彇鍐呭杞〃杈惧紡 (濡: 0=鐢,1=濂,2=鏈煡) - */ - public String readConverterExp() default ""; - - /** - * 瀵煎嚭绫诲瀷锛0鏁板瓧 1瀛楃涓诧級 - */ - public ColumnType cellType() default ColumnType.STRING; - - /** - * 瀵煎嚭鏃跺湪excel涓瘡涓垪鐨勯珮搴 鍗曚綅涓哄瓧绗 - */ - public double height() default 14; - - /** - * 瀵煎嚭鏃跺湪excel涓瘡涓垪鐨勫 鍗曚綅涓哄瓧绗 - */ - public double width() default 16; - - /** - * 鏂囧瓧鍚庣紑,濡% 90 鍙樻垚90% - */ - public String suffix() default ""; - - /** - * 褰撳间负绌烘椂,瀛楁鐨勯粯璁ゅ - */ - public String defaultValue() default ""; - - /** - * 鎻愮ず淇℃伅 - */ - public String prompt() default ""; - - /** - * 璁剧疆鍙兘閫夋嫨涓嶈兘杈撳叆鐨勫垪鍐呭. - */ - public String[] combo() default {}; - - /** - * 鏄惁瀵煎嚭鏁版嵁,搴斿闇姹:鏈夋椂鎴戜滑闇瑕佸鍑轰竴浠芥ā鏉,杩欐槸鏍囬闇瑕佷絾鍐呭闇瑕佺敤鎴锋墜宸ュ~鍐. - */ - public boolean isExport() default true; - - /** - * 鍙︿竴涓被涓殑灞炴у悕绉,鏀寔澶氱骇鑾峰彇,浠ュ皬鏁扮偣闅斿紑 - */ - public String targetAttr() default ""; - - /** - * 瀛楁绫诲瀷锛0锛氬鍑哄鍏ワ紱1锛氫粎瀵煎嚭锛2锛氫粎瀵煎叆锛 - */ - Type type() default Type.ALL; - - public enum Type - { - ALL(0), EXPORT(1), IMPORT(2); - private final int value; - - Type(int value) - { - this.value = value; - } - - public int value() - { - return this.value; - } - } - - public enum ColumnType - { - NUMERIC(0), STRING(1); - private final int value; - - ColumnType(int value) - { - this.value = value; - } - - public int value() - { - return this.value; - } - } -} \ No newline at end of file +package com.ruoyi.common.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * 鑷畾涔夊鍑篍xcel鏁版嵁娉ㄨВ + * + * @author ruoyi + */ +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.FIELD) +public @interface Excel +{ + /** + * 瀵煎嚭鏃跺湪excel涓帓搴 + */ + public int sort() default Integer.MAX_VALUE; + + /** + * 瀵煎嚭鍒癊xcel涓殑鍚嶅瓧. + */ + public String name() default ""; + + /** + * 鏃ユ湡鏍煎紡, 濡: yyyy-MM-dd + */ + public String dateFormat() default ""; + + /** + * 璇诲彇鍐呭杞〃杈惧紡 (濡: 0=鐢,1=濂,2=鏈煡) + */ + public String readConverterExp() default ""; + + /** + * 瀵煎嚭绫诲瀷锛0鏁板瓧 1瀛楃涓诧級 + */ + public ColumnType cellType() default ColumnType.STRING; + + /** + * 瀵煎嚭鏃跺湪excel涓瘡涓垪鐨勯珮搴 鍗曚綅涓哄瓧绗 + */ + public double height() default 14; + + /** + * 瀵煎嚭鏃跺湪excel涓瘡涓垪鐨勫 鍗曚綅涓哄瓧绗 + */ + public double width() default 16; + + /** + * 鏂囧瓧鍚庣紑,濡% 90 鍙樻垚90% + */ + public String suffix() default ""; + + /** + * 褰撳间负绌烘椂,瀛楁鐨勯粯璁ゅ + */ + public String defaultValue() default ""; + + /** + * 鎻愮ず淇℃伅 + */ + public String prompt() default ""; + + /** + * 璁剧疆鍙兘閫夋嫨涓嶈兘杈撳叆鐨勫垪鍐呭. + */ + public String[] combo() default {}; + + /** + * 鏄惁瀵煎嚭鏁版嵁,搴斿闇姹:鏈夋椂鎴戜滑闇瑕佸鍑轰竴浠芥ā鏉,杩欐槸鏍囬闇瑕佷絾鍐呭闇瑕佺敤鎴锋墜宸ュ~鍐. + */ + public boolean isExport() default true; + + /** + * 鍙︿竴涓被涓殑灞炴у悕绉,鏀寔澶氱骇鑾峰彇,浠ュ皬鏁扮偣闅斿紑 + */ + public String targetAttr() default ""; + + /** + * 瀛楁绫诲瀷锛0锛氬鍑哄鍏ワ紱1锛氫粎瀵煎嚭锛2锛氫粎瀵煎叆锛 + */ + Type type() default Type.ALL; + + public enum Type + { + ALL(0), EXPORT(1), IMPORT(2); + private final int value; + + Type(int value) + { + this.value = value; + } + + public int value() + { + return this.value; + } + } + + public enum ColumnType + { + NUMERIC(0), STRING(1); + private final int value; + + ColumnType(int value) + { + this.value = value; + } + + public int value() + { + return this.value; + } + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Excels.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excels.java similarity index 84% rename from ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Excels.java rename to ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excels.java index ff2280201..940763f06 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Excels.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Excels.java @@ -1,18 +1,18 @@ -package com.ruoyi.framework.aspectj.lang.annotation; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** - * Excel娉ㄨВ闆 - * - * @author ruoyi - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Excels -{ - Excel[] value(); -} \ No newline at end of file +package com.ruoyi.common.annotation; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +/** + * Excel娉ㄨВ闆 + * + * @author ruoyi + */ +@Target(ElementType.FIELD) +@Retention(RetentionPolicy.RUNTIME) +public @interface Excels +{ + Excel[] value(); +} diff --git a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Log.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java similarity index 78% rename from ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Log.java rename to ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java index 548eaced3..3458c882d 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/annotation/Log.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/Log.java @@ -1,12 +1,12 @@ -package com.ruoyi.framework.aspectj.lang.annotation; +package com.ruoyi.common.annotation; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.aspectj.lang.enums.OperatorType; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.enums.OperatorType; /** * 鑷畾涔夋搷浣滄棩蹇楄褰曟敞瑙 diff --git a/ruoyi/src/main/java/com/ruoyi/framework/interceptor/annotation/RepeatSubmit.java b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java similarity index 87% rename from ruoyi/src/main/java/com/ruoyi/framework/interceptor/annotation/RepeatSubmit.java rename to ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java index 0fbd73b68..628eef1ef 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/interceptor/annotation/RepeatSubmit.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/annotation/RepeatSubmit.java @@ -1,23 +1,23 @@ -package com.ruoyi.framework.interceptor.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; - -/** - * 鑷畾涔夋敞瑙i槻姝㈣〃鍗曢噸澶嶆彁浜 - * - * @author ruoyi - * - */ -@Inherited -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -@Documented -public @interface RepeatSubmit -{ - -} \ No newline at end of file +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; + +/** + * 鑷畾涔夋敞瑙i槻姝㈣〃鍗曢噸澶嶆彁浜 + * + * @author ruoyi + * + */ +@Inherited +@Target(ElementType.METHOD) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface RepeatSubmit +{ + +} diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/RuoYiConfig.java b/ruoyi-common/src/main/java/com/ruoyi/common/config/RuoYiConfig.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/framework/config/RuoYiConfig.java rename to ruoyi-common/src/main/java/com/ruoyi/common/config/RuoYiConfig.java index 1f6e20ad1..c64ce71d6 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/config/RuoYiConfig.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/config/RuoYiConfig.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.config; +package com.ruoyi.common.config; import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.stereotype.Component; @@ -113,4 +113,4 @@ public class RuoYiConfig { return getProfile() + "/upload"; } -} \ No newline at end of file +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java rename to ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java index fe8afc003..9ee27077a 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/constant/Constants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/Constants.java @@ -1,7 +1,5 @@ package com.ruoyi.common.constant; -import io.jsonwebtoken.Claims; - /** * 閫氱敤甯搁噺淇℃伅 * @@ -92,7 +90,7 @@ public class Constants /** * 鐢ㄦ埛鍚嶇О */ - public static final String JWT_USERNAME = Claims.SUBJECT; + public static final String JWT_USERNAME = "sub"; /** * 鐢ㄦ埛澶村儚 diff --git a/ruoyi/src/main/java/com/ruoyi/common/constant/GenConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/constant/GenConstants.java rename to ruoyi-common/src/main/java/com/ruoyi/common/constant/GenConstants.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/constant/HttpStatus.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/HttpStatus.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/constant/HttpStatus.java rename to ruoyi-common/src/main/java/com/ruoyi/common/constant/HttpStatus.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java similarity index 95% rename from ruoyi/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java rename to ruoyi-common/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java index 62ad81545..8318b8f5f 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/constant/ScheduleConstants.java @@ -1,50 +1,50 @@ -package com.ruoyi.common.constant; - -/** - * 浠诲姟璋冨害閫氱敤甯搁噺 - * - * @author ruoyi - */ -public class ScheduleConstants -{ - public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME"; - - /** 鎵ц鐩爣key */ - public static final String TASK_PROPERTIES = "TASK_PROPERTIES"; - - /** 榛樿 */ - public static final String MISFIRE_DEFAULT = "0"; - - /** 绔嬪嵆瑙﹀彂鎵ц */ - public static final String MISFIRE_IGNORE_MISFIRES = "1"; - - /** 瑙﹀彂涓娆℃墽琛 */ - public static final String MISFIRE_FIRE_AND_PROCEED = "2"; - - /** 涓嶈Е鍙戠珛鍗虫墽琛 */ - public static final String MISFIRE_DO_NOTHING = "3"; - - public enum Status - { - /** - * 姝e父 - */ - NORMAL("0"), - /** - * 鏆傚仠 - */ - PAUSE("1"); - - private String value; - - private Status(String value) - { - this.value = value; - } - - public String getValue() - { - return value; - } - } -} +package com.ruoyi.common.constant; + +/** + * 浠诲姟璋冨害閫氱敤甯搁噺 + * + * @author ruoyi + */ +public class ScheduleConstants +{ + public static final String TASK_CLASS_NAME = "TASK_CLASS_NAME"; + + /** 鎵ц鐩爣key */ + public static final String TASK_PROPERTIES = "TASK_PROPERTIES"; + + /** 榛樿 */ + public static final String MISFIRE_DEFAULT = "0"; + + /** 绔嬪嵆瑙﹀彂鎵ц */ + public static final String MISFIRE_IGNORE_MISFIRES = "1"; + + /** 瑙﹀彂涓娆℃墽琛 */ + public static final String MISFIRE_FIRE_AND_PROCEED = "2"; + + /** 涓嶈Е鍙戠珛鍗虫墽琛 */ + public static final String MISFIRE_DO_NOTHING = "3"; + + public enum Status + { + /** + * 姝e父 + */ + NORMAL("0"), + /** + * 鏆傚仠 + */ + PAUSE("1"); + + private String value; + + private Status(String value) + { + this.value = value; + } + + public String getValue() + { + return value; + } + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/constant/UserConstants.java b/ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/constant/UserConstants.java rename to ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/controller/BaseController.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java similarity index 82% rename from ruoyi/src/main/java/com/ruoyi/framework/web/controller/BaseController.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java index cb9b7d0c5..ab78abdad 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/web/controller/BaseController.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/controller/BaseController.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.web.controller; +package com.ruoyi.common.core.controller; import java.beans.PropertyEditorSupport; import java.util.Date; @@ -10,13 +10,13 @@ import org.springframework.web.bind.annotation.InitBinder; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.PageDomain; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.core.page.TableSupport; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.sql.SqlUtil; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.framework.web.page.PageDomain; -import com.ruoyi.framework.web.page.TableDataInfo; -import com.ruoyi.framework.web.page.TableSupport; /** * web灞傞氱敤鏁版嵁澶勭悊 @@ -83,4 +83,12 @@ public class BaseController { return rows > 0 ? AjaxResult.success() : AjaxResult.error(); } + + /** + * 椤甸潰璺宠浆 + */ + public String redirect(String url) + { + return StringUtils.format("redirect:{}", url); + } } diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/AjaxResult.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java similarity index 94% rename from ruoyi/src/main/java/com/ruoyi/framework/web/domain/AjaxResult.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java index 5c551bd7b..b26e066ab 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/AjaxResult.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/AjaxResult.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.web.domain; +package com.ruoyi.common.core.domain; import java.util.HashMap; import com.ruoyi.common.constant.HttpStatus; diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/BaseEntity.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/framework/web/domain/BaseEntity.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java index 08f4f9027..a8c51a7b6 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/BaseEntity.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/BaseEntity.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.web.domain; +package com.ruoyi.common.core.domain; import java.io.Serializable; import java.util.Date; diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/TreeEntity.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeEntity.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/framework/web/domain/TreeEntity.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeEntity.java index af8643736..171f04c9b 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/TreeEntity.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeEntity.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.web.domain; +package com.ruoyi.common.core.domain; import java.util.ArrayList; import java.util.List; diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/TreeSelect.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java similarity index 86% rename from ruoyi/src/main/java/com/ruoyi/framework/web/domain/TreeSelect.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java index 2ace4e9c1..4a59e402a 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/TreeSelect.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java @@ -1,11 +1,11 @@ -package com.ruoyi.framework.web.domain; +package com.ruoyi.common.core.domain; import java.io.Serializable; import java.util.List; import java.util.stream.Collectors; import com.fasterxml.jackson.annotation.JsonInclude; -import com.ruoyi.project.system.domain.SysDept; -import com.ruoyi.project.system.domain.SysMenu; +import com.ruoyi.common.core.domain.entity.SysDept; +import com.ruoyi.common.core.domain.entity.SysMenu; /** * Treeselect鏍戠粨鏋勫疄浣撶被 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDept.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDept.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java index ba12f1549..423ef6852 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDept.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDept.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.domain; +package com.ruoyi.common.core.domain.entity; import java.util.ArrayList; import java.util.List; @@ -7,7 +7,7 @@ import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.framework.web.domain.BaseEntity; +import com.ruoyi.common.core.domain.BaseEntity; /** * 閮ㄩ棬琛 sys_dept diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDictData.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDictData.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java index 8f7ec6140..4fa5f0bd8 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDictData.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictData.java @@ -1,13 +1,13 @@ -package com.ruoyi.project.system.domain; +package com.ruoyi.common.core.domain.entity; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; import com.ruoyi.common.constant.UserConstants; -import com.ruoyi.framework.aspectj.lang.annotation.Excel; -import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType; -import com.ruoyi.framework.web.domain.BaseEntity; +import com.ruoyi.common.core.domain.BaseEntity; /** * 瀛楀吀鏁版嵁琛 sys_dict_data diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDictType.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java similarity index 87% rename from ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDictType.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java index a800f6904..6683c9194 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysDictType.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysDictType.java @@ -1,12 +1,12 @@ -package com.ruoyi.project.system.domain; +package com.ruoyi.common.core.domain.entity; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.framework.aspectj.lang.annotation.Excel; -import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType; -import com.ruoyi.framework.web.domain.BaseEntity; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.core.domain.BaseEntity; /** * 瀛楀吀绫诲瀷琛 sys_dict_type diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysMenu.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/project/system/domain/SysMenu.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java index 24990c072..b8ad1f389 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysMenu.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysMenu.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.domain; +package com.ruoyi.common.core.domain.entity; import java.util.ArrayList; import java.util.List; @@ -6,7 +6,7 @@ import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.framework.web.domain.BaseEntity; +import com.ruoyi.common.core.domain.BaseEntity; /** * 鑿滃崟鏉冮檺琛 sys_menu diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysRole.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/project/system/domain/SysRole.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java index 677c2e461..9330f8ea9 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysRole.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysRole.java @@ -1,12 +1,12 @@ -package com.ruoyi.project.system.domain; +package com.ruoyi.common.core.domain.entity; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.framework.aspectj.lang.annotation.Excel; -import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType; -import com.ruoyi.framework.web.domain.BaseEntity; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.core.domain.BaseEntity; /** * 瑙掕壊琛 sys_role diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/project/system/domain/SysUser.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java index f63f59832..f7e68e7b0 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysUser.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUser.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.domain; +package com.ruoyi.common.core.domain.entity; import java.util.Date; import java.util.List; @@ -9,11 +9,11 @@ import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonProperty; -import com.ruoyi.framework.aspectj.lang.annotation.Excel; -import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType; -import com.ruoyi.framework.aspectj.lang.annotation.Excel.Type; -import com.ruoyi.framework.aspectj.lang.annotation.Excels; -import com.ruoyi.framework.web.domain.BaseEntity; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.annotation.Excel.Type; +import com.ruoyi.common.annotation.Excels; +import com.ruoyi.common.core.domain.BaseEntity; /** * 鐢ㄦ埛瀵硅薄 sys_user diff --git a/ruoyi/src/main/java/com/ruoyi/framework/security/LoginBody.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/framework/security/LoginBody.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java index 59860537a..a1f8b8337 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/security/LoginBody.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginBody.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.security; +package com.ruoyi.common.core.domain.model; /** * 鐢ㄦ埛鐧诲綍瀵硅薄 diff --git a/ruoyi/src/main/java/com/ruoyi/framework/security/LoginUser.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/framework/security/LoginUser.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java index 6b2ff0940..a8b112692 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/security/LoginUser.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/model/LoginUser.java @@ -1,11 +1,11 @@ -package com.ruoyi.framework.security; +package com.ruoyi.common.core.domain.model; import java.util.Collection; import java.util.Set; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; import com.fasterxml.jackson.annotation.JsonIgnore; -import com.ruoyi.project.system.domain.SysUser; +import com.ruoyi.common.core.domain.entity.SysUser; /** * 鐧诲綍鐢ㄦ埛韬唤鏉冮檺 diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/page/PageDomain.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/framework/web/page/PageDomain.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java index 7e50472d6..e6dd98e22 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/web/page/PageDomain.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/PageDomain.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.web.page; +package com.ruoyi.common.core.page; import com.ruoyi.common.utils.StringUtils; @@ -11,10 +11,13 @@ public class PageDomain { /** 褰撳墠璁板綍璧峰绱㈠紩 */ private Integer pageNum; + /** 姣忛〉鏄剧ず璁板綍鏁 */ private Integer pageSize; + /** 鎺掑簭鍒 */ private String orderByColumn; + /** 鎺掑簭鐨勬柟鍚 "desc" 鎴栬 "asc". */ private String isAsc; diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/page/TableDataInfo.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/framework/web/page/TableDataInfo.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java index e8b24ffe5..a3487b8ed 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/web/page/TableDataInfo.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableDataInfo.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.web.page; +package com.ruoyi.common.core.page; import java.io.Serializable; import java.util.List; @@ -82,4 +82,4 @@ public class TableDataInfo implements Serializable { this.msg = msg; } -} \ No newline at end of file +} diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/page/TableSupport.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/framework/web/page/TableSupport.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java index fa6a9ee38..511e24b8d 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/web/page/TableSupport.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/page/TableSupport.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.web.page; +package com.ruoyi.common.core.page; import com.ruoyi.common.utils.ServletUtils; diff --git a/ruoyi/src/main/java/com/ruoyi/framework/redis/RedisCache.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java similarity index 95% rename from ruoyi/src/main/java/com/ruoyi/framework/redis/RedisCache.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java index 2905a3834..530dcd9f7 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/redis/RedisCache.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/redis/RedisCache.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.redis; +package com.ruoyi.common.core.redis; import java.util.Collection; import java.util.List; diff --git a/ruoyi/src/main/java/com/ruoyi/common/core/text/CharsetKit.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/text/CharsetKit.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/core/text/CharsetKit.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/text/CharsetKit.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/core/text/Convert.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/text/Convert.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/core/text/Convert.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/text/Convert.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/core/text/StrFormatter.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/text/StrFormatter.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/core/text/StrFormatter.java rename to ruoyi-common/src/main/java/com/ruoyi/common/core/text/StrFormatter.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/BusinessStatus.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessStatus.java similarity index 70% rename from ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/BusinessStatus.java rename to ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessStatus.java index 7e27f2ecb..78188fc16 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/BusinessStatus.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessStatus.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.aspectj.lang.enums; +package com.ruoyi.common.enums; /** * 鎿嶄綔鐘舵 diff --git a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/BusinessType.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java similarity index 83% rename from ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/BusinessType.java rename to ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java index d974a6489..2bbeaf7d3 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/BusinessType.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/BusinessType.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.aspectj.lang.enums; +package com.ruoyi.common.enums; /** * 涓氬姟鎿嶄綔绫诲瀷 diff --git a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/DataSourceType.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java similarity index 70% rename from ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/DataSourceType.java rename to ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java index 274dd3497..4b5341d19 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/DataSourceType.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/DataSourceType.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.aspectj.lang.enums; +package com.ruoyi.common.enums; /** * 鏁版嵁婧 diff --git a/ruoyi/src/main/java/com/ruoyi/common/enums/HttpMethod.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/HttpMethod.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/enums/HttpMethod.java rename to ruoyi-common/src/main/java/com/ruoyi/common/enums/HttpMethod.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/OperatorType.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/OperatorType.java similarity index 75% rename from ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/OperatorType.java rename to ruoyi-common/src/main/java/com/ruoyi/common/enums/OperatorType.java index 98685a61d..06532af8f 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/lang/enums/OperatorType.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/enums/OperatorType.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.aspectj.lang.enums; +package com.ruoyi.common.enums; /** * 鎿嶄綔浜虹被鍒 diff --git a/ruoyi/src/main/java/com/ruoyi/common/enums/UserStatus.java b/ruoyi-common/src/main/java/com/ruoyi/common/enums/UserStatus.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/enums/UserStatus.java rename to ruoyi-common/src/main/java/com/ruoyi/common/enums/UserStatus.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/BaseException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/BaseException.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/exception/BaseException.java rename to ruoyi-common/src/main/java/com/ruoyi/common/exception/BaseException.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/CustomException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/CustomException.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/exception/CustomException.java rename to ruoyi-common/src/main/java/com/ruoyi/common/exception/CustomException.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/DemoModeException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/DemoModeException.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/exception/DemoModeException.java rename to ruoyi-common/src/main/java/com/ruoyi/common/exception/DemoModeException.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/UtilException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/UtilException.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/exception/UtilException.java rename to ruoyi-common/src/main/java/com/ruoyi/common/exception/UtilException.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/file/FileException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileException.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/exception/file/FileException.java rename to ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileException.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java rename to ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileNameLengthLimitExceededException.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java rename to ruoyi-common/src/main/java/com/ruoyi/common/exception/file/FileSizeLimitExceededException.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java rename to ruoyi-common/src/main/java/com/ruoyi/common/exception/file/InvalidExtensionException.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/job/TaskException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java similarity index 94% rename from ruoyi/src/main/java/com/ruoyi/common/exception/job/TaskException.java rename to ruoyi-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java index a567b408b..14b2361d0 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/exception/job/TaskException.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/exception/job/TaskException.java @@ -1,34 +1,34 @@ -package com.ruoyi.common.exception.job; - -/** - * 璁″垝绛栫暐寮傚父 - * - * @author ruoyi - */ -public class TaskException extends Exception -{ - private static final long serialVersionUID = 1L; - - private Code code; - - public TaskException(String msg, Code code) - { - this(msg, code, null); - } - - public TaskException(String msg, Code code, Exception nestedEx) - { - super(msg, nestedEx); - this.code = code; - } - - public Code getCode() - { - return code; - } - - public enum Code - { - TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE - } +package com.ruoyi.common.exception.job; + +/** + * 璁″垝绛栫暐寮傚父 + * + * @author ruoyi + */ +public class TaskException extends Exception +{ + private static final long serialVersionUID = 1L; + + private Code code; + + public TaskException(String msg, Code code) + { + this(msg, code, null); + } + + public TaskException(String msg, Code code, Exception nestedEx) + { + super(msg, nestedEx); + this.code = code; + } + + public Code getCode() + { + return code; + } + + public enum Code + { + TASK_EXISTS, NO_TASK_EXISTS, TASK_ALREADY_STARTED, UNKNOWN, CONFIG_ERROR, TASK_NODE_NOT_AVAILABLE + } } \ No newline at end of file diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java rename to ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaException.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/user/CaptchaExpireException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaExpireException.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/exception/user/CaptchaExpireException.java rename to ruoyi-common/src/main/java/com/ruoyi/common/exception/user/CaptchaExpireException.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/user/UserException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserException.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/exception/user/UserException.java rename to ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserException.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java b/ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java rename to ruoyi-common/src/main/java/com/ruoyi/common/exception/user/UserPasswordNotMatchException.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java b/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java similarity index 96% rename from ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java rename to ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java index 6e3edfcee..15a6804f2 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatableFilter.java @@ -1,52 +1,52 @@ -package com.ruoyi.common.filter; - -import java.io.IOException; -import javax.servlet.Filter; -import javax.servlet.FilterChain; -import javax.servlet.FilterConfig; -import javax.servlet.ServletException; -import javax.servlet.ServletRequest; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import org.springframework.http.MediaType; -import com.ruoyi.common.utils.StringUtils; - -/** - * Repeatable 杩囨护鍣 - * - * @author ruoyi - */ -public class RepeatableFilter implements Filter -{ - @Override - public void init(FilterConfig filterConfig) throws ServletException - { - - } - - @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) - throws IOException, ServletException - { - ServletRequest requestWrapper = null; - if (request instanceof HttpServletRequest && StringUtils.equalsAnyIgnoreCase(request.getContentType(), - MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_UTF8_VALUE)) - { - requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response); - } - if (null == requestWrapper) - { - chain.doFilter(request, response); - } - else - { - chain.doFilter(requestWrapper, response); - } - } - - @Override - public void destroy() - { - - } -} +package com.ruoyi.common.filter; + +import java.io.IOException; +import javax.servlet.Filter; +import javax.servlet.FilterChain; +import javax.servlet.FilterConfig; +import javax.servlet.ServletException; +import javax.servlet.ServletRequest; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import org.springframework.http.MediaType; +import com.ruoyi.common.utils.StringUtils; + +/** + * Repeatable 杩囨护鍣 + * + * @author ruoyi + */ +public class RepeatableFilter implements Filter +{ + @Override + public void init(FilterConfig filterConfig) throws ServletException + { + + } + + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) + throws IOException, ServletException + { + ServletRequest requestWrapper = null; + if (request instanceof HttpServletRequest && StringUtils.equalsAnyIgnoreCase(request.getContentType(), + MediaType.APPLICATION_JSON_VALUE, MediaType.APPLICATION_JSON_UTF8_VALUE)) + { + requestWrapper = new RepeatedlyRequestWrapper((HttpServletRequest) request, response); + } + if (null == requestWrapper) + { + chain.doFilter(request, response); + } + else + { + chain.doFilter(requestWrapper, response); + } + } + + @Override + public void destroy() + { + + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java b/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java similarity index 96% rename from ruoyi/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java rename to ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java index bd7097f53..9ad6f4940 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/filter/RepeatedlyRequestWrapper.java @@ -1,72 +1,72 @@ -package com.ruoyi.common.filter; - -import java.io.BufferedReader; -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStreamReader; -import javax.servlet.ReadListener; -import javax.servlet.ServletInputStream; -import javax.servlet.ServletResponse; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletRequestWrapper; -import com.ruoyi.common.utils.http.HttpHelper; - -/** - * 鏋勫缓鍙噸澶嶈鍙杋nputStream鐨剅equest - * - * @author ruoyi - */ -public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper -{ - private final byte[] body; - - public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException - { - super(request); - request.setCharacterEncoding("UTF-8"); - response.setCharacterEncoding("UTF-8"); - - body = HttpHelper.getBodyString(request).getBytes("UTF-8"); - } - - @Override - public BufferedReader getReader() throws IOException - { - return new BufferedReader(new InputStreamReader(getInputStream())); - } - - @Override - public ServletInputStream getInputStream() throws IOException - { - - final ByteArrayInputStream bais = new ByteArrayInputStream(body); - - return new ServletInputStream() - { - - @Override - public int read() throws IOException - { - return bais.read(); - } - - @Override - public boolean isFinished() - { - return false; - } - - @Override - public boolean isReady() - { - return false; - } - - @Override - public void setReadListener(ReadListener readListener) - { - - } - }; - } -} +package com.ruoyi.common.filter; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import javax.servlet.ReadListener; +import javax.servlet.ServletInputStream; +import javax.servlet.ServletResponse; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletRequestWrapper; +import com.ruoyi.common.utils.http.HttpHelper; + +/** + * 鏋勫缓鍙噸澶嶈鍙杋nputStream鐨剅equest + * + * @author ruoyi + */ +public class RepeatedlyRequestWrapper extends HttpServletRequestWrapper +{ + private final byte[] body; + + public RepeatedlyRequestWrapper(HttpServletRequest request, ServletResponse response) throws IOException + { + super(request); + request.setCharacterEncoding("UTF-8"); + response.setCharacterEncoding("UTF-8"); + + body = HttpHelper.getBodyString(request).getBytes("UTF-8"); + } + + @Override + public BufferedReader getReader() throws IOException + { + return new BufferedReader(new InputStreamReader(getInputStream())); + } + + @Override + public ServletInputStream getInputStream() throws IOException + { + + final ByteArrayInputStream bais = new ByteArrayInputStream(body); + + return new ServletInputStream() + { + + @Override + public int read() throws IOException + { + return bais.read(); + } + + @Override + public boolean isFinished() + { + return false; + } + + @Override + public boolean isReady() + { + return false; + } + + @Override + public void setReadListener(ReadListener readListener) + { + + } + }; + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/filter/XssFilter.java b/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssFilter.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/filter/XssFilter.java rename to ruoyi-common/src/main/java/com/ruoyi/common/filter/XssFilter.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java b/ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java rename to ruoyi-common/src/main/java/com/ruoyi/common/filter/XssHttpServletRequestWrapper.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/Arith.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/Arith.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/Arith.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/DateUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/DateUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/DateUtils.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/DictUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java similarity index 90% rename from ruoyi/src/main/java/com/ruoyi/common/utils/DictUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java index 0c1ee5dba..6fb6289c4 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/DictUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/DictUtils.java @@ -2,10 +2,11 @@ package com.ruoyi.common.utils; import java.util.Collection; import java.util.List; + import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.framework.redis.RedisCache; -import com.ruoyi.project.system.domain.SysDictData; /** * 瀛楀吀宸ュ叿绫 diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java similarity index 95% rename from ruoyi/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java index ad57439b7..4ca52838a 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ExceptionUtil.java @@ -1,40 +1,40 @@ -package com.ruoyi.common.utils; - -import java.io.PrintWriter; -import java.io.StringWriter; -import org.apache.commons.lang3.exception.ExceptionUtils; - -/** - * 閿欒淇℃伅澶勭悊绫汇 - * - * @author ruoyi - */ -public class ExceptionUtil -{ - /** - * 鑾峰彇exception鐨勮缁嗛敊璇俊鎭 - */ - public static String getExceptionMessage(Throwable e) - { - StringWriter sw = new StringWriter(); - e.printStackTrace(new PrintWriter(sw, true)); - String str = sw.toString(); - return str; - } - - public static String getRootErrorMseeage(Exception e) - { - Throwable root = ExceptionUtils.getRootCause(e); - root = (root == null ? e : root); - if (root == null) - { - return ""; - } - String msg = root.getMessage(); - if (msg == null) - { - return "null"; - } - return StringUtils.defaultString(msg); - } -} +package com.ruoyi.common.utils; + +import java.io.PrintWriter; +import java.io.StringWriter; +import org.apache.commons.lang3.exception.ExceptionUtils; + +/** + * 閿欒淇℃伅澶勭悊绫汇 + * + * @author ruoyi + */ +public class ExceptionUtil +{ + /** + * 鑾峰彇exception鐨勮缁嗛敊璇俊鎭 + */ + public static String getExceptionMessage(Throwable e) + { + StringWriter sw = new StringWriter(); + e.printStackTrace(new PrintWriter(sw, true)); + String str = sw.toString(); + return str; + } + + public static String getRootErrorMseeage(Exception e) + { + Throwable root = ExceptionUtils.getRootCause(e); + root = (root == null ? e : root); + if (root == null) + { + return ""; + } + String msg = root.getMessage(); + if (msg == null) + { + return "null"; + } + return StringUtils.defaultString(msg); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/LogUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/LogUtils.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/LogUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/LogUtils.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/MessageUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/MessageUtils.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/MessageUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/MessageUtils.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/SecurityUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/common/utils/SecurityUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java index c8d1783e6..ce7f3b64f 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/SecurityUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java @@ -4,8 +4,8 @@ import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.exception.CustomException; -import com.ruoyi.framework.security.LoginUser; /** * 瀹夊叏鏈嶅姟宸ュ叿绫 diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/ServletUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/ServletUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/ServletUtils.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/StringUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/StringUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/StringUtils.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/Threads.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/Threads.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/Threads.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/VerifyCodeUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/VerifyCodeUtils.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/VerifyCodeUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/VerifyCodeUtils.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java similarity index 96% rename from ruoyi/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java index 4463662d4..51cdc2fb1 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/bean/BeanUtils.java @@ -1,110 +1,110 @@ -package com.ruoyi.common.utils.bean; - -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * Bean 宸ュ叿绫 - * - * @author ruoyi - */ -public class BeanUtils extends org.springframework.beans.BeanUtils -{ - /** Bean鏂规硶鍚嶄腑灞炴у悕寮濮嬬殑涓嬫爣 */ - private static final int BEAN_METHOD_PROP_INDEX = 3; - - /** * 鍖归厤getter鏂规硶鐨勬鍒欒〃杈惧紡 */ - private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)"); - - /** * 鍖归厤setter鏂规硶鐨勬鍒欒〃杈惧紡 */ - private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)"); - - /** - * Bean灞炴у鍒跺伐鍏锋柟娉曘 - * - * @param dest 鐩爣瀵硅薄 - * @param src 婧愬璞 - */ - public static void copyBeanProp(Object dest, Object src) - { - try - { - copyProperties(src, dest); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - /** - * 鑾峰彇瀵硅薄鐨剆etter鏂规硶銆 - * - * @param obj 瀵硅薄 - * @return 瀵硅薄鐨剆etter鏂规硶鍒楄〃 - */ - public static List getSetterMethods(Object obj) - { - // setter鏂规硶鍒楄〃 - List setterMethods = new ArrayList(); - - // 鑾峰彇鎵鏈夋柟娉 - Method[] methods = obj.getClass().getMethods(); - - // 鏌ユ壘setter鏂规硶 - - for (Method method : methods) - { - Matcher m = SET_PATTERN.matcher(method.getName()); - if (m.matches() && (method.getParameterTypes().length == 1)) - { - setterMethods.add(method); - } - } - // 杩斿洖setter鏂规硶鍒楄〃 - return setterMethods; - } - - /** - * 鑾峰彇瀵硅薄鐨刧etter鏂规硶銆 - * - * @param obj 瀵硅薄 - * @return 瀵硅薄鐨刧etter鏂规硶鍒楄〃 - */ - - public static List getGetterMethods(Object obj) - { - // getter鏂规硶鍒楄〃 - List getterMethods = new ArrayList(); - // 鑾峰彇鎵鏈夋柟娉 - Method[] methods = obj.getClass().getMethods(); - // 鏌ユ壘getter鏂规硶 - for (Method method : methods) - { - Matcher m = GET_PATTERN.matcher(method.getName()); - if (m.matches() && (method.getParameterTypes().length == 0)) - { - getterMethods.add(method); - } - } - // 杩斿洖getter鏂规硶鍒楄〃 - return getterMethods; - } - - /** - * 妫鏌ean鏂规硶鍚嶄腑鐨勫睘鎬у悕鏄惁鐩哥瓑銆
- * 濡俫etName()鍜宻etName()灞炴у悕涓鏍凤紝getName()鍜宻etAge()灞炴у悕涓嶄竴鏍枫 - * - * @param m1 鏂规硶鍚1 - * @param m2 鏂规硶鍚2 - * @return 灞炴у悕涓鏍疯繑鍥瀟rue锛屽惁鍒欒繑鍥瀎alse - */ - - public static boolean isMethodPropEquals(String m1, String m2) - { - return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX)); - } -} +package com.ruoyi.common.utils.bean; + +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Bean 宸ュ叿绫 + * + * @author ruoyi + */ +public class BeanUtils extends org.springframework.beans.BeanUtils +{ + /** Bean鏂规硶鍚嶄腑灞炴у悕寮濮嬬殑涓嬫爣 */ + private static final int BEAN_METHOD_PROP_INDEX = 3; + + /** * 鍖归厤getter鏂规硶鐨勬鍒欒〃杈惧紡 */ + private static final Pattern GET_PATTERN = Pattern.compile("get(\\p{javaUpperCase}\\w*)"); + + /** * 鍖归厤setter鏂规硶鐨勬鍒欒〃杈惧紡 */ + private static final Pattern SET_PATTERN = Pattern.compile("set(\\p{javaUpperCase}\\w*)"); + + /** + * Bean灞炴у鍒跺伐鍏锋柟娉曘 + * + * @param dest 鐩爣瀵硅薄 + * @param src 婧愬璞 + */ + public static void copyBeanProp(Object dest, Object src) + { + try + { + copyProperties(src, dest); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + /** + * 鑾峰彇瀵硅薄鐨剆etter鏂规硶銆 + * + * @param obj 瀵硅薄 + * @return 瀵硅薄鐨剆etter鏂规硶鍒楄〃 + */ + public static List getSetterMethods(Object obj) + { + // setter鏂规硶鍒楄〃 + List setterMethods = new ArrayList(); + + // 鑾峰彇鎵鏈夋柟娉 + Method[] methods = obj.getClass().getMethods(); + + // 鏌ユ壘setter鏂规硶 + + for (Method method : methods) + { + Matcher m = SET_PATTERN.matcher(method.getName()); + if (m.matches() && (method.getParameterTypes().length == 1)) + { + setterMethods.add(method); + } + } + // 杩斿洖setter鏂规硶鍒楄〃 + return setterMethods; + } + + /** + * 鑾峰彇瀵硅薄鐨刧etter鏂规硶銆 + * + * @param obj 瀵硅薄 + * @return 瀵硅薄鐨刧etter鏂规硶鍒楄〃 + */ + + public static List getGetterMethods(Object obj) + { + // getter鏂规硶鍒楄〃 + List getterMethods = new ArrayList(); + // 鑾峰彇鎵鏈夋柟娉 + Method[] methods = obj.getClass().getMethods(); + // 鏌ユ壘getter鏂规硶 + for (Method method : methods) + { + Matcher m = GET_PATTERN.matcher(method.getName()); + if (m.matches() && (method.getParameterTypes().length == 0)) + { + getterMethods.add(method); + } + } + // 杩斿洖getter鏂规硶鍒楄〃 + return getterMethods; + } + + /** + * 妫鏌ean鏂规硶鍚嶄腑鐨勫睘鎬у悕鏄惁鐩哥瓑銆
+ * 濡俫etName()鍜宻etName()灞炴у悕涓鏍凤紝getName()鍜宻etAge()灞炴у悕涓嶄竴鏍枫 + * + * @param m1 鏂规硶鍚1 + * @param m2 鏂规硶鍚2 + * @return 灞炴у悕涓鏍疯繑鍥瀟rue锛屽惁鍒欒繑鍥瀎alse + */ + + public static boolean isMethodPropEquals(String m1, String m2) + { + return m1.substring(BEAN_METHOD_PROP_INDEX).equals(m2.substring(BEAN_METHOD_PROP_INDEX)); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java similarity index 95% rename from ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java index 5b356e294..183f91867 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUploadUtils.java @@ -4,14 +4,14 @@ import java.io.File; import java.io.IOException; 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; import com.ruoyi.common.exception.file.FileSizeLimitExceededException; import com.ruoyi.common.exception.file.InvalidExtensionException; import com.ruoyi.common.utils.DateUtils; -import com.ruoyi.common.utils.IdUtils; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.config.RuoYiConfig; +import com.ruoyi.common.utils.uuid.IdUtils; /** * 鏂囦欢涓婁紶宸ュ叿绫 diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/file/FileUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/file/FileUtils.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/file/MimeTypeUtils.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/html/EscapeUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/EscapeUtil.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/html/EscapeUtil.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/html/EscapeUtil.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java similarity index 97% rename from ruoyi/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java index 6244cd57b..41739569d 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/html/HTMLFilter.java @@ -1,569 +1,569 @@ -package com.ruoyi.common.utils.html; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -/** - * HTML杩囨护鍣紝鐢ㄤ簬鍘婚櫎XSS婕忔礊闅愭偅銆 - * - * @author ruoyi - */ -public final class HTMLFilter -{ - /** - * regex flag union representing /si modifiers in php - **/ - private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL; - private static final Pattern P_COMMENTS = Pattern.compile("", Pattern.DOTALL); - private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI); - private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL); - private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI); - private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI); - private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI); - private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI); - private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI); - private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?"); - private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?"); - private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?"); - private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))"); - private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL); - private static final Pattern P_END_ARROW = Pattern.compile("^>"); - private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)"); - private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)"); - private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)"); - private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)"); - private static final Pattern P_AMP = Pattern.compile("&"); - private static final Pattern P_QUOTE = Pattern.compile("\""); - private static final Pattern P_LEFT_ARROW = Pattern.compile("<"); - private static final Pattern P_RIGHT_ARROW = Pattern.compile(">"); - private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>"); - - // @xxx could grow large... maybe use sesat's ReferenceMap - private static final ConcurrentMap P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<>(); - private static final ConcurrentMap P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<>(); - - /** - * set of allowed html elements, along with allowed attributes for each element - **/ - private final Map> vAllowed; - /** - * counts of open tags for each (allowable) html element - **/ - private final Map vTagCounts = new HashMap<>(); - - /** - * html elements which must always be self-closing (e.g. "") - **/ - private final String[] vSelfClosingTags; - /** - * html elements which must always have separate opening and closing tags (e.g. "") - **/ - private final String[] vNeedClosingTags; - /** - * set of disallowed html elements - **/ - private final String[] vDisallowed; - /** - * attributes which should be checked for valid protocols - **/ - private final String[] vProtocolAtts; - /** - * allowed protocols - **/ - private final String[] vAllowedProtocols; - /** - * tags which should be removed if they contain no content (e.g. "" or "") - **/ - private final String[] vRemoveBlanks; - /** - * entities allowed within html markup - **/ - private final String[] vAllowedEntities; - /** - * flag determining whether comments are allowed in input String. - */ - private final boolean stripComment; - private final boolean encodeQuotes; - /** - * flag determining whether to try to make tags when presented with "unbalanced" angle brackets (e.g. "" - * becomes " text "). If set to false, unbalanced angle brackets will be html escaped. - */ - private final boolean alwaysMakeTags; - - /** - * Default constructor. - */ - public HTMLFilter() - { - vAllowed = new HashMap<>(); - - final ArrayList a_atts = new ArrayList<>(); - a_atts.add("href"); - a_atts.add("target"); - vAllowed.put("a", a_atts); - - final ArrayList img_atts = new ArrayList<>(); - img_atts.add("src"); - img_atts.add("width"); - img_atts.add("height"); - img_atts.add("alt"); - vAllowed.put("img", img_atts); - - final ArrayList no_atts = new ArrayList<>(); - vAllowed.put("b", no_atts); - vAllowed.put("strong", no_atts); - vAllowed.put("i", no_atts); - vAllowed.put("em", no_atts); - - vSelfClosingTags = new String[] { "img" }; - vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" }; - vDisallowed = new String[] {}; - vAllowedProtocols = new String[] { "http", "mailto", "https" }; // no ftp. - vProtocolAtts = new String[] { "src", "href" }; - vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" }; - vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" }; - stripComment = true; - encodeQuotes = true; - alwaysMakeTags = true; - } - - /** - * Map-parameter configurable constructor. - * - * @param conf map containing configuration. keys match field names. - */ - @SuppressWarnings("unchecked") - public HTMLFilter(final Map conf) - { - - assert conf.containsKey("vAllowed") : "configuration requires vAllowed"; - assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags"; - assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags"; - assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed"; - assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols"; - assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts"; - assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks"; - assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities"; - - vAllowed = Collections.unmodifiableMap((HashMap>) conf.get("vAllowed")); - vSelfClosingTags = (String[]) conf.get("vSelfClosingTags"); - vNeedClosingTags = (String[]) conf.get("vNeedClosingTags"); - vDisallowed = (String[]) conf.get("vDisallowed"); - vAllowedProtocols = (String[]) conf.get("vAllowedProtocols"); - vProtocolAtts = (String[]) conf.get("vProtocolAtts"); - vRemoveBlanks = (String[]) conf.get("vRemoveBlanks"); - vAllowedEntities = (String[]) conf.get("vAllowedEntities"); - stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true; - encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true; - alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true; - } - - private void reset() - { - vTagCounts.clear(); - } - - // --------------------------------------------------------------- - // my versions of some PHP library functions - public static String chr(final int decimal) - { - return String.valueOf((char) decimal); - } - - public static String htmlSpecialChars(final String s) - { - String result = s; - result = regexReplace(P_AMP, "&", result); - result = regexReplace(P_QUOTE, """, result); - result = regexReplace(P_LEFT_ARROW, "<", result); - result = regexReplace(P_RIGHT_ARROW, ">", result); - return result; - } - - // --------------------------------------------------------------- - - /** - * given a user submitted input String, filter out any invalid or restricted html. - * - * @param input text (i.e. submitted by a user) than may contain html - * @return "clean" version of input, with only valid, whitelisted html elements allowed - */ - public String filter(final String input) - { - reset(); - String s = input; - - s = escapeComments(s); - - s = balanceHTML(s); - - s = checkTags(s); - - s = processRemoveBlanks(s); - - s = validateEntities(s); - - return s; - } - - public boolean isAlwaysMakeTags() - { - return alwaysMakeTags; - } - - public boolean isStripComments() - { - return stripComment; - } - - private String escapeComments(final String s) - { - final Matcher m = P_COMMENTS.matcher(s); - final StringBuffer buf = new StringBuffer(); - if (m.find()) - { - final String match = m.group(1); // (.*?) - m.appendReplacement(buf, Matcher.quoteReplacement("")); - } - m.appendTail(buf); - - return buf.toString(); - } - - private String balanceHTML(String s) - { - if (alwaysMakeTags) - { - // - // try and form html - // - s = regexReplace(P_END_ARROW, "", s); - s = regexReplace(P_BODY_TO_END, "<$1>", s); - s = regexReplace(P_XML_CONTENT, "$1<$2", s); - - } - else - { - // - // escape stray brackets - // - s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s); - s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s); - - // - // the last regexp causes '<>' entities to appear - // (we need to do a lookahead assertion so that the last bracket can - // be used in the next pass of the regexp) - // - s = regexReplace(P_BOTH_ARROWS, "", s); - } - - return s; - } - - private String checkTags(String s) - { - Matcher m = P_TAGS.matcher(s); - - final StringBuffer buf = new StringBuffer(); - while (m.find()) - { - String replaceStr = m.group(1); - replaceStr = processTag(replaceStr); - m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr)); - } - m.appendTail(buf); - - // these get tallied in processTag - // (remember to reset before subsequent calls to filter method) - final StringBuilder sBuilder = new StringBuilder(buf.toString()); - for (String key : vTagCounts.keySet()) - { - for (int ii = 0; ii < vTagCounts.get(key); ii++) - { - sBuilder.append(""); - } - } - s = sBuilder.toString(); - - return s; - } - - private String processRemoveBlanks(final String s) - { - String result = s; - for (String tag : vRemoveBlanks) - { - if (!P_REMOVE_PAIR_BLANKS.containsKey(tag)) - { - P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?>")); - } - result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result); - if (!P_REMOVE_SELF_BLANKS.containsKey(tag)) - { - P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>")); - } - result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result); - } - - return result; - } - - private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) - { - Matcher m = regex_pattern.matcher(s); - return m.replaceAll(replacement); - } - - private String processTag(final String s) - { - // ending tags - Matcher m = P_END_TAG.matcher(s); - if (m.find()) - { - final String name = m.group(1).toLowerCase(); - if (allowed(name)) - { - if (false == inArray(name, vSelfClosingTags)) - { - if (vTagCounts.containsKey(name)) - { - vTagCounts.put(name, vTagCounts.get(name) - 1); - return ""; - } - } - } - } - - // starting tags - m = P_START_TAG.matcher(s); - if (m.find()) - { - final String name = m.group(1).toLowerCase(); - final String body = m.group(2); - String ending = m.group(3); - - // debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" ); - if (allowed(name)) - { - final StringBuilder params = new StringBuilder(); - - final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body); - final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body); - final List paramNames = new ArrayList<>(); - final List paramValues = new ArrayList<>(); - while (m2.find()) - { - paramNames.add(m2.group(1)); // ([a-z0-9]+) - paramValues.add(m2.group(3)); // (.*?) - } - while (m3.find()) - { - paramNames.add(m3.group(1)); // ([a-z0-9]+) - paramValues.add(m3.group(3)); // ([^\"\\s']+) - } - - String paramName, paramValue; - for (int ii = 0; ii < paramNames.size(); ii++) - { - paramName = paramNames.get(ii).toLowerCase(); - paramValue = paramValues.get(ii); - - // debug( "paramName='" + paramName + "'" ); - // debug( "paramValue='" + paramValue + "'" ); - // debug( "allowed? " + vAllowed.get( name ).contains( paramName ) ); - - if (allowedAttribute(name, paramName)) - { - if (inArray(paramName, vProtocolAtts)) - { - paramValue = processParamProtocol(paramValue); - } - params.append(' ').append(paramName).append("=\"").append(paramValue).append("\""); - } - } - - if (inArray(name, vSelfClosingTags)) - { - ending = " /"; - } - - if (inArray(name, vNeedClosingTags)) - { - ending = ""; - } - - if (ending == null || ending.length() < 1) - { - if (vTagCounts.containsKey(name)) - { - vTagCounts.put(name, vTagCounts.get(name) + 1); - } - else - { - vTagCounts.put(name, 1); - } - } - else - { - ending = " /"; - } - return "<" + name + params + ending + ">"; - } - else - { - return ""; - } - } - - // comments - m = P_COMMENT.matcher(s); - if (!stripComment && m.find()) - { - return "<" + m.group() + ">"; - } - - return ""; - } - - private String processParamProtocol(String s) - { - s = decodeEntities(s); - final Matcher m = P_PROTOCOL.matcher(s); - if (m.find()) - { - final String protocol = m.group(1); - if (!inArray(protocol, vAllowedProtocols)) - { - // bad protocol, turn into local anchor link instead - s = "#" + s.substring(protocol.length() + 1); - if (s.startsWith("#//")) - { - s = "#" + s.substring(3); - } - } - } - - return s; - } - - private String decodeEntities(String s) - { - StringBuffer buf = new StringBuffer(); - - Matcher m = P_ENTITY.matcher(s); - while (m.find()) - { - final String match = m.group(1); - final int decimal = Integer.decode(match).intValue(); - m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); - } - m.appendTail(buf); - s = buf.toString(); - - buf = new StringBuffer(); - m = P_ENTITY_UNICODE.matcher(s); - while (m.find()) - { - final String match = m.group(1); - final int decimal = Integer.valueOf(match, 16).intValue(); - m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); - } - m.appendTail(buf); - s = buf.toString(); - - buf = new StringBuffer(); - m = P_ENCODE.matcher(s); - while (m.find()) - { - final String match = m.group(1); - final int decimal = Integer.valueOf(match, 16).intValue(); - m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); - } - m.appendTail(buf); - s = buf.toString(); - - s = validateEntities(s); - return s; - } - - private String validateEntities(final String s) - { - StringBuffer buf = new StringBuffer(); - - // validate entities throughout the string - Matcher m = P_VALID_ENTITIES.matcher(s); - while (m.find()) - { - final String one = m.group(1); // ([^&;]*) - final String two = m.group(2); // (?=(;|&|$)) - m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two))); - } - m.appendTail(buf); - - return encodeQuotes(buf.toString()); - } - - private String encodeQuotes(final String s) - { - if (encodeQuotes) - { - StringBuffer buf = new StringBuffer(); - Matcher m = P_VALID_QUOTES.matcher(s); - while (m.find()) - { - final String one = m.group(1); // (>|^) - final String two = m.group(2); // ([^<]+?) - final String three = m.group(3); // (<|$) - // 涓嶆浛鎹㈠弻寮曞彿涓"锛岄槻姝son鏍煎紡鏃犳晥 regexReplace(P_QUOTE, """, two) - m.appendReplacement(buf, Matcher.quoteReplacement(one + two + three)); - } - m.appendTail(buf); - return buf.toString(); - } - else - { - return s; - } - } - - private String checkEntity(final String preamble, final String term) - { - - return ";".equals(term) && isValidEntity(preamble) ? '&' + preamble : "&" + preamble; - } - - private boolean isValidEntity(final String entity) - { - return inArray(entity, vAllowedEntities); - } - - private static boolean inArray(final String s, final String[] array) - { - for (String item : array) - { - if (item != null && item.equals(s)) - { - return true; - } - } - return false; - } - - private boolean allowed(final String name) - { - return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed); - } - - private boolean allowedAttribute(final String name, final String paramName) - { - return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName)); - } +package com.ruoyi.common.utils.html; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * HTML杩囨护鍣紝鐢ㄤ簬鍘婚櫎XSS婕忔礊闅愭偅銆 + * + * @author ruoyi + */ +public final class HTMLFilter +{ + /** + * regex flag union representing /si modifiers in php + **/ + private static final int REGEX_FLAGS_SI = Pattern.CASE_INSENSITIVE | Pattern.DOTALL; + private static final Pattern P_COMMENTS = Pattern.compile("", Pattern.DOTALL); + private static final Pattern P_COMMENT = Pattern.compile("^!--(.*)--$", REGEX_FLAGS_SI); + private static final Pattern P_TAGS = Pattern.compile("<(.*?)>", Pattern.DOTALL); + private static final Pattern P_END_TAG = Pattern.compile("^/([a-z0-9]+)", REGEX_FLAGS_SI); + private static final Pattern P_START_TAG = Pattern.compile("^([a-z0-9]+)(.*?)(/?)$", REGEX_FLAGS_SI); + private static final Pattern P_QUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)=([\"'])(.*?)\\2", REGEX_FLAGS_SI); + private static final Pattern P_UNQUOTED_ATTRIBUTES = Pattern.compile("([a-z0-9]+)(=)([^\"\\s']+)", REGEX_FLAGS_SI); + private static final Pattern P_PROTOCOL = Pattern.compile("^([^:]+):", REGEX_FLAGS_SI); + private static final Pattern P_ENTITY = Pattern.compile("&#(\\d+);?"); + private static final Pattern P_ENTITY_UNICODE = Pattern.compile("&#x([0-9a-f]+);?"); + private static final Pattern P_ENCODE = Pattern.compile("%([0-9a-f]{2});?"); + private static final Pattern P_VALID_ENTITIES = Pattern.compile("&([^&;]*)(?=(;|&|$))"); + private static final Pattern P_VALID_QUOTES = Pattern.compile("(>|^)([^<]+?)(<|$)", Pattern.DOTALL); + private static final Pattern P_END_ARROW = Pattern.compile("^>"); + private static final Pattern P_BODY_TO_END = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_XML_CONTENT = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_STRAY_LEFT_ARROW = Pattern.compile("<([^>]*?)(?=<|$)"); + private static final Pattern P_STRAY_RIGHT_ARROW = Pattern.compile("(^|>)([^<]*?)(?=>)"); + private static final Pattern P_AMP = Pattern.compile("&"); + private static final Pattern P_QUOTE = Pattern.compile("\""); + private static final Pattern P_LEFT_ARROW = Pattern.compile("<"); + private static final Pattern P_RIGHT_ARROW = Pattern.compile(">"); + private static final Pattern P_BOTH_ARROWS = Pattern.compile("<>"); + + // @xxx could grow large... maybe use sesat's ReferenceMap + private static final ConcurrentMap P_REMOVE_PAIR_BLANKS = new ConcurrentHashMap<>(); + private static final ConcurrentMap P_REMOVE_SELF_BLANKS = new ConcurrentHashMap<>(); + + /** + * set of allowed html elements, along with allowed attributes for each element + **/ + private final Map> vAllowed; + /** + * counts of open tags for each (allowable) html element + **/ + private final Map vTagCounts = new HashMap<>(); + + /** + * html elements which must always be self-closing (e.g. "") + **/ + private final String[] vSelfClosingTags; + /** + * html elements which must always have separate opening and closing tags (e.g. "") + **/ + private final String[] vNeedClosingTags; + /** + * set of disallowed html elements + **/ + private final String[] vDisallowed; + /** + * attributes which should be checked for valid protocols + **/ + private final String[] vProtocolAtts; + /** + * allowed protocols + **/ + private final String[] vAllowedProtocols; + /** + * tags which should be removed if they contain no content (e.g. "" or "") + **/ + private final String[] vRemoveBlanks; + /** + * entities allowed within html markup + **/ + private final String[] vAllowedEntities; + /** + * flag determining whether comments are allowed in input String. + */ + private final boolean stripComment; + private final boolean encodeQuotes; + /** + * flag determining whether to try to make tags when presented with "unbalanced" angle brackets (e.g. "" + * becomes " text "). If set to false, unbalanced angle brackets will be html escaped. + */ + private final boolean alwaysMakeTags; + + /** + * Default constructor. + */ + public HTMLFilter() + { + vAllowed = new HashMap<>(); + + final ArrayList a_atts = new ArrayList<>(); + a_atts.add("href"); + a_atts.add("target"); + vAllowed.put("a", a_atts); + + final ArrayList img_atts = new ArrayList<>(); + img_atts.add("src"); + img_atts.add("width"); + img_atts.add("height"); + img_atts.add("alt"); + vAllowed.put("img", img_atts); + + final ArrayList no_atts = new ArrayList<>(); + vAllowed.put("b", no_atts); + vAllowed.put("strong", no_atts); + vAllowed.put("i", no_atts); + vAllowed.put("em", no_atts); + + vSelfClosingTags = new String[] { "img" }; + vNeedClosingTags = new String[] { "a", "b", "strong", "i", "em" }; + vDisallowed = new String[] {}; + vAllowedProtocols = new String[] { "http", "mailto", "https" }; // no ftp. + vProtocolAtts = new String[] { "src", "href" }; + vRemoveBlanks = new String[] { "a", "b", "strong", "i", "em" }; + vAllowedEntities = new String[] { "amp", "gt", "lt", "quot" }; + stripComment = true; + encodeQuotes = true; + alwaysMakeTags = true; + } + + /** + * Map-parameter configurable constructor. + * + * @param conf map containing configuration. keys match field names. + */ + @SuppressWarnings("unchecked") + public HTMLFilter(final Map conf) + { + + assert conf.containsKey("vAllowed") : "configuration requires vAllowed"; + assert conf.containsKey("vSelfClosingTags") : "configuration requires vSelfClosingTags"; + assert conf.containsKey("vNeedClosingTags") : "configuration requires vNeedClosingTags"; + assert conf.containsKey("vDisallowed") : "configuration requires vDisallowed"; + assert conf.containsKey("vAllowedProtocols") : "configuration requires vAllowedProtocols"; + assert conf.containsKey("vProtocolAtts") : "configuration requires vProtocolAtts"; + assert conf.containsKey("vRemoveBlanks") : "configuration requires vRemoveBlanks"; + assert conf.containsKey("vAllowedEntities") : "configuration requires vAllowedEntities"; + + vAllowed = Collections.unmodifiableMap((HashMap>) conf.get("vAllowed")); + vSelfClosingTags = (String[]) conf.get("vSelfClosingTags"); + vNeedClosingTags = (String[]) conf.get("vNeedClosingTags"); + vDisallowed = (String[]) conf.get("vDisallowed"); + vAllowedProtocols = (String[]) conf.get("vAllowedProtocols"); + vProtocolAtts = (String[]) conf.get("vProtocolAtts"); + vRemoveBlanks = (String[]) conf.get("vRemoveBlanks"); + vAllowedEntities = (String[]) conf.get("vAllowedEntities"); + stripComment = conf.containsKey("stripComment") ? (Boolean) conf.get("stripComment") : true; + encodeQuotes = conf.containsKey("encodeQuotes") ? (Boolean) conf.get("encodeQuotes") : true; + alwaysMakeTags = conf.containsKey("alwaysMakeTags") ? (Boolean) conf.get("alwaysMakeTags") : true; + } + + private void reset() + { + vTagCounts.clear(); + } + + // --------------------------------------------------------------- + // my versions of some PHP library functions + public static String chr(final int decimal) + { + return String.valueOf((char) decimal); + } + + public static String htmlSpecialChars(final String s) + { + String result = s; + result = regexReplace(P_AMP, "&", result); + result = regexReplace(P_QUOTE, """, result); + result = regexReplace(P_LEFT_ARROW, "<", result); + result = regexReplace(P_RIGHT_ARROW, ">", result); + return result; + } + + // --------------------------------------------------------------- + + /** + * given a user submitted input String, filter out any invalid or restricted html. + * + * @param input text (i.e. submitted by a user) than may contain html + * @return "clean" version of input, with only valid, whitelisted html elements allowed + */ + public String filter(final String input) + { + reset(); + String s = input; + + s = escapeComments(s); + + s = balanceHTML(s); + + s = checkTags(s); + + s = processRemoveBlanks(s); + + s = validateEntities(s); + + return s; + } + + public boolean isAlwaysMakeTags() + { + return alwaysMakeTags; + } + + public boolean isStripComments() + { + return stripComment; + } + + private String escapeComments(final String s) + { + final Matcher m = P_COMMENTS.matcher(s); + final StringBuffer buf = new StringBuffer(); + if (m.find()) + { + final String match = m.group(1); // (.*?) + m.appendReplacement(buf, Matcher.quoteReplacement("")); + } + m.appendTail(buf); + + return buf.toString(); + } + + private String balanceHTML(String s) + { + if (alwaysMakeTags) + { + // + // try and form html + // + s = regexReplace(P_END_ARROW, "", s); + s = regexReplace(P_BODY_TO_END, "<$1>", s); + s = regexReplace(P_XML_CONTENT, "$1<$2", s); + + } + else + { + // + // escape stray brackets + // + s = regexReplace(P_STRAY_LEFT_ARROW, "<$1", s); + s = regexReplace(P_STRAY_RIGHT_ARROW, "$1$2><", s); + + // + // the last regexp causes '<>' entities to appear + // (we need to do a lookahead assertion so that the last bracket can + // be used in the next pass of the regexp) + // + s = regexReplace(P_BOTH_ARROWS, "", s); + } + + return s; + } + + private String checkTags(String s) + { + Matcher m = P_TAGS.matcher(s); + + final StringBuffer buf = new StringBuffer(); + while (m.find()) + { + String replaceStr = m.group(1); + replaceStr = processTag(replaceStr); + m.appendReplacement(buf, Matcher.quoteReplacement(replaceStr)); + } + m.appendTail(buf); + + // these get tallied in processTag + // (remember to reset before subsequent calls to filter method) + final StringBuilder sBuilder = new StringBuilder(buf.toString()); + for (String key : vTagCounts.keySet()) + { + for (int ii = 0; ii < vTagCounts.get(key); ii++) + { + sBuilder.append(""); + } + } + s = sBuilder.toString(); + + return s; + } + + private String processRemoveBlanks(final String s) + { + String result = s; + for (String tag : vRemoveBlanks) + { + if (!P_REMOVE_PAIR_BLANKS.containsKey(tag)) + { + P_REMOVE_PAIR_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?>")); + } + result = regexReplace(P_REMOVE_PAIR_BLANKS.get(tag), "", result); + if (!P_REMOVE_SELF_BLANKS.containsKey(tag)) + { + P_REMOVE_SELF_BLANKS.putIfAbsent(tag, Pattern.compile("<" + tag + "(\\s[^>]*)?/>")); + } + result = regexReplace(P_REMOVE_SELF_BLANKS.get(tag), "", result); + } + + return result; + } + + private static String regexReplace(final Pattern regex_pattern, final String replacement, final String s) + { + Matcher m = regex_pattern.matcher(s); + return m.replaceAll(replacement); + } + + private String processTag(final String s) + { + // ending tags + Matcher m = P_END_TAG.matcher(s); + if (m.find()) + { + final String name = m.group(1).toLowerCase(); + if (allowed(name)) + { + if (false == inArray(name, vSelfClosingTags)) + { + if (vTagCounts.containsKey(name)) + { + vTagCounts.put(name, vTagCounts.get(name) - 1); + return ""; + } + } + } + } + + // starting tags + m = P_START_TAG.matcher(s); + if (m.find()) + { + final String name = m.group(1).toLowerCase(); + final String body = m.group(2); + String ending = m.group(3); + + // debug( "in a starting tag, name='" + name + "'; body='" + body + "'; ending='" + ending + "'" ); + if (allowed(name)) + { + final StringBuilder params = new StringBuilder(); + + final Matcher m2 = P_QUOTED_ATTRIBUTES.matcher(body); + final Matcher m3 = P_UNQUOTED_ATTRIBUTES.matcher(body); + final List paramNames = new ArrayList<>(); + final List paramValues = new ArrayList<>(); + while (m2.find()) + { + paramNames.add(m2.group(1)); // ([a-z0-9]+) + paramValues.add(m2.group(3)); // (.*?) + } + while (m3.find()) + { + paramNames.add(m3.group(1)); // ([a-z0-9]+) + paramValues.add(m3.group(3)); // ([^\"\\s']+) + } + + String paramName, paramValue; + for (int ii = 0; ii < paramNames.size(); ii++) + { + paramName = paramNames.get(ii).toLowerCase(); + paramValue = paramValues.get(ii); + + // debug( "paramName='" + paramName + "'" ); + // debug( "paramValue='" + paramValue + "'" ); + // debug( "allowed? " + vAllowed.get( name ).contains( paramName ) ); + + if (allowedAttribute(name, paramName)) + { + if (inArray(paramName, vProtocolAtts)) + { + paramValue = processParamProtocol(paramValue); + } + params.append(' ').append(paramName).append("=\"").append(paramValue).append("\""); + } + } + + if (inArray(name, vSelfClosingTags)) + { + ending = " /"; + } + + if (inArray(name, vNeedClosingTags)) + { + ending = ""; + } + + if (ending == null || ending.length() < 1) + { + if (vTagCounts.containsKey(name)) + { + vTagCounts.put(name, vTagCounts.get(name) + 1); + } + else + { + vTagCounts.put(name, 1); + } + } + else + { + ending = " /"; + } + return "<" + name + params + ending + ">"; + } + else + { + return ""; + } + } + + // comments + m = P_COMMENT.matcher(s); + if (!stripComment && m.find()) + { + return "<" + m.group() + ">"; + } + + return ""; + } + + private String processParamProtocol(String s) + { + s = decodeEntities(s); + final Matcher m = P_PROTOCOL.matcher(s); + if (m.find()) + { + final String protocol = m.group(1); + if (!inArray(protocol, vAllowedProtocols)) + { + // bad protocol, turn into local anchor link instead + s = "#" + s.substring(protocol.length() + 1); + if (s.startsWith("#//")) + { + s = "#" + s.substring(3); + } + } + } + + return s; + } + + private String decodeEntities(String s) + { + StringBuffer buf = new StringBuffer(); + + Matcher m = P_ENTITY.matcher(s); + while (m.find()) + { + final String match = m.group(1); + final int decimal = Integer.decode(match).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENTITY_UNICODE.matcher(s); + while (m.find()) + { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + buf = new StringBuffer(); + m = P_ENCODE.matcher(s); + while (m.find()) + { + final String match = m.group(1); + final int decimal = Integer.valueOf(match, 16).intValue(); + m.appendReplacement(buf, Matcher.quoteReplacement(chr(decimal))); + } + m.appendTail(buf); + s = buf.toString(); + + s = validateEntities(s); + return s; + } + + private String validateEntities(final String s) + { + StringBuffer buf = new StringBuffer(); + + // validate entities throughout the string + Matcher m = P_VALID_ENTITIES.matcher(s); + while (m.find()) + { + final String one = m.group(1); // ([^&;]*) + final String two = m.group(2); // (?=(;|&|$)) + m.appendReplacement(buf, Matcher.quoteReplacement(checkEntity(one, two))); + } + m.appendTail(buf); + + return encodeQuotes(buf.toString()); + } + + private String encodeQuotes(final String s) + { + if (encodeQuotes) + { + StringBuffer buf = new StringBuffer(); + Matcher m = P_VALID_QUOTES.matcher(s); + while (m.find()) + { + final String one = m.group(1); // (>|^) + final String two = m.group(2); // ([^<]+?) + final String three = m.group(3); // (<|$) + // 涓嶆浛鎹㈠弻寮曞彿涓"锛岄槻姝son鏍煎紡鏃犳晥 regexReplace(P_QUOTE, """, two) + m.appendReplacement(buf, Matcher.quoteReplacement(one + two + three)); + } + m.appendTail(buf); + return buf.toString(); + } + else + { + return s; + } + } + + private String checkEntity(final String preamble, final String term) + { + + return ";".equals(term) && isValidEntity(preamble) ? '&' + preamble : "&" + preamble; + } + + private boolean isValidEntity(final String entity) + { + return inArray(entity, vAllowedEntities); + } + + private static boolean inArray(final String s, final String[] array) + { + for (String item : array) + { + if (item != null && item.equals(s)) + { + return true; + } + } + return false; + } + + private boolean allowed(final String name) + { + return (vAllowed.isEmpty() || vAllowed.containsKey(name)) && !inArray(name, vDisallowed); + } + + private boolean allowedAttribute(final String name, final String paramName) + { + return allowed(name) && (vAllowed.isEmpty() || vAllowed.get(name).contains(paramName)); + } } \ No newline at end of file diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java similarity index 88% rename from ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java index dcf1b8f53..e34fa5ae6 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpHelper.java @@ -1,55 +1,55 @@ -package com.ruoyi.common.utils.http; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.nio.charset.Charset; -import javax.servlet.ServletRequest; -import org.apache.commons.lang.exception.ExceptionUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * 閫氱敤http宸ュ叿灏佽 - * - * @author ruoyi - */ -public class HttpHelper -{ - private static final Logger LOGGER = LoggerFactory.getLogger(HttpHelper.class); - - public static String getBodyString(ServletRequest request) - { - StringBuilder sb = new StringBuilder(); - BufferedReader reader = null; - try (InputStream inputStream = request.getInputStream()) - { - reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8"))); - String line = ""; - while ((line = reader.readLine()) != null) - { - sb.append(line); - } - } - catch (IOException e) - { - LOGGER.warn("getBodyString鍑虹幇闂锛"); - } - finally - { - if (reader != null) - { - try - { - reader.close(); - } - catch (IOException e) - { - LOGGER.error(ExceptionUtils.getFullStackTrace(e)); - } - } - } - return sb.toString(); - } -} +package com.ruoyi.common.utils.http; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.nio.charset.Charset; +import javax.servlet.ServletRequest; +import org.apache.commons.lang3.exception.ExceptionUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * 閫氱敤http宸ュ叿灏佽 + * + * @author ruoyi + */ +public class HttpHelper +{ + private static final Logger LOGGER = LoggerFactory.getLogger(HttpHelper.class); + + public static String getBodyString(ServletRequest request) + { + StringBuilder sb = new StringBuilder(); + BufferedReader reader = null; + try (InputStream inputStream = request.getInputStream()) + { + reader = new BufferedReader(new InputStreamReader(inputStream, Charset.forName("UTF-8"))); + String line = ""; + while ((line = reader.readLine()) != null) + { + sb.append(line); + } + } + catch (IOException e) + { + LOGGER.warn("getBodyString鍑虹幇闂锛"); + } + finally + { + if (reader != null) + { + try + { + reader.close(); + } + catch (IOException e) + { + LOGGER.error(ExceptionUtils.getMessage(e)); + } + } + } + return sb.toString(); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/http/HttpUtils.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java index c36431f99..11faa3236 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/AddressUtils.java @@ -3,10 +3,10 @@ package com.ruoyi.common.utils.ip; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import com.alibaba.fastjson.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 com.ruoyi.framework.config.RuoYiConfig; /** * 鑾峰彇鍦板潃绫 diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/ip/IpUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/IpUtils.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/ip/IpUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/ip/IpUtils.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java similarity index 95% rename from ruoyi/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java index 3211ac551..f4947e0c6 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/poi/ExcelUtil.java @@ -1,875 +1,875 @@ -package com.ruoyi.common.utils.poi; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.math.BigDecimal; -import java.text.DecimalFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Comparator; -import java.util.Date; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.stream.Collectors; -import org.apache.poi.hssf.usermodel.HSSFDateUtil; -import org.apache.poi.ss.usermodel.BorderStyle; -import org.apache.poi.ss.usermodel.Cell; -import org.apache.poi.ss.usermodel.CellStyle; -import org.apache.poi.ss.usermodel.CellType; -import org.apache.poi.ss.usermodel.DataValidation; -import org.apache.poi.ss.usermodel.DataValidationConstraint; -import org.apache.poi.ss.usermodel.DataValidationHelper; -import org.apache.poi.ss.usermodel.DateUtil; -import org.apache.poi.ss.usermodel.FillPatternType; -import org.apache.poi.ss.usermodel.Font; -import org.apache.poi.ss.usermodel.HorizontalAlignment; -import org.apache.poi.ss.usermodel.IndexedColors; -import org.apache.poi.ss.usermodel.Row; -import org.apache.poi.ss.usermodel.Sheet; -import org.apache.poi.ss.usermodel.VerticalAlignment; -import org.apache.poi.ss.usermodel.Workbook; -import org.apache.poi.ss.usermodel.WorkbookFactory; -import org.apache.poi.ss.util.CellRangeAddressList; -import org.apache.poi.xssf.streaming.SXSSFWorkbook; -import org.apache.poi.xssf.usermodel.XSSFDataValidation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.exception.CustomException; -import com.ruoyi.common.utils.DateUtils; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.reflect.ReflectUtils; -import com.ruoyi.framework.aspectj.lang.annotation.Excel; -import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType; -import com.ruoyi.framework.aspectj.lang.annotation.Excel.Type; -import com.ruoyi.framework.aspectj.lang.annotation.Excels; -import com.ruoyi.framework.config.RuoYiConfig; -import com.ruoyi.framework.web.domain.AjaxResult; - -/** - * Excel鐩稿叧澶勭悊 - * - * @author ruoyi - */ -public class ExcelUtil -{ - private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class); - - /** - * Excel sheet鏈澶ц鏁帮紝榛樿65536 - */ - public static final int sheetSize = 65536; - - /** - * 宸ヤ綔琛ㄥ悕绉 - */ - private String sheetName; - - /** - * 瀵煎嚭绫诲瀷锛圗XPORT:瀵煎嚭鏁版嵁锛汭MPORT锛氬鍏ユā鏉匡級 - */ - private Type type; - - /** - * 宸ヤ綔钖勫璞 - */ - private Workbook wb; - - /** - * 宸ヤ綔琛ㄥ璞 - */ - private Sheet sheet; - - /** - * 鏍峰紡鍒楄〃 - */ - private Map styles; - - /** - * 瀵煎叆瀵煎嚭鏁版嵁鍒楄〃 - */ - private List list; - - /** - * 娉ㄨВ鍒楄〃 - */ - private List fields; - - /** - * 瀹炰綋瀵硅薄 - */ - public Class clazz; - - public ExcelUtil(Class clazz) - { - this.clazz = clazz; - } - - public void init(List list, String sheetName, Type type) - { - if (list == null) - { - list = new ArrayList(); - } - this.list = list; - this.sheetName = sheetName; - this.type = type; - createExcelField(); - createWorkbook(); - } - - /** - * 瀵筫xcel琛ㄥ崟榛樿绗竴涓储寮曞悕杞崲鎴恖ist - * - * @param is 杈撳叆娴 - * @return 杞崲鍚庨泦鍚 - */ - public List importExcel(InputStream is) throws Exception - { - return importExcel(StringUtils.EMPTY, is); - } - - /** - * 瀵筫xcel琛ㄥ崟鎸囧畾琛ㄦ牸绱㈠紩鍚嶈浆鎹㈡垚list - * - * @param sheetName 琛ㄦ牸绱㈠紩鍚 - * @param is 杈撳叆娴 - * @return 杞崲鍚庨泦鍚 - */ - public List importExcel(String sheetName, InputStream is) throws Exception - { - this.type = Type.IMPORT; - this.wb = WorkbookFactory.create(is); - List list = new ArrayList(); - Sheet sheet = null; - if (StringUtils.isNotEmpty(sheetName)) - { - // 濡傛灉鎸囧畾sheet鍚,鍒欏彇鎸囧畾sheet涓殑鍐呭. - sheet = wb.getSheet(sheetName); - } - else - { - // 濡傛灉浼犲叆鐨剆heet鍚嶄笉瀛樺湪鍒欓粯璁ゆ寚鍚戠1涓猻heet. - sheet = wb.getSheetAt(0); - } - - if (sheet == null) - { - throw new IOException("鏂囦欢sheet涓嶅瓨鍦"); - } - - int rows = sheet.getPhysicalNumberOfRows(); - - if (rows > 0) - { - // 瀹氫箟涓涓猰ap鐢ㄤ簬瀛樻斁excel鍒楃殑搴忓彿鍜宖ield. - Map cellMap = new HashMap(); - // 鑾峰彇琛ㄥご - Row heard = sheet.getRow(0); - for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) - { - Cell cell = heard.getCell(i); - if (StringUtils.isNotNull(cell)) - { - String value = this.getCellValue(heard, i).toString(); - cellMap.put(value, i); - } - else - { - cellMap.put(null, i); - } - } - // 鏈夋暟鎹椂鎵嶅鐞 寰楀埌绫荤殑鎵鏈塮ield. - Field[] allFields = clazz.getDeclaredFields(); - // 瀹氫箟涓涓猰ap鐢ㄤ簬瀛樻斁鍒楃殑搴忓彿鍜宖ield. - Map fieldsMap = new HashMap(); - for (int col = 0; col < allFields.length; col++) - { - Field field = allFields[col]; - Excel attr = field.getAnnotation(Excel.class); - if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) - { - // 璁剧疆绫荤殑绉佹湁瀛楁灞炴у彲璁块棶. - field.setAccessible(true); - Integer column = cellMap.get(attr.name()); - fieldsMap.put(column, field); - } - } - for (int i = 1; i < rows; i++) - { - // 浠庣2琛屽紑濮嬪彇鏁版嵁,榛樿绗竴琛屾槸琛ㄥご. - Row row = sheet.getRow(i); - T entity = null; - for (Map.Entry entry : fieldsMap.entrySet()) - { - Object val = this.getCellValue(row, entry.getKey()); - - // 濡傛灉涓嶅瓨鍦ㄥ疄渚嬪垯鏂板缓. - entity = (entity == null ? clazz.newInstance() : entity); - // 浠巑ap涓緱鍒板搴斿垪鐨刦ield. - Field field = fieldsMap.get(entry.getKey()); - // 鍙栧緱绫诲瀷,骞舵牴鎹璞$被鍨嬭缃. - Class fieldType = field.getType(); - if (String.class == fieldType) - { - String s = Convert.toStr(val); - if (StringUtils.endsWith(s, ".0")) - { - val = StringUtils.substringBefore(s, ".0"); - } - else - { - val = Convert.toStr(val); - } - } - else if ((Integer.TYPE == fieldType) || (Integer.class == fieldType)) - { - val = Convert.toInt(val); - } - else if ((Long.TYPE == fieldType) || (Long.class == fieldType)) - { - val = Convert.toLong(val); - } - else if ((Double.TYPE == fieldType) || (Double.class == fieldType)) - { - val = Convert.toDouble(val); - } - else if ((Float.TYPE == fieldType) || (Float.class == fieldType)) - { - val = Convert.toFloat(val); - } - else if (BigDecimal.class == fieldType) - { - val = Convert.toBigDecimal(val); - } - else if (Date.class == fieldType) - { - if (val instanceof String) - { - val = DateUtils.parseDate(val); - } - else if (val instanceof Double) - { - val = DateUtil.getJavaDate((Double) val); - } - } - if (StringUtils.isNotNull(fieldType)) - { - Excel attr = field.getAnnotation(Excel.class); - String propertyName = field.getName(); - if (StringUtils.isNotEmpty(attr.targetAttr())) - { - propertyName = field.getName() + "." + attr.targetAttr(); - } - else if (StringUtils.isNotEmpty(attr.readConverterExp())) - { - val = reverseByExp(String.valueOf(val), attr.readConverterExp()); - } - ReflectUtils.invokeSetter(entity, propertyName, val); - } - } - list.add(entity); - } - } - return list; - } - - /** - * 瀵筶ist鏁版嵁婧愬皢鍏堕噷闈㈢殑鏁版嵁瀵煎叆鍒癳xcel琛ㄥ崟 - * - * @param list 瀵煎嚭鏁版嵁闆嗗悎 - * @param sheetName 宸ヤ綔琛ㄧ殑鍚嶇О - * @return 缁撴灉 - */ - public AjaxResult exportExcel(List list, String sheetName) - { - this.init(list, sheetName, Type.EXPORT); - return exportExcel(); - } - - /** - * 瀵筶ist鏁版嵁婧愬皢鍏堕噷闈㈢殑鏁版嵁瀵煎叆鍒癳xcel琛ㄥ崟 - * - * @param sheetName 宸ヤ綔琛ㄧ殑鍚嶇О - * @return 缁撴灉 - */ - public AjaxResult importTemplateExcel(String sheetName) - { - this.init(null, sheetName, Type.IMPORT); - return exportExcel(); - } - - /** - * 瀵筶ist鏁版嵁婧愬皢鍏堕噷闈㈢殑鏁版嵁瀵煎叆鍒癳xcel琛ㄥ崟 - * - * @return 缁撴灉 - */ - public AjaxResult exportExcel() - { - OutputStream out = null; - try - { - // 鍙栧嚭涓鍏辨湁澶氬皯涓猻heet. - double sheetNo = Math.ceil(list.size() / sheetSize); - for (int index = 0; index <= sheetNo; index++) - { - createSheet(sheetNo, index); - - // 浜х敓涓琛 - Row row = sheet.createRow(0); - int column = 0; - // 鍐欏叆鍚勪釜瀛楁鐨勫垪澶村悕绉 - for (Object[] os : fields) - { - Excel excel = (Excel) os[1]; - this.createCell(excel, row, column++); - } - if (Type.EXPORT.equals(type)) - { - fillExcelData(index, row); - } - } - String filename = encodingFilename(sheetName); - out = new FileOutputStream(getAbsoluteFile(filename)); - wb.write(out); - return AjaxResult.success(filename); - } - catch (Exception e) - { - log.error("瀵煎嚭Excel寮傚父{}", e.getMessage()); - throw new CustomException("瀵煎嚭Excel澶辫触锛岃鑱旂郴缃戠珯绠$悊鍛橈紒"); - } - finally - { - if (wb != null) - { - try - { - wb.close(); - } - catch (IOException e1) - { - e1.printStackTrace(); - } - } - if (out != null) - { - try - { - out.close(); - } - catch (IOException e1) - { - e1.printStackTrace(); - } - } - } - } - - /** - * 濉厖excel鏁版嵁 - * - * @param index 搴忓彿 - * @param row 鍗曞厓鏍艰 - */ - public void fillExcelData(int index, Row row) - { - int startNo = index * sheetSize; - int endNo = Math.min(startNo + sheetSize, list.size()); - for (int i = startNo; i < endNo; i++) - { - row = sheet.createRow(i + 1 - startNo); - // 寰楀埌瀵煎嚭瀵硅薄. - T vo = (T) list.get(i); - int column = 0; - for (Object[] os : fields) - { - Field field = (Field) os[0]; - Excel excel = (Excel) os[1]; - // 璁剧疆瀹炰綋绫荤鏈夊睘鎬у彲璁块棶 - field.setAccessible(true); - this.addCell(excel, row, vo, field, column++); - } - } - } - - /** - * 鍒涘缓琛ㄦ牸鏍峰紡 - * - * @param wb 宸ヤ綔钖勫璞 - * @return 鏍峰紡鍒楄〃 - */ - private Map createStyles(Workbook wb) - { - // 鍐欏叆鍚勬潯璁板綍,姣忔潯璁板綍瀵瑰簲excel琛ㄤ腑鐨勪竴琛 - Map styles = new HashMap(); - CellStyle style = wb.createCellStyle(); - style.setAlignment(HorizontalAlignment.CENTER); - style.setVerticalAlignment(VerticalAlignment.CENTER); - style.setBorderRight(BorderStyle.THIN); - style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); - style.setBorderLeft(BorderStyle.THIN); - style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); - style.setBorderTop(BorderStyle.THIN); - style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); - style.setBorderBottom(BorderStyle.THIN); - style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); - Font dataFont = wb.createFont(); - dataFont.setFontName("Arial"); - dataFont.setFontHeightInPoints((short) 10); - style.setFont(dataFont); - styles.put("data", style); - - style = wb.createCellStyle(); - style.cloneStyleFrom(styles.get("data")); - style.setAlignment(HorizontalAlignment.CENTER); - style.setVerticalAlignment(VerticalAlignment.CENTER); - style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); - style.setFillPattern(FillPatternType.SOLID_FOREGROUND); - Font headerFont = wb.createFont(); - headerFont.setFontName("Arial"); - headerFont.setFontHeightInPoints((short) 10); - headerFont.setBold(true); - headerFont.setColor(IndexedColors.WHITE.getIndex()); - style.setFont(headerFont); - styles.put("header", style); - - return styles; - } - - /** - * 鍒涘缓鍗曞厓鏍 - */ - public Cell createCell(Excel attr, Row row, int column) - { - // 鍒涘缓鍒 - Cell cell = row.createCell(column); - // 鍐欏叆鍒椾俊鎭 - cell.setCellValue(attr.name()); - setDataValidation(attr, row, column); - cell.setCellStyle(styles.get("header")); - return cell; - } - - /** - * 璁剧疆鍗曞厓鏍间俊鎭 - * - * @param value 鍗曞厓鏍煎 - * @param attr 娉ㄨВ鐩稿叧 - * @param cell 鍗曞厓鏍间俊鎭 - */ - public void setCellVo(Object value, Excel attr, Cell cell) - { - if (ColumnType.STRING == attr.cellType()) - { - cell.setCellType(CellType.NUMERIC); - cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix()); - } - else if (ColumnType.NUMERIC == attr.cellType()) - { - cell.setCellType(CellType.NUMERIC); - cell.setCellValue(Integer.parseInt(value + "")); - } - } - - /** - * 鍒涘缓琛ㄦ牸鏍峰紡 - */ - public void setDataValidation(Excel attr, Row row, int column) - { - if (attr.name().indexOf("娉細") >= 0) - { - sheet.setColumnWidth(column, 6000); - } - else - { - // 璁剧疆鍒楀 - sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256)); - row.setHeight((short) (attr.height() * 20)); - } - // 濡傛灉璁剧疆浜嗘彁绀轰俊鎭垯榧犳爣鏀句笂鍘绘彁绀. - if (StringUtils.isNotEmpty(attr.prompt())) - { - // 杩欓噷榛樿璁句簡2-101鍒楁彁绀. - setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column); - } - // 濡傛灉璁剧疆浜哻ombo灞炴у垯鏈垪鍙兘閫夋嫨涓嶈兘杈撳叆 - if (attr.combo().length > 0) - { - // 杩欓噷榛樿璁句簡2-101鍒楀彧鑳介夋嫨涓嶈兘杈撳叆. - setXSSFValidation(sheet, attr.combo(), 1, 100, column, column); - } - } - - /** - * 娣诲姞鍗曞厓鏍 - */ - public Cell addCell(Excel attr, Row row, T vo, Field field, int column) - { - Cell cell = null; - try - { - // 璁剧疆琛岄珮 - row.setHeight((short) (attr.height() * 20)); - // 鏍规嵁Excel涓缃儏鍐靛喅瀹氭槸鍚﹀鍑,鏈変簺鎯呭喌闇瑕佷繚鎸佷负绌,甯屾湜鐢ㄦ埛濉啓杩欎竴鍒. - if (attr.isExport()) - { - // 鍒涘缓cell - cell = row.createCell(column); - cell.setCellStyle(styles.get("data")); - - // 鐢ㄤ簬璇诲彇瀵硅薄涓殑灞炴 - Object value = getTargetValue(vo, field, attr); - String dateFormat = attr.dateFormat(); - String readConverterExp = attr.readConverterExp(); - if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) - { - cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value)); - } - else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) - { - cell.setCellValue(convertByExp(String.valueOf(value), readConverterExp)); - } - else - { - // 璁剧疆鍒楃被鍨 - setCellVo(value, attr, cell); - } - } - } - catch (Exception e) - { - log.error("瀵煎嚭Excel澶辫触{}", e); - } - return cell; - } - - /** - * 璁剧疆 POI XSSFSheet 鍗曞厓鏍兼彁绀 - * - * @param sheet 琛ㄥ崟 - * @param promptTitle 鎻愮ず鏍囬 - * @param promptContent 鎻愮ず鍐呭 - * @param firstRow 寮濮嬭 - * @param endRow 缁撴潫琛 - * @param firstCol 寮濮嬪垪 - * @param endCol 缁撴潫鍒 - */ - public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow, - int firstCol, int endCol) - { - DataValidationHelper helper = sheet.getDataValidationHelper(); - DataValidationConstraint constraint = helper.createCustomConstraint("DD1"); - CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); - DataValidation dataValidation = helper.createValidation(constraint, regions); - dataValidation.createPromptBox(promptTitle, promptContent); - dataValidation.setShowPromptBox(true); - sheet.addValidationData(dataValidation); - } - - /** - * 璁剧疆鏌愪簺鍒楃殑鍊煎彧鑳借緭鍏ラ鍒剁殑鏁版嵁,鏄剧ず涓嬫媺妗. - * - * @param sheet 瑕佽缃殑sheet. - * @param textlist 涓嬫媺妗嗘樉绀虹殑鍐呭 - * @param firstRow 寮濮嬭 - * @param endRow 缁撴潫琛 - * @param firstCol 寮濮嬪垪 - * @param endCol 缁撴潫鍒 - * @return 璁剧疆濂界殑sheet. - */ - public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol) - { - DataValidationHelper helper = sheet.getDataValidationHelper(); - // 鍔犺浇涓嬫媺鍒楄〃鍐呭 - DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist); - // 璁剧疆鏁版嵁鏈夋晥鎬у姞杞藉湪鍝釜鍗曞厓鏍间笂,鍥涗釜鍙傛暟鍒嗗埆鏄細璧峰琛屻佺粓姝㈣銆佽捣濮嬪垪銆佺粓姝㈠垪 - CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); - // 鏁版嵁鏈夋晥鎬у璞 - DataValidation dataValidation = helper.createValidation(constraint, regions); - // 澶勭悊Excel鍏煎鎬ч棶棰 - if (dataValidation instanceof XSSFDataValidation) - { - dataValidation.setSuppressDropDownArrow(true); - dataValidation.setShowErrorBox(true); - } - else - { - dataValidation.setSuppressDropDownArrow(false); - } - - sheet.addValidationData(dataValidation); - } - - /** - * 瑙f瀽瀵煎嚭鍊 0=鐢,1=濂,2=鏈煡 - * - * @param propertyValue 鍙傛暟鍊 - * @param converterExp 缈昏瘧娉ㄨВ - * @return 瑙f瀽鍚庡 - * @throws Exception - */ - public static String convertByExp(String propertyValue, String converterExp) throws Exception - { - try - { - String[] convertSource = converterExp.split(","); - for (String item : convertSource) - { - String[] itemArray = item.split("="); - if (itemArray[0].equals(propertyValue)) - { - return itemArray[1]; - } - } - } - catch (Exception e) - { - throw e; - } - return propertyValue; - } - - /** - * 鍙嶅悜瑙f瀽鍊 鐢=0,濂=1,鏈煡=2 - * - * @param propertyValue 鍙傛暟鍊 - * @param converterExp 缈昏瘧娉ㄨВ - * @return 瑙f瀽鍚庡 - * @throws Exception - */ - public static String reverseByExp(String propertyValue, String converterExp) throws Exception - { - try - { - String[] convertSource = converterExp.split(","); - for (String item : convertSource) - { - String[] itemArray = item.split("="); - if (itemArray[1].equals(propertyValue)) - { - return itemArray[0]; - } - } - } - catch (Exception e) - { - throw e; - } - return propertyValue; - } - - /** - * 缂栫爜鏂囦欢鍚 - */ - public String encodingFilename(String filename) - { - filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx"; - return filename; - } - - /** - * 鑾峰彇涓嬭浇璺緞 - * - * @param filename 鏂囦欢鍚嶇О - */ - public String getAbsoluteFile(String filename) - { - String downloadPath = RuoYiConfig.getDownloadPath() + filename; - File desc = new File(downloadPath); - if (!desc.getParentFile().exists()) - { - desc.getParentFile().mkdirs(); - } - return downloadPath; - } - - /** - * 鑾峰彇bean涓殑灞炴у - * - * @param vo 瀹炰綋瀵硅薄 - * @param field 瀛楁 - * @param excel 娉ㄨВ - * @return 鏈缁堢殑灞炴у - * @throws Exception - */ - private Object getTargetValue(T vo, Field field, Excel excel) throws Exception - { - Object o = field.get(vo); - if (StringUtils.isNotEmpty(excel.targetAttr())) - { - String target = excel.targetAttr(); - if (target.indexOf(".") > -1) - { - String[] targets = target.split("[.]"); - for (String name : targets) - { - o = getValue(o, name); - } - } - else - { - o = getValue(o, target); - } - } - return o; - } - - /** - * 浠ョ被鐨勫睘鎬х殑get鏂规硶鏂规硶褰㈠紡鑾峰彇鍊 - * - * @param o - * @param name - * @return value - * @throws Exception - */ - private Object getValue(Object o, String name) throws Exception - { - if (StringUtils.isNotEmpty(name)) - { - Class clazz = o.getClass(); - String methodName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1); - Method method = clazz.getMethod(methodName); - o = method.invoke(o); - } - return o; - } - - /** - * 寰楀埌鎵鏈夊畾涔夊瓧娈 - */ - private void createExcelField() - { - this.fields = new ArrayList(); - List tempFields = new ArrayList<>(); - tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields())); - tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); - for (Field field : tempFields) - { - // 鍗曟敞瑙 - if (field.isAnnotationPresent(Excel.class)) - { - putToField(field, field.getAnnotation(Excel.class)); - } - - // 澶氭敞瑙 - if (field.isAnnotationPresent(Excels.class)) - { - Excels attrs = field.getAnnotation(Excels.class); - Excel[] excels = attrs.value(); - for (Excel excel : excels) - { - putToField(field, excel); - } - } - } - this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList()); - } - - /** - * 鏀惧埌瀛楁闆嗗悎涓 - */ - private void putToField(Field field, Excel attr) - { - if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) - { - this.fields.add(new Object[] { field, attr }); - } - } - - /** - * 鍒涘缓涓涓伐浣滅翱 - */ - public void createWorkbook() - { - this.wb = new SXSSFWorkbook(500); - } - - /** - * 鍒涘缓宸ヤ綔琛 - * - * @param sheetNo sheet鏁伴噺 - * @param index 搴忓彿 - */ - public void createSheet(double sheetNo, int index) - { - this.sheet = wb.createSheet(); - this.styles = createStyles(wb); - // 璁剧疆宸ヤ綔琛ㄧ殑鍚嶇О. - if (sheetNo == 0) - { - wb.setSheetName(index, sheetName); - } - else - { - wb.setSheetName(index, sheetName + index); - } - } - - /** - * 鑾峰彇鍗曞厓鏍煎 - * - * @param row 鑾峰彇鐨勮 - * @param column 鑾峰彇鍗曞厓鏍煎垪鍙 - * @return 鍗曞厓鏍煎 - */ - public Object getCellValue(Row row, int column) - { - if (row == null) - { - return row; - } - Object val = ""; - try - { - Cell cell = row.getCell(column); - if (StringUtils.isNotNull(cell)) - { - if (cell.getCellTypeEnum() == CellType.NUMERIC || cell.getCellTypeEnum() == CellType.FORMULA) - { - val = cell.getNumericCellValue(); - if (HSSFDateUtil.isCellDateFormatted(cell)) - { - val = DateUtil.getJavaDate((Double) val); // POI Excel 鏃ユ湡鏍煎紡杞崲 - } - else - { - if ((Double) val % 1 > 0) - { - val = new DecimalFormat("0.00").format(val); - } - else - { - val = new DecimalFormat("0").format(val); - } - } - } - else if (cell.getCellTypeEnum() == CellType.STRING) - { - val = cell.getStringCellValue(); - } - else if (cell.getCellTypeEnum() == CellType.BOOLEAN) - { - val = cell.getBooleanCellValue(); - } - else if (cell.getCellTypeEnum() == CellType.ERROR) - { - val = cell.getErrorCellValue(); - } - - } - } - catch (Exception e) - { - return val; - } - return val; - } +package com.ruoyi.common.utils.poi; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.math.BigDecimal; +import java.text.DecimalFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.Date; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.stream.Collectors; +import org.apache.poi.hssf.usermodel.HSSFDateUtil; +import org.apache.poi.ss.usermodel.BorderStyle; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.ss.usermodel.DataValidation; +import org.apache.poi.ss.usermodel.DataValidationConstraint; +import org.apache.poi.ss.usermodel.DataValidationHelper; +import org.apache.poi.ss.usermodel.DateUtil; +import org.apache.poi.ss.usermodel.FillPatternType; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.HorizontalAlignment; +import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.usermodel.Row; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.VerticalAlignment; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.ss.usermodel.WorkbookFactory; +import org.apache.poi.ss.util.CellRangeAddressList; +import org.apache.poi.xssf.streaming.SXSSFWorkbook; +import org.apache.poi.xssf.usermodel.XSSFDataValidation; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.annotation.Excel.Type; +import com.ruoyi.common.annotation.Excels; +import com.ruoyi.common.config.RuoYiConfig; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.exception.CustomException; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.reflect.ReflectUtils; + +/** + * Excel鐩稿叧澶勭悊 + * + * @author ruoyi + */ +public class ExcelUtil +{ + private static final Logger log = LoggerFactory.getLogger(ExcelUtil.class); + + /** + * Excel sheet鏈澶ц鏁帮紝榛樿65536 + */ + public static final int sheetSize = 65536; + + /** + * 宸ヤ綔琛ㄥ悕绉 + */ + private String sheetName; + + /** + * 瀵煎嚭绫诲瀷锛圗XPORT:瀵煎嚭鏁版嵁锛汭MPORT锛氬鍏ユā鏉匡級 + */ + private Type type; + + /** + * 宸ヤ綔钖勫璞 + */ + private Workbook wb; + + /** + * 宸ヤ綔琛ㄥ璞 + */ + private Sheet sheet; + + /** + * 鏍峰紡鍒楄〃 + */ + private Map styles; + + /** + * 瀵煎叆瀵煎嚭鏁版嵁鍒楄〃 + */ + private List list; + + /** + * 娉ㄨВ鍒楄〃 + */ + private List fields; + + /** + * 瀹炰綋瀵硅薄 + */ + public Class clazz; + + public ExcelUtil(Class clazz) + { + this.clazz = clazz; + } + + public void init(List list, String sheetName, Type type) + { + if (list == null) + { + list = new ArrayList(); + } + this.list = list; + this.sheetName = sheetName; + this.type = type; + createExcelField(); + createWorkbook(); + } + + /** + * 瀵筫xcel琛ㄥ崟榛樿绗竴涓储寮曞悕杞崲鎴恖ist + * + * @param is 杈撳叆娴 + * @return 杞崲鍚庨泦鍚 + */ + public List importExcel(InputStream is) throws Exception + { + return importExcel(StringUtils.EMPTY, is); + } + + /** + * 瀵筫xcel琛ㄥ崟鎸囧畾琛ㄦ牸绱㈠紩鍚嶈浆鎹㈡垚list + * + * @param sheetName 琛ㄦ牸绱㈠紩鍚 + * @param is 杈撳叆娴 + * @return 杞崲鍚庨泦鍚 + */ + public List importExcel(String sheetName, InputStream is) throws Exception + { + this.type = Type.IMPORT; + this.wb = WorkbookFactory.create(is); + List list = new ArrayList(); + Sheet sheet = null; + if (StringUtils.isNotEmpty(sheetName)) + { + // 濡傛灉鎸囧畾sheet鍚,鍒欏彇鎸囧畾sheet涓殑鍐呭. + sheet = wb.getSheet(sheetName); + } + else + { + // 濡傛灉浼犲叆鐨剆heet鍚嶄笉瀛樺湪鍒欓粯璁ゆ寚鍚戠1涓猻heet. + sheet = wb.getSheetAt(0); + } + + if (sheet == null) + { + throw new IOException("鏂囦欢sheet涓嶅瓨鍦"); + } + + int rows = sheet.getPhysicalNumberOfRows(); + + if (rows > 0) + { + // 瀹氫箟涓涓猰ap鐢ㄤ簬瀛樻斁excel鍒楃殑搴忓彿鍜宖ield. + Map cellMap = new HashMap(); + // 鑾峰彇琛ㄥご + Row heard = sheet.getRow(0); + for (int i = 0; i < heard.getPhysicalNumberOfCells(); i++) + { + Cell cell = heard.getCell(i); + if (StringUtils.isNotNull(cell)) + { + String value = this.getCellValue(heard, i).toString(); + cellMap.put(value, i); + } + else + { + cellMap.put(null, i); + } + } + // 鏈夋暟鎹椂鎵嶅鐞 寰楀埌绫荤殑鎵鏈塮ield. + Field[] allFields = clazz.getDeclaredFields(); + // 瀹氫箟涓涓猰ap鐢ㄤ簬瀛樻斁鍒楃殑搴忓彿鍜宖ield. + Map fieldsMap = new HashMap(); + for (int col = 0; col < allFields.length; col++) + { + Field field = allFields[col]; + Excel attr = field.getAnnotation(Excel.class); + if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) + { + // 璁剧疆绫荤殑绉佹湁瀛楁灞炴у彲璁块棶. + field.setAccessible(true); + Integer column = cellMap.get(attr.name()); + fieldsMap.put(column, field); + } + } + for (int i = 1; i < rows; i++) + { + // 浠庣2琛屽紑濮嬪彇鏁版嵁,榛樿绗竴琛屾槸琛ㄥご. + Row row = sheet.getRow(i); + T entity = null; + for (Map.Entry entry : fieldsMap.entrySet()) + { + Object val = this.getCellValue(row, entry.getKey()); + + // 濡傛灉涓嶅瓨鍦ㄥ疄渚嬪垯鏂板缓. + entity = (entity == null ? clazz.newInstance() : entity); + // 浠巑ap涓緱鍒板搴斿垪鐨刦ield. + Field field = fieldsMap.get(entry.getKey()); + // 鍙栧緱绫诲瀷,骞舵牴鎹璞$被鍨嬭缃. + Class fieldType = field.getType(); + if (String.class == fieldType) + { + String s = Convert.toStr(val); + if (StringUtils.endsWith(s, ".0")) + { + val = StringUtils.substringBefore(s, ".0"); + } + else + { + val = Convert.toStr(val); + } + } + else if ((Integer.TYPE == fieldType) || (Integer.class == fieldType)) + { + val = Convert.toInt(val); + } + else if ((Long.TYPE == fieldType) || (Long.class == fieldType)) + { + val = Convert.toLong(val); + } + else if ((Double.TYPE == fieldType) || (Double.class == fieldType)) + { + val = Convert.toDouble(val); + } + else if ((Float.TYPE == fieldType) || (Float.class == fieldType)) + { + val = Convert.toFloat(val); + } + else if (BigDecimal.class == fieldType) + { + val = Convert.toBigDecimal(val); + } + else if (Date.class == fieldType) + { + if (val instanceof String) + { + val = DateUtils.parseDate(val); + } + else if (val instanceof Double) + { + val = DateUtil.getJavaDate((Double) val); + } + } + if (StringUtils.isNotNull(fieldType)) + { + Excel attr = field.getAnnotation(Excel.class); + String propertyName = field.getName(); + if (StringUtils.isNotEmpty(attr.targetAttr())) + { + propertyName = field.getName() + "." + attr.targetAttr(); + } + else if (StringUtils.isNotEmpty(attr.readConverterExp())) + { + val = reverseByExp(String.valueOf(val), attr.readConverterExp()); + } + ReflectUtils.invokeSetter(entity, propertyName, val); + } + } + list.add(entity); + } + } + return list; + } + + /** + * 瀵筶ist鏁版嵁婧愬皢鍏堕噷闈㈢殑鏁版嵁瀵煎叆鍒癳xcel琛ㄥ崟 + * + * @param list 瀵煎嚭鏁版嵁闆嗗悎 + * @param sheetName 宸ヤ綔琛ㄧ殑鍚嶇О + * @return 缁撴灉 + */ + public AjaxResult exportExcel(List list, String sheetName) + { + this.init(list, sheetName, Type.EXPORT); + return exportExcel(); + } + + /** + * 瀵筶ist鏁版嵁婧愬皢鍏堕噷闈㈢殑鏁版嵁瀵煎叆鍒癳xcel琛ㄥ崟 + * + * @param sheetName 宸ヤ綔琛ㄧ殑鍚嶇О + * @return 缁撴灉 + */ + public AjaxResult importTemplateExcel(String sheetName) + { + this.init(null, sheetName, Type.IMPORT); + return exportExcel(); + } + + /** + * 瀵筶ist鏁版嵁婧愬皢鍏堕噷闈㈢殑鏁版嵁瀵煎叆鍒癳xcel琛ㄥ崟 + * + * @return 缁撴灉 + */ + public AjaxResult exportExcel() + { + OutputStream out = null; + try + { + // 鍙栧嚭涓鍏辨湁澶氬皯涓猻heet. + double sheetNo = Math.ceil(list.size() / sheetSize); + for (int index = 0; index <= sheetNo; index++) + { + createSheet(sheetNo, index); + + // 浜х敓涓琛 + Row row = sheet.createRow(0); + int column = 0; + // 鍐欏叆鍚勪釜瀛楁鐨勫垪澶村悕绉 + for (Object[] os : fields) + { + Excel excel = (Excel) os[1]; + this.createCell(excel, row, column++); + } + if (Type.EXPORT.equals(type)) + { + fillExcelData(index, row); + } + } + String filename = encodingFilename(sheetName); + out = new FileOutputStream(getAbsoluteFile(filename)); + wb.write(out); + return AjaxResult.success(filename); + } + catch (Exception e) + { + log.error("瀵煎嚭Excel寮傚父{}", e.getMessage()); + throw new CustomException("瀵煎嚭Excel澶辫触锛岃鑱旂郴缃戠珯绠$悊鍛橈紒"); + } + finally + { + if (wb != null) + { + try + { + wb.close(); + } + catch (IOException e1) + { + e1.printStackTrace(); + } + } + if (out != null) + { + try + { + out.close(); + } + catch (IOException e1) + { + e1.printStackTrace(); + } + } + } + } + + /** + * 濉厖excel鏁版嵁 + * + * @param index 搴忓彿 + * @param row 鍗曞厓鏍艰 + */ + public void fillExcelData(int index, Row row) + { + int startNo = index * sheetSize; + int endNo = Math.min(startNo + sheetSize, list.size()); + for (int i = startNo; i < endNo; i++) + { + row = sheet.createRow(i + 1 - startNo); + // 寰楀埌瀵煎嚭瀵硅薄. + T vo = (T) list.get(i); + int column = 0; + for (Object[] os : fields) + { + Field field = (Field) os[0]; + Excel excel = (Excel) os[1]; + // 璁剧疆瀹炰綋绫荤鏈夊睘鎬у彲璁块棶 + field.setAccessible(true); + this.addCell(excel, row, vo, field, column++); + } + } + } + + /** + * 鍒涘缓琛ㄦ牸鏍峰紡 + * + * @param wb 宸ヤ綔钖勫璞 + * @return 鏍峰紡鍒楄〃 + */ + private Map createStyles(Workbook wb) + { + // 鍐欏叆鍚勬潯璁板綍,姣忔潯璁板綍瀵瑰簲excel琛ㄤ腑鐨勪竴琛 + Map styles = new HashMap(); + CellStyle style = wb.createCellStyle(); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + style.setBorderRight(BorderStyle.THIN); + style.setRightBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setBorderLeft(BorderStyle.THIN); + style.setLeftBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setBorderTop(BorderStyle.THIN); + style.setTopBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setBorderBottom(BorderStyle.THIN); + style.setBottomBorderColor(IndexedColors.GREY_50_PERCENT.getIndex()); + Font dataFont = wb.createFont(); + dataFont.setFontName("Arial"); + dataFont.setFontHeightInPoints((short) 10); + style.setFont(dataFont); + styles.put("data", style); + + style = wb.createCellStyle(); + style.cloneStyleFrom(styles.get("data")); + style.setAlignment(HorizontalAlignment.CENTER); + style.setVerticalAlignment(VerticalAlignment.CENTER); + style.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex()); + style.setFillPattern(FillPatternType.SOLID_FOREGROUND); + Font headerFont = wb.createFont(); + headerFont.setFontName("Arial"); + headerFont.setFontHeightInPoints((short) 10); + headerFont.setBold(true); + headerFont.setColor(IndexedColors.WHITE.getIndex()); + style.setFont(headerFont); + styles.put("header", style); + + return styles; + } + + /** + * 鍒涘缓鍗曞厓鏍 + */ + public Cell createCell(Excel attr, Row row, int column) + { + // 鍒涘缓鍒 + Cell cell = row.createCell(column); + // 鍐欏叆鍒椾俊鎭 + cell.setCellValue(attr.name()); + setDataValidation(attr, row, column); + cell.setCellStyle(styles.get("header")); + return cell; + } + + /** + * 璁剧疆鍗曞厓鏍间俊鎭 + * + * @param value 鍗曞厓鏍煎 + * @param attr 娉ㄨВ鐩稿叧 + * @param cell 鍗曞厓鏍间俊鎭 + */ + public void setCellVo(Object value, Excel attr, Cell cell) + { + if (ColumnType.STRING == attr.cellType()) + { + cell.setCellType(CellType.NUMERIC); + cell.setCellValue(StringUtils.isNull(value) ? attr.defaultValue() : value + attr.suffix()); + } + else if (ColumnType.NUMERIC == attr.cellType()) + { + cell.setCellType(CellType.NUMERIC); + cell.setCellValue(Integer.parseInt(value + "")); + } + } + + /** + * 鍒涘缓琛ㄦ牸鏍峰紡 + */ + public void setDataValidation(Excel attr, Row row, int column) + { + if (attr.name().indexOf("娉細") >= 0) + { + sheet.setColumnWidth(column, 6000); + } + else + { + // 璁剧疆鍒楀 + sheet.setColumnWidth(column, (int) ((attr.width() + 0.72) * 256)); + row.setHeight((short) (attr.height() * 20)); + } + // 濡傛灉璁剧疆浜嗘彁绀轰俊鎭垯榧犳爣鏀句笂鍘绘彁绀. + if (StringUtils.isNotEmpty(attr.prompt())) + { + // 杩欓噷榛樿璁句簡2-101鍒楁彁绀. + setXSSFPrompt(sheet, "", attr.prompt(), 1, 100, column, column); + } + // 濡傛灉璁剧疆浜哻ombo灞炴у垯鏈垪鍙兘閫夋嫨涓嶈兘杈撳叆 + if (attr.combo().length > 0) + { + // 杩欓噷榛樿璁句簡2-101鍒楀彧鑳介夋嫨涓嶈兘杈撳叆. + setXSSFValidation(sheet, attr.combo(), 1, 100, column, column); + } + } + + /** + * 娣诲姞鍗曞厓鏍 + */ + public Cell addCell(Excel attr, Row row, T vo, Field field, int column) + { + Cell cell = null; + try + { + // 璁剧疆琛岄珮 + row.setHeight((short) (attr.height() * 20)); + // 鏍规嵁Excel涓缃儏鍐靛喅瀹氭槸鍚﹀鍑,鏈変簺鎯呭喌闇瑕佷繚鎸佷负绌,甯屾湜鐢ㄦ埛濉啓杩欎竴鍒. + if (attr.isExport()) + { + // 鍒涘缓cell + cell = row.createCell(column); + cell.setCellStyle(styles.get("data")); + + // 鐢ㄤ簬璇诲彇瀵硅薄涓殑灞炴 + Object value = getTargetValue(vo, field, attr); + String dateFormat = attr.dateFormat(); + String readConverterExp = attr.readConverterExp(); + if (StringUtils.isNotEmpty(dateFormat) && StringUtils.isNotNull(value)) + { + cell.setCellValue(DateUtils.parseDateToStr(dateFormat, (Date) value)); + } + else if (StringUtils.isNotEmpty(readConverterExp) && StringUtils.isNotNull(value)) + { + cell.setCellValue(convertByExp(String.valueOf(value), readConverterExp)); + } + else + { + // 璁剧疆鍒楃被鍨 + setCellVo(value, attr, cell); + } + } + } + catch (Exception e) + { + log.error("瀵煎嚭Excel澶辫触{}", e); + } + return cell; + } + + /** + * 璁剧疆 POI XSSFSheet 鍗曞厓鏍兼彁绀 + * + * @param sheet 琛ㄥ崟 + * @param promptTitle 鎻愮ず鏍囬 + * @param promptContent 鎻愮ず鍐呭 + * @param firstRow 寮濮嬭 + * @param endRow 缁撴潫琛 + * @param firstCol 寮濮嬪垪 + * @param endCol 缁撴潫鍒 + */ + public void setXSSFPrompt(Sheet sheet, String promptTitle, String promptContent, int firstRow, int endRow, + int firstCol, int endCol) + { + DataValidationHelper helper = sheet.getDataValidationHelper(); + DataValidationConstraint constraint = helper.createCustomConstraint("DD1"); + CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); + DataValidation dataValidation = helper.createValidation(constraint, regions); + dataValidation.createPromptBox(promptTitle, promptContent); + dataValidation.setShowPromptBox(true); + sheet.addValidationData(dataValidation); + } + + /** + * 璁剧疆鏌愪簺鍒楃殑鍊煎彧鑳借緭鍏ラ鍒剁殑鏁版嵁,鏄剧ず涓嬫媺妗. + * + * @param sheet 瑕佽缃殑sheet. + * @param textlist 涓嬫媺妗嗘樉绀虹殑鍐呭 + * @param firstRow 寮濮嬭 + * @param endRow 缁撴潫琛 + * @param firstCol 寮濮嬪垪 + * @param endCol 缁撴潫鍒 + * @return 璁剧疆濂界殑sheet. + */ + public void setXSSFValidation(Sheet sheet, String[] textlist, int firstRow, int endRow, int firstCol, int endCol) + { + DataValidationHelper helper = sheet.getDataValidationHelper(); + // 鍔犺浇涓嬫媺鍒楄〃鍐呭 + DataValidationConstraint constraint = helper.createExplicitListConstraint(textlist); + // 璁剧疆鏁版嵁鏈夋晥鎬у姞杞藉湪鍝釜鍗曞厓鏍间笂,鍥涗釜鍙傛暟鍒嗗埆鏄細璧峰琛屻佺粓姝㈣銆佽捣濮嬪垪銆佺粓姝㈠垪 + CellRangeAddressList regions = new CellRangeAddressList(firstRow, endRow, firstCol, endCol); + // 鏁版嵁鏈夋晥鎬у璞 + DataValidation dataValidation = helper.createValidation(constraint, regions); + // 澶勭悊Excel鍏煎鎬ч棶棰 + if (dataValidation instanceof XSSFDataValidation) + { + dataValidation.setSuppressDropDownArrow(true); + dataValidation.setShowErrorBox(true); + } + else + { + dataValidation.setSuppressDropDownArrow(false); + } + + sheet.addValidationData(dataValidation); + } + + /** + * 瑙f瀽瀵煎嚭鍊 0=鐢,1=濂,2=鏈煡 + * + * @param propertyValue 鍙傛暟鍊 + * @param converterExp 缈昏瘧娉ㄨВ + * @return 瑙f瀽鍚庡 + * @throws Exception + */ + public static String convertByExp(String propertyValue, String converterExp) throws Exception + { + try + { + String[] convertSource = converterExp.split(","); + for (String item : convertSource) + { + String[] itemArray = item.split("="); + if (itemArray[0].equals(propertyValue)) + { + return itemArray[1]; + } + } + } + catch (Exception e) + { + throw e; + } + return propertyValue; + } + + /** + * 鍙嶅悜瑙f瀽鍊 鐢=0,濂=1,鏈煡=2 + * + * @param propertyValue 鍙傛暟鍊 + * @param converterExp 缈昏瘧娉ㄨВ + * @return 瑙f瀽鍚庡 + * @throws Exception + */ + public static String reverseByExp(String propertyValue, String converterExp) throws Exception + { + try + { + String[] convertSource = converterExp.split(","); + for (String item : convertSource) + { + String[] itemArray = item.split("="); + if (itemArray[1].equals(propertyValue)) + { + return itemArray[0]; + } + } + } + catch (Exception e) + { + throw e; + } + return propertyValue; + } + + /** + * 缂栫爜鏂囦欢鍚 + */ + public String encodingFilename(String filename) + { + filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx"; + return filename; + } + + /** + * 鑾峰彇涓嬭浇璺緞 + * + * @param filename 鏂囦欢鍚嶇О + */ + public String getAbsoluteFile(String filename) + { + String downloadPath = RuoYiConfig.getDownloadPath() + filename; + File desc = new File(downloadPath); + if (!desc.getParentFile().exists()) + { + desc.getParentFile().mkdirs(); + } + return downloadPath; + } + + /** + * 鑾峰彇bean涓殑灞炴у + * + * @param vo 瀹炰綋瀵硅薄 + * @param field 瀛楁 + * @param excel 娉ㄨВ + * @return 鏈缁堢殑灞炴у + * @throws Exception + */ + private Object getTargetValue(T vo, Field field, Excel excel) throws Exception + { + Object o = field.get(vo); + if (StringUtils.isNotEmpty(excel.targetAttr())) + { + String target = excel.targetAttr(); + if (target.indexOf(".") > -1) + { + String[] targets = target.split("[.]"); + for (String name : targets) + { + o = getValue(o, name); + } + } + else + { + o = getValue(o, target); + } + } + return o; + } + + /** + * 浠ョ被鐨勫睘鎬х殑get鏂规硶鏂规硶褰㈠紡鑾峰彇鍊 + * + * @param o + * @param name + * @return value + * @throws Exception + */ + private Object getValue(Object o, String name) throws Exception + { + if (StringUtils.isNotEmpty(name)) + { + Class clazz = o.getClass(); + String methodName = "get" + name.substring(0, 1).toUpperCase() + name.substring(1); + Method method = clazz.getMethod(methodName); + o = method.invoke(o); + } + return o; + } + + /** + * 寰楀埌鎵鏈夊畾涔夊瓧娈 + */ + private void createExcelField() + { + this.fields = new ArrayList(); + List tempFields = new ArrayList<>(); + tempFields.addAll(Arrays.asList(clazz.getSuperclass().getDeclaredFields())); + tempFields.addAll(Arrays.asList(clazz.getDeclaredFields())); + for (Field field : tempFields) + { + // 鍗曟敞瑙 + if (field.isAnnotationPresent(Excel.class)) + { + putToField(field, field.getAnnotation(Excel.class)); + } + + // 澶氭敞瑙 + if (field.isAnnotationPresent(Excels.class)) + { + Excels attrs = field.getAnnotation(Excels.class); + Excel[] excels = attrs.value(); + for (Excel excel : excels) + { + putToField(field, excel); + } + } + } + this.fields = this.fields.stream().sorted(Comparator.comparing(objects -> ((Excel) objects[1]).sort())).collect(Collectors.toList()); + } + + /** + * 鏀惧埌瀛楁闆嗗悎涓 + */ + private void putToField(Field field, Excel attr) + { + if (attr != null && (attr.type() == Type.ALL || attr.type() == type)) + { + this.fields.add(new Object[] { field, attr }); + } + } + + /** + * 鍒涘缓涓涓伐浣滅翱 + */ + public void createWorkbook() + { + this.wb = new SXSSFWorkbook(500); + } + + /** + * 鍒涘缓宸ヤ綔琛 + * + * @param sheetNo sheet鏁伴噺 + * @param index 搴忓彿 + */ + public void createSheet(double sheetNo, int index) + { + this.sheet = wb.createSheet(); + this.styles = createStyles(wb); + // 璁剧疆宸ヤ綔琛ㄧ殑鍚嶇О. + if (sheetNo == 0) + { + wb.setSheetName(index, sheetName); + } + else + { + wb.setSheetName(index, sheetName + index); + } + } + + /** + * 鑾峰彇鍗曞厓鏍煎 + * + * @param row 鑾峰彇鐨勮 + * @param column 鑾峰彇鍗曞厓鏍煎垪鍙 + * @return 鍗曞厓鏍煎 + */ + public Object getCellValue(Row row, int column) + { + if (row == null) + { + return row; + } + Object val = ""; + try + { + Cell cell = row.getCell(column); + if (StringUtils.isNotNull(cell)) + { + if (cell.getCellTypeEnum() == CellType.NUMERIC || cell.getCellTypeEnum() == CellType.FORMULA) + { + val = cell.getNumericCellValue(); + if (HSSFDateUtil.isCellDateFormatted(cell)) + { + val = DateUtil.getJavaDate((Double) val); // POI Excel 鏃ユ湡鏍煎紡杞崲 + } + else + { + if ((Double) val % 1 > 0) + { + val = new DecimalFormat("0.00").format(val); + } + else + { + val = new DecimalFormat("0").format(val); + } + } + } + else if (cell.getCellTypeEnum() == CellType.STRING) + { + val = cell.getStringCellValue(); + } + else if (cell.getCellTypeEnum() == CellType.BOOLEAN) + { + val = cell.getBooleanCellValue(); + } + else if (cell.getCellTypeEnum() == CellType.ERROR) + { + val = cell.getErrorCellValue(); + } + + } + } + catch (Exception e) + { + return val; + } + return val; + } } \ No newline at end of file diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java similarity index 97% rename from ruoyi/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java index b78e53e10..5241101be 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/reflect/ReflectUtils.java @@ -1,406 +1,406 @@ -package com.ruoyi.common.utils.reflect; - -import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.lang.reflect.Modifier; -import java.lang.reflect.ParameterizedType; -import java.lang.reflect.Type; -import java.util.Date; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.Validate; -import org.apache.poi.ss.usermodel.DateUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import com.ruoyi.common.core.text.Convert; -import com.ruoyi.common.utils.DateUtils; - -/** - * 鍙嶅皠宸ュ叿绫. 鎻愪緵璋冪敤getter/setter鏂规硶, 璁块棶绉佹湁鍙橀噺, 璋冪敤绉佹湁鏂规硶, 鑾峰彇娉涘瀷绫诲瀷Class, 琚獳OP杩囩殑鐪熷疄绫荤瓑宸ュ叿鍑芥暟. - * - * @author ruoyi - */ -@SuppressWarnings("rawtypes") -public class ReflectUtils -{ - private static final String SETTER_PREFIX = "set"; - - private static final String GETTER_PREFIX = "get"; - - private static final String CGLIB_CLASS_SEPARATOR = "$$"; - - private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class); - - /** - * 璋冪敤Getter鏂规硶. - * 鏀寔澶氱骇锛屽锛氬璞″悕.瀵硅薄鍚.鏂规硶 - */ - @SuppressWarnings("unchecked") - public static E invokeGetter(Object obj, String propertyName) - { - Object object = obj; - for (String name : StringUtils.split(propertyName, ".")) - { - String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name); - object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); - } - return (E) object; - } - - /** - * 璋冪敤Setter鏂规硶, 浠呭尮閰嶆柟娉曞悕銆 - * 鏀寔澶氱骇锛屽锛氬璞″悕.瀵硅薄鍚.鏂规硶 - */ - public static void invokeSetter(Object obj, String propertyName, E value) - { - Object object = obj; - String[] names = StringUtils.split(propertyName, "."); - for (int i = 0; i < names.length; i++) - { - if (i < names.length - 1) - { - String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]); - object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); - } - else - { - String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]); - invokeMethodByName(object, setterMethodName, new Object[] { value }); - } - } - } - - /** - * 鐩存帴璇诲彇瀵硅薄灞炴у, 鏃犺private/protected淇グ绗, 涓嶇粡杩噂etter鍑芥暟. - */ - @SuppressWarnings("unchecked") - public static E getFieldValue(final Object obj, final String fieldName) - { - Field field = getAccessibleField(obj, fieldName); - if (field == null) - { - logger.debug("鍦 [" + obj.getClass() + "] 涓紝娌℃湁鎵惧埌 [" + fieldName + "] 瀛楁 "); - return null; - } - E result = null; - try - { - result = (E) field.get(obj); - } - catch (IllegalAccessException e) - { - logger.error("涓嶅彲鑳芥姏鍑虹殑寮傚父{}", e.getMessage()); - } - return result; - } - - /** - * 鐩存帴璁剧疆瀵硅薄灞炴у, 鏃犺private/protected淇グ绗, 涓嶇粡杩噑etter鍑芥暟. - */ - public static void setFieldValue(final Object obj, final String fieldName, final E value) - { - Field field = getAccessibleField(obj, fieldName); - if (field == null) - { - // throw new IllegalArgumentException("鍦 [" + obj.getClass() + "] 涓紝娌℃湁鎵惧埌 [" + fieldName + "] 瀛楁 "); - logger.debug("鍦 [" + obj.getClass() + "] 涓紝娌℃湁鎵惧埌 [" + fieldName + "] 瀛楁 "); - return; - } - try - { - field.set(obj, value); - } - catch (IllegalAccessException e) - { - logger.error("涓嶅彲鑳芥姏鍑虹殑寮傚父: {}", e.getMessage()); - } - } - - /** - * 鐩存帴璋冪敤瀵硅薄鏂规硶, 鏃犺private/protected淇グ绗. - * 鐢ㄤ簬涓娆℃ц皟鐢ㄧ殑鎯呭喌锛屽惁鍒欏簲浣跨敤getAccessibleMethod()鍑芥暟鑾峰緱Method鍚庡弽澶嶈皟鐢. - * 鍚屾椂鍖归厤鏂规硶鍚+鍙傛暟绫诲瀷锛 - */ - @SuppressWarnings("unchecked") - public static E invokeMethod(final Object obj, final String methodName, final Class[] parameterTypes, - final Object[] args) - { - if (obj == null || methodName == null) - { - return null; - } - Method method = getAccessibleMethod(obj, methodName, parameterTypes); - if (method == null) - { - logger.debug("鍦 [" + obj.getClass() + "] 涓紝娌℃湁鎵惧埌 [" + methodName + "] 鏂规硶 "); - return null; - } - try - { - return (E) method.invoke(obj, args); - } - catch (Exception e) - { - String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; - throw convertReflectionExceptionToUnchecked(msg, e); - } - } - - /** - * 鐩存帴璋冪敤瀵硅薄鏂规硶, 鏃犺private/protected淇グ绗︼紝 - * 鐢ㄤ簬涓娆℃ц皟鐢ㄧ殑鎯呭喌锛屽惁鍒欏簲浣跨敤getAccessibleMethodByName()鍑芥暟鑾峰緱Method鍚庡弽澶嶈皟鐢. - * 鍙尮閰嶅嚱鏁板悕锛屽鏋滄湁澶氫釜鍚屽悕鍑芥暟璋冪敤绗竴涓 - */ - @SuppressWarnings("unchecked") - public static E invokeMethodByName(final Object obj, final String methodName, final Object[] args) - { - Method method = getAccessibleMethodByName(obj, methodName, args.length); - if (method == null) - { - // 濡傛灉涓虹┖涓嶆姤閿欙紝鐩存帴杩斿洖绌恒 - logger.debug("鍦 [" + obj.getClass() + "] 涓紝娌℃湁鎵惧埌 [" + methodName + "] 鏂规硶 "); - return null; - } - try - { - // 绫诲瀷杞崲锛堝皢鍙傛暟鏁版嵁绫诲瀷杞崲涓虹洰鏍囨柟娉曞弬鏁扮被鍨嬶級 - Class[] cs = method.getParameterTypes(); - for (int i = 0; i < cs.length; i++) - { - if (args[i] != null && !args[i].getClass().equals(cs[i])) - { - if (cs[i] == String.class) - { - args[i] = Convert.toStr(args[i]); - if (StringUtils.endsWith((String) args[i], ".0")) - { - args[i] = StringUtils.substringBefore((String) args[i], ".0"); - } - } - else if (cs[i] == Integer.class) - { - args[i] = Convert.toInt(args[i]); - } - else if (cs[i] == Long.class) - { - args[i] = Convert.toLong(args[i]); - } - else if (cs[i] == Double.class) - { - args[i] = Convert.toDouble(args[i]); - } - else if (cs[i] == Float.class) - { - args[i] = Convert.toFloat(args[i]); - } - else if (cs[i] == Date.class) - { - if (args[i] instanceof String) - { - args[i] = DateUtils.parseDate(args[i]); - } - else - { - args[i] = DateUtil.getJavaDate((Double) args[i]); - } - } - } - } - return (E) method.invoke(obj, args); - } - catch (Exception e) - { - String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; - throw convertReflectionExceptionToUnchecked(msg, e); - } - } - - /** - * 寰幆鍚戜笂杞瀷, 鑾峰彇瀵硅薄鐨凞eclaredField, 骞跺己鍒惰缃负鍙闂. - * 濡傚悜涓婅浆鍨嬪埌Object浠嶆棤娉曟壘鍒, 杩斿洖null. - */ - public static Field getAccessibleField(final Object obj, final String fieldName) - { - // 涓虹┖涓嶆姤閿欍傜洿鎺ヨ繑鍥 null - if (obj == null) - { - return null; - } - Validate.notBlank(fieldName, "fieldName can't be blank"); - for (Class superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) - { - try - { - Field field = superClass.getDeclaredField(fieldName); - makeAccessible(field); - return field; - } - catch (NoSuchFieldException e) - { - continue; - } - } - return null; - } - - /** - * 寰幆鍚戜笂杞瀷, 鑾峰彇瀵硅薄鐨凞eclaredMethod,骞跺己鍒惰缃负鍙闂. - * 濡傚悜涓婅浆鍨嬪埌Object浠嶆棤娉曟壘鍒, 杩斿洖null. - * 鍖归厤鍑芥暟鍚+鍙傛暟绫诲瀷銆 - * 鐢ㄤ簬鏂规硶闇瑕佽澶氭璋冪敤鐨勬儏鍐. 鍏堜娇鐢ㄦ湰鍑芥暟鍏堝彇寰桵ethod,鐒跺悗璋冪敤Method.invoke(Object obj, Object... args) - */ - public static Method getAccessibleMethod(final Object obj, final String methodName, - final Class... parameterTypes) - { - // 涓虹┖涓嶆姤閿欍傜洿鎺ヨ繑鍥 null - if (obj == null) - { - return null; - } - Validate.notBlank(methodName, "methodName can't be blank"); - for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) - { - try - { - Method method = searchType.getDeclaredMethod(methodName, parameterTypes); - makeAccessible(method); - return method; - } - catch (NoSuchMethodException e) - { - continue; - } - } - return null; - } - - /** - * 寰幆鍚戜笂杞瀷, 鑾峰彇瀵硅薄鐨凞eclaredMethod,骞跺己鍒惰缃负鍙闂. - * 濡傚悜涓婅浆鍨嬪埌Object浠嶆棤娉曟壘鍒, 杩斿洖null. - * 鍙尮閰嶅嚱鏁板悕銆 - * 鐢ㄤ簬鏂规硶闇瑕佽澶氭璋冪敤鐨勬儏鍐. 鍏堜娇鐢ㄦ湰鍑芥暟鍏堝彇寰桵ethod,鐒跺悗璋冪敤Method.invoke(Object obj, Object... args) - */ - public static Method getAccessibleMethodByName(final Object obj, final String methodName, int argsNum) - { - // 涓虹┖涓嶆姤閿欍傜洿鎺ヨ繑鍥 null - if (obj == null) - { - return null; - } - Validate.notBlank(methodName, "methodName can't be blank"); - for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) - { - Method[] methods = searchType.getDeclaredMethods(); - for (Method method : methods) - { - if (method.getName().equals(methodName) && method.getParameterTypes().length == argsNum) - { - makeAccessible(method); - return method; - } - } - } - return null; - } - - /** - * 鏀瑰彉private/protected鐨勬柟娉曚负public锛屽敖閲忎笉璋冪敤瀹為檯鏀瑰姩鐨勮鍙ワ紝閬垮厤JDK鐨凷ecurityManager鎶辨ㄣ - */ - public static void makeAccessible(Method method) - { - if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) - && !method.isAccessible()) - { - method.setAccessible(true); - } - } - - /** - * 鏀瑰彉private/protected鐨勬垚鍛樺彉閲忎负public锛屽敖閲忎笉璋冪敤瀹為檯鏀瑰姩鐨勮鍙ワ紝閬垮厤JDK鐨凷ecurityManager鎶辨ㄣ - */ - public static void makeAccessible(Field field) - { - if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) - || Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) - { - field.setAccessible(true); - } - } - - /** - * 閫氳繃鍙嶅皠, 鑾峰緱Class瀹氫箟涓0鏄庣殑娉涘瀷鍙傛暟鐨勭被鍨, 娉ㄦ剰娉涘瀷蹇呴』瀹氫箟鍦ㄧ埗绫诲 - * 濡傛棤娉曟壘鍒, 杩斿洖Object.class. - */ - @SuppressWarnings("unchecked") - public static Class getClassGenricType(final Class clazz) - { - return getClassGenricType(clazz, 0); - } - - /** - * 閫氳繃鍙嶅皠, 鑾峰緱Class瀹氫箟涓0鏄庣殑鐖剁被鐨勬硾鍨嬪弬鏁扮殑绫诲瀷. - * 濡傛棤娉曟壘鍒, 杩斿洖Object.class. - */ - public static Class getClassGenricType(final Class clazz, final int index) - { - Type genType = clazz.getGenericSuperclass(); - - if (!(genType instanceof ParameterizedType)) - { - logger.debug(clazz.getSimpleName() + "'s superclass not ParameterizedType"); - return Object.class; - } - - Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); - - if (index >= params.length || index < 0) - { - logger.debug("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: " - + params.length); - return Object.class; - } - if (!(params[index] instanceof Class)) - { - logger.debug(clazz.getSimpleName() + " not set the actual class on superclass generic parameter"); - return Object.class; - } - - return (Class) params[index]; - } - - public static Class getUserClass(Object instance) - { - if (instance == null) - { - throw new RuntimeException("Instance must not be null"); - } - Class clazz = instance.getClass(); - if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) - { - Class superClass = clazz.getSuperclass(); - if (superClass != null && !Object.class.equals(superClass)) - { - return superClass; - } - } - return clazz; - - } - - /** - * 灏嗗弽灏勬椂鐨刢hecked exception杞崲涓簎nchecked exception. - */ - public static RuntimeException convertReflectionExceptionToUnchecked(String msg, Exception e) - { - if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException - || e instanceof NoSuchMethodException) - { - return new IllegalArgumentException(msg, e); - } - else if (e instanceof InvocationTargetException) - { - return new RuntimeException(msg, ((InvocationTargetException) e).getTargetException()); - } - return new RuntimeException(msg, e); - } -} +package com.ruoyi.common.utils.reflect; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.lang.reflect.Modifier; +import java.lang.reflect.ParameterizedType; +import java.lang.reflect.Type; +import java.util.Date; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.Validate; +import org.apache.poi.ss.usermodel.DateUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.utils.DateUtils; + +/** + * 鍙嶅皠宸ュ叿绫. 鎻愪緵璋冪敤getter/setter鏂规硶, 璁块棶绉佹湁鍙橀噺, 璋冪敤绉佹湁鏂规硶, 鑾峰彇娉涘瀷绫诲瀷Class, 琚獳OP杩囩殑鐪熷疄绫荤瓑宸ュ叿鍑芥暟. + * + * @author ruoyi + */ +@SuppressWarnings("rawtypes") +public class ReflectUtils +{ + private static final String SETTER_PREFIX = "set"; + + private static final String GETTER_PREFIX = "get"; + + private static final String CGLIB_CLASS_SEPARATOR = "$$"; + + private static Logger logger = LoggerFactory.getLogger(ReflectUtils.class); + + /** + * 璋冪敤Getter鏂规硶. + * 鏀寔澶氱骇锛屽锛氬璞″悕.瀵硅薄鍚.鏂规硶 + */ + @SuppressWarnings("unchecked") + public static E invokeGetter(Object obj, String propertyName) + { + Object object = obj; + for (String name : StringUtils.split(propertyName, ".")) + { + String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(name); + object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); + } + return (E) object; + } + + /** + * 璋冪敤Setter鏂规硶, 浠呭尮閰嶆柟娉曞悕銆 + * 鏀寔澶氱骇锛屽锛氬璞″悕.瀵硅薄鍚.鏂规硶 + */ + public static void invokeSetter(Object obj, String propertyName, E value) + { + Object object = obj; + String[] names = StringUtils.split(propertyName, "."); + for (int i = 0; i < names.length; i++) + { + if (i < names.length - 1) + { + String getterMethodName = GETTER_PREFIX + StringUtils.capitalize(names[i]); + object = invokeMethod(object, getterMethodName, new Class[] {}, new Object[] {}); + } + else + { + String setterMethodName = SETTER_PREFIX + StringUtils.capitalize(names[i]); + invokeMethodByName(object, setterMethodName, new Object[] { value }); + } + } + } + + /** + * 鐩存帴璇诲彇瀵硅薄灞炴у, 鏃犺private/protected淇グ绗, 涓嶇粡杩噂etter鍑芥暟. + */ + @SuppressWarnings("unchecked") + public static E getFieldValue(final Object obj, final String fieldName) + { + Field field = getAccessibleField(obj, fieldName); + if (field == null) + { + logger.debug("鍦 [" + obj.getClass() + "] 涓紝娌℃湁鎵惧埌 [" + fieldName + "] 瀛楁 "); + return null; + } + E result = null; + try + { + result = (E) field.get(obj); + } + catch (IllegalAccessException e) + { + logger.error("涓嶅彲鑳芥姏鍑虹殑寮傚父{}", e.getMessage()); + } + return result; + } + + /** + * 鐩存帴璁剧疆瀵硅薄灞炴у, 鏃犺private/protected淇グ绗, 涓嶇粡杩噑etter鍑芥暟. + */ + public static void setFieldValue(final Object obj, final String fieldName, final E value) + { + Field field = getAccessibleField(obj, fieldName); + if (field == null) + { + // throw new IllegalArgumentException("鍦 [" + obj.getClass() + "] 涓紝娌℃湁鎵惧埌 [" + fieldName + "] 瀛楁 "); + logger.debug("鍦 [" + obj.getClass() + "] 涓紝娌℃湁鎵惧埌 [" + fieldName + "] 瀛楁 "); + return; + } + try + { + field.set(obj, value); + } + catch (IllegalAccessException e) + { + logger.error("涓嶅彲鑳芥姏鍑虹殑寮傚父: {}", e.getMessage()); + } + } + + /** + * 鐩存帴璋冪敤瀵硅薄鏂规硶, 鏃犺private/protected淇グ绗. + * 鐢ㄤ簬涓娆℃ц皟鐢ㄧ殑鎯呭喌锛屽惁鍒欏簲浣跨敤getAccessibleMethod()鍑芥暟鑾峰緱Method鍚庡弽澶嶈皟鐢. + * 鍚屾椂鍖归厤鏂规硶鍚+鍙傛暟绫诲瀷锛 + */ + @SuppressWarnings("unchecked") + public static E invokeMethod(final Object obj, final String methodName, final Class[] parameterTypes, + final Object[] args) + { + if (obj == null || methodName == null) + { + return null; + } + Method method = getAccessibleMethod(obj, methodName, parameterTypes); + if (method == null) + { + logger.debug("鍦 [" + obj.getClass() + "] 涓紝娌℃湁鎵惧埌 [" + methodName + "] 鏂规硶 "); + return null; + } + try + { + return (E) method.invoke(obj, args); + } + catch (Exception e) + { + String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; + throw convertReflectionExceptionToUnchecked(msg, e); + } + } + + /** + * 鐩存帴璋冪敤瀵硅薄鏂规硶, 鏃犺private/protected淇グ绗︼紝 + * 鐢ㄤ簬涓娆℃ц皟鐢ㄧ殑鎯呭喌锛屽惁鍒欏簲浣跨敤getAccessibleMethodByName()鍑芥暟鑾峰緱Method鍚庡弽澶嶈皟鐢. + * 鍙尮閰嶅嚱鏁板悕锛屽鏋滄湁澶氫釜鍚屽悕鍑芥暟璋冪敤绗竴涓 + */ + @SuppressWarnings("unchecked") + public static E invokeMethodByName(final Object obj, final String methodName, final Object[] args) + { + Method method = getAccessibleMethodByName(obj, methodName, args.length); + if (method == null) + { + // 濡傛灉涓虹┖涓嶆姤閿欙紝鐩存帴杩斿洖绌恒 + logger.debug("鍦 [" + obj.getClass() + "] 涓紝娌℃湁鎵惧埌 [" + methodName + "] 鏂规硶 "); + return null; + } + try + { + // 绫诲瀷杞崲锛堝皢鍙傛暟鏁版嵁绫诲瀷杞崲涓虹洰鏍囨柟娉曞弬鏁扮被鍨嬶級 + Class[] cs = method.getParameterTypes(); + for (int i = 0; i < cs.length; i++) + { + if (args[i] != null && !args[i].getClass().equals(cs[i])) + { + if (cs[i] == String.class) + { + args[i] = Convert.toStr(args[i]); + if (StringUtils.endsWith((String) args[i], ".0")) + { + args[i] = StringUtils.substringBefore((String) args[i], ".0"); + } + } + else if (cs[i] == Integer.class) + { + args[i] = Convert.toInt(args[i]); + } + else if (cs[i] == Long.class) + { + args[i] = Convert.toLong(args[i]); + } + else if (cs[i] == Double.class) + { + args[i] = Convert.toDouble(args[i]); + } + else if (cs[i] == Float.class) + { + args[i] = Convert.toFloat(args[i]); + } + else if (cs[i] == Date.class) + { + if (args[i] instanceof String) + { + args[i] = DateUtils.parseDate(args[i]); + } + else + { + args[i] = DateUtil.getJavaDate((Double) args[i]); + } + } + } + } + return (E) method.invoke(obj, args); + } + catch (Exception e) + { + String msg = "method: " + method + ", obj: " + obj + ", args: " + args + ""; + throw convertReflectionExceptionToUnchecked(msg, e); + } + } + + /** + * 寰幆鍚戜笂杞瀷, 鑾峰彇瀵硅薄鐨凞eclaredField, 骞跺己鍒惰缃负鍙闂. + * 濡傚悜涓婅浆鍨嬪埌Object浠嶆棤娉曟壘鍒, 杩斿洖null. + */ + public static Field getAccessibleField(final Object obj, final String fieldName) + { + // 涓虹┖涓嶆姤閿欍傜洿鎺ヨ繑鍥 null + if (obj == null) + { + return null; + } + Validate.notBlank(fieldName, "fieldName can't be blank"); + for (Class superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) + { + try + { + Field field = superClass.getDeclaredField(fieldName); + makeAccessible(field); + return field; + } + catch (NoSuchFieldException e) + { + continue; + } + } + return null; + } + + /** + * 寰幆鍚戜笂杞瀷, 鑾峰彇瀵硅薄鐨凞eclaredMethod,骞跺己鍒惰缃负鍙闂. + * 濡傚悜涓婅浆鍨嬪埌Object浠嶆棤娉曟壘鍒, 杩斿洖null. + * 鍖归厤鍑芥暟鍚+鍙傛暟绫诲瀷銆 + * 鐢ㄤ簬鏂规硶闇瑕佽澶氭璋冪敤鐨勬儏鍐. 鍏堜娇鐢ㄦ湰鍑芥暟鍏堝彇寰桵ethod,鐒跺悗璋冪敤Method.invoke(Object obj, Object... args) + */ + public static Method getAccessibleMethod(final Object obj, final String methodName, + final Class... parameterTypes) + { + // 涓虹┖涓嶆姤閿欍傜洿鎺ヨ繑鍥 null + if (obj == null) + { + return null; + } + Validate.notBlank(methodName, "methodName can't be blank"); + for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) + { + try + { + Method method = searchType.getDeclaredMethod(methodName, parameterTypes); + makeAccessible(method); + return method; + } + catch (NoSuchMethodException e) + { + continue; + } + } + return null; + } + + /** + * 寰幆鍚戜笂杞瀷, 鑾峰彇瀵硅薄鐨凞eclaredMethod,骞跺己鍒惰缃负鍙闂. + * 濡傚悜涓婅浆鍨嬪埌Object浠嶆棤娉曟壘鍒, 杩斿洖null. + * 鍙尮閰嶅嚱鏁板悕銆 + * 鐢ㄤ簬鏂规硶闇瑕佽澶氭璋冪敤鐨勬儏鍐. 鍏堜娇鐢ㄦ湰鍑芥暟鍏堝彇寰桵ethod,鐒跺悗璋冪敤Method.invoke(Object obj, Object... args) + */ + public static Method getAccessibleMethodByName(final Object obj, final String methodName, int argsNum) + { + // 涓虹┖涓嶆姤閿欍傜洿鎺ヨ繑鍥 null + if (obj == null) + { + return null; + } + Validate.notBlank(methodName, "methodName can't be blank"); + for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) + { + Method[] methods = searchType.getDeclaredMethods(); + for (Method method : methods) + { + if (method.getName().equals(methodName) && method.getParameterTypes().length == argsNum) + { + makeAccessible(method); + return method; + } + } + } + return null; + } + + /** + * 鏀瑰彉private/protected鐨勬柟娉曚负public锛屽敖閲忎笉璋冪敤瀹為檯鏀瑰姩鐨勮鍙ワ紝閬垮厤JDK鐨凷ecurityManager鎶辨ㄣ + */ + public static void makeAccessible(Method method) + { + if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) + && !method.isAccessible()) + { + method.setAccessible(true); + } + } + + /** + * 鏀瑰彉private/protected鐨勬垚鍛樺彉閲忎负public锛屽敖閲忎笉璋冪敤瀹為檯鏀瑰姩鐨勮鍙ワ紝閬垮厤JDK鐨凷ecurityManager鎶辨ㄣ + */ + public static void makeAccessible(Field field) + { + if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) + || Modifier.isFinal(field.getModifiers())) && !field.isAccessible()) + { + field.setAccessible(true); + } + } + + /** + * 閫氳繃鍙嶅皠, 鑾峰緱Class瀹氫箟涓0鏄庣殑娉涘瀷鍙傛暟鐨勭被鍨, 娉ㄦ剰娉涘瀷蹇呴』瀹氫箟鍦ㄧ埗绫诲 + * 濡傛棤娉曟壘鍒, 杩斿洖Object.class. + */ + @SuppressWarnings("unchecked") + public static Class getClassGenricType(final Class clazz) + { + return getClassGenricType(clazz, 0); + } + + /** + * 閫氳繃鍙嶅皠, 鑾峰緱Class瀹氫箟涓0鏄庣殑鐖剁被鐨勬硾鍨嬪弬鏁扮殑绫诲瀷. + * 濡傛棤娉曟壘鍒, 杩斿洖Object.class. + */ + public static Class getClassGenricType(final Class clazz, final int index) + { + Type genType = clazz.getGenericSuperclass(); + + if (!(genType instanceof ParameterizedType)) + { + logger.debug(clazz.getSimpleName() + "'s superclass not ParameterizedType"); + return Object.class; + } + + Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); + + if (index >= params.length || index < 0) + { + logger.debug("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: " + + params.length); + return Object.class; + } + if (!(params[index] instanceof Class)) + { + logger.debug(clazz.getSimpleName() + " not set the actual class on superclass generic parameter"); + return Object.class; + } + + return (Class) params[index]; + } + + public static Class getUserClass(Object instance) + { + if (instance == null) + { + throw new RuntimeException("Instance must not be null"); + } + Class clazz = instance.getClass(); + if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) + { + Class superClass = clazz.getSuperclass(); + if (superClass != null && !Object.class.equals(superClass)) + { + return superClass; + } + } + return clazz; + + } + + /** + * 灏嗗弽灏勬椂鐨刢hecked exception杞崲涓簎nchecked exception. + */ + public static RuntimeException convertReflectionExceptionToUnchecked(String msg, Exception e) + { + if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException + || e instanceof NoSuchMethodException) + { + return new IllegalArgumentException(msg, e); + } + else if (e instanceof InvocationTargetException) + { + return new RuntimeException(msg, ((InvocationTargetException) e).getTargetException()); + } + return new RuntimeException(msg, e); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/sign/Base64.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Base64.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/sign/Base64.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Base64.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/sign/Md5Utils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Md5Utils.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/sign/Md5Utils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/sign/Md5Utils.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/spring/SpringUtils.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/sql/SqlUtil.java diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/IdUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/IdUtils.java similarity index 87% rename from ruoyi/src/main/java/com/ruoyi/common/utils/IdUtils.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/IdUtils.java index 45d8ac91a..eb78f6fed 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/IdUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/IdUtils.java @@ -1,6 +1,6 @@ -package com.ruoyi.common.utils; +package com.ruoyi.common.utils.uuid; -import com.ruoyi.common.core.lang.UUID; +import com.ruoyi.common.utils.uuid.UUID; /** * ID鐢熸垚鍣ㄥ伐鍏风被 diff --git a/ruoyi/src/main/java/com/ruoyi/common/core/lang/UUID.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/UUID.java similarity index 96% rename from ruoyi/src/main/java/com/ruoyi/common/core/lang/UUID.java rename to ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/UUID.java index fa7429774..eef72ee0b 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/core/lang/UUID.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/uuid/UUID.java @@ -1,4 +1,4 @@ -package com.ruoyi.common.core.lang; +package com.ruoyi.common.utils.uuid; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; diff --git a/ruoyi-framework/pom.xml b/ruoyi-framework/pom.xml new file mode 100644 index 000000000..4d93d31a7 --- /dev/null +++ b/ruoyi-framework/pom.xml @@ -0,0 +1,62 @@ + + + + ruoyi + com.ruoyi + 3.0.0 + + 4.0.0 + + ruoyi-framework + + + framework妗嗘灦鏍稿績 + + + + + + + org.springframework.boot + spring-boot-starter-web + + + + + org.springframework.boot + spring-boot-starter-aop + + + + + com.alibaba + druid-spring-boot-starter + + + + + com.github.oshi + oshi-core + + + + net.java.dev.jna + jna + + + + net.java.dev.jna + jna-platform + + + + + com.ruoyi + ruoyi-system + + + + + \ No newline at end of file diff --git a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java index e28e9680c..58040b6dc 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataScopeAspect.java @@ -8,15 +8,15 @@ import org.aspectj.lang.annotation.Before; import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.reflect.MethodSignature; 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; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.framework.aspectj.lang.annotation.DataScope; -import com.ruoyi.framework.security.LoginUser; -import com.ruoyi.framework.security.service.TokenService; -import com.ruoyi.framework.web.domain.BaseEntity; -import com.ruoyi.project.system.domain.SysRole; -import com.ruoyi.project.system.domain.SysUser; +import com.ruoyi.framework.web.service.TokenService; /** * 鏁版嵁杩囨护澶勭悊 @@ -58,7 +58,7 @@ public class DataScopeAspect public static final String DATA_SCOPE = "dataScope"; // 閰嶇疆缁囧叆鐐 - @Pointcut("@annotation(com.ruoyi.framework.aspectj.lang.annotation.DataScope)") + @Pointcut("@annotation(com.ruoyi.common.annotation.DataScope)") public void dataScopePointCut() { } diff --git a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java similarity index 86% rename from ruoyi/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java index bc850732f..4648fcd3c 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/DataSourceAspect.java @@ -11,8 +11,8 @@ 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.aspectj.lang.annotation.DataSource; import com.ruoyi.framework.datasource.DynamicDataSourceContextHolder; /** @@ -27,8 +27,8 @@ public class DataSourceAspect { protected Logger logger = LoggerFactory.getLogger(getClass()); - @Pointcut("@annotation(com.ruoyi.framework.aspectj.lang.annotation.DataSource)" - + "|| @within(com.ruoyi.framework.aspectj.lang.annotation.DataSource)") + @Pointcut("@annotation(com.ruoyi.common.annotation.DataSource)" + + "|| @within(com.ruoyi.common.annotation.DataSource)") public void dsPointCut() { diff --git a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java index 29a1c97e6..51a7cd2bf 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/aspectj/LogAspect.java @@ -17,18 +17,18 @@ import org.springframework.stereotype.Component; import org.springframework.web.multipart.MultipartFile; import org.springframework.web.servlet.HandlerMapping; import com.alibaba.fastjson.JSON; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.enums.BusinessStatus; import com.ruoyi.common.enums.HttpMethod; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.ip.IpUtils; import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessStatus; import com.ruoyi.framework.manager.AsyncManager; import com.ruoyi.framework.manager.factory.AsyncFactory; -import com.ruoyi.framework.security.LoginUser; -import com.ruoyi.framework.security.service.TokenService; -import com.ruoyi.project.monitor.domain.SysOperLog; +import com.ruoyi.framework.web.service.TokenService; +import com.ruoyi.system.domain.SysOperLog; /** * 鎿嶄綔鏃ュ織璁板綍澶勭悊 @@ -42,7 +42,7 @@ public class LogAspect private static final Logger log = LoggerFactory.getLogger(LogAspect.class); // 閰嶇疆缁囧叆鐐 - @Pointcut("@annotation(com.ruoyi.framework.aspectj.lang.annotation.Log)") + @Pointcut("@annotation(com.ruoyi.common.annotation.Log)") public void logPointCut() { } diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java index 5a6da111c..66a00e7cb 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ApplicationConfig.java @@ -16,7 +16,7 @@ import org.springframework.context.annotation.EnableAspectJAutoProxy; // 琛ㄧず閫氳繃aop妗嗘灦鏆撮湶璇ヤ唬鐞嗗璞,AopContext鑳藉璁块棶 @EnableAspectJAutoProxy(exposeProxy = true) // 鎸囧畾瑕佹壂鎻忕殑Mapper绫荤殑鍖呯殑璺緞 -@MapperScan("com.ruoyi.project.**.mapper") +@MapperScan("com.ruoyi.**.mapper") public class ApplicationConfig { /** diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/DruidConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java similarity index 96% rename from ruoyi/src/main/java/com/ruoyi/framework/config/DruidConfig.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java index f0519d5ac..f671b3a30 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/config/DruidConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/DruidConfig.java @@ -19,8 +19,8 @@ import com.alibaba.druid.pool.DruidDataSource; import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceBuilder; import com.alibaba.druid.spring.boot.autoconfigure.properties.DruidStatProperties; import com.alibaba.druid.util.Utils; +import com.ruoyi.common.enums.DataSourceType; import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.framework.aspectj.lang.enums.DataSourceType; import com.ruoyi.framework.config.properties.DruidProperties; import com.ruoyi.framework.datasource.DynamicDataSource; diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/config/FastJson2JsonRedisSerializer.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/FilterConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/FilterConfig.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/config/FilterConfig.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/config/FilterConfig.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/RedisConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/config/RedisConfig.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/config/RedisConfig.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java similarity index 94% rename from ruoyi/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java index 8c19564b1..2e120aab8 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ResourcesConfig.java @@ -5,6 +5,7 @@ import org.springframework.context.annotation.Configuration; import org.springframework.web.servlet.config.annotation.InterceptorRegistry; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; +import com.ruoyi.common.config.RuoYiConfig; import com.ruoyi.common.constant.Constants; import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/config/SecurityConfig.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/ServerConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/config/ServerConfig.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/config/ServerConfig.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/ThreadPoolConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/ThreadPoolConfig.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/config/ThreadPoolConfig.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/config/ThreadPoolConfig.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/properties/DruidProperties.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/DruidProperties.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/config/properties/DruidProperties.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/config/properties/DruidProperties.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSource.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/datasource/DynamicDataSourceContextHolder.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSourceContextHolder.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/datasource/DynamicDataSourceContextHolder.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/datasource/DynamicDataSourceContextHolder.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java index 088798d55..bce2f3fe1 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/RepeatSubmitInterceptor.java @@ -1,55 +1,55 @@ -package com.ruoyi.framework.interceptor; - -import java.lang.reflect.Method; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import org.springframework.stereotype.Component; -import org.springframework.web.method.HandlerMethod; -import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; -import com.alibaba.fastjson.JSONObject; -import com.ruoyi.common.utils.ServletUtils; -import com.ruoyi.framework.interceptor.annotation.RepeatSubmit; -import com.ruoyi.framework.web.domain.AjaxResult; - -/** - * 闃叉閲嶅鎻愪氦鎷︽埅鍣 - * - * @author ruoyi - */ -@Component -public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter -{ - @Override - public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception - { - if (handler instanceof HandlerMethod) - { - HandlerMethod handlerMethod = (HandlerMethod) handler; - Method method = handlerMethod.getMethod(); - RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class); - if (annotation != null) - { - if (this.isRepeatSubmit(request)) - { - AjaxResult ajaxResult = AjaxResult.error("涓嶅厑璁搁噸澶嶆彁浜わ紝璇风◢鍚庡啀璇"); - ServletUtils.renderString(response, JSONObject.toJSONString(ajaxResult)); - return false; - } - } - return true; - } - else - { - return super.preHandle(request, response, handler); - } - } - - /** - * 楠岃瘉鏄惁閲嶅鎻愪氦鐢卞瓙绫诲疄鐜板叿浣撶殑闃查噸澶嶆彁浜ょ殑瑙勫垯 - * - * @param httpServletRequest - * @return - * @throws Exception - */ - public abstract boolean isRepeatSubmit(HttpServletRequest request); -} +package com.ruoyi.framework.interceptor; + +import java.lang.reflect.Method; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import org.springframework.stereotype.Component; +import org.springframework.web.method.HandlerMethod; +import org.springframework.web.servlet.handler.HandlerInterceptorAdapter; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.annotation.RepeatSubmit; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.utils.ServletUtils; + +/** + * 闃叉閲嶅鎻愪氦鎷︽埅鍣 + * + * @author ruoyi + */ +@Component +public abstract class RepeatSubmitInterceptor extends HandlerInterceptorAdapter +{ + @Override + public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception + { + if (handler instanceof HandlerMethod) + { + HandlerMethod handlerMethod = (HandlerMethod) handler; + Method method = handlerMethod.getMethod(); + RepeatSubmit annotation = method.getAnnotation(RepeatSubmit.class); + if (annotation != null) + { + if (this.isRepeatSubmit(request)) + { + AjaxResult ajaxResult = AjaxResult.error("涓嶅厑璁搁噸澶嶆彁浜わ紝璇风◢鍚庡啀璇"); + ServletUtils.renderString(response, JSONObject.toJSONString(ajaxResult)); + return false; + } + } + return true; + } + else + { + return super.preHandle(request, response, handler); + } + } + + /** + * 楠岃瘉鏄惁閲嶅鎻愪氦鐢卞瓙绫诲疄鐜板叿浣撶殑闃查噸澶嶆彁浜ょ殑瑙勫垯 + * + * @param httpServletRequest + * @return + * @throws Exception + */ + public abstract boolean isRepeatSubmit(HttpServletRequest request); +} diff --git a/ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java similarity index 95% rename from ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java index 05f59ee00..5f78380b9 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/interceptor/impl/SameUrlDataInterceptor.java @@ -1,107 +1,107 @@ -package com.ruoyi.framework.interceptor.impl; - -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.TimeUnit; -import javax.servlet.http.HttpServletRequest; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Component; -import com.alibaba.fastjson.JSONObject; -import com.ruoyi.common.filter.RepeatedlyRequestWrapper; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.http.HttpHelper; -import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; -import com.ruoyi.framework.redis.RedisCache; - -/** - * 鍒ゆ柇璇锋眰url鍜屾暟鎹槸鍚﹀拰涓婁竴娆$浉鍚岋紝 - * 濡傛灉鍜屼笂娆$浉鍚岋紝鍒欐槸閲嶅鎻愪氦琛ㄥ崟銆 鏈夋晥鏃堕棿涓10绉掑唴銆 - * - * @author ruoyi - */ -@Component -public class SameUrlDataInterceptor extends RepeatSubmitInterceptor -{ - public final String REPEAT_PARAMS = "repeatParams"; - - public final String REPEAT_TIME = "repeatTime"; - - public final String CACHE_REPEAT_KEY = "repeatData"; - - @Autowired - private RedisCache redisCache; - - /** - * 闂撮殧鏃堕棿锛屽崟浣:绉 榛樿10绉 - * - * 涓ゆ鐩稿悓鍙傛暟鐨勮姹傦紝濡傛灉闂撮殧鏃堕棿澶т簬璇ュ弬鏁帮紝绯荤粺涓嶄細璁ゅ畾涓洪噸澶嶆彁浜ょ殑鏁版嵁 - */ - private int intervalTime = 10; - - public void setIntervalTime(int intervalTime) - { - this.intervalTime = intervalTime; - } - - @SuppressWarnings("unchecked") - @Override - public boolean isRepeatSubmit(HttpServletRequest request) - { - RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request; - String nowParams = HttpHelper.getBodyString(repeatedlyRequest); - - // body鍙傛暟涓虹┖锛岃幏鍙朠arameter鐨勬暟鎹 - if (StringUtils.isEmpty(nowParams)) - { - nowParams = JSONObject.toJSONString(request.getParameterMap()); - } - Map nowDataMap = new HashMap(); - nowDataMap.put(REPEAT_PARAMS, nowParams); - nowDataMap.put(REPEAT_TIME, System.currentTimeMillis()); - - // 璇锋眰鍦板潃锛堜綔涓哄瓨鏀綾ache鐨刱ey鍊硷級 - String url = request.getRequestURI(); - - Object sessionObj = redisCache.getCacheObject(CACHE_REPEAT_KEY); - if (sessionObj != null) - { - Map sessionMap = (Map) sessionObj; - if (sessionMap.containsKey(url)) - { - Map preDataMap = (Map) sessionMap.get(url); - if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap)) - { - return true; - } - } - } - Map cacheMap = new HashMap(); - cacheMap.put(url, nowDataMap); - redisCache.setCacheObject(CACHE_REPEAT_KEY, cacheMap, intervalTime, TimeUnit.SECONDS); - return false; - } - - /** - * 鍒ゆ柇鍙傛暟鏄惁鐩稿悓 - */ - private boolean compareParams(Map nowMap, Map preMap) - { - String nowParams = (String) nowMap.get(REPEAT_PARAMS); - String preParams = (String) preMap.get(REPEAT_PARAMS); - return nowParams.equals(preParams); - } - - /** - * 鍒ゆ柇涓ゆ闂撮殧鏃堕棿 - */ - private boolean compareTime(Map nowMap, Map preMap) - { - long time1 = (Long) nowMap.get(REPEAT_TIME); - long time2 = (Long) preMap.get(REPEAT_TIME); - if ((time1 - time2) < (this.intervalTime * 1000)) - { - return true; - } - return false; - } -} +package com.ruoyi.framework.interceptor.impl; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; +import javax.servlet.http.HttpServletRequest; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import com.alibaba.fastjson.JSONObject; +import com.ruoyi.common.core.redis.RedisCache; +import com.ruoyi.common.filter.RepeatedlyRequestWrapper; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.http.HttpHelper; +import com.ruoyi.framework.interceptor.RepeatSubmitInterceptor; + +/** + * 鍒ゆ柇璇锋眰url鍜屾暟鎹槸鍚﹀拰涓婁竴娆$浉鍚岋紝 + * 濡傛灉鍜屼笂娆$浉鍚岋紝鍒欐槸閲嶅鎻愪氦琛ㄥ崟銆 鏈夋晥鏃堕棿涓10绉掑唴銆 + * + * @author ruoyi + */ +@Component +public class SameUrlDataInterceptor extends RepeatSubmitInterceptor +{ + public final String REPEAT_PARAMS = "repeatParams"; + + public final String REPEAT_TIME = "repeatTime"; + + public final String CACHE_REPEAT_KEY = "repeatData"; + + @Autowired + private RedisCache redisCache; + + /** + * 闂撮殧鏃堕棿锛屽崟浣:绉 榛樿10绉 + * + * 涓ゆ鐩稿悓鍙傛暟鐨勮姹傦紝濡傛灉闂撮殧鏃堕棿澶т簬璇ュ弬鏁帮紝绯荤粺涓嶄細璁ゅ畾涓洪噸澶嶆彁浜ょ殑鏁版嵁 + */ + private int intervalTime = 10; + + public void setIntervalTime(int intervalTime) + { + this.intervalTime = intervalTime; + } + + @SuppressWarnings("unchecked") + @Override + public boolean isRepeatSubmit(HttpServletRequest request) + { + RepeatedlyRequestWrapper repeatedlyRequest = (RepeatedlyRequestWrapper) request; + String nowParams = HttpHelper.getBodyString(repeatedlyRequest); + + // body鍙傛暟涓虹┖锛岃幏鍙朠arameter鐨勬暟鎹 + if (StringUtils.isEmpty(nowParams)) + { + nowParams = JSONObject.toJSONString(request.getParameterMap()); + } + Map nowDataMap = new HashMap(); + nowDataMap.put(REPEAT_PARAMS, nowParams); + nowDataMap.put(REPEAT_TIME, System.currentTimeMillis()); + + // 璇锋眰鍦板潃锛堜綔涓哄瓨鏀綾ache鐨刱ey鍊硷級 + String url = request.getRequestURI(); + + Object sessionObj = redisCache.getCacheObject(CACHE_REPEAT_KEY); + if (sessionObj != null) + { + Map sessionMap = (Map) sessionObj; + if (sessionMap.containsKey(url)) + { + Map preDataMap = (Map) sessionMap.get(url); + if (compareParams(nowDataMap, preDataMap) && compareTime(nowDataMap, preDataMap)) + { + return true; + } + } + } + Map cacheMap = new HashMap(); + cacheMap.put(url, nowDataMap); + redisCache.setCacheObject(CACHE_REPEAT_KEY, cacheMap, intervalTime, TimeUnit.SECONDS); + return false; + } + + /** + * 鍒ゆ柇鍙傛暟鏄惁鐩稿悓 + */ + private boolean compareParams(Map nowMap, Map preMap) + { + String nowParams = (String) nowMap.get(REPEAT_PARAMS); + String preParams = (String) preMap.get(REPEAT_PARAMS); + return nowParams.equals(preParams); + } + + /** + * 鍒ゆ柇涓ゆ闂撮殧鏃堕棿 + */ + private boolean compareTime(Map nowMap, Map preMap) + { + long time1 = (Long) nowMap.get(REPEAT_TIME); + long time2 = (Long) preMap.get(REPEAT_TIME); + if ((time1 - time2) < (this.intervalTime * 1000)) + { + return true; + } + return false; + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/framework/manager/AsyncManager.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/manager/AsyncManager.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/manager/AsyncManager.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/manager/ShutdownManager.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java index 0be7a3073..3d6cef9f0 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/manager/factory/AsyncFactory.java @@ -9,10 +9,10 @@ import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.ip.AddressUtils; import com.ruoyi.common.utils.ip.IpUtils; import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.project.monitor.domain.SysLogininfor; -import com.ruoyi.project.monitor.domain.SysOperLog; -import com.ruoyi.project.monitor.service.ISysLogininforService; -import com.ruoyi.project.monitor.service.ISysOperLogService; +import com.ruoyi.system.domain.SysLogininfor; +import com.ruoyi.system.domain.SysOperLog; +import com.ruoyi.system.service.ISysLogininforService; +import com.ruoyi.system.service.ISysOperLogService; import eu.bitwalker.useragentutils.UserAgent; /** diff --git a/ruoyi/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java index ede50befd..75fd00d16 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/filter/JwtAuthenticationTokenFilter.java @@ -11,10 +11,10 @@ import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.web.authentication.WebAuthenticationDetailsSource; import org.springframework.stereotype.Component; import org.springframework.web.filter.OncePerRequestFilter; +import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.security.LoginUser; -import com.ruoyi.framework.security.service.TokenService; +import com.ruoyi.framework.web.service.TokenService; /** * token杩囨护鍣 楠岃瘉token鏈夋晥鎬 diff --git a/ruoyi/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java index 995b1f36a..bf9965d31 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/AuthenticationEntryPointImpl.java @@ -9,9 +9,9 @@ import org.springframework.security.web.AuthenticationEntryPoint; import org.springframework.stereotype.Component; import com.alibaba.fastjson.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 com.ruoyi.framework.web.domain.AjaxResult; /** * 璁よ瘉澶辫触澶勭悊绫 杩斿洖鏈巿鏉 diff --git a/ruoyi/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java index c2cc60baa..1d5b1f9c6 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/security/handle/LogoutSuccessHandlerImpl.java @@ -11,13 +11,13 @@ import org.springframework.security.web.authentication.logout.LogoutSuccessHandl import com.alibaba.fastjson.JSON; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.framework.manager.AsyncManager; import com.ruoyi.framework.manager.factory.AsyncFactory; -import com.ruoyi.framework.security.LoginUser; -import com.ruoyi.framework.security.service.TokenService; -import com.ruoyi.framework.web.domain.AjaxResult; +import com.ruoyi.framework.web.service.TokenService; /** * 鑷畾涔夐鍑哄鐞嗙被 杩斿洖鎴愬姛 diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/Server.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/web/domain/Server.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/Server.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Cpu.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Jvm.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Mem.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/Sys.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java similarity index 100% rename from ruoyi/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/web/domain/server/SysFile.java diff --git a/ruoyi/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java similarity index 95% rename from ruoyi/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java index 12b4358df..300fe9d29 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/exception/GlobalExceptionHandler.java @@ -11,11 +11,11 @@ import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.bind.annotation.RestControllerAdvice; import org.springframework.web.servlet.NoHandlerFoundException; import com.ruoyi.common.constant.HttpStatus; +import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.exception.BaseException; import com.ruoyi.common.exception.CustomException; import com.ruoyi.common.exception.DemoModeException; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.web.domain.AjaxResult; /** * 鍏ㄥ眬寮傚父澶勭悊鍣 diff --git a/ruoyi/src/main/java/com/ruoyi/framework/security/service/PermissionService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/framework/security/service/PermissionService.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java index c0b40a67d..2b7ad7ebb 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/security/service/PermissionService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/PermissionService.java @@ -1,13 +1,13 @@ -package com.ruoyi.framework.security.service; +package com.ruoyi.framework.web.service; import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.security.LoginUser; -import com.ruoyi.project.system.domain.SysRole; /** * RuoYi棣栧垱 鑷畾涔夋潈闄愬疄鐜帮紝ss鍙栬嚜SpringSecurity棣栧瓧姣 diff --git a/ruoyi/src/main/java/com/ruoyi/framework/security/service/SysLoginService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/framework/security/service/SysLoginService.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java index 67b6b4949..020831036 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/security/service/SysLoginService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysLoginService.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.security.service; +package com.ruoyi.framework.web.service; import javax.annotation.Resource; import org.springframework.beans.factory.annotation.Autowired; @@ -8,6 +8,8 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio import org.springframework.security.core.Authentication; import org.springframework.stereotype.Component; import com.ruoyi.common.constant.Constants; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.exception.CustomException; import com.ruoyi.common.exception.user.CaptchaException; import com.ruoyi.common.exception.user.CaptchaExpireException; @@ -15,8 +17,6 @@ import com.ruoyi.common.exception.user.UserPasswordNotMatchException; import com.ruoyi.common.utils.MessageUtils; import com.ruoyi.framework.manager.AsyncManager; import com.ruoyi.framework.manager.factory.AsyncFactory; -import com.ruoyi.framework.redis.RedisCache; -import com.ruoyi.framework.security.LoginUser; /** * 鐧诲綍鏍¢獙鏂规硶 diff --git a/ruoyi/src/main/java/com/ruoyi/framework/security/service/SysPermissionService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPermissionService.java similarity index 83% rename from ruoyi/src/main/java/com/ruoyi/framework/security/service/SysPermissionService.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPermissionService.java index 021e9a5b6..19c4a5158 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/security/service/SysPermissionService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/SysPermissionService.java @@ -1,12 +1,12 @@ -package com.ruoyi.framework.security.service; +package com.ruoyi.framework.web.service; import java.util.HashSet; import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; -import com.ruoyi.project.system.domain.SysUser; -import com.ruoyi.project.system.service.ISysMenuService; -import com.ruoyi.project.system.service.ISysRoleService; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.system.service.ISysMenuService; +import com.ruoyi.system.service.ISysRoleService; /** * 鐢ㄦ埛鏉冮檺澶勭悊 diff --git a/ruoyi/src/main/java/com/ruoyi/framework/security/service/TokenService.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/framework/security/service/TokenService.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java index 7637ed88d..66885afdc 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/security/service/TokenService.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/TokenService.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.security.service; +package com.ruoyi.framework.web.service; import java.util.HashMap; import java.util.Map; @@ -8,13 +8,13 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import com.ruoyi.common.constant.Constants; -import com.ruoyi.common.utils.IdUtils; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.utils.ServletUtils; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.ip.AddressUtils; import com.ruoyi.common.utils.ip.IpUtils; -import com.ruoyi.framework.redis.RedisCache; -import com.ruoyi.framework.security.LoginUser; +import com.ruoyi.common.utils.uuid.IdUtils; import eu.bitwalker.useragentutils.UserAgent; import io.jsonwebtoken.Claims; import io.jsonwebtoken.Jwts; diff --git a/ruoyi/src/main/java/com/ruoyi/framework/security/service/UserDetailsServiceImpl.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java similarity index 88% rename from ruoyi/src/main/java/com/ruoyi/framework/security/service/UserDetailsServiceImpl.java rename to ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java index 2a8c69272..a78f2c753 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/security/service/UserDetailsServiceImpl.java +++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/web/service/UserDetailsServiceImpl.java @@ -1,4 +1,4 @@ -package com.ruoyi.framework.security.service; +package com.ruoyi.framework.web.service; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -7,12 +7,12 @@ import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; import org.springframework.stereotype.Service; +import com.ruoyi.common.core.domain.entity.SysUser; +import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.enums.UserStatus; import com.ruoyi.common.exception.BaseException; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.security.LoginUser; -import com.ruoyi.project.system.domain.SysUser; -import com.ruoyi.project.system.service.ISysUserService; +import com.ruoyi.system.service.ISysUserService; /** * 鐢ㄦ埛楠岃瘉澶勭悊 diff --git a/ruoyi-generator/pom.xml b/ruoyi-generator/pom.xml new file mode 100644 index 000000000..5929f4dd8 --- /dev/null +++ b/ruoyi-generator/pom.xml @@ -0,0 +1,34 @@ + + + + ruoyi + com.ruoyi + 3.0.0 + + 4.0.0 + + ruoyi-generator + + + generator浠g爜鐢熸垚 + + + + + + + org.apache.velocity + velocity + + + + + com.ruoyi + ruoyi-common + + + + + \ No newline at end of file diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/GenConfig.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java similarity index 73% rename from ruoyi/src/main/java/com/ruoyi/framework/config/GenConfig.java rename to ruoyi-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java index a74e2c38e..1b144deb9 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/config/GenConfig.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/config/GenConfig.java @@ -1,6 +1,8 @@ -package com.ruoyi.framework.config; +package com.ruoyi.generator.config; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.PropertySource; import org.springframework.stereotype.Component; /** @@ -10,6 +12,7 @@ import org.springframework.stereotype.Component; */ @Component @ConfigurationProperties(prefix = "gen") +@PropertySource(value = { "classpath:generator.yml" }) public class GenConfig { /** 浣滆 */ @@ -18,7 +21,7 @@ public class GenConfig /** 鐢熸垚鍖呰矾寰 */ public static String packageName; - /** 鑷姩鍘婚櫎琛ㄥ墠缂锛岄粯璁ゆ槸true */ + /** 鑷姩鍘婚櫎琛ㄥ墠缂锛岄粯璁ゆ槸false */ public static boolean autoRemovePre; /** 琛ㄥ墠缂(绫诲悕涓嶄細鍖呭惈琛ㄥ墠缂) */ @@ -29,6 +32,7 @@ public class GenConfig return author; } + @Value("${author}") public void setAuthor(String author) { GenConfig.author = author; @@ -39,6 +43,7 @@ public class GenConfig return packageName; } + @Value("${packageName}") public void setPackageName(String packageName) { GenConfig.packageName = packageName; @@ -49,6 +54,7 @@ public class GenConfig return autoRemovePre; } + @Value("${autoRemovePre}") public void setAutoRemovePre(boolean autoRemovePre) { GenConfig.autoRemovePre = autoRemovePre; @@ -59,6 +65,7 @@ public class GenConfig return tablePrefix; } + @Value("${tablePrefix}") public void setTablePrefix(String tablePrefix) { GenConfig.tablePrefix = tablePrefix; diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java similarity index 88% rename from ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java rename to ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java index 05f9414e9..816ce1422 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/controller/GenController.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/controller/GenController.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.tool.gen.controller; +package com.ruoyi.generator.controller; import java.io.IOException; import java.util.HashMap; @@ -17,16 +17,16 @@ import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.core.text.Convert; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.framework.web.page.TableDataInfo; -import com.ruoyi.project.tool.gen.domain.GenTable; -import com.ruoyi.project.tool.gen.domain.GenTableColumn; -import com.ruoyi.project.tool.gen.service.IGenTableColumnService; -import com.ruoyi.project.tool.gen.service.IGenTableService; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.generator.domain.GenTable; +import com.ruoyi.generator.domain.GenTableColumn; +import com.ruoyi.generator.service.IGenTableColumnService; +import com.ruoyi.generator.service.IGenTableService; /** * 浠g爜鐢熸垚 鎿嶄綔澶勭悊 @@ -183,4 +183,4 @@ public class GenController extends BaseController response.setContentType("application/octet-stream; charset=UTF-8"); IOUtils.write(data, response.getOutputStream()); } -} \ No newline at end of file +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTable.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTable.java rename to ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java index 039af5eb2..5123165e3 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTable.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTable.java @@ -1,12 +1,12 @@ -package com.ruoyi.project.tool.gen.domain; +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 com.ruoyi.framework.web.domain.BaseEntity; /** * 涓氬姟琛 gen_table @@ -268,4 +268,4 @@ public class GenTable extends BaseEntity } return StringUtils.equalsAnyIgnoreCase(javaField, GenConstants.BASE_ENTITY); } -} \ No newline at end of file +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTableColumn.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java similarity index 94% rename from ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTableColumn.java rename to ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java index 303575f55..bee9ae12b 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/domain/GenTableColumn.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/domain/GenTableColumn.java @@ -1,8 +1,8 @@ -package com.ruoyi.project.tool.gen.domain; +package com.ruoyi.generator.domain; import javax.validation.constraints.NotBlank; +import com.ruoyi.common.core.domain.BaseEntity; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.web.domain.BaseEntity; /** * 浠g爜鐢熸垚涓氬姟瀛楁琛 gen_table_column @@ -365,4 +365,4 @@ public class GenTableColumn extends BaseEntity return this.columnComment; } } -} \ No newline at end of file +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableColumnMapper.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableColumnMapper.java similarity index 87% rename from ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableColumnMapper.java rename to ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableColumnMapper.java index dfd8ddd09..1366453c8 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableColumnMapper.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableColumnMapper.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.tool.gen.mapper; +package com.ruoyi.generator.mapper; import java.util.List; -import com.ruoyi.project.tool.gen.domain.GenTableColumn; +import com.ruoyi.generator.domain.GenTableColumn; /** * 涓氬姟瀛楁 鏁版嵁灞 @@ -49,4 +49,4 @@ public interface GenTableColumnMapper * @return 缁撴灉 */ public int deleteGenTableColumnByIds(Long[] ids); -} \ No newline at end of file +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableMapper.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableMapper.java rename to ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java index eae10e485..4288d889b 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/mapper/GenTableMapper.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/mapper/GenTableMapper.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.tool.gen.mapper; +package com.ruoyi.generator.mapper; import java.util.List; -import com.ruoyi.project.tool.gen.domain.GenTable; +import com.ruoyi.generator.domain.GenTable; /** * 涓氬姟 鏁版嵁灞 @@ -73,4 +73,4 @@ public interface GenTableMapper * @return 缁撴灉 */ public int deleteGenTableByIds(Long[] ids); -} \ No newline at end of file +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableColumnServiceImpl.java similarity index 86% rename from ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java rename to ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableColumnServiceImpl.java index 61ae55e3a..3a2d66a59 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableColumnServiceImpl.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableColumnServiceImpl.java @@ -1,11 +1,11 @@ -package com.ruoyi.project.tool.gen.service; +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; -import com.ruoyi.project.tool.gen.domain.GenTableColumn; -import com.ruoyi.project.tool.gen.mapper.GenTableColumnMapper; +import com.ruoyi.generator.domain.GenTableColumn; +import com.ruoyi.generator.mapper.GenTableColumnMapper; /** * 涓氬姟瀛楁 鏈嶅姟灞傚疄鐜 @@ -65,4 +65,4 @@ public class GenTableColumnServiceImpl implements IGenTableColumnService { return genTableColumnMapper.deleteGenTableColumnByIds(Convert.toLongArray(ids)); } -} \ No newline at end of file +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableServiceImpl.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableServiceImpl.java rename to ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java index b10c54946..955960f54 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/GenTableServiceImpl.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/GenTableServiceImpl.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.tool.gen.service; +package com.ruoyi.generator.service; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -24,13 +24,13 @@ import com.ruoyi.common.constant.GenConstants; import com.ruoyi.common.exception.CustomException; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.project.tool.gen.domain.GenTable; -import com.ruoyi.project.tool.gen.domain.GenTableColumn; -import com.ruoyi.project.tool.gen.mapper.GenTableColumnMapper; -import com.ruoyi.project.tool.gen.mapper.GenTableMapper; -import com.ruoyi.project.tool.gen.util.GenUtils; -import com.ruoyi.project.tool.gen.util.VelocityInitializer; -import com.ruoyi.project.tool.gen.util.VelocityUtils; +import com.ruoyi.generator.domain.GenTable; +import com.ruoyi.generator.domain.GenTableColumn; +import com.ruoyi.generator.mapper.GenTableColumnMapper; +import com.ruoyi.generator.mapper.GenTableMapper; +import com.ruoyi.generator.util.GenUtils; +import com.ruoyi.generator.util.VelocityInitializer; +import com.ruoyi.generator.util.VelocityUtils; /** * 涓氬姟 鏈嶅姟灞傚疄鐜 @@ -342,4 +342,4 @@ public class GenTableServiceImpl implements IGenTableService genTable.setTreeName(treeName); } } -} \ No newline at end of file +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableColumnService.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableColumnService.java similarity index 85% rename from ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableColumnService.java rename to ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableColumnService.java index a2c7fc288..2130d0431 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableColumnService.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableColumnService.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.tool.gen.service; +package com.ruoyi.generator.service; import java.util.List; -import com.ruoyi.project.tool.gen.domain.GenTableColumn; +import com.ruoyi.generator.domain.GenTableColumn; /** * 涓氬姟瀛楁 鏈嶅姟灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableService.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java similarity index 90% rename from ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableService.java rename to ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java index 73093fe5e..2bff5976c 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/service/IGenTableService.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/service/IGenTableService.java @@ -1,8 +1,8 @@ -package com.ruoyi.project.tool.gen.service; +package com.ruoyi.generator.service; import java.util.List; import java.util.Map; -import com.ruoyi.project.tool.gen.domain.GenTable; +import com.ruoyi.generator.domain.GenTable; /** * 涓氬姟 鏈嶅姟灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/GenUtils.java similarity index 94% rename from ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java rename to ruoyi-generator/src/main/java/com/ruoyi/generator/util/GenUtils.java index 29a840dd6..e141dffa7 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/GenUtils.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/GenUtils.java @@ -1,12 +1,12 @@ -package com.ruoyi.project.tool.gen.util; +package com.ruoyi.generator.util; import java.util.Arrays; import org.apache.commons.lang3.RegExUtils; import com.ruoyi.common.constant.GenConstants; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.config.GenConfig; -import com.ruoyi.project.tool.gen.domain.GenTable; -import com.ruoyi.project.tool.gen.domain.GenTableColumn; +import com.ruoyi.generator.config.GenConfig; +import com.ruoyi.generator.domain.GenTable; +import com.ruoyi.generator.domain.GenTableColumn; /** * 浠g爜鐢熸垚鍣 宸ュ叿绫 @@ -239,4 +239,4 @@ public class GenUtils return 0; } } -} \ No newline at end of file +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityInitializer.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityInitializer.java rename to ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java index 7f932fc3b..8f9ee07b8 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityInitializer.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityInitializer.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.tool.gen.util; +package com.ruoyi.generator.util; import java.util.Properties; import org.apache.velocity.app.Velocity; diff --git a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java similarity index 95% rename from ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java rename to ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java index f3e38a87f..9ec14c33c 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/tool/gen/util/VelocityUtils.java +++ b/ruoyi-generator/src/main/java/com/ruoyi/generator/util/VelocityUtils.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.tool.gen.util; +package com.ruoyi.generator.util; import java.util.ArrayList; import java.util.HashSet; @@ -8,16 +8,21 @@ import com.alibaba.fastjson.JSONObject; import com.ruoyi.common.constant.GenConstants; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.project.tool.gen.domain.GenTable; -import com.ruoyi.project.tool.gen.domain.GenTableColumn; +import com.ruoyi.generator.domain.GenTable; +import com.ruoyi.generator.domain.GenTableColumn; +/** + * 浠g爜鐢熸垚妯℃澘澶勭悊 + * + * @author ruoyi + */ public class VelocityUtils { /** 椤圭洰绌洪棿璺緞 */ private static final String PROJECT_PATH = "main/java"; /** mybatis绌洪棿璺緞 */ - private static final String MYBATIS_PATH = "main/resources/mybatis"; + private static final String MYBATIS_PATH = "main/resources/mapper"; /** * 璁剧疆妯℃澘鍙橀噺淇℃伅 @@ -290,4 +295,4 @@ public class VelocityUtils } return num; } -} \ No newline at end of file +} diff --git a/ruoyi-generator/src/main/resources/generator.yml b/ruoyi-generator/src/main/resources/generator.yml new file mode 100644 index 000000000..4544c8c24 --- /dev/null +++ b/ruoyi-generator/src/main/resources/generator.yml @@ -0,0 +1,10 @@ +# 浠g爜鐢熸垚 +gen: + # 浣滆 + author: ruoyi + # 榛樿鐢熸垚鍖呰矾寰 system 闇鏀规垚鑷繁鐨勬ā鍧楀悕绉 濡 system monitor tool + packageName: com.ruoyi.system + # 鑷姩鍘婚櫎琛ㄥ墠缂锛岄粯璁ゆ槸false + autoRemovePre: false + # 琛ㄥ墠缂锛堢敓鎴愮被鍚嶄笉浼氬寘鍚〃鍓嶇紑锛屽涓敤閫楀彿鍒嗛殧锛 + tablePrefix: sys_ \ No newline at end of file diff --git a/ruoyi/src/main/resources/mybatis/tool/GenTableColumnMapper.xml b/ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml similarity index 96% rename from ruoyi/src/main/resources/mybatis/tool/GenTableColumnMapper.xml rename to ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml index c936fe07f..513275653 100644 --- a/ruoyi/src/main/resources/mybatis/tool/GenTableColumnMapper.xml +++ b/ruoyi-generator/src/main/resources/mapper/generator/GenTableColumnMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/mybatis/tool/GenTableMapper.xml b/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml similarity index 97% rename from ruoyi/src/main/resources/mybatis/tool/GenTableMapper.xml rename to ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml index 64a1f5e59..503bb15c9 100644 --- a/ruoyi/src/main/resources/mybatis/tool/GenTableMapper.xml +++ b/ruoyi-generator/src/main/resources/mapper/generator/GenTableMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/vm/java/controller.java.vm b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm similarity index 90% rename from ruoyi/src/main/resources/vm/java/controller.java.vm rename to ruoyi-generator/src/main/resources/vm/java/controller.java.vm index c45ba6699..6c349df1e 100644 --- a/ruoyi/src/main/resources/vm/java/controller.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/controller.java.vm @@ -11,15 +11,15 @@ import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.enums.BusinessType; import ${packageName}.domain.${ClassName}; import ${packageName}.service.I${ClassName}Service; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; import com.ruoyi.common.utils.poi.ExcelUtil; #if($table.crud) -import com.ruoyi.framework.web.page.TableDataInfo; +import com.ruoyi.common.core.page.TableDataInfo; #elseif($table.tree) #end diff --git a/ruoyi/src/main/resources/vm/java/domain.java.vm b/ruoyi-generator/src/main/resources/vm/java/domain.java.vm similarity index 90% rename from ruoyi/src/main/resources/vm/java/domain.java.vm rename to ruoyi-generator/src/main/resources/vm/java/domain.java.vm index c943c1b21..9dd824786 100644 --- a/ruoyi/src/main/resources/vm/java/domain.java.vm +++ b/ruoyi-generator/src/main/resources/vm/java/domain.java.vm @@ -5,11 +5,11 @@ import ${import}; #end import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.framework.aspectj.lang.annotation.Excel; +import com.ruoyi.common.annotation.Excel; #if($table.crud) -import com.ruoyi.framework.web.domain.BaseEntity; +import com.ruoyi.common.core.domain.BaseEntity; #elseif($table.tree) -import com.ruoyi.framework.web.domain.TreeEntity; +import com.ruoyi.common.core.domain.TreeEntity; #end /** diff --git a/ruoyi/src/main/resources/vm/java/mapper.java.vm b/ruoyi-generator/src/main/resources/vm/java/mapper.java.vm similarity index 100% rename from ruoyi/src/main/resources/vm/java/mapper.java.vm rename to ruoyi-generator/src/main/resources/vm/java/mapper.java.vm diff --git a/ruoyi/src/main/resources/vm/java/service.java.vm b/ruoyi-generator/src/main/resources/vm/java/service.java.vm similarity index 100% rename from ruoyi/src/main/resources/vm/java/service.java.vm rename to ruoyi-generator/src/main/resources/vm/java/service.java.vm diff --git a/ruoyi/src/main/resources/vm/java/serviceImpl.java.vm b/ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm similarity index 100% rename from ruoyi/src/main/resources/vm/java/serviceImpl.java.vm rename to ruoyi-generator/src/main/resources/vm/java/serviceImpl.java.vm diff --git a/ruoyi/src/main/resources/vm/js/api.js.vm b/ruoyi-generator/src/main/resources/vm/js/api.js.vm similarity index 100% rename from ruoyi/src/main/resources/vm/js/api.js.vm rename to ruoyi-generator/src/main/resources/vm/js/api.js.vm diff --git a/ruoyi/src/main/resources/vm/sql/sql.vm b/ruoyi-generator/src/main/resources/vm/sql/sql.vm similarity index 100% rename from ruoyi/src/main/resources/vm/sql/sql.vm rename to ruoyi-generator/src/main/resources/vm/sql/sql.vm diff --git a/ruoyi/src/main/resources/vm/vue/index-tree.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm similarity index 100% rename from ruoyi/src/main/resources/vm/vue/index-tree.vue.vm rename to ruoyi-generator/src/main/resources/vm/vue/index-tree.vue.vm diff --git a/ruoyi/src/main/resources/vm/vue/index.vue.vm b/ruoyi-generator/src/main/resources/vm/vue/index.vue.vm similarity index 100% rename from ruoyi/src/main/resources/vm/vue/index.vue.vm rename to ruoyi-generator/src/main/resources/vm/vue/index.vue.vm diff --git a/ruoyi/src/main/resources/vm/xml/mapper.xml.vm b/ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm similarity index 100% rename from ruoyi/src/main/resources/vm/xml/mapper.xml.vm rename to ruoyi-generator/src/main/resources/vm/xml/mapper.xml.vm diff --git a/ruoyi-quartz/pom.xml b/ruoyi-quartz/pom.xml new file mode 100644 index 000000000..b62c7f7f0 --- /dev/null +++ b/ruoyi-quartz/pom.xml @@ -0,0 +1,40 @@ + + + + ruoyi + com.ruoyi + 3.0.0 + + 4.0.0 + + ruoyi-quartz + + + quartz瀹氭椂浠诲姟 + + + + + + + org.quartz-scheduler + quartz + + + com.mchange + c3p0 + + + + + + + com.ruoyi + ruoyi-common + + + + + \ No newline at end of file diff --git a/ruoyi/src/main/java/com/ruoyi/framework/config/ScheduleConfig.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java similarity index 96% rename from ruoyi/src/main/java/com/ruoyi/framework/config/ScheduleConfig.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java index a607e85f7..e466ed057 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/config/ScheduleConfig.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/config/ScheduleConfig.java @@ -1,57 +1,57 @@ -package com.ruoyi.framework.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.scheduling.quartz.SchedulerFactoryBean; -import javax.sql.DataSource; -import java.util.Properties; - -/** - * 瀹氭椂浠诲姟閰嶇疆 - * - * @author ruoyi - */ -@Configuration -public class ScheduleConfig -{ - @Bean - public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) - { - SchedulerFactoryBean factory = new SchedulerFactoryBean(); - factory.setDataSource(dataSource); - - // quartz鍙傛暟 - Properties prop = new Properties(); - prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler"); - prop.put("org.quartz.scheduler.instanceId", "AUTO"); - // 绾跨▼姹犻厤缃 - prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool"); - prop.put("org.quartz.threadPool.threadCount", "20"); - prop.put("org.quartz.threadPool.threadPriority", "5"); - // JobStore閰嶇疆 - prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX"); - // 闆嗙兢閰嶇疆 - prop.put("org.quartz.jobStore.isClustered", "true"); - prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); - prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1"); - prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true"); - - // sqlserver 鍚敤 - // prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?"); - prop.put("org.quartz.jobStore.misfireThreshold", "12000"); - prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); - factory.setQuartzProperties(prop); - - factory.setSchedulerName("RuoyiScheduler"); - // 寤舵椂鍚姩 - factory.setStartupDelay(1); - factory.setApplicationContextSchedulerContextKey("applicationContextKey"); - // 鍙夛紝QuartzScheduler - // 鍚姩鏃舵洿鏂板繁瀛樺湪鐨凧ob锛岃繖鏍峰氨涓嶇敤姣忔淇敼targetObject鍚庡垹闄rtz_job_details琛ㄥ搴旇褰曚簡 - factory.setOverwriteExistingJobs(true); - // 璁剧疆鑷姩鍚姩锛岄粯璁や负true - factory.setAutoStartup(true); - - return factory; - } -} +package com.ruoyi.quartz.config; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.scheduling.quartz.SchedulerFactoryBean; +import javax.sql.DataSource; +import java.util.Properties; + +/** + * 瀹氭椂浠诲姟閰嶇疆 + * + * @author ruoyi + */ +@Configuration +public class ScheduleConfig +{ + @Bean + public SchedulerFactoryBean schedulerFactoryBean(DataSource dataSource) + { + SchedulerFactoryBean factory = new SchedulerFactoryBean(); + factory.setDataSource(dataSource); + + // quartz鍙傛暟 + Properties prop = new Properties(); + prop.put("org.quartz.scheduler.instanceName", "RuoyiScheduler"); + prop.put("org.quartz.scheduler.instanceId", "AUTO"); + // 绾跨▼姹犻厤缃 + prop.put("org.quartz.threadPool.class", "org.quartz.simpl.SimpleThreadPool"); + prop.put("org.quartz.threadPool.threadCount", "20"); + prop.put("org.quartz.threadPool.threadPriority", "5"); + // JobStore閰嶇疆 + prop.put("org.quartz.jobStore.class", "org.quartz.impl.jdbcjobstore.JobStoreTX"); + // 闆嗙兢閰嶇疆 + prop.put("org.quartz.jobStore.isClustered", "true"); + prop.put("org.quartz.jobStore.clusterCheckinInterval", "15000"); + prop.put("org.quartz.jobStore.maxMisfiresToHandleAtATime", "1"); + prop.put("org.quartz.jobStore.txIsolationLevelSerializable", "true"); + + // sqlserver 鍚敤 + // prop.put("org.quartz.jobStore.selectWithLockSQL", "SELECT * FROM {0}LOCKS UPDLOCK WHERE LOCK_NAME = ?"); + prop.put("org.quartz.jobStore.misfireThreshold", "12000"); + prop.put("org.quartz.jobStore.tablePrefix", "QRTZ_"); + factory.setQuartzProperties(prop); + + factory.setSchedulerName("RuoyiScheduler"); + // 寤舵椂鍚姩 + factory.setStartupDelay(1); + factory.setApplicationContextSchedulerContextKey("applicationContextKey"); + // 鍙夛紝QuartzScheduler + // 鍚姩鏃舵洿鏂板繁瀛樺湪鐨凧ob锛岃繖鏍峰氨涓嶇敤姣忔淇敼targetObject鍚庡垹闄rtz_job_details琛ㄥ搴旇褰曚簡 + factory.setOverwriteExistingJobs(true); + // 璁剧疆鑷姩鍚姩锛岄粯璁や负true + factory.setAutoStartup(true); + + return factory; + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysJobController.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysJobController.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java index 742d281c0..f770a7d8f 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysJobController.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobController.java @@ -1,142 +1,142 @@ -package com.ruoyi.project.monitor.controller; - -import java.util.List; -import org.quartz.SchedulerException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.common.exception.job.TaskException; -import com.ruoyi.common.utils.SecurityUtils; -import com.ruoyi.common.utils.job.CronUtils; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.framework.web.page.TableDataInfo; -import com.ruoyi.project.monitor.domain.SysJob; -import com.ruoyi.project.monitor.service.ISysJobService; - -/** - * 璋冨害浠诲姟淇℃伅鎿嶄綔澶勭悊 - * - * @author ruoyi - */ -@RestController -@RequestMapping("/monitor/job") -public class SysJobController extends BaseController -{ - @Autowired - private ISysJobService jobService; - - /** - * 鏌ヨ瀹氭椂浠诲姟鍒楄〃 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:list')") - @GetMapping("/list") - public TableDataInfo list(SysJob sysJob) - { - startPage(); - List list = jobService.selectJobList(sysJob); - return getDataTable(list); - } - - /** - * 瀵煎嚭瀹氭椂浠诲姟鍒楄〃 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:export')") - @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.EXPORT) - @GetMapping("/export") - public AjaxResult export(SysJob sysJob) - { - List list = jobService.selectJobList(sysJob); - ExcelUtil util = new ExcelUtil(SysJob.class); - return util.exportExcel(list, "瀹氭椂浠诲姟"); - } - - /** - * 鑾峰彇瀹氭椂浠诲姟璇︾粏淇℃伅 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:query')") - @GetMapping(value = "/{jobId}") - public AjaxResult getInfo(@PathVariable("jobId") Long jobId) - { - return AjaxResult.success(jobService.selectJobById(jobId)); - } - - /** - * 鏂板瀹氭椂浠诲姟 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:add')") - @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.INSERT) - @PostMapping - public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException - { - if (!CronUtils.isValid(sysJob.getCronExpression())) - { - return AjaxResult.error("cron琛ㄨ揪寮忎笉姝g‘"); - } - sysJob.setCreateBy(SecurityUtils.getUsername()); - return toAjax(jobService.insertJob(sysJob)); - } - - /** - * 淇敼瀹氭椂浠诲姟 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:edit')") - @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.UPDATE) - @PutMapping - public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException - { - if (!CronUtils.isValid(sysJob.getCronExpression())) - { - return AjaxResult.error("cron琛ㄨ揪寮忎笉姝g‘"); - } - sysJob.setUpdateBy(SecurityUtils.getUsername()); - return toAjax(jobService.updateJob(sysJob)); - } - - /** - * 瀹氭椂浠诲姟鐘舵佷慨鏀 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") - @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.UPDATE) - @PutMapping("/changeStatus") - public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException - { - SysJob newJob = jobService.selectJobById(job.getJobId()); - newJob.setStatus(job.getStatus()); - return toAjax(jobService.changeStatus(newJob)); - } - - /** - * 瀹氭椂浠诲姟绔嬪嵆鎵ц涓娆 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") - @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.UPDATE) - @PutMapping("/run") - public AjaxResult run(@RequestBody SysJob job) throws SchedulerException - { - jobService.run(job); - return AjaxResult.success(); - } - - /** - * 鍒犻櫎瀹氭椂浠诲姟 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:remove')") - @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.DELETE) - @DeleteMapping("/{jobIds}") - public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException - { - jobService.deleteJobByIds(jobIds); - return AjaxResult.success(); - } -} +package com.ruoyi.quartz.controller; + +import java.util.List; +import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.exception.job.TaskException; +import com.ruoyi.common.utils.SecurityUtils; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.quartz.domain.SysJob; +import com.ruoyi.quartz.service.ISysJobService; +import com.ruoyi.quartz.util.CronUtils; + +/** + * 璋冨害浠诲姟淇℃伅鎿嶄綔澶勭悊 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/monitor/job") +public class SysJobController extends BaseController +{ + @Autowired + private ISysJobService jobService; + + /** + * 鏌ヨ瀹氭椂浠诲姟鍒楄〃 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:list')") + @GetMapping("/list") + public TableDataInfo list(SysJob sysJob) + { + startPage(); + List list = jobService.selectJobList(sysJob); + return getDataTable(list); + } + + /** + * 瀵煎嚭瀹氭椂浠诲姟鍒楄〃 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:export')") + @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(SysJob sysJob) + { + List list = jobService.selectJobList(sysJob); + ExcelUtil util = new ExcelUtil(SysJob.class); + return util.exportExcel(list, "瀹氭椂浠诲姟"); + } + + /** + * 鑾峰彇瀹氭椂浠诲姟璇︾粏淇℃伅 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:query')") + @GetMapping(value = "/{jobId}") + public AjaxResult getInfo(@PathVariable("jobId") Long jobId) + { + return AjaxResult.success(jobService.selectJobById(jobId)); + } + + /** + * 鏂板瀹氭椂浠诲姟 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:add')") + @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.INSERT) + @PostMapping + public AjaxResult add(@RequestBody SysJob sysJob) throws SchedulerException, TaskException + { + if (!CronUtils.isValid(sysJob.getCronExpression())) + { + return AjaxResult.error("cron琛ㄨ揪寮忎笉姝g‘"); + } + sysJob.setCreateBy(SecurityUtils.getUsername()); + return toAjax(jobService.insertJob(sysJob)); + } + + /** + * 淇敼瀹氭椂浠诲姟 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:edit')") + @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.UPDATE) + @PutMapping + public AjaxResult edit(@RequestBody SysJob sysJob) throws SchedulerException, TaskException + { + if (!CronUtils.isValid(sysJob.getCronExpression())) + { + return AjaxResult.error("cron琛ㄨ揪寮忎笉姝g‘"); + } + sysJob.setUpdateBy(SecurityUtils.getUsername()); + return toAjax(jobService.updateJob(sysJob)); + } + + /** + * 瀹氭椂浠诲姟鐘舵佷慨鏀 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") + @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.UPDATE) + @PutMapping("/changeStatus") + public AjaxResult changeStatus(@RequestBody SysJob job) throws SchedulerException + { + SysJob newJob = jobService.selectJobById(job.getJobId()); + newJob.setStatus(job.getStatus()); + return toAjax(jobService.changeStatus(newJob)); + } + + /** + * 瀹氭椂浠诲姟绔嬪嵆鎵ц涓娆 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:changeStatus')") + @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.UPDATE) + @PutMapping("/run") + public AjaxResult run(@RequestBody SysJob job) throws SchedulerException + { + jobService.run(job); + return AjaxResult.success(); + } + + /** + * 鍒犻櫎瀹氭椂浠诲姟 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:remove')") + @Log(title = "瀹氭椂浠诲姟", businessType = BusinessType.DELETE) + @DeleteMapping("/{jobIds}") + public AjaxResult remove(@PathVariable Long[] jobIds) throws SchedulerException, TaskException + { + jobService.deleteJobByIds(jobIds); + return AjaxResult.success(); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysJobLogController.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java similarity index 84% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysJobLogController.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java index ba1181649..10a842b6d 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/controller/SysJobLogController.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/controller/SysJobLogController.java @@ -1,90 +1,90 @@ -package com.ruoyi.project.monitor.controller; - -import java.util.List; -import org.springframework.security.access.prepost.PreAuthorize; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; -import com.ruoyi.framework.aspectj.lang.annotation.Log; -import com.ruoyi.framework.aspectj.lang.enums.BusinessType; -import com.ruoyi.project.monitor.domain.SysJobLog; -import com.ruoyi.project.monitor.service.ISysJobLogService; -import com.ruoyi.framework.web.controller.BaseController; -import com.ruoyi.framework.web.domain.AjaxResult; -import com.ruoyi.common.utils.poi.ExcelUtil; -import com.ruoyi.framework.web.page.TableDataInfo; - -/** - * 璋冨害鏃ュ織鎿嶄綔澶勭悊 - * - * @author ruoyi - */ -@RestController -@RequestMapping("/monitor/jobLog") -public class SysJobLogController extends BaseController -{ - @Autowired - private ISysJobLogService jobLogService; - - /** - * 鏌ヨ瀹氭椂浠诲姟璋冨害鏃ュ織鍒楄〃 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:list')") - @GetMapping("/list") - public TableDataInfo list(SysJobLog sysJobLog) - { - startPage(); - List list = jobLogService.selectJobLogList(sysJobLog); - return getDataTable(list); - } - - /** - * 瀵煎嚭瀹氭椂浠诲姟璋冨害鏃ュ織鍒楄〃 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:export')") - @Log(title = "浠诲姟璋冨害鏃ュ織", businessType = BusinessType.EXPORT) - @GetMapping("/export") - public AjaxResult export(SysJobLog sysJobLog) - { - List list = jobLogService.selectJobLogList(sysJobLog); - ExcelUtil util = new ExcelUtil(SysJobLog.class); - return util.exportExcel(list, "璋冨害鏃ュ織"); - } - - /** - * 鏍规嵁璋冨害缂栧彿鑾峰彇璇︾粏淇℃伅 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:query')") - @GetMapping(value = "/{configId}") - public AjaxResult getInfo(@PathVariable Long jobLogId) - { - return AjaxResult.success(jobLogService.selectJobLogById(jobLogId)); - } - - - /** - * 鍒犻櫎瀹氭椂浠诲姟璋冨害鏃ュ織 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:remove')") - @Log(title = "瀹氭椂浠诲姟璋冨害鏃ュ織", businessType = BusinessType.DELETE) - @DeleteMapping("/{jobLogIds}") - public AjaxResult remove(@PathVariable Long[] jobLogIds) - { - return toAjax(jobLogService.deleteJobLogByIds(jobLogIds)); - } - - /** - * 娓呯┖瀹氭椂浠诲姟璋冨害鏃ュ織 - */ - @PreAuthorize("@ss.hasPermi('monitor:job:remove')") - @Log(title = "璋冨害鏃ュ織", businessType = BusinessType.CLEAN) - @DeleteMapping("/clean") - public AjaxResult clean() - { - jobLogService.cleanJobLog(); - return AjaxResult.success(); - } -} +package com.ruoyi.quartz.controller; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; +import com.ruoyi.common.annotation.Log; +import com.ruoyi.common.core.controller.BaseController; +import com.ruoyi.common.core.domain.AjaxResult; +import com.ruoyi.common.core.page.TableDataInfo; +import com.ruoyi.common.enums.BusinessType; +import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.quartz.domain.SysJobLog; +import com.ruoyi.quartz.service.ISysJobLogService; + +/** + * 璋冨害鏃ュ織鎿嶄綔澶勭悊 + * + * @author ruoyi + */ +@RestController +@RequestMapping("/monitor/jobLog") +public class SysJobLogController extends BaseController +{ + @Autowired + private ISysJobLogService jobLogService; + + /** + * 鏌ヨ瀹氭椂浠诲姟璋冨害鏃ュ織鍒楄〃 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:list')") + @GetMapping("/list") + public TableDataInfo list(SysJobLog sysJobLog) + { + startPage(); + List list = jobLogService.selectJobLogList(sysJobLog); + return getDataTable(list); + } + + /** + * 瀵煎嚭瀹氭椂浠诲姟璋冨害鏃ュ織鍒楄〃 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:export')") + @Log(title = "浠诲姟璋冨害鏃ュ織", businessType = BusinessType.EXPORT) + @GetMapping("/export") + public AjaxResult export(SysJobLog sysJobLog) + { + List list = jobLogService.selectJobLogList(sysJobLog); + ExcelUtil util = new ExcelUtil(SysJobLog.class); + return util.exportExcel(list, "璋冨害鏃ュ織"); + } + + /** + * 鏍规嵁璋冨害缂栧彿鑾峰彇璇︾粏淇℃伅 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:query')") + @GetMapping(value = "/{configId}") + public AjaxResult getInfo(@PathVariable Long jobLogId) + { + return AjaxResult.success(jobLogService.selectJobLogById(jobLogId)); + } + + + /** + * 鍒犻櫎瀹氭椂浠诲姟璋冨害鏃ュ織 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:remove')") + @Log(title = "瀹氭椂浠诲姟璋冨害鏃ュ織", businessType = BusinessType.DELETE) + @DeleteMapping("/{jobLogIds}") + public AjaxResult remove(@PathVariable Long[] jobLogIds) + { + return toAjax(jobLogService.deleteJobLogByIds(jobLogIds)); + } + + /** + * 娓呯┖瀹氭椂浠诲姟璋冨害鏃ュ織 + */ + @PreAuthorize("@ss.hasPermi('monitor:job:remove')") + @Log(title = "璋冨害鏃ュ織", businessType = BusinessType.CLEAN) + @DeleteMapping("/clean") + public AjaxResult clean() + { + jobLogService.cleanJobLog(); + return AjaxResult.success(); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysJob.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysJob.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java index 126be47f3..8e0048bec 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysJob.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJob.java @@ -1,172 +1,172 @@ -package com.ruoyi.project.monitor.domain; - -import java.io.Serializable; -import java.util.Date; -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.Size; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.fasterxml.jackson.annotation.JsonFormat; -import com.ruoyi.common.constant.ScheduleConstants; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.job.CronUtils; -import com.ruoyi.framework.aspectj.lang.annotation.Excel; -import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType; -import com.ruoyi.framework.web.domain.BaseEntity; - -/** - * 瀹氭椂浠诲姟璋冨害琛 sys_job - * - * @author ruoyi - */ -public class SysJob extends BaseEntity implements Serializable -{ - private static final long serialVersionUID = 1L; - - /** 浠诲姟ID */ - @Excel(name = "浠诲姟搴忓彿", cellType = ColumnType.NUMERIC) - private Long jobId; - - /** 浠诲姟鍚嶇О */ - @Excel(name = "浠诲姟鍚嶇О") - private String jobName; - - /** 浠诲姟缁勫悕 */ - @Excel(name = "浠诲姟缁勫悕") - private String jobGroup; - - /** 璋冪敤鐩爣瀛楃涓 */ - @Excel(name = "璋冪敤鐩爣瀛楃涓") - private String invokeTarget; - - /** cron鎵ц琛ㄨ揪寮 */ - @Excel(name = "鎵ц琛ㄨ揪寮 ") - private String cronExpression; - - /** cron璁″垝绛栫暐 */ - @Excel(name = "璁″垝绛栫暐 ", readConverterExp = "0=榛樿,1=绔嬪嵆瑙﹀彂鎵ц,2=瑙﹀彂涓娆℃墽琛,3=涓嶈Е鍙戠珛鍗虫墽琛") - private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT; - - /** 鏄惁骞跺彂鎵ц锛0鍏佽 1绂佹锛 */ - @Excel(name = "骞跺彂鎵ц", readConverterExp = "0=鍏佽,1=绂佹") - private String concurrent; - - /** 浠诲姟鐘舵侊紙0姝e父 1鏆傚仠锛 */ - @Excel(name = "浠诲姟鐘舵", readConverterExp = "0=姝e父,1=鏆傚仠") - private String status; - - public Long getJobId() - { - return jobId; - } - - public void setJobId(Long jobId) - { - this.jobId = jobId; - } - - @NotBlank(message = "浠诲姟鍚嶇О涓嶈兘涓虹┖") - @Size(min = 0, max = 64, message = "浠诲姟鍚嶇О涓嶈兘瓒呰繃64涓瓧绗") - public String getJobName() - { - return jobName; - } - - public void setJobName(String jobName) - { - this.jobName = jobName; - } - - public String getJobGroup() - { - return jobGroup; - } - - public void setJobGroup(String jobGroup) - { - this.jobGroup = jobGroup; - } - - @NotBlank(message = "璋冪敤鐩爣瀛楃涓蹭笉鑳戒负绌") - @Size(min = 0, max = 1000, message = "璋冪敤鐩爣瀛楃涓查暱搴︿笉鑳借秴杩500涓瓧绗") - public String getInvokeTarget() - { - return invokeTarget; - } - - public void setInvokeTarget(String invokeTarget) - { - this.invokeTarget = invokeTarget; - } - - @NotBlank(message = "Cron鎵ц琛ㄨ揪寮忎笉鑳戒负绌") - @Size(min = 0, max = 255, message = "Cron鎵ц琛ㄨ揪寮忎笉鑳借秴杩255涓瓧绗") - public String getCronExpression() - { - return cronExpression; - } - - public void setCronExpression(String cronExpression) - { - this.cronExpression = cronExpression; - } - - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") - public Date getNextValidTime() - { - if (StringUtils.isNotEmpty(cronExpression)) - { - return CronUtils.getNextExecution(cronExpression); - } - return null; - } - - public String getMisfirePolicy() - { - return misfirePolicy; - } - - public void setMisfirePolicy(String misfirePolicy) - { - this.misfirePolicy = misfirePolicy; - } - - public String getConcurrent() - { - return concurrent; - } - - public void setConcurrent(String concurrent) - { - this.concurrent = concurrent; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("jobId", getJobId()) - .append("jobName", getJobName()) - .append("jobGroup", getJobGroup()) - .append("cronExpression", getCronExpression()) - .append("nextValidTime", getNextValidTime()) - .append("misfirePolicy", getMisfirePolicy()) - .append("concurrent", getConcurrent()) - .append("status", getStatus()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); - } -} \ No newline at end of file +package com.ruoyi.quartz.domain; + +import java.io.Serializable; +import java.util.Date; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.Size; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.constant.ScheduleConstants; +import com.ruoyi.common.core.domain.BaseEntity; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.quartz.util.CronUtils; + +/** + * 瀹氭椂浠诲姟璋冨害琛 sys_job + * + * @author ruoyi + */ +public class SysJob extends BaseEntity implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** 浠诲姟ID */ + @Excel(name = "浠诲姟搴忓彿", cellType = ColumnType.NUMERIC) + private Long jobId; + + /** 浠诲姟鍚嶇О */ + @Excel(name = "浠诲姟鍚嶇О") + private String jobName; + + /** 浠诲姟缁勫悕 */ + @Excel(name = "浠诲姟缁勫悕") + private String jobGroup; + + /** 璋冪敤鐩爣瀛楃涓 */ + @Excel(name = "璋冪敤鐩爣瀛楃涓") + private String invokeTarget; + + /** cron鎵ц琛ㄨ揪寮 */ + @Excel(name = "鎵ц琛ㄨ揪寮 ") + private String cronExpression; + + /** cron璁″垝绛栫暐 */ + @Excel(name = "璁″垝绛栫暐 ", readConverterExp = "0=榛樿,1=绔嬪嵆瑙﹀彂鎵ц,2=瑙﹀彂涓娆℃墽琛,3=涓嶈Е鍙戠珛鍗虫墽琛") + private String misfirePolicy = ScheduleConstants.MISFIRE_DEFAULT; + + /** 鏄惁骞跺彂鎵ц锛0鍏佽 1绂佹锛 */ + @Excel(name = "骞跺彂鎵ц", readConverterExp = "0=鍏佽,1=绂佹") + private String concurrent; + + /** 浠诲姟鐘舵侊紙0姝e父 1鏆傚仠锛 */ + @Excel(name = "浠诲姟鐘舵", readConverterExp = "0=姝e父,1=鏆傚仠") + private String status; + + public Long getJobId() + { + return jobId; + } + + public void setJobId(Long jobId) + { + this.jobId = jobId; + } + + @NotBlank(message = "浠诲姟鍚嶇О涓嶈兘涓虹┖") + @Size(min = 0, max = 64, message = "浠诲姟鍚嶇О涓嶈兘瓒呰繃64涓瓧绗") + public String getJobName() + { + return jobName; + } + + public void setJobName(String jobName) + { + this.jobName = jobName; + } + + public String getJobGroup() + { + return jobGroup; + } + + public void setJobGroup(String jobGroup) + { + this.jobGroup = jobGroup; + } + + @NotBlank(message = "璋冪敤鐩爣瀛楃涓蹭笉鑳戒负绌") + @Size(min = 0, max = 1000, message = "璋冪敤鐩爣瀛楃涓查暱搴︿笉鑳借秴杩500涓瓧绗") + public String getInvokeTarget() + { + return invokeTarget; + } + + public void setInvokeTarget(String invokeTarget) + { + this.invokeTarget = invokeTarget; + } + + @NotBlank(message = "Cron鎵ц琛ㄨ揪寮忎笉鑳戒负绌") + @Size(min = 0, max = 255, message = "Cron鎵ц琛ㄨ揪寮忎笉鑳借秴杩255涓瓧绗") + public String getCronExpression() + { + return cronExpression; + } + + public void setCronExpression(String cronExpression) + { + this.cronExpression = cronExpression; + } + + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + public Date getNextValidTime() + { + if (StringUtils.isNotEmpty(cronExpression)) + { + return CronUtils.getNextExecution(cronExpression); + } + return null; + } + + public String getMisfirePolicy() + { + return misfirePolicy; + } + + public void setMisfirePolicy(String misfirePolicy) + { + this.misfirePolicy = misfirePolicy; + } + + public String getConcurrent() + { + return concurrent; + } + + public void setConcurrent(String concurrent) + { + this.concurrent = concurrent; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("jobId", getJobId()) + .append("jobName", getJobName()) + .append("jobGroup", getJobGroup()) + .append("cronExpression", getCronExpression()) + .append("nextValidTime", getNextValidTime()) + .append("misfirePolicy", getMisfirePolicy()) + .append("concurrent", getConcurrent()) + .append("status", getStatus()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysJobLog.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysJobLog.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java index c7a3cd229..63c4cd69d 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysJobLog.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/domain/SysJobLog.java @@ -1,155 +1,155 @@ -package com.ruoyi.project.monitor.domain; - -import java.util.Date; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.framework.aspectj.lang.annotation.Excel; -import com.ruoyi.framework.web.domain.BaseEntity; - -/** - * 瀹氭椂浠诲姟璋冨害鏃ュ織琛 sys_job_log - * - * @author ruoyi - */ -public class SysJobLog extends BaseEntity -{ - private static final long serialVersionUID = 1L; - - /** ID */ - @Excel(name = "鏃ュ織搴忓彿") - private Long jobLogId; - - /** 浠诲姟鍚嶇О */ - @Excel(name = "浠诲姟鍚嶇О") - private String jobName; - - /** 浠诲姟缁勫悕 */ - @Excel(name = "浠诲姟缁勫悕") - private String jobGroup; - - /** 璋冪敤鐩爣瀛楃涓 */ - @Excel(name = "璋冪敤鐩爣瀛楃涓") - private String invokeTarget; - - /** 鏃ュ織淇℃伅 */ - @Excel(name = "鏃ュ織淇℃伅") - private String jobMessage; - - /** 鎵ц鐘舵侊紙0姝e父 1澶辫触锛 */ - @Excel(name = "鎵ц鐘舵", readConverterExp = "0=姝e父,1=澶辫触") - private String status; - - /** 寮傚父淇℃伅 */ - @Excel(name = "寮傚父淇℃伅") - private String exceptionInfo; - - /** 寮濮嬫椂闂 */ - private Date startTime; - - /** 鍋滄鏃堕棿 */ - private Date stopTime; - - public Long getJobLogId() - { - return jobLogId; - } - - public void setJobLogId(Long jobLogId) - { - this.jobLogId = jobLogId; - } - - public String getJobName() - { - return jobName; - } - - public void setJobName(String jobName) - { - this.jobName = jobName; - } - - public String getJobGroup() - { - return jobGroup; - } - - public void setJobGroup(String jobGroup) - { - this.jobGroup = jobGroup; - } - - public String getInvokeTarget() - { - return invokeTarget; - } - - public void setInvokeTarget(String invokeTarget) - { - this.invokeTarget = invokeTarget; - } - - public String getJobMessage() - { - return jobMessage; - } - - public void setJobMessage(String jobMessage) - { - this.jobMessage = jobMessage; - } - - public String getStatus() - { - return status; - } - - public void setStatus(String status) - { - this.status = status; - } - - public String getExceptionInfo() - { - return exceptionInfo; - } - - public void setExceptionInfo(String exceptionInfo) - { - this.exceptionInfo = exceptionInfo; - } - - public Date getStartTime() - { - return startTime; - } - - public void setStartTime(Date startTime) - { - this.startTime = startTime; - } - - public Date getStopTime() - { - return stopTime; - } - - public void setStopTime(Date stopTime) - { - this.stopTime = stopTime; - } - - @Override - public String toString() { - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("jobLogId", getJobLogId()) - .append("jobName", getJobName()) - .append("jobGroup", getJobGroup()) - .append("jobMessage", getJobMessage()) - .append("status", getStatus()) - .append("exceptionInfo", getExceptionInfo()) - .append("startTime", getStartTime()) - .append("stopTime", getStopTime()) - .toString(); - } -} +package com.ruoyi.quartz.domain; + +import java.util.Date; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +/** + * 瀹氭椂浠诲姟璋冨害鏃ュ織琛 sys_job_log + * + * @author ruoyi + */ +public class SysJobLog extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** ID */ + @Excel(name = "鏃ュ織搴忓彿") + private Long jobLogId; + + /** 浠诲姟鍚嶇О */ + @Excel(name = "浠诲姟鍚嶇О") + private String jobName; + + /** 浠诲姟缁勫悕 */ + @Excel(name = "浠诲姟缁勫悕") + private String jobGroup; + + /** 璋冪敤鐩爣瀛楃涓 */ + @Excel(name = "璋冪敤鐩爣瀛楃涓") + private String invokeTarget; + + /** 鏃ュ織淇℃伅 */ + @Excel(name = "鏃ュ織淇℃伅") + private String jobMessage; + + /** 鎵ц鐘舵侊紙0姝e父 1澶辫触锛 */ + @Excel(name = "鎵ц鐘舵", readConverterExp = "0=姝e父,1=澶辫触") + private String status; + + /** 寮傚父淇℃伅 */ + @Excel(name = "寮傚父淇℃伅") + private String exceptionInfo; + + /** 寮濮嬫椂闂 */ + private Date startTime; + + /** 鍋滄鏃堕棿 */ + private Date stopTime; + + public Long getJobLogId() + { + return jobLogId; + } + + public void setJobLogId(Long jobLogId) + { + this.jobLogId = jobLogId; + } + + public String getJobName() + { + return jobName; + } + + public void setJobName(String jobName) + { + this.jobName = jobName; + } + + public String getJobGroup() + { + return jobGroup; + } + + public void setJobGroup(String jobGroup) + { + this.jobGroup = jobGroup; + } + + public String getInvokeTarget() + { + return invokeTarget; + } + + public void setInvokeTarget(String invokeTarget) + { + this.invokeTarget = invokeTarget; + } + + public String getJobMessage() + { + return jobMessage; + } + + public void setJobMessage(String jobMessage) + { + this.jobMessage = jobMessage; + } + + public String getStatus() + { + return status; + } + + public void setStatus(String status) + { + this.status = status; + } + + public String getExceptionInfo() + { + return exceptionInfo; + } + + public void setExceptionInfo(String exceptionInfo) + { + this.exceptionInfo = exceptionInfo; + } + + public Date getStartTime() + { + return startTime; + } + + public void setStartTime(Date startTime) + { + this.startTime = startTime; + } + + public Date getStopTime() + { + return stopTime; + } + + public void setStopTime(Date stopTime) + { + this.stopTime = stopTime; + } + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("jobLogId", getJobLogId()) + .append("jobName", getJobName()) + .append("jobGroup", getJobGroup()) + .append("jobMessage", getJobMessage()) + .append("status", getStatus()) + .append("exceptionInfo", getExceptionInfo()) + .append("startTime", getStartTime()) + .append("stopTime", getStopTime()) + .toString(); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysJobLogMapper.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java similarity index 90% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysJobLogMapper.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java index 39137dd85..ed01ef72e 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysJobLogMapper.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobLogMapper.java @@ -1,64 +1,64 @@ -package com.ruoyi.project.monitor.mapper; - -import java.util.List; -import com.ruoyi.project.monitor.domain.SysJobLog; - -/** - * 璋冨害浠诲姟鏃ュ織淇℃伅 鏁版嵁灞 - * - * @author ruoyi - */ -public interface SysJobLogMapper -{ - /** - * 鑾峰彇quartz璋冨害鍣ㄦ棩蹇楃殑璁″垝浠诲姟 - * - * @param jobLog 璋冨害鏃ュ織淇℃伅 - * @return 璋冨害浠诲姟鏃ュ織闆嗗悎 - */ - public List selectJobLogList(SysJobLog jobLog); - - /** - * 鏌ヨ鎵鏈夎皟搴︿换鍔℃棩蹇 - * - * @return 璋冨害浠诲姟鏃ュ織鍒楄〃 - */ - public List selectJobLogAll(); - - /** - * 閫氳繃璋冨害浠诲姟鏃ュ織ID鏌ヨ璋冨害淇℃伅 - * - * @param jobLogId 璋冨害浠诲姟鏃ュ織ID - * @return 璋冨害浠诲姟鏃ュ織瀵硅薄淇℃伅 - */ - public SysJobLog selectJobLogById(Long jobLogId); - - /** - * 鏂板浠诲姟鏃ュ織 - * - * @param jobLog 璋冨害鏃ュ織淇℃伅 - * @return 缁撴灉 - */ - public int insertJobLog(SysJobLog jobLog); - - /** - * 鎵归噺鍒犻櫎璋冨害鏃ュ織淇℃伅 - * - * @param logIds 闇瑕佸垹闄ょ殑鏁版嵁ID - * @return 缁撴灉 - */ - public int deleteJobLogByIds(Long[] logIds); - - /** - * 鍒犻櫎浠诲姟鏃ュ織 - * - * @param jobId 璋冨害鏃ュ織ID - * @return 缁撴灉 - */ - public int deleteJobLogById(Long jobId); - - /** - * 娓呯┖浠诲姟鏃ュ織 - */ - public void cleanJobLog(); -} +package com.ruoyi.quartz.mapper; + +import java.util.List; +import com.ruoyi.quartz.domain.SysJobLog; + +/** + * 璋冨害浠诲姟鏃ュ織淇℃伅 鏁版嵁灞 + * + * @author ruoyi + */ +public interface SysJobLogMapper +{ + /** + * 鑾峰彇quartz璋冨害鍣ㄦ棩蹇楃殑璁″垝浠诲姟 + * + * @param jobLog 璋冨害鏃ュ織淇℃伅 + * @return 璋冨害浠诲姟鏃ュ織闆嗗悎 + */ + public List selectJobLogList(SysJobLog jobLog); + + /** + * 鏌ヨ鎵鏈夎皟搴︿换鍔℃棩蹇 + * + * @return 璋冨害浠诲姟鏃ュ織鍒楄〃 + */ + public List selectJobLogAll(); + + /** + * 閫氳繃璋冨害浠诲姟鏃ュ織ID鏌ヨ璋冨害淇℃伅 + * + * @param jobLogId 璋冨害浠诲姟鏃ュ織ID + * @return 璋冨害浠诲姟鏃ュ織瀵硅薄淇℃伅 + */ + public SysJobLog selectJobLogById(Long jobLogId); + + /** + * 鏂板浠诲姟鏃ュ織 + * + * @param jobLog 璋冨害鏃ュ織淇℃伅 + * @return 缁撴灉 + */ + public int insertJobLog(SysJobLog jobLog); + + /** + * 鎵归噺鍒犻櫎璋冨害鏃ュ織淇℃伅 + * + * @param logIds 闇瑕佸垹闄ょ殑鏁版嵁ID + * @return 缁撴灉 + */ + public int deleteJobLogByIds(Long[] logIds); + + /** + * 鍒犻櫎浠诲姟鏃ュ織 + * + * @param jobId 璋冨害鏃ュ織ID + * @return 缁撴灉 + */ + public int deleteJobLogById(Long jobId); + + /** + * 娓呯┖浠诲姟鏃ュ織 + */ + public void cleanJobLog(); +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysJobMapper.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysJobMapper.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java index ab1146188..f481ea12e 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysJobMapper.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/mapper/SysJobMapper.java @@ -1,67 +1,67 @@ -package com.ruoyi.project.monitor.mapper; - -import java.util.List; -import com.ruoyi.project.monitor.domain.SysJob; - -/** - * 璋冨害浠诲姟淇℃伅 鏁版嵁灞 - * - * @author ruoyi - */ -public interface SysJobMapper -{ - /** - * 鏌ヨ璋冨害浠诲姟鏃ュ織闆嗗悎 - * - * @param job 璋冨害淇℃伅 - * @return 鎿嶄綔鏃ュ織闆嗗悎 - */ - public List selectJobList(SysJob job); - - /** - * 鏌ヨ鎵鏈夎皟搴︿换鍔 - * - * @return 璋冨害浠诲姟鍒楄〃 - */ - public List selectJobAll(); - - /** - * 閫氳繃璋冨害ID鏌ヨ璋冨害浠诲姟淇℃伅 - * - * @param jobId 璋冨害ID - * @return 瑙掕壊瀵硅薄淇℃伅 - */ - public SysJob selectJobById(Long jobId); - - /** - * 閫氳繃璋冨害ID鍒犻櫎璋冨害浠诲姟淇℃伅 - * - * @param jobId 璋冨害ID - * @return 缁撴灉 - */ - public int deleteJobById(Long jobId); - - /** - * 鎵归噺鍒犻櫎璋冨害浠诲姟淇℃伅 - * - * @param ids 闇瑕佸垹闄ょ殑鏁版嵁ID - * @return 缁撴灉 - */ - public int deleteJobByIds(Long[] ids); - - /** - * 淇敼璋冨害浠诲姟淇℃伅 - * - * @param job 璋冨害浠诲姟淇℃伅 - * @return 缁撴灉 - */ - public int updateJob(SysJob job); - - /** - * 鏂板璋冨害浠诲姟淇℃伅 - * - * @param job 璋冨害浠诲姟淇℃伅 - * @return 缁撴灉 - */ - public int insertJob(SysJob job); -} +package com.ruoyi.quartz.mapper; + +import java.util.List; +import com.ruoyi.quartz.domain.SysJob; + +/** + * 璋冨害浠诲姟淇℃伅 鏁版嵁灞 + * + * @author ruoyi + */ +public interface SysJobMapper +{ + /** + * 鏌ヨ璋冨害浠诲姟鏃ュ織闆嗗悎 + * + * @param job 璋冨害淇℃伅 + * @return 鎿嶄綔鏃ュ織闆嗗悎 + */ + public List selectJobList(SysJob job); + + /** + * 鏌ヨ鎵鏈夎皟搴︿换鍔 + * + * @return 璋冨害浠诲姟鍒楄〃 + */ + public List selectJobAll(); + + /** + * 閫氳繃璋冨害ID鏌ヨ璋冨害浠诲姟淇℃伅 + * + * @param jobId 璋冨害ID + * @return 瑙掕壊瀵硅薄淇℃伅 + */ + public SysJob selectJobById(Long jobId); + + /** + * 閫氳繃璋冨害ID鍒犻櫎璋冨害浠诲姟淇℃伅 + * + * @param jobId 璋冨害ID + * @return 缁撴灉 + */ + public int deleteJobById(Long jobId); + + /** + * 鎵归噺鍒犻櫎璋冨害浠诲姟淇℃伅 + * + * @param ids 闇瑕佸垹闄ょ殑鏁版嵁ID + * @return 缁撴灉 + */ + public int deleteJobByIds(Long[] ids); + + /** + * 淇敼璋冨害浠诲姟淇℃伅 + * + * @param job 璋冨害浠诲姟淇℃伅 + * @return 缁撴灉 + */ + public int updateJob(SysJob job); + + /** + * 鏂板璋冨害浠诲姟淇℃伅 + * + * @param job 璋冨害浠诲姟淇℃伅 + * @return 缁撴灉 + */ + public int insertJob(SysJob job); +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysJobLogService.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysJobLogService.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java index 85561e766..5291a63ac 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysJobLogService.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobLogService.java @@ -1,56 +1,56 @@ -package com.ruoyi.project.monitor.service; - -import java.util.List; -import com.ruoyi.project.monitor.domain.SysJobLog; - -/** - * 瀹氭椂浠诲姟璋冨害鏃ュ織淇℃伅淇℃伅 鏈嶅姟灞 - * - * @author ruoyi - */ -public interface ISysJobLogService -{ - /** - * 鑾峰彇quartz璋冨害鍣ㄦ棩蹇楃殑璁″垝浠诲姟 - * - * @param jobLog 璋冨害鏃ュ織淇℃伅 - * @return 璋冨害浠诲姟鏃ュ織闆嗗悎 - */ - public List selectJobLogList(SysJobLog jobLog); - - /** - * 閫氳繃璋冨害浠诲姟鏃ュ織ID鏌ヨ璋冨害淇℃伅 - * - * @param jobLogId 璋冨害浠诲姟鏃ュ織ID - * @return 璋冨害浠诲姟鏃ュ織瀵硅薄淇℃伅 - */ - public SysJobLog selectJobLogById(Long jobLogId); - - /** - * 鏂板浠诲姟鏃ュ織 - * - * @param jobLog 璋冨害鏃ュ織淇℃伅 - */ - public void addJobLog(SysJobLog jobLog); - - /** - * 鎵归噺鍒犻櫎璋冨害鏃ュ織淇℃伅 - * - * @param logIds 闇瑕佸垹闄ょ殑鏃ュ織ID - * @return 缁撴灉 - */ - public int deleteJobLogByIds(Long[] logIds); - - /** - * 鍒犻櫎浠诲姟鏃ュ織 - * - * @param jobId 璋冨害鏃ュ織ID - * @return 缁撴灉 - */ - public int deleteJobLogById(Long jobId); - - /** - * 娓呯┖浠诲姟鏃ュ織 - */ - public void cleanJobLog(); -} +package com.ruoyi.quartz.service; + +import java.util.List; +import com.ruoyi.quartz.domain.SysJobLog; + +/** + * 瀹氭椂浠诲姟璋冨害鏃ュ織淇℃伅淇℃伅 鏈嶅姟灞 + * + * @author ruoyi + */ +public interface ISysJobLogService +{ + /** + * 鑾峰彇quartz璋冨害鍣ㄦ棩蹇楃殑璁″垝浠诲姟 + * + * @param jobLog 璋冨害鏃ュ織淇℃伅 + * @return 璋冨害浠诲姟鏃ュ織闆嗗悎 + */ + public List selectJobLogList(SysJobLog jobLog); + + /** + * 閫氳繃璋冨害浠诲姟鏃ュ織ID鏌ヨ璋冨害淇℃伅 + * + * @param jobLogId 璋冨害浠诲姟鏃ュ織ID + * @return 璋冨害浠诲姟鏃ュ織瀵硅薄淇℃伅 + */ + public SysJobLog selectJobLogById(Long jobLogId); + + /** + * 鏂板浠诲姟鏃ュ織 + * + * @param jobLog 璋冨害鏃ュ織淇℃伅 + */ + public void addJobLog(SysJobLog jobLog); + + /** + * 鎵归噺鍒犻櫎璋冨害鏃ュ織淇℃伅 + * + * @param logIds 闇瑕佸垹闄ょ殑鏃ュ織ID + * @return 缁撴灉 + */ + public int deleteJobLogByIds(Long[] logIds); + + /** + * 鍒犻櫎浠诲姟鏃ュ織 + * + * @param jobId 璋冨害鏃ュ織ID + * @return 缁撴灉 + */ + public int deleteJobLogById(Long jobId); + + /** + * 娓呯┖浠诲姟鏃ュ織 + */ + public void cleanJobLog(); +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysJobService.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysJobService.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java index f7da1ac62..53f098956 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysJobService.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/ISysJobService.java @@ -1,102 +1,102 @@ -package com.ruoyi.project.monitor.service; - -import java.util.List; -import org.quartz.SchedulerException; -import com.ruoyi.common.exception.job.TaskException; -import com.ruoyi.project.monitor.domain.SysJob; - -/** - * 瀹氭椂浠诲姟璋冨害淇℃伅淇℃伅 鏈嶅姟灞 - * - * @author ruoyi - */ -public interface ISysJobService -{ - /** - * 鑾峰彇quartz璋冨害鍣ㄧ殑璁″垝浠诲姟 - * - * @param job 璋冨害淇℃伅 - * @return 璋冨害浠诲姟闆嗗悎 - */ - public List selectJobList(SysJob job); - - /** - * 閫氳繃璋冨害浠诲姟ID鏌ヨ璋冨害淇℃伅 - * - * @param jobId 璋冨害浠诲姟ID - * @return 璋冨害浠诲姟瀵硅薄淇℃伅 - */ - public SysJob selectJobById(Long jobId); - - /** - * 鏆傚仠浠诲姟 - * - * @param job 璋冨害淇℃伅 - * @return 缁撴灉 - */ - public int pauseJob(SysJob job) throws SchedulerException; - - /** - * 鎭㈠浠诲姟 - * - * @param job 璋冨害淇℃伅 - * @return 缁撴灉 - */ - public int resumeJob(SysJob job) throws SchedulerException; - - /** - * 鍒犻櫎浠诲姟鍚庯紝鎵瀵瑰簲鐨則rigger涔熷皢琚垹闄 - * - * @param job 璋冨害淇℃伅 - * @return 缁撴灉 - */ - public int deleteJob(SysJob job) throws SchedulerException; - - /** - * 鎵归噺鍒犻櫎璋冨害淇℃伅 - * - * @param jobIds 闇瑕佸垹闄ょ殑浠诲姟ID - * @return 缁撴灉 - */ - public void deleteJobByIds(Long[] jobIds) throws SchedulerException; - - /** - * 浠诲姟璋冨害鐘舵佷慨鏀 - * - * @param job 璋冨害淇℃伅 - * @return 缁撴灉 - */ - public int changeStatus(SysJob job) throws SchedulerException; - - /** - * 绔嬪嵆杩愯浠诲姟 - * - * @param job 璋冨害淇℃伅 - * @return 缁撴灉 - */ - public void run(SysJob job) throws SchedulerException; - - /** - * 鏂板浠诲姟 - * - * @param job 璋冨害淇℃伅 - * @return 缁撴灉 - */ - public int insertJob(SysJob job) throws SchedulerException, TaskException; - - /** - * 鏇存柊浠诲姟 - * - * @param job 璋冨害淇℃伅 - * @return 缁撴灉 - */ - public int updateJob(SysJob job) throws SchedulerException, TaskException; - - /** - * 鏍¢獙cron琛ㄨ揪寮忔槸鍚︽湁鏁 - * - * @param cronExpression 琛ㄨ揪寮 - * @return 缁撴灉 - */ - public boolean checkCronExpressionIsValid(String cronExpression); -} \ No newline at end of file +package com.ruoyi.quartz.service; + +import java.util.List; +import org.quartz.SchedulerException; +import com.ruoyi.common.exception.job.TaskException; +import com.ruoyi.quartz.domain.SysJob; + +/** + * 瀹氭椂浠诲姟璋冨害淇℃伅淇℃伅 鏈嶅姟灞 + * + * @author ruoyi + */ +public interface ISysJobService +{ + /** + * 鑾峰彇quartz璋冨害鍣ㄧ殑璁″垝浠诲姟 + * + * @param job 璋冨害淇℃伅 + * @return 璋冨害浠诲姟闆嗗悎 + */ + public List selectJobList(SysJob job); + + /** + * 閫氳繃璋冨害浠诲姟ID鏌ヨ璋冨害淇℃伅 + * + * @param jobId 璋冨害浠诲姟ID + * @return 璋冨害浠诲姟瀵硅薄淇℃伅 + */ + public SysJob selectJobById(Long jobId); + + /** + * 鏆傚仠浠诲姟 + * + * @param job 璋冨害淇℃伅 + * @return 缁撴灉 + */ + public int pauseJob(SysJob job) throws SchedulerException; + + /** + * 鎭㈠浠诲姟 + * + * @param job 璋冨害淇℃伅 + * @return 缁撴灉 + */ + public int resumeJob(SysJob job) throws SchedulerException; + + /** + * 鍒犻櫎浠诲姟鍚庯紝鎵瀵瑰簲鐨則rigger涔熷皢琚垹闄 + * + * @param job 璋冨害淇℃伅 + * @return 缁撴灉 + */ + public int deleteJob(SysJob job) throws SchedulerException; + + /** + * 鎵归噺鍒犻櫎璋冨害淇℃伅 + * + * @param jobIds 闇瑕佸垹闄ょ殑浠诲姟ID + * @return 缁撴灉 + */ + public void deleteJobByIds(Long[] jobIds) throws SchedulerException; + + /** + * 浠诲姟璋冨害鐘舵佷慨鏀 + * + * @param job 璋冨害淇℃伅 + * @return 缁撴灉 + */ + public int changeStatus(SysJob job) throws SchedulerException; + + /** + * 绔嬪嵆杩愯浠诲姟 + * + * @param job 璋冨害淇℃伅 + * @return 缁撴灉 + */ + public void run(SysJob job) throws SchedulerException; + + /** + * 鏂板浠诲姟 + * + * @param job 璋冨害淇℃伅 + * @return 缁撴灉 + */ + public int insertJob(SysJob job) throws SchedulerException, TaskException; + + /** + * 鏇存柊浠诲姟 + * + * @param job 璋冨害淇℃伅 + * @return 缁撴灉 + */ + public int updateJob(SysJob job) throws SchedulerException, TaskException; + + /** + * 鏍¢獙cron琛ㄨ揪寮忔槸鍚︽湁鏁 + * + * @param cronExpression 琛ㄨ揪寮 + * @return 缁撴灉 + */ + public boolean checkCronExpressionIsValid(String cronExpression); +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysJobLogServiceImpl.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java similarity index 86% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysJobLogServiceImpl.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java index 991cf813f..f68a5482b 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysJobLogServiceImpl.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobLogServiceImpl.java @@ -1,87 +1,87 @@ -package com.ruoyi.project.monitor.service.impl; - -import java.util.List; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import com.ruoyi.project.monitor.domain.SysJobLog; -import com.ruoyi.project.monitor.mapper.SysJobLogMapper; -import com.ruoyi.project.monitor.service.ISysJobLogService; - -/** - * 瀹氭椂浠诲姟璋冨害鏃ュ織淇℃伅 鏈嶅姟灞 - * - * @author ruoyi - */ -@Service -public class SysJobLogServiceImpl implements ISysJobLogService -{ - @Autowired - private SysJobLogMapper jobLogMapper; - - /** - * 鑾峰彇quartz璋冨害鍣ㄦ棩蹇楃殑璁″垝浠诲姟 - * - * @param jobLog 璋冨害鏃ュ織淇℃伅 - * @return 璋冨害浠诲姟鏃ュ織闆嗗悎 - */ - @Override - public List selectJobLogList(SysJobLog jobLog) - { - return jobLogMapper.selectJobLogList(jobLog); - } - - /** - * 閫氳繃璋冨害浠诲姟鏃ュ織ID鏌ヨ璋冨害淇℃伅 - * - * @param jobLogId 璋冨害浠诲姟鏃ュ織ID - * @return 璋冨害浠诲姟鏃ュ織瀵硅薄淇℃伅 - */ - @Override - public SysJobLog selectJobLogById(Long jobLogId) - { - return jobLogMapper.selectJobLogById(jobLogId); - } - - /** - * 鏂板浠诲姟鏃ュ織 - * - * @param jobLog 璋冨害鏃ュ織淇℃伅 - */ - @Override - public void addJobLog(SysJobLog jobLog) - { - jobLogMapper.insertJobLog(jobLog); - } - - /** - * 鎵归噺鍒犻櫎璋冨害鏃ュ織淇℃伅 - * - * @param logIds 闇瑕佸垹闄ょ殑鏁版嵁ID - * @return 缁撴灉 - */ - @Override - public int deleteJobLogByIds(Long[] logIds) - { - return jobLogMapper.deleteJobLogByIds(logIds); - } - - /** - * 鍒犻櫎浠诲姟鏃ュ織 - * - * @param jobId 璋冨害鏃ュ織ID - */ - @Override - public int deleteJobLogById(Long jobId) - { - return jobLogMapper.deleteJobLogById(jobId); - } - - /** - * 娓呯┖浠诲姟鏃ュ織 - */ - @Override - public void cleanJobLog() - { - jobLogMapper.cleanJobLog(); - } -} +package com.ruoyi.quartz.service.impl; + +import java.util.List; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.ruoyi.quartz.domain.SysJobLog; +import com.ruoyi.quartz.mapper.SysJobLogMapper; +import com.ruoyi.quartz.service.ISysJobLogService; + +/** + * 瀹氭椂浠诲姟璋冨害鏃ュ織淇℃伅 鏈嶅姟灞 + * + * @author ruoyi + */ +@Service +public class SysJobLogServiceImpl implements ISysJobLogService +{ + @Autowired + private SysJobLogMapper jobLogMapper; + + /** + * 鑾峰彇quartz璋冨害鍣ㄦ棩蹇楃殑璁″垝浠诲姟 + * + * @param jobLog 璋冨害鏃ュ織淇℃伅 + * @return 璋冨害浠诲姟鏃ュ織闆嗗悎 + */ + @Override + public List selectJobLogList(SysJobLog jobLog) + { + return jobLogMapper.selectJobLogList(jobLog); + } + + /** + * 閫氳繃璋冨害浠诲姟鏃ュ織ID鏌ヨ璋冨害淇℃伅 + * + * @param jobLogId 璋冨害浠诲姟鏃ュ織ID + * @return 璋冨害浠诲姟鏃ュ織瀵硅薄淇℃伅 + */ + @Override + public SysJobLog selectJobLogById(Long jobLogId) + { + return jobLogMapper.selectJobLogById(jobLogId); + } + + /** + * 鏂板浠诲姟鏃ュ織 + * + * @param jobLog 璋冨害鏃ュ織淇℃伅 + */ + @Override + public void addJobLog(SysJobLog jobLog) + { + jobLogMapper.insertJobLog(jobLog); + } + + /** + * 鎵归噺鍒犻櫎璋冨害鏃ュ織淇℃伅 + * + * @param logIds 闇瑕佸垹闄ょ殑鏁版嵁ID + * @return 缁撴灉 + */ + @Override + public int deleteJobLogByIds(Long[] logIds) + { + return jobLogMapper.deleteJobLogByIds(logIds); + } + + /** + * 鍒犻櫎浠诲姟鏃ュ織 + * + * @param jobId 璋冨害鏃ュ織ID + */ + @Override + public int deleteJobLogById(Long jobId) + { + return jobLogMapper.deleteJobLogById(jobId); + } + + /** + * 娓呯┖浠诲姟鏃ュ織 + */ + @Override + public void cleanJobLog() + { + jobLogMapper.cleanJobLog(); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysJobServiceImpl.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysJobServiceImpl.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java index c53cd3c91..d7bc6c984 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysJobServiceImpl.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/service/impl/SysJobServiceImpl.java @@ -1,254 +1,254 @@ -package com.ruoyi.project.monitor.service.impl; - -import java.util.List; -import javax.annotation.PostConstruct; -import org.quartz.JobDataMap; -import org.quartz.JobKey; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; -import com.ruoyi.common.constant.ScheduleConstants; -import com.ruoyi.common.exception.job.TaskException; -import com.ruoyi.common.utils.job.CronUtils; -import com.ruoyi.common.utils.job.ScheduleUtils; -import com.ruoyi.project.monitor.domain.SysJob; -import com.ruoyi.project.monitor.mapper.SysJobMapper; -import com.ruoyi.project.monitor.service.ISysJobService; - -/** - * 瀹氭椂浠诲姟璋冨害淇℃伅 鏈嶅姟灞 - * - * @author ruoyi - */ -@Service -public class SysJobServiceImpl implements ISysJobService -{ - @Autowired - private Scheduler scheduler; - - @Autowired - private SysJobMapper jobMapper; - - /** - * 椤圭洰鍚姩鏃讹紝鍒濆鍖栧畾鏃跺櫒 涓昏鏄槻姝㈡墜鍔ㄤ慨鏀规暟鎹簱瀵艰嚧鏈悓姝ュ埌瀹氭椂浠诲姟澶勭悊锛堟敞锛氫笉鑳芥墜鍔ㄤ慨鏀规暟鎹簱ID鍜屼换鍔$粍鍚嶏紝鍚﹀垯浼氬鑷磋剰鏁版嵁锛 - */ - @PostConstruct - public void init() throws SchedulerException, TaskException - { - scheduler.clear(); - List jobList = jobMapper.selectJobAll(); - for (SysJob job : jobList) - { - ScheduleUtils.createScheduleJob(scheduler, job); - } - } - - /** - * 鑾峰彇quartz璋冨害鍣ㄧ殑璁″垝浠诲姟鍒楄〃 - * - * @param job 璋冨害淇℃伅 - * @return - */ - @Override - public List selectJobList(SysJob job) - { - return jobMapper.selectJobList(job); - } - - /** - * 閫氳繃璋冨害浠诲姟ID鏌ヨ璋冨害淇℃伅 - * - * @param jobId 璋冨害浠诲姟ID - * @return 璋冨害浠诲姟瀵硅薄淇℃伅 - */ - @Override - public SysJob selectJobById(Long jobId) - { - return jobMapper.selectJobById(jobId); - } - - /** - * 鏆傚仠浠诲姟 - * - * @param job 璋冨害淇℃伅 - */ - @Override - @Transactional - public int pauseJob(SysJob job) throws SchedulerException - { - Long jobId = job.getJobId(); - String jobGroup = job.getJobGroup(); - job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); - int rows = jobMapper.updateJob(job); - if (rows > 0) - { - scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); - } - return rows; - } - - /** - * 鎭㈠浠诲姟 - * - * @param job 璋冨害淇℃伅 - */ - @Override - @Transactional - public int resumeJob(SysJob job) throws SchedulerException - { - Long jobId = job.getJobId(); - String jobGroup = job.getJobGroup(); - job.setStatus(ScheduleConstants.Status.NORMAL.getValue()); - int rows = jobMapper.updateJob(job); - if (rows > 0) - { - scheduler.resumeJob(ScheduleUtils.getJobKey(jobId, jobGroup)); - } - return rows; - } - - /** - * 鍒犻櫎浠诲姟鍚庯紝鎵瀵瑰簲鐨則rigger涔熷皢琚垹闄 - * - * @param job 璋冨害淇℃伅 - */ - @Override - @Transactional - public int deleteJob(SysJob job) throws SchedulerException - { - Long jobId = job.getJobId(); - String jobGroup = job.getJobGroup(); - int rows = jobMapper.deleteJobById(jobId); - if (rows > 0) - { - scheduler.deleteJob(ScheduleUtils.getJobKey(jobId, jobGroup)); - } - return rows; - } - - /** - * 鎵归噺鍒犻櫎璋冨害淇℃伅 - * - * @param jobIds 闇瑕佸垹闄ょ殑浠诲姟ID - * @return 缁撴灉 - */ - @Override - @Transactional - public void deleteJobByIds(Long[] jobIds) throws SchedulerException - { - for (Long jobId : jobIds) - { - SysJob job = jobMapper.selectJobById(jobId); - deleteJob(job); - } - } - - /** - * 浠诲姟璋冨害鐘舵佷慨鏀 - * - * @param job 璋冨害淇℃伅 - */ - @Override - @Transactional - public int changeStatus(SysJob job) throws SchedulerException - { - int rows = 0; - String status = job.getStatus(); - if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) - { - rows = resumeJob(job); - } - else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) - { - rows = pauseJob(job); - } - return rows; - } - - /** - * 绔嬪嵆杩愯浠诲姟 - * - * @param job 璋冨害淇℃伅 - */ - @Override - @Transactional - public void run(SysJob job) throws SchedulerException - { - Long jobId = job.getJobId(); - String jobGroup = job.getJobGroup(); - SysJob properties = selectJobById(job.getJobId()); - // 鍙傛暟 - JobDataMap dataMap = new JobDataMap(); - dataMap.put(ScheduleConstants.TASK_PROPERTIES, properties); - scheduler.triggerJob(ScheduleUtils.getJobKey(jobId, jobGroup), dataMap); - } - - /** - * 鏂板浠诲姟 - * - * @param job 璋冨害淇℃伅 璋冨害淇℃伅 - */ - @Override - @Transactional - public int insertJob(SysJob job) throws SchedulerException, TaskException - { - job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); - int rows = jobMapper.insertJob(job); - if (rows > 0) - { - ScheduleUtils.createScheduleJob(scheduler, job); - } - return rows; - } - - /** - * 鏇存柊浠诲姟鐨勬椂闂磋〃杈惧紡 - * - * @param job 璋冨害淇℃伅 - */ - @Override - @Transactional - public int updateJob(SysJob job) throws SchedulerException, TaskException - { - SysJob properties = selectJobById(job.getJobId()); - int rows = jobMapper.updateJob(job); - if (rows > 0) - { - updateSchedulerJob(job, properties.getJobGroup()); - } - return rows; - } - - /** - * 鏇存柊浠诲姟 - * - * @param job 浠诲姟瀵硅薄 - * @param jobGroup 浠诲姟缁勫悕 - */ - public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException - { - Long jobId = job.getJobId(); - // 鍒ゆ柇鏄惁瀛樺湪 - JobKey jobKey = ScheduleUtils.getJobKey(jobId, jobGroup); - if (scheduler.checkExists(jobKey)) - { - // 闃叉鍒涘缓鏃跺瓨鍦ㄦ暟鎹棶棰 鍏堢Щ闄わ紝鐒跺悗鍦ㄦ墽琛屽垱寤烘搷浣 - scheduler.deleteJob(jobKey); - } - ScheduleUtils.createScheduleJob(scheduler, job); - } - - /** - * 鏍¢獙cron琛ㄨ揪寮忔槸鍚︽湁鏁 - * - * @param cronExpression 琛ㄨ揪寮 - * @return 缁撴灉 - */ - @Override - public boolean checkCronExpressionIsValid(String cronExpression) - { - return CronUtils.isValid(cronExpression); - } -} \ No newline at end of file +package com.ruoyi.quartz.service.impl; + +import java.util.List; +import javax.annotation.PostConstruct; +import org.quartz.JobDataMap; +import org.quartz.JobKey; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import com.ruoyi.common.constant.ScheduleConstants; +import com.ruoyi.common.exception.job.TaskException; +import com.ruoyi.quartz.domain.SysJob; +import com.ruoyi.quartz.mapper.SysJobMapper; +import com.ruoyi.quartz.service.ISysJobService; +import com.ruoyi.quartz.util.CronUtils; +import com.ruoyi.quartz.util.ScheduleUtils; + +/** + * 瀹氭椂浠诲姟璋冨害淇℃伅 鏈嶅姟灞 + * + * @author ruoyi + */ +@Service +public class SysJobServiceImpl implements ISysJobService +{ + @Autowired + private Scheduler scheduler; + + @Autowired + private SysJobMapper jobMapper; + + /** + * 椤圭洰鍚姩鏃讹紝鍒濆鍖栧畾鏃跺櫒 涓昏鏄槻姝㈡墜鍔ㄤ慨鏀规暟鎹簱瀵艰嚧鏈悓姝ュ埌瀹氭椂浠诲姟澶勭悊锛堟敞锛氫笉鑳芥墜鍔ㄤ慨鏀规暟鎹簱ID鍜屼换鍔$粍鍚嶏紝鍚﹀垯浼氬鑷磋剰鏁版嵁锛 + */ + @PostConstruct + public void init() throws SchedulerException, TaskException + { + scheduler.clear(); + List jobList = jobMapper.selectJobAll(); + for (SysJob job : jobList) + { + ScheduleUtils.createScheduleJob(scheduler, job); + } + } + + /** + * 鑾峰彇quartz璋冨害鍣ㄧ殑璁″垝浠诲姟鍒楄〃 + * + * @param job 璋冨害淇℃伅 + * @return + */ + @Override + public List selectJobList(SysJob job) + { + return jobMapper.selectJobList(job); + } + + /** + * 閫氳繃璋冨害浠诲姟ID鏌ヨ璋冨害淇℃伅 + * + * @param jobId 璋冨害浠诲姟ID + * @return 璋冨害浠诲姟瀵硅薄淇℃伅 + */ + @Override + public SysJob selectJobById(Long jobId) + { + return jobMapper.selectJobById(jobId); + } + + /** + * 鏆傚仠浠诲姟 + * + * @param job 璋冨害淇℃伅 + */ + @Override + @Transactional + public int pauseJob(SysJob job) throws SchedulerException + { + Long jobId = job.getJobId(); + String jobGroup = job.getJobGroup(); + job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); + int rows = jobMapper.updateJob(job); + if (rows > 0) + { + scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); + } + return rows; + } + + /** + * 鎭㈠浠诲姟 + * + * @param job 璋冨害淇℃伅 + */ + @Override + @Transactional + public int resumeJob(SysJob job) throws SchedulerException + { + Long jobId = job.getJobId(); + String jobGroup = job.getJobGroup(); + job.setStatus(ScheduleConstants.Status.NORMAL.getValue()); + int rows = jobMapper.updateJob(job); + if (rows > 0) + { + scheduler.resumeJob(ScheduleUtils.getJobKey(jobId, jobGroup)); + } + return rows; + } + + /** + * 鍒犻櫎浠诲姟鍚庯紝鎵瀵瑰簲鐨則rigger涔熷皢琚垹闄 + * + * @param job 璋冨害淇℃伅 + */ + @Override + @Transactional + public int deleteJob(SysJob job) throws SchedulerException + { + Long jobId = job.getJobId(); + String jobGroup = job.getJobGroup(); + int rows = jobMapper.deleteJobById(jobId); + if (rows > 0) + { + scheduler.deleteJob(ScheduleUtils.getJobKey(jobId, jobGroup)); + } + return rows; + } + + /** + * 鎵归噺鍒犻櫎璋冨害淇℃伅 + * + * @param jobIds 闇瑕佸垹闄ょ殑浠诲姟ID + * @return 缁撴灉 + */ + @Override + @Transactional + public void deleteJobByIds(Long[] jobIds) throws SchedulerException + { + for (Long jobId : jobIds) + { + SysJob job = jobMapper.selectJobById(jobId); + deleteJob(job); + } + } + + /** + * 浠诲姟璋冨害鐘舵佷慨鏀 + * + * @param job 璋冨害淇℃伅 + */ + @Override + @Transactional + public int changeStatus(SysJob job) throws SchedulerException + { + int rows = 0; + String status = job.getStatus(); + if (ScheduleConstants.Status.NORMAL.getValue().equals(status)) + { + rows = resumeJob(job); + } + else if (ScheduleConstants.Status.PAUSE.getValue().equals(status)) + { + rows = pauseJob(job); + } + return rows; + } + + /** + * 绔嬪嵆杩愯浠诲姟 + * + * @param job 璋冨害淇℃伅 + */ + @Override + @Transactional + public void run(SysJob job) throws SchedulerException + { + Long jobId = job.getJobId(); + String jobGroup = job.getJobGroup(); + SysJob properties = selectJobById(job.getJobId()); + // 鍙傛暟 + JobDataMap dataMap = new JobDataMap(); + dataMap.put(ScheduleConstants.TASK_PROPERTIES, properties); + scheduler.triggerJob(ScheduleUtils.getJobKey(jobId, jobGroup), dataMap); + } + + /** + * 鏂板浠诲姟 + * + * @param job 璋冨害淇℃伅 璋冨害淇℃伅 + */ + @Override + @Transactional + public int insertJob(SysJob job) throws SchedulerException, TaskException + { + job.setStatus(ScheduleConstants.Status.PAUSE.getValue()); + int rows = jobMapper.insertJob(job); + if (rows > 0) + { + ScheduleUtils.createScheduleJob(scheduler, job); + } + return rows; + } + + /** + * 鏇存柊浠诲姟鐨勬椂闂磋〃杈惧紡 + * + * @param job 璋冨害淇℃伅 + */ + @Override + @Transactional + public int updateJob(SysJob job) throws SchedulerException, TaskException + { + SysJob properties = selectJobById(job.getJobId()); + int rows = jobMapper.updateJob(job); + if (rows > 0) + { + updateSchedulerJob(job, properties.getJobGroup()); + } + return rows; + } + + /** + * 鏇存柊浠诲姟 + * + * @param job 浠诲姟瀵硅薄 + * @param jobGroup 浠诲姟缁勫悕 + */ + public void updateSchedulerJob(SysJob job, String jobGroup) throws SchedulerException, TaskException + { + Long jobId = job.getJobId(); + // 鍒ゆ柇鏄惁瀛樺湪 + JobKey jobKey = ScheduleUtils.getJobKey(jobId, jobGroup); + if (scheduler.checkExists(jobKey)) + { + // 闃叉鍒涘缓鏃跺瓨鍦ㄦ暟鎹棶棰 鍏堢Щ闄わ紝鐒跺悗鍦ㄦ墽琛屽垱寤烘搷浣 + scheduler.deleteJob(jobKey); + } + ScheduleUtils.createScheduleJob(scheduler, job); + } + + /** + * 鏍¢獙cron琛ㄨ揪寮忔槸鍚︽湁鏁 + * + * @param cronExpression 琛ㄨ揪寮 + * @return 缁撴灉 + */ + @Override + public boolean checkCronExpressionIsValid(String cronExpression) + { + return CronUtils.isValid(cronExpression); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/framework/task/RyTask.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/framework/task/RyTask.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java index eb7f5b9a4..25d1ddd02 100644 --- a/ruoyi/src/main/java/com/ruoyi/framework/task/RyTask.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/task/RyTask.java @@ -1,28 +1,28 @@ -package com.ruoyi.framework.task; - -import org.springframework.stereotype.Component; -import com.ruoyi.common.utils.StringUtils; - -/** - * 瀹氭椂浠诲姟璋冨害娴嬭瘯 - * - * @author ruoyi - */ -@Component("ryTask") -public class RyTask -{ - public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) - { - System.out.println(StringUtils.format("鎵ц澶氬弬鏂规硶锛 瀛楃涓茬被鍨媨}锛屽竷灏旂被鍨媨}锛岄暱鏁村瀷{}锛屾诞鐐瑰瀷{}锛屾暣褰}", s, b, l, d, i)); - } - - public void ryParams(String params) - { - System.out.println("鎵ц鏈夊弬鏂规硶锛" + params); - } - - public void ryNoParams() - { - System.out.println("鎵ц鏃犲弬鏂规硶"); - } -} +package com.ruoyi.quartz.task; + +import org.springframework.stereotype.Component; +import com.ruoyi.common.utils.StringUtils; + +/** + * 瀹氭椂浠诲姟璋冨害娴嬭瘯 + * + * @author ruoyi + */ +@Component("ryTask") +public class RyTask +{ + public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) + { + System.out.println(StringUtils.format("鎵ц澶氬弬鏂规硶锛 瀛楃涓茬被鍨媨}锛屽竷灏旂被鍨媨}锛岄暱鏁村瀷{}锛屾诞鐐瑰瀷{}锛屾暣褰}", s, b, l, d, i)); + } + + public void ryParams(String params) + { + System.out.println("鎵ц鏈夊弬鏂规硶锛" + params); + } + + public void ryNoParams() + { + System.out.println("鎵ц鏃犲弬鏂规硶"); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/job/AbstractQuartzJob.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/common/utils/job/AbstractQuartzJob.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java index ec7e62216..a0aadb689 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/job/AbstractQuartzJob.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/AbstractQuartzJob.java @@ -1,107 +1,107 @@ -package com.ruoyi.common.utils.job; - -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; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.bean.BeanUtils; -import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.project.monitor.domain.SysJob; -import com.ruoyi.project.monitor.domain.SysJobLog; -import com.ruoyi.project.monitor.service.ISysJobLogService; - -/** - * 鎶借薄quartz璋冪敤 - * - * @author ruoyi - */ -public abstract class AbstractQuartzJob implements Job -{ - private static final Logger log = LoggerFactory.getLogger(AbstractQuartzJob.class); - - /** - * 绾跨▼鏈湴鍙橀噺 - */ - private static ThreadLocal threadLocal = new ThreadLocal<>(); - - @Override - public void execute(JobExecutionContext context) throws JobExecutionException - { - SysJob sysJob = new SysJob(); - BeanUtils.copyBeanProp(sysJob, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES)); - try - { - before(context, sysJob); - if (sysJob != null) - { - doExecute(context, sysJob); - } - after(context, sysJob, null); - } - catch (Exception e) - { - log.error("浠诲姟鎵ц寮傚父 - 锛", e); - after(context, sysJob, e); - } - } - - /** - * 鎵ц鍓 - * - * @param context 宸ヤ綔鎵ц涓婁笅鏂囧璞 - * @param sysJob 绯荤粺璁″垝浠诲姟 - */ - protected void before(JobExecutionContext context, SysJob sysJob) - { - threadLocal.set(new Date()); - } - - /** - * 鎵ц鍚 - * - * @param context 宸ヤ綔鎵ц涓婁笅鏂囧璞 - * @param sysScheduleJob 绯荤粺璁″垝浠诲姟 - */ - protected void after(JobExecutionContext context, SysJob sysJob, Exception e) - { - Date startTime = threadLocal.get(); - threadLocal.remove(); - - final SysJobLog sysJobLog = new SysJobLog(); - sysJobLog.setJobName(sysJob.getJobName()); - sysJobLog.setJobGroup(sysJob.getJobGroup()); - sysJobLog.setInvokeTarget(sysJob.getInvokeTarget()); - sysJobLog.setStartTime(startTime); - sysJobLog.setStopTime(new Date()); - long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime(); - sysJobLog.setJobMessage(sysJobLog.getJobName() + " 鎬诲叡鑰楁椂锛" + runMs + "姣"); - if (e != null) - { - sysJobLog.setStatus(Constants.FAIL); - String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000); - sysJobLog.setExceptionInfo(errorMsg); - } - else - { - sysJobLog.setStatus(Constants.SUCCESS); - } - - // 鍐欏叆鏁版嵁搴撳綋涓 - SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog); - } - - /** - * 鎵ц鏂规硶锛岀敱瀛愮被閲嶈浇 - * - * @param context 宸ヤ綔鎵ц涓婁笅鏂囧璞 - * @param sysJob 绯荤粺璁″垝浠诲姟 - * @throws Exception 鎵ц杩囩▼涓殑寮傚父 - */ - protected abstract void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception; -} +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; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.bean.BeanUtils; +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; + +/** + * 鎶借薄quartz璋冪敤 + * + * @author ruoyi + */ +public abstract class AbstractQuartzJob implements Job +{ + private static final Logger log = LoggerFactory.getLogger(AbstractQuartzJob.class); + + /** + * 绾跨▼鏈湴鍙橀噺 + */ + private static ThreadLocal threadLocal = new ThreadLocal<>(); + + @Override + public void execute(JobExecutionContext context) throws JobExecutionException + { + SysJob sysJob = new SysJob(); + BeanUtils.copyBeanProp(sysJob, context.getMergedJobDataMap().get(ScheduleConstants.TASK_PROPERTIES)); + try + { + before(context, sysJob); + if (sysJob != null) + { + doExecute(context, sysJob); + } + after(context, sysJob, null); + } + catch (Exception e) + { + log.error("浠诲姟鎵ц寮傚父 - 锛", e); + after(context, sysJob, e); + } + } + + /** + * 鎵ц鍓 + * + * @param context 宸ヤ綔鎵ц涓婁笅鏂囧璞 + * @param sysJob 绯荤粺璁″垝浠诲姟 + */ + protected void before(JobExecutionContext context, SysJob sysJob) + { + threadLocal.set(new Date()); + } + + /** + * 鎵ц鍚 + * + * @param context 宸ヤ綔鎵ц涓婁笅鏂囧璞 + * @param sysScheduleJob 绯荤粺璁″垝浠诲姟 + */ + protected void after(JobExecutionContext context, SysJob sysJob, Exception e) + { + Date startTime = threadLocal.get(); + threadLocal.remove(); + + final SysJobLog sysJobLog = new SysJobLog(); + sysJobLog.setJobName(sysJob.getJobName()); + sysJobLog.setJobGroup(sysJob.getJobGroup()); + sysJobLog.setInvokeTarget(sysJob.getInvokeTarget()); + sysJobLog.setStartTime(startTime); + sysJobLog.setStopTime(new Date()); + long runMs = sysJobLog.getStopTime().getTime() - sysJobLog.getStartTime().getTime(); + sysJobLog.setJobMessage(sysJobLog.getJobName() + " 鎬诲叡鑰楁椂锛" + runMs + "姣"); + if (e != null) + { + sysJobLog.setStatus(Constants.FAIL); + String errorMsg = StringUtils.substring(ExceptionUtil.getExceptionMessage(e), 0, 2000); + sysJobLog.setExceptionInfo(errorMsg); + } + else + { + sysJobLog.setStatus(Constants.SUCCESS); + } + + // 鍐欏叆鏁版嵁搴撳綋涓 + SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog); + } + + /** + * 鎵ц鏂规硶锛岀敱瀛愮被閲嶈浇 + * + * @param context 宸ヤ綔鎵ц涓婁笅鏂囧璞 + * @param sysJob 绯荤粺璁″垝浠诲姟 + * @throws Exception 鎵ц杩囩▼涓殑寮傚父 + */ + protected abstract void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception; +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/job/CronUtils.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java similarity index 94% rename from ruoyi/src/main/java/com/ruoyi/common/utils/job/CronUtils.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java index 0763a8d0f..6826787a6 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/job/CronUtils.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/CronUtils.java @@ -1,63 +1,63 @@ -package com.ruoyi.common.utils.job; - -import java.text.ParseException; -import java.util.Date; -import org.quartz.CronExpression; - -/** - * cron琛ㄨ揪寮忓伐鍏风被 - * - * @author ruoyi - * - */ -public class CronUtils -{ - /** - * 杩斿洖涓涓竷灏斿间唬琛ㄤ竴涓粰瀹氱殑Cron琛ㄨ揪寮忕殑鏈夋晥鎬 - * - * @param cronExpression Cron琛ㄨ揪寮 - * @return boolean 琛ㄨ揪寮忔槸鍚︽湁鏁 - */ - public static boolean isValid(String cronExpression) - { - return CronExpression.isValidExpression(cronExpression); - } - - /** - * 杩斿洖涓涓瓧绗︿覆鍊,琛ㄧず璇ユ秷鎭棤鏁圕ron琛ㄨ揪寮忕粰鍑烘湁鏁堟 - * - * @param cronExpression Cron琛ㄨ揪寮 - * @return String 鏃犳晥鏃惰繑鍥炶〃杈惧紡閿欒鎻忚堪,濡傛灉鏈夋晥杩斿洖null - */ - public static String getInvalidMessage(String cronExpression) - { - try - { - new CronExpression(cronExpression); - return null; - } - catch (ParseException pe) - { - return pe.getMessage(); - } - } - - /** - * 杩斿洖涓嬩竴涓墽琛屾椂闂存牴鎹粰瀹氱殑Cron琛ㄨ揪寮 - * - * @param cronExpression Cron琛ㄨ揪寮 - * @return Date 涓嬫Cron琛ㄨ揪寮忔墽琛屾椂闂 - */ - public static Date getNextExecution(String cronExpression) - { - try - { - CronExpression cron = new CronExpression(cronExpression); - return cron.getNextValidTimeAfter(new Date(System.currentTimeMillis())); - } - catch (ParseException e) - { - throw new IllegalArgumentException(e.getMessage()); - } - } -} +package com.ruoyi.quartz.util; + +import java.text.ParseException; +import java.util.Date; +import org.quartz.CronExpression; + +/** + * cron琛ㄨ揪寮忓伐鍏风被 + * + * @author ruoyi + * + */ +public class CronUtils +{ + /** + * 杩斿洖涓涓竷灏斿间唬琛ㄤ竴涓粰瀹氱殑Cron琛ㄨ揪寮忕殑鏈夋晥鎬 + * + * @param cronExpression Cron琛ㄨ揪寮 + * @return boolean 琛ㄨ揪寮忔槸鍚︽湁鏁 + */ + public static boolean isValid(String cronExpression) + { + return CronExpression.isValidExpression(cronExpression); + } + + /** + * 杩斿洖涓涓瓧绗︿覆鍊,琛ㄧず璇ユ秷鎭棤鏁圕ron琛ㄨ揪寮忕粰鍑烘湁鏁堟 + * + * @param cronExpression Cron琛ㄨ揪寮 + * @return String 鏃犳晥鏃惰繑鍥炶〃杈惧紡閿欒鎻忚堪,濡傛灉鏈夋晥杩斿洖null + */ + public static String getInvalidMessage(String cronExpression) + { + try + { + new CronExpression(cronExpression); + return null; + } + catch (ParseException pe) + { + return pe.getMessage(); + } + } + + /** + * 杩斿洖涓嬩竴涓墽琛屾椂闂存牴鎹粰瀹氱殑Cron琛ㄨ揪寮 + * + * @param cronExpression Cron琛ㄨ揪寮 + * @return Date 涓嬫Cron琛ㄨ揪寮忔墽琛屾椂闂 + */ + public static Date getNextExecution(String cronExpression) + { + try + { + CronExpression cron = new CronExpression(cronExpression); + return cron.getNextValidTimeAfter(new Date(System.currentTimeMillis())); + } + catch (ParseException e) + { + throw new IllegalArgumentException(e.getMessage()); + } + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/job/JobInvokeUtil.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java similarity index 95% rename from ruoyi/src/main/java/com/ruoyi/common/utils/job/JobInvokeUtil.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java index 1670ee536..5519c672f 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/job/JobInvokeUtil.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/JobInvokeUtil.java @@ -1,182 +1,182 @@ -package com.ruoyi.common.utils.job; - -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.LinkedList; -import java.util.List; -import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.project.monitor.domain.SysJob; - -/** - * 浠诲姟鎵ц宸ュ叿 - * - * @author ruoyi - */ -public class JobInvokeUtil -{ - /** - * 鎵ц鏂规硶 - * - * @param sysJob 绯荤粺浠诲姟 - */ - public static void invokeMethod(SysJob sysJob) throws Exception - { - String invokeTarget = sysJob.getInvokeTarget(); - String beanName = getBeanName(invokeTarget); - String methodName = getMethodName(invokeTarget); - List methodParams = getMethodParams(invokeTarget); - - if (!isValidClassName(beanName)) - { - Object bean = SpringUtils.getBean(beanName); - invokeMethod(bean, methodName, methodParams); - } - else - { - Object bean = Class.forName(beanName).newInstance(); - invokeMethod(bean, methodName, methodParams); - } - } - - /** - * 璋冪敤浠诲姟鏂规硶 - * - * @param bean 鐩爣瀵硅薄 - * @param methodName 鏂规硶鍚嶇О - * @param methodParams 鏂规硶鍙傛暟 - */ - private static void invokeMethod(Object bean, String methodName, List methodParams) - throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, - InvocationTargetException - { - if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0) - { - Method method = bean.getClass().getDeclaredMethod(methodName, getMethodParamsType(methodParams)); - method.invoke(bean, getMethodParamsValue(methodParams)); - } - else - { - Method method = bean.getClass().getDeclaredMethod(methodName); - method.invoke(bean); - } - } - - /** - * 鏍¢獙鏄惁涓轰负class鍖呭悕 - * - * @param str 鍚嶇О - * @return true鏄 false鍚 - */ - public static boolean isValidClassName(String invokeTarget) - { - return StringUtils.countMatches(invokeTarget, ".") > 1; - } - - /** - * 鑾峰彇bean鍚嶇О - * - * @param invokeTarget 鐩爣瀛楃涓 - * @return bean鍚嶇О - */ - public static String getBeanName(String invokeTarget) - { - String beanName = StringUtils.substringBefore(invokeTarget, "("); - return StringUtils.substringBeforeLast(beanName, "."); - } - - /** - * 鑾峰彇bean鏂规硶 - * - * @param invokeTarget 鐩爣瀛楃涓 - * @return method鏂规硶 - */ - public static String getMethodName(String invokeTarget) - { - String methodName = StringUtils.substringBefore(invokeTarget, "("); - return StringUtils.substringAfterLast(methodName, "."); - } - - /** - * 鑾峰彇method鏂规硶鍙傛暟鐩稿叧鍒楄〃 - * - * @param invokeTarget 鐩爣瀛楃涓 - * @return method鏂规硶鐩稿叧鍙傛暟鍒楄〃 - */ - public static List getMethodParams(String invokeTarget) - { - String methodStr = StringUtils.substringBetween(invokeTarget, "(", ")"); - if (StringUtils.isEmpty(methodStr)) - { - return null; - } - String[] methodParams = methodStr.split(","); - List classs = new LinkedList<>(); - for (int i = 0; i < methodParams.length; i++) - { - String str = StringUtils.trimToEmpty(methodParams[i]); - // String瀛楃涓茬被鍨嬶紝鍖呭惈' - if (StringUtils.contains(str, "'")) - { - classs.add(new Object[] { StringUtils.replace(str, "'", ""), String.class }); - } - // boolean甯冨皵绫诲瀷锛岀瓑浜巘rue鎴栬協alse - else if (StringUtils.equals(str, "true") || StringUtils.equalsIgnoreCase(str, "false")) - { - classs.add(new Object[] { Boolean.valueOf(str), Boolean.class }); - } - // long闀挎暣褰紝鍖呭惈L - else if (StringUtils.containsIgnoreCase(str, "L")) - { - classs.add(new Object[] { Long.valueOf(StringUtils.replaceIgnoreCase(str, "L", "")), Long.class }); - } - // double娴偣绫诲瀷锛屽寘鍚獶 - else if (StringUtils.containsIgnoreCase(str, "D")) - { - classs.add(new Object[] { Double.valueOf(StringUtils.replaceIgnoreCase(str, "D", "")), Double.class }); - } - // 鍏朵粬绫诲瀷褰掔被涓烘暣褰 - else - { - classs.add(new Object[] { Integer.valueOf(str), Integer.class }); - } - } - return classs; - } - - /** - * 鑾峰彇鍙傛暟绫诲瀷 - * - * @param methodParams 鍙傛暟鐩稿叧鍒楄〃 - * @return 鍙傛暟绫诲瀷鍒楄〃 - */ - public static Class[] getMethodParamsType(List methodParams) - { - Class[] classs = new Class[methodParams.size()]; - int index = 0; - for (Object[] os : methodParams) - { - classs[index] = (Class) os[1]; - index++; - } - return classs; - } - - /** - * 鑾峰彇鍙傛暟鍊 - * - * @param methodParams 鍙傛暟鐩稿叧鍒楄〃 - * @return 鍙傛暟鍊煎垪琛 - */ - public static Object[] getMethodParamsValue(List methodParams) - { - Object[] classs = new Object[methodParams.size()]; - int index = 0; - for (Object[] os : methodParams) - { - classs[index] = (Object) os[0]; - index++; - } - return classs; - } -} +package com.ruoyi.quartz.util; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.LinkedList; +import java.util.List; +import com.ruoyi.common.utils.StringUtils; +import com.ruoyi.common.utils.spring.SpringUtils; +import com.ruoyi.quartz.domain.SysJob; + +/** + * 浠诲姟鎵ц宸ュ叿 + * + * @author ruoyi + */ +public class JobInvokeUtil +{ + /** + * 鎵ц鏂规硶 + * + * @param sysJob 绯荤粺浠诲姟 + */ + public static void invokeMethod(SysJob sysJob) throws Exception + { + String invokeTarget = sysJob.getInvokeTarget(); + String beanName = getBeanName(invokeTarget); + String methodName = getMethodName(invokeTarget); + List methodParams = getMethodParams(invokeTarget); + + if (!isValidClassName(beanName)) + { + Object bean = SpringUtils.getBean(beanName); + invokeMethod(bean, methodName, methodParams); + } + else + { + Object bean = Class.forName(beanName).newInstance(); + invokeMethod(bean, methodName, methodParams); + } + } + + /** + * 璋冪敤浠诲姟鏂规硶 + * + * @param bean 鐩爣瀵硅薄 + * @param methodName 鏂规硶鍚嶇О + * @param methodParams 鏂规硶鍙傛暟 + */ + private static void invokeMethod(Object bean, String methodName, List methodParams) + throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, + InvocationTargetException + { + if (StringUtils.isNotNull(methodParams) && methodParams.size() > 0) + { + Method method = bean.getClass().getDeclaredMethod(methodName, getMethodParamsType(methodParams)); + method.invoke(bean, getMethodParamsValue(methodParams)); + } + else + { + Method method = bean.getClass().getDeclaredMethod(methodName); + method.invoke(bean); + } + } + + /** + * 鏍¢獙鏄惁涓轰负class鍖呭悕 + * + * @param str 鍚嶇О + * @return true鏄 false鍚 + */ + public static boolean isValidClassName(String invokeTarget) + { + return StringUtils.countMatches(invokeTarget, ".") > 1; + } + + /** + * 鑾峰彇bean鍚嶇О + * + * @param invokeTarget 鐩爣瀛楃涓 + * @return bean鍚嶇О + */ + public static String getBeanName(String invokeTarget) + { + String beanName = StringUtils.substringBefore(invokeTarget, "("); + return StringUtils.substringBeforeLast(beanName, "."); + } + + /** + * 鑾峰彇bean鏂规硶 + * + * @param invokeTarget 鐩爣瀛楃涓 + * @return method鏂规硶 + */ + public static String getMethodName(String invokeTarget) + { + String methodName = StringUtils.substringBefore(invokeTarget, "("); + return StringUtils.substringAfterLast(methodName, "."); + } + + /** + * 鑾峰彇method鏂规硶鍙傛暟鐩稿叧鍒楄〃 + * + * @param invokeTarget 鐩爣瀛楃涓 + * @return method鏂规硶鐩稿叧鍙傛暟鍒楄〃 + */ + public static List getMethodParams(String invokeTarget) + { + String methodStr = StringUtils.substringBetween(invokeTarget, "(", ")"); + if (StringUtils.isEmpty(methodStr)) + { + return null; + } + String[] methodParams = methodStr.split(","); + List classs = new LinkedList<>(); + for (int i = 0; i < methodParams.length; i++) + { + String str = StringUtils.trimToEmpty(methodParams[i]); + // String瀛楃涓茬被鍨嬶紝鍖呭惈' + if (StringUtils.contains(str, "'")) + { + classs.add(new Object[] { StringUtils.replace(str, "'", ""), String.class }); + } + // boolean甯冨皵绫诲瀷锛岀瓑浜巘rue鎴栬協alse + else if (StringUtils.equals(str, "true") || StringUtils.equalsIgnoreCase(str, "false")) + { + classs.add(new Object[] { Boolean.valueOf(str), Boolean.class }); + } + // long闀挎暣褰紝鍖呭惈L + else if (StringUtils.containsIgnoreCase(str, "L")) + { + classs.add(new Object[] { Long.valueOf(StringUtils.replaceIgnoreCase(str, "L", "")), Long.class }); + } + // double娴偣绫诲瀷锛屽寘鍚獶 + else if (StringUtils.containsIgnoreCase(str, "D")) + { + classs.add(new Object[] { Double.valueOf(StringUtils.replaceIgnoreCase(str, "D", "")), Double.class }); + } + // 鍏朵粬绫诲瀷褰掔被涓烘暣褰 + else + { + classs.add(new Object[] { Integer.valueOf(str), Integer.class }); + } + } + return classs; + } + + /** + * 鑾峰彇鍙傛暟绫诲瀷 + * + * @param methodParams 鍙傛暟鐩稿叧鍒楄〃 + * @return 鍙傛暟绫诲瀷鍒楄〃 + */ + public static Class[] getMethodParamsType(List methodParams) + { + Class[] classs = new Class[methodParams.size()]; + int index = 0; + for (Object[] os : methodParams) + { + classs[index] = (Class) os[1]; + index++; + } + return classs; + } + + /** + * 鑾峰彇鍙傛暟鍊 + * + * @param methodParams 鍙傛暟鐩稿叧鍒楄〃 + * @return 鍙傛暟鍊煎垪琛 + */ + public static Object[] getMethodParamsValue(List methodParams) + { + Object[] classs = new Object[methodParams.size()]; + int index = 0; + for (Object[] os : methodParams) + { + classs[index] = (Object) os[0]; + index++; + } + return classs; + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/job/QuartzDisallowConcurrentExecution.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java similarity index 82% rename from ruoyi/src/main/java/com/ruoyi/common/utils/job/QuartzDisallowConcurrentExecution.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java index 709708839..96a6dcf8e 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/job/QuartzDisallowConcurrentExecution.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzDisallowConcurrentExecution.java @@ -1,21 +1,21 @@ -package com.ruoyi.common.utils.job; - -import org.quartz.DisallowConcurrentExecution; -import org.quartz.JobExecutionContext; -import com.ruoyi.project.monitor.domain.SysJob; - -/** - * 瀹氭椂浠诲姟澶勭悊锛堢姝㈠苟鍙戞墽琛岋級 - * - * @author ruoyi - * - */ -@DisallowConcurrentExecution -public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob -{ - @Override - protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception - { - JobInvokeUtil.invokeMethod(sysJob); - } -} +package com.ruoyi.quartz.util; + +import org.quartz.DisallowConcurrentExecution; +import org.quartz.JobExecutionContext; +import com.ruoyi.quartz.domain.SysJob; + +/** + * 瀹氭椂浠诲姟澶勭悊锛堢姝㈠苟鍙戞墽琛岋級 + * + * @author ruoyi + * + */ +@DisallowConcurrentExecution +public class QuartzDisallowConcurrentExecution extends AbstractQuartzJob +{ + @Override + protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception + { + JobInvokeUtil.invokeMethod(sysJob); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/job/QuartzJobExecution.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java similarity index 79% rename from ruoyi/src/main/java/com/ruoyi/common/utils/job/QuartzJobExecution.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java index 55aa7e040..87a06bc13 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/job/QuartzJobExecution.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/QuartzJobExecution.java @@ -1,19 +1,19 @@ -package com.ruoyi.common.utils.job; - -import org.quartz.JobExecutionContext; -import com.ruoyi.project.monitor.domain.SysJob; - -/** - * 瀹氭椂浠诲姟澶勭悊锛堝厑璁稿苟鍙戞墽琛岋級 - * - * @author ruoyi - * - */ -public class QuartzJobExecution extends AbstractQuartzJob -{ - @Override - protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception - { - JobInvokeUtil.invokeMethod(sysJob); - } -} +package com.ruoyi.quartz.util; + +import org.quartz.JobExecutionContext; +import com.ruoyi.quartz.domain.SysJob; + +/** + * 瀹氭椂浠诲姟澶勭悊锛堝厑璁稿苟鍙戞墽琛岋級 + * + * @author ruoyi + * + */ +public class QuartzJobExecution extends AbstractQuartzJob +{ + @Override + protected void doExecute(JobExecutionContext context, SysJob sysJob) throws Exception + { + JobInvokeUtil.invokeMethod(sysJob); + } +} diff --git a/ruoyi/src/main/java/com/ruoyi/common/utils/job/ScheduleUtils.java b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java similarity index 95% rename from ruoyi/src/main/java/com/ruoyi/common/utils/job/ScheduleUtils.java rename to ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java index 3e107c695..37fe72e04 100644 --- a/ruoyi/src/main/java/com/ruoyi/common/utils/job/ScheduleUtils.java +++ b/ruoyi-quartz/src/main/java/com/ruoyi/quartz/util/ScheduleUtils.java @@ -1,113 +1,113 @@ -package com.ruoyi.common.utils.job; - -import org.quartz.CronScheduleBuilder; -import org.quartz.CronTrigger; -import org.quartz.Job; -import org.quartz.JobBuilder; -import org.quartz.JobDetail; -import org.quartz.JobKey; -import org.quartz.Scheduler; -import org.quartz.SchedulerException; -import org.quartz.TriggerBuilder; -import org.quartz.TriggerKey; -import com.ruoyi.common.constant.ScheduleConstants; -import com.ruoyi.common.exception.job.TaskException; -import com.ruoyi.common.exception.job.TaskException.Code; -import com.ruoyi.project.monitor.domain.SysJob; - -/** - * 瀹氭椂浠诲姟宸ュ叿绫 - * - * @author ruoyi - * - */ -public class ScheduleUtils -{ - /** - * 寰楀埌quartz浠诲姟绫 - * - * @param sysJob 鎵ц璁″垝 - * @return 鍏蜂綋鎵ц浠诲姟绫 - */ - private static Class getQuartzJobClass(SysJob sysJob) - { - boolean isConcurrent = "0".equals(sysJob.getConcurrent()); - return isConcurrent ? QuartzJobExecution.class : QuartzDisallowConcurrentExecution.class; - } - - /** - * 鏋勫缓浠诲姟瑙﹀彂瀵硅薄 - */ - public static TriggerKey getTriggerKey(Long jobId, String jobGroup) - { - return TriggerKey.triggerKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); - } - - /** - * 鏋勫缓浠诲姟閿璞 - */ - public static JobKey getJobKey(Long jobId, String jobGroup) - { - return JobKey.jobKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); - } - - /** - * 鍒涘缓瀹氭椂浠诲姟 - */ - public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException - { - Class jobClass = getQuartzJobClass(job); - // 鏋勫缓job淇℃伅 - Long jobId = job.getJobId(); - String jobGroup = job.getJobGroup(); - JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build(); - - // 琛ㄨ揪寮忚皟搴︽瀯寤哄櫒 - CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression()); - cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder); - - // 鎸夋柊鐨刢ronExpression琛ㄨ揪寮忔瀯寤轰竴涓柊鐨則rigger - CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(jobId, jobGroup)) - .withSchedule(cronScheduleBuilder).build(); - - // 鏀惧叆鍙傛暟锛岃繍琛屾椂鐨勬柟娉曞彲浠ヨ幏鍙 - jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job); - - // 鍒ゆ柇鏄惁瀛樺湪 - if (scheduler.checkExists(getJobKey(jobId, jobGroup))) - { - // 闃叉鍒涘缓鏃跺瓨鍦ㄦ暟鎹棶棰 鍏堢Щ闄わ紝鐒跺悗鍦ㄦ墽琛屽垱寤烘搷浣 - scheduler.deleteJob(getJobKey(jobId, jobGroup)); - } - - scheduler.scheduleJob(jobDetail, trigger); - - // 鏆傚仠浠诲姟 - if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue())) - { - scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); - } - } - - /** - * 璁剧疆瀹氭椂浠诲姟绛栫暐 - */ - public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb) - throws TaskException - { - switch (job.getMisfirePolicy()) - { - case ScheduleConstants.MISFIRE_DEFAULT: - return cb; - case ScheduleConstants.MISFIRE_IGNORE_MISFIRES: - return cb.withMisfireHandlingInstructionIgnoreMisfires(); - case ScheduleConstants.MISFIRE_FIRE_AND_PROCEED: - return cb.withMisfireHandlingInstructionFireAndProceed(); - case ScheduleConstants.MISFIRE_DO_NOTHING: - return cb.withMisfireHandlingInstructionDoNothing(); - default: - throw new TaskException("The task misfire policy '" + job.getMisfirePolicy() - + "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR); - } - } -} \ No newline at end of file +package com.ruoyi.quartz.util; + +import org.quartz.CronScheduleBuilder; +import org.quartz.CronTrigger; +import org.quartz.Job; +import org.quartz.JobBuilder; +import org.quartz.JobDetail; +import org.quartz.JobKey; +import org.quartz.Scheduler; +import org.quartz.SchedulerException; +import org.quartz.TriggerBuilder; +import org.quartz.TriggerKey; +import com.ruoyi.common.constant.ScheduleConstants; +import com.ruoyi.common.exception.job.TaskException; +import com.ruoyi.common.exception.job.TaskException.Code; +import com.ruoyi.quartz.domain.SysJob; + +/** + * 瀹氭椂浠诲姟宸ュ叿绫 + * + * @author ruoyi + * + */ +public class ScheduleUtils +{ + /** + * 寰楀埌quartz浠诲姟绫 + * + * @param sysJob 鎵ц璁″垝 + * @return 鍏蜂綋鎵ц浠诲姟绫 + */ + private static Class getQuartzJobClass(SysJob sysJob) + { + boolean isConcurrent = "0".equals(sysJob.getConcurrent()); + return isConcurrent ? QuartzJobExecution.class : QuartzDisallowConcurrentExecution.class; + } + + /** + * 鏋勫缓浠诲姟瑙﹀彂瀵硅薄 + */ + public static TriggerKey getTriggerKey(Long jobId, String jobGroup) + { + return TriggerKey.triggerKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); + } + + /** + * 鏋勫缓浠诲姟閿璞 + */ + public static JobKey getJobKey(Long jobId, String jobGroup) + { + return JobKey.jobKey(ScheduleConstants.TASK_CLASS_NAME + jobId, jobGroup); + } + + /** + * 鍒涘缓瀹氭椂浠诲姟 + */ + public static void createScheduleJob(Scheduler scheduler, SysJob job) throws SchedulerException, TaskException + { + Class jobClass = getQuartzJobClass(job); + // 鏋勫缓job淇℃伅 + Long jobId = job.getJobId(); + String jobGroup = job.getJobGroup(); + JobDetail jobDetail = JobBuilder.newJob(jobClass).withIdentity(getJobKey(jobId, jobGroup)).build(); + + // 琛ㄨ揪寮忚皟搴︽瀯寤哄櫒 + CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression()); + cronScheduleBuilder = handleCronScheduleMisfirePolicy(job, cronScheduleBuilder); + + // 鎸夋柊鐨刢ronExpression琛ㄨ揪寮忔瀯寤轰竴涓柊鐨則rigger + CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(getTriggerKey(jobId, jobGroup)) + .withSchedule(cronScheduleBuilder).build(); + + // 鏀惧叆鍙傛暟锛岃繍琛屾椂鐨勬柟娉曞彲浠ヨ幏鍙 + jobDetail.getJobDataMap().put(ScheduleConstants.TASK_PROPERTIES, job); + + // 鍒ゆ柇鏄惁瀛樺湪 + if (scheduler.checkExists(getJobKey(jobId, jobGroup))) + { + // 闃叉鍒涘缓鏃跺瓨鍦ㄦ暟鎹棶棰 鍏堢Щ闄わ紝鐒跺悗鍦ㄦ墽琛屽垱寤烘搷浣 + scheduler.deleteJob(getJobKey(jobId, jobGroup)); + } + + scheduler.scheduleJob(jobDetail, trigger); + + // 鏆傚仠浠诲姟 + if (job.getStatus().equals(ScheduleConstants.Status.PAUSE.getValue())) + { + scheduler.pauseJob(ScheduleUtils.getJobKey(jobId, jobGroup)); + } + } + + /** + * 璁剧疆瀹氭椂浠诲姟绛栫暐 + */ + public static CronScheduleBuilder handleCronScheduleMisfirePolicy(SysJob job, CronScheduleBuilder cb) + throws TaskException + { + switch (job.getMisfirePolicy()) + { + case ScheduleConstants.MISFIRE_DEFAULT: + return cb; + case ScheduleConstants.MISFIRE_IGNORE_MISFIRES: + return cb.withMisfireHandlingInstructionIgnoreMisfires(); + case ScheduleConstants.MISFIRE_FIRE_AND_PROCEED: + return cb.withMisfireHandlingInstructionFireAndProceed(); + case ScheduleConstants.MISFIRE_DO_NOTHING: + return cb.withMisfireHandlingInstructionDoNothing(); + default: + throw new TaskException("The task misfire policy '" + job.getMisfirePolicy() + + "' cannot be used in cron schedule tasks", Code.CONFIG_ERROR); + } + } +} diff --git a/ruoyi/src/main/resources/mybatis/system/SysJobLogMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml similarity index 95% rename from ruoyi/src/main/resources/mybatis/system/SysJobLogMapper.xml rename to ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml index bf8157543..7601e63d9 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysJobLogMapper.xml +++ b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobLogMapper.xml @@ -1,93 +1,93 @@ - - - - - - - - - - - - - - - - - select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time - from sys_job_log - - - - - - - - - - delete from sys_job_log where job_log_id = #{jobLogId} - - - - delete from sys_job_log where job_log_id in - - #{jobLogId} - - - - - truncate table sys_job_log - - - - insert into sys_job_log( - job_log_id, - job_name, - job_group, - invoke_target, - job_message, - status, - exception_info, - create_time - )values( - #{jobLogId}, - #{jobName}, - #{jobGroup}, - #{invokeTarget}, - #{jobMessage}, - #{status}, - #{exceptionInfo}, - sysdate() - ) - - + + + + + + + + + + + + + + + + + select job_log_id, job_name, job_group, invoke_target, job_message, status, exception_info, create_time + from sys_job_log + + + + + + + + + + delete from sys_job_log where job_log_id = #{jobLogId} + + + + delete from sys_job_log where job_log_id in + + #{jobLogId} + + + + + truncate table sys_job_log + + + + insert into sys_job_log( + job_log_id, + job_name, + job_group, + invoke_target, + job_message, + status, + exception_info, + create_time + )values( + #{jobLogId}, + #{jobName}, + #{jobGroup}, + #{invokeTarget}, + #{jobMessage}, + #{status}, + #{exceptionInfo}, + sysdate() + ) + + \ No newline at end of file diff --git a/ruoyi/src/main/resources/mybatis/system/SysJobMapper.xml b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml similarity index 96% rename from ruoyi/src/main/resources/mybatis/system/SysJobMapper.xml rename to ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml index 47f61c964..69233bdf7 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysJobMapper.xml +++ b/ruoyi-quartz/src/main/resources/mapper/quartz/SysJobMapper.xml @@ -1,111 +1,111 @@ - - - - - - - - - - - - - - - - - - - - - - select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark - from sys_job - - - - - - - - - - delete from sys_job where job_id = #{jobId} - - - - delete from sys_job where job_id in - - #{jobId} - - - - - update sys_job - - job_name = #{jobName}, - job_group = #{jobGroup}, - invoke_target = #{invokeTarget}, - cron_expression = #{cronExpression}, - misfire_policy = #{misfirePolicy}, - concurrent = #{concurrent}, - status = #{status}, - remark = #{remark}, - update_by = #{updateBy}, - update_time = sysdate() - - where job_id = #{jobId} - - - - insert into sys_job( - job_id, - job_name, - job_group, - invoke_target, - cron_expression, - misfire_policy, - concurrent, - status, - remark, - create_by, - create_time - )values( - #{jobId}, - #{jobName}, - #{jobGroup}, - #{invokeTarget}, - #{cronExpression}, - #{misfirePolicy}, - #{concurrent}, - #{status}, - #{remark}, - #{createBy}, - sysdate() - ) - - + + + + + + + + + + + + + + + + + + + + + + select job_id, job_name, job_group, invoke_target, cron_expression, misfire_policy, concurrent, status, create_by, create_time, remark + from sys_job + + + + + + + + + + delete from sys_job where job_id = #{jobId} + + + + delete from sys_job where job_id in + + #{jobId} + + + + + update sys_job + + job_name = #{jobName}, + job_group = #{jobGroup}, + invoke_target = #{invokeTarget}, + cron_expression = #{cronExpression}, + misfire_policy = #{misfirePolicy}, + concurrent = #{concurrent}, + status = #{status}, + remark = #{remark}, + update_by = #{updateBy}, + update_time = sysdate() + + where job_id = #{jobId} + + + + insert into sys_job( + job_id, + job_name, + job_group, + invoke_target, + cron_expression, + misfire_policy, + concurrent, + status, + remark, + create_by, + create_time + )values( + #{jobId}, + #{jobName}, + #{jobGroup}, + #{invokeTarget}, + #{cronExpression}, + #{misfirePolicy}, + #{concurrent}, + #{status}, + #{remark}, + #{createBy}, + sysdate() + ) + + \ No newline at end of file diff --git a/ruoyi-system/pom.xml b/ruoyi-system/pom.xml new file mode 100644 index 000000000..ebcee00c6 --- /dev/null +++ b/ruoyi-system/pom.xml @@ -0,0 +1,28 @@ + + + + ruoyi + com.ruoyi + 3.0.0 + + 4.0.0 + + ruoyi-system + + + system绯荤粺妯″潡 + + + + + + + com.ruoyi + ruoyi-common + + + + + \ No newline at end of file diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysConfig.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysConfig.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/system/domain/SysConfig.java rename to ruoyi-system/src/main/java/com/ruoyi/system/domain/SysConfig.java index ba1c0220b..676a8916b 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysConfig.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysConfig.java @@ -1,12 +1,12 @@ -package com.ruoyi.project.system.domain; +package com.ruoyi.system.domain; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.framework.aspectj.lang.annotation.Excel; -import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType; -import com.ruoyi.framework.web.domain.BaseEntity; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.core.domain.BaseEntity; /** * 鍙傛暟閰嶇疆琛 sys_config diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysLogininfor.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java similarity index 87% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysLogininfor.java rename to ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java index cea9373d4..02a7fb5c0 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysLogininfor.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysLogininfor.java @@ -1,10 +1,10 @@ -package com.ruoyi.project.monitor.domain; +package com.ruoyi.system.domain; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; -import com.ruoyi.framework.aspectj.lang.annotation.Excel; -import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType; -import com.ruoyi.framework.web.domain.BaseEntity; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.core.domain.BaseEntity; /** * 绯荤粺璁块棶璁板綍琛 sys_logininfor @@ -141,4 +141,4 @@ public class SysLogininfor extends BaseEntity { this.loginTime = loginTime; } -} \ No newline at end of file +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysNotice.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/project/system/domain/SysNotice.java rename to ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java index 916fd320f..cb739dc41 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysNotice.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysNotice.java @@ -1,10 +1,10 @@ -package com.ruoyi.project.system.domain; +package com.ruoyi.system.domain; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.framework.web.domain.BaseEntity; +import com.ruoyi.common.core.domain.BaseEntity; /** * 閫氱煡鍏憡琛 sys_notice diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysOperLog.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysOperLog.java rename to ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java index 71d77fa83..4110b8aca 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysOperLog.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysOperLog.java @@ -1,10 +1,10 @@ -package com.ruoyi.project.monitor.domain; +package com.ruoyi.system.domain; import java.util.Date; import com.fasterxml.jackson.annotation.JsonFormat; -import com.ruoyi.framework.aspectj.lang.annotation.Excel; -import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType; -import com.ruoyi.framework.web.domain.BaseEntity; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.core.domain.BaseEntity; /** * 鎿嶄綔鏃ュ織璁板綍琛 oper_log diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysPost.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/system/domain/SysPost.java rename to ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java index ebafe7d9b..1e7556b8d 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysPost.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysPost.java @@ -1,12 +1,12 @@ -package com.ruoyi.project.system.domain; +package com.ruoyi.system.domain; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Size; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; -import com.ruoyi.framework.aspectj.lang.annotation.Excel; -import com.ruoyi.framework.aspectj.lang.annotation.Excel.ColumnType; -import com.ruoyi.framework.web.domain.BaseEntity; +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.annotation.Excel.ColumnType; +import com.ruoyi.common.core.domain.BaseEntity; /** * 宀椾綅琛 sys_post diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysRoleDept.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleDept.java similarity index 90% rename from ruoyi/src/main/java/com/ruoyi/project/system/domain/SysRoleDept.java rename to ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleDept.java index f3dbd03c8..8ed8e473e 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysRoleDept.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleDept.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.domain; +package com.ruoyi.system.domain; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysRoleMenu.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleMenu.java similarity index 90% rename from ruoyi/src/main/java/com/ruoyi/project/system/domain/SysRoleMenu.java rename to ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleMenu.java index 54452296f..59d286999 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysRoleMenu.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysRoleMenu.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.domain; +package com.ruoyi.system.domain; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysUserOnline.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserOnline.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysUserOnline.java rename to ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserOnline.java index 843148b4e..e1495aaa7 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/domain/SysUserOnline.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserOnline.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.monitor.domain; +package com.ruoyi.system.domain; /** * 褰撳墠鍦ㄧ嚎浼氳瘽 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysUserPost.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserPost.java similarity index 90% rename from ruoyi/src/main/java/com/ruoyi/project/system/domain/SysUserPost.java rename to ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserPost.java index 1ac4bfc4b..07ceb85cc 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysUserPost.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserPost.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.domain; +package com.ruoyi.system.domain; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysUserRole.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserRole.java similarity index 90% rename from ruoyi/src/main/java/com/ruoyi/project/system/domain/SysUserRole.java rename to ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserRole.java index e951bf3de..ce2af2bda 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/SysUserRole.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/SysUserRole.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.domain; +package com.ruoyi.system.domain; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/vo/MetaVo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/MetaVo.java similarity index 88% rename from ruoyi/src/main/java/com/ruoyi/project/system/domain/vo/MetaVo.java rename to ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/MetaVo.java index 118d2fa41..e83ef10c0 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/vo/MetaVo.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/MetaVo.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.domain.vo; +package com.ruoyi.system.domain.vo; /** * 璺敱鏄剧ず淇℃伅 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/domain/vo/RouterVo.java b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RouterVo.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/project/system/domain/vo/RouterVo.java rename to ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RouterVo.java index f81fc0bb0..21ff6b59a 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/domain/vo/RouterVo.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/domain/vo/RouterVo.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.domain.vo; +package com.ruoyi.system.domain.vo; import com.fasterxml.jackson.annotation.JsonInclude; import java.util.List; diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysConfigMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysConfigMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java index eea48d60e..0c395f65b 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysConfigMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysConfigMapper.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.system.mapper; +package com.ruoyi.system.mapper; import java.util.List; -import com.ruoyi.project.system.domain.SysConfig; +import com.ruoyi.system.domain.SysConfig; /** * 鍙傛暟閰嶇疆 鏁版嵁灞 @@ -65,4 +65,4 @@ public interface SysConfigMapper * @return 缁撴灉 */ public int deleteConfigByIds(Long[] configIds); -} \ No newline at end of file +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDeptMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDeptMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java index 113db2963..6261a873a 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDeptMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDeptMapper.java @@ -1,8 +1,8 @@ -package com.ruoyi.project.system.mapper; +package com.ruoyi.system.mapper; import java.util.List; import org.apache.ibatis.annotations.Param; -import com.ruoyi.project.system.domain.SysDept; +import com.ruoyi.common.core.domain.entity.SysDept; /** * 閮ㄩ棬绠$悊 鏁版嵁灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDictDataMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDictDataMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java index c938d884f..92f799e55 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDictDataMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictDataMapper.java @@ -1,8 +1,8 @@ -package com.ruoyi.project.system.mapper; +package com.ruoyi.system.mapper; import java.util.List; import org.apache.ibatis.annotations.Param; -import com.ruoyi.project.system.domain.SysDictData; +import com.ruoyi.common.core.domain.entity.SysDictData; /** * 瀛楀吀琛 鏁版嵁灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDictTypeMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java similarity index 90% rename from ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDictTypeMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java index 8a71574fd..81bc78090 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysDictTypeMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysDictTypeMapper.java @@ -1,8 +1,8 @@ -package com.ruoyi.project.system.mapper; +package com.ruoyi.system.mapper; import java.util.List; import org.apache.ibatis.annotations.Mapper; -import com.ruoyi.project.system.domain.SysDictType; +import com.ruoyi.common.core.domain.entity.SysDictType; /** * 瀛楀吀琛 鏁版嵁灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysLogininforMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java similarity index 85% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysLogininforMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java index 707fed1fc..480dd9ff6 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysLogininforMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysLogininforMapper.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.monitor.mapper; +package com.ruoyi.system.mapper; import java.util.List; -import com.ruoyi.project.monitor.domain.SysLogininfor; +import com.ruoyi.system.domain.SysLogininfor; /** * 绯荤粺璁块棶鏃ュ織鎯呭喌淇℃伅 鏁版嵁灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysMenuMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysMenuMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java index fc4608526..907c613f2 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysMenuMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysMenuMapper.java @@ -1,8 +1,8 @@ -package com.ruoyi.project.system.mapper; +package com.ruoyi.system.mapper; import java.util.List; import org.apache.ibatis.annotations.Param; -import com.ruoyi.project.system.domain.SysMenu; +import com.ruoyi.common.core.domain.entity.SysMenu; /** * 鑿滃崟琛 鏁版嵁灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java similarity index 87% rename from ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java index 3a9370fd9..cc267ac0c 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysNoticeMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysNoticeMapper.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.system.mapper; +package com.ruoyi.system.mapper; import java.util.List; -import com.ruoyi.project.system.domain.SysNotice; +import com.ruoyi.system.domain.SysNotice; /** * 閫氱煡鍏憡琛 鏁版嵁灞 @@ -57,4 +57,4 @@ public interface SysNoticeMapper * @return 缁撴灉 */ public int deleteNoticeByIds(Long[] noticeIds); -} \ No newline at end of file +} diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysOperLogMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java similarity index 86% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysOperLogMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java index 25b1904ab..3bf69bb8e 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/mapper/SysOperLogMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysOperLogMapper.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.monitor.mapper; +package com.ruoyi.system.mapper; import java.util.List; -import com.ruoyi.project.monitor.domain.SysOperLog; +import com.ruoyi.system.domain.SysOperLog; /** * 鎿嶄綔鏃ュ織 鏁版嵁灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysPostMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysPostMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java index 2cb34f788..a98326f8b 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysPostMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysPostMapper.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.system.mapper; +package com.ruoyi.system.mapper; import java.util.List; -import com.ruoyi.project.system.domain.SysPost; +import com.ruoyi.system.domain.SysPost; /** * 宀椾綅淇℃伅 鏁版嵁灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysRoleDeptMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java similarity index 86% rename from ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysRoleDeptMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java index fd4d6bd5c..a4ad4de24 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysRoleDeptMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleDeptMapper.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.system.mapper; +package com.ruoyi.system.mapper; import java.util.List; -import com.ruoyi.project.system.domain.SysRoleDept; +import com.ruoyi.system.domain.SysRoleDept; /** * 瑙掕壊涓庨儴闂ㄥ叧鑱旇〃 鏁版嵁灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysRoleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysRoleMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java index 200bb1ebe..e4379c97b 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysRoleMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMapper.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.system.mapper; +package com.ruoyi.system.mapper; import java.util.List; -import com.ruoyi.project.system.domain.SysRole; +import com.ruoyi.common.core.domain.entity.SysRole; /** * 瑙掕壊琛 鏁版嵁灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysRoleMenuMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java similarity index 83% rename from ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysRoleMenuMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java index 8d2e37682..99de1dece 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysRoleMenuMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysRoleMenuMapper.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.system.mapper; +package com.ruoyi.system.mapper; import java.util.List; -import com.ruoyi.project.system.domain.SysRoleMenu; +import com.ruoyi.system.domain.SysRoleMenu; /** * 瑙掕壊涓庤彍鍗曞叧鑱旇〃 鏁版嵁灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java index bb073350f..b9937f399 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysUserMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserMapper.java @@ -1,10 +1,8 @@ -package com.ruoyi.project.system.mapper; +package com.ruoyi.system.mapper; import java.util.List; - import org.apache.ibatis.annotations.Param; - -import com.ruoyi.project.system.domain.SysUser; +import com.ruoyi.common.core.domain.entity.SysUser; /** * 鐢ㄦ埛琛 鏁版嵁灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysUserPostMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java similarity index 86% rename from ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysUserPostMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java index d67f4032e..9c33e546d 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysUserPostMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserPostMapper.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.system.mapper; +package com.ruoyi.system.mapper; import java.util.List; -import com.ruoyi.project.system.domain.SysUserPost; +import com.ruoyi.system.domain.SysUserPost; /** * 鐢ㄦ埛涓庡矖浣嶅叧鑱旇〃 鏁版嵁灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysUserRoleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysUserRoleMapper.java rename to ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java index 614538db4..ad3fe62c1 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/mapper/SysUserRoleMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/mapper/SysUserRoleMapper.java @@ -1,8 +1,8 @@ -package com.ruoyi.project.system.mapper; +package com.ruoyi.system.mapper; import java.util.List; import org.apache.ibatis.annotations.Param; -import com.ruoyi.project.system.domain.SysUserRole; +import com.ruoyi.system.domain.SysUserRole; /** * 鐢ㄦ埛涓庤鑹插叧鑱旇〃 鏁版嵁灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysConfigService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/ISysConfigService.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java index 4d95ee7e9..a937e8308 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysConfigService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysConfigService.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.system.service; +package com.ruoyi.system.service; import java.util.List; -import com.ruoyi.project.system.domain.SysConfig; +import com.ruoyi.system.domain.SysConfig; /** * 鍙傛暟閰嶇疆 鏈嶅姟灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDeptService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDeptService.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java index 5f59b8ad5..e3850cf22 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDeptService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDeptService.java @@ -1,8 +1,8 @@ -package com.ruoyi.project.system.service; +package com.ruoyi.system.service; import java.util.List; -import com.ruoyi.framework.web.domain.TreeSelect; -import com.ruoyi.project.system.domain.SysDept; +import com.ruoyi.common.core.domain.TreeSelect; +import com.ruoyi.common.core.domain.entity.SysDept; /** * 閮ㄩ棬绠$悊 鏈嶅姟灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictDataService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictDataService.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java index 65693d119..5fe8956be 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictDataService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictDataService.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.system.service; +package com.ruoyi.system.service; import java.util.List; -import com.ruoyi.project.system.domain.SysDictData; +import com.ruoyi.common.core.domain.entity.SysDictData; /** * 瀛楀吀 涓氬姟灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictTypeService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java similarity index 88% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictTypeService.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java index c6708d32e..3603d896d 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysDictTypeService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java @@ -1,8 +1,8 @@ -package com.ruoyi.project.system.service; +package com.ruoyi.system.service; import java.util.List; -import com.ruoyi.project.system.domain.SysDictData; -import com.ruoyi.project.system.domain.SysDictType; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.domain.entity.SysDictType; /** * 瀛楀吀 涓氬姟灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysLogininforService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java similarity index 85% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysLogininforService.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java index f46dddfad..f77aaa7e1 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysLogininforService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysLogininforService.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.monitor.service; +package com.ruoyi.system.service; import java.util.List; -import com.ruoyi.project.monitor.domain.SysLogininfor; +import com.ruoyi.system.domain.SysLogininfor; /** * 绯荤粺璁块棶鏃ュ織鎯呭喌淇℃伅 鏈嶅姟灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysMenuService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/ISysMenuService.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java index 95f49aea1..78553d59d 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysMenuService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysMenuService.java @@ -1,10 +1,10 @@ -package com.ruoyi.project.system.service; +package com.ruoyi.system.service; import java.util.List; import java.util.Set; -import com.ruoyi.framework.web.domain.TreeSelect; -import com.ruoyi.project.system.domain.SysMenu; -import com.ruoyi.project.system.domain.vo.RouterVo; +import com.ruoyi.common.core.domain.TreeSelect; +import com.ruoyi.common.core.domain.entity.SysMenu; +import com.ruoyi.system.domain.vo.RouterVo; /** * 鑿滃崟 涓氬姟灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java similarity index 87% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java index 98bd8902e..fb1e420fd 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysNoticeService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysNoticeService.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.system.service; +package com.ruoyi.system.service; import java.util.List; -import com.ruoyi.project.system.domain.SysNotice; +import com.ruoyi.system.domain.SysNotice; /** * 鍏憡 鏈嶅姟灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysOperLogService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java similarity index 86% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysOperLogService.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java index 3e062acde..241f121ae 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/ISysOperLogService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysOperLogService.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.monitor.service; +package com.ruoyi.system.service; import java.util.List; -import com.ruoyi.project.monitor.domain.SysOperLog; +import com.ruoyi.system.domain.SysOperLog; /** * 鎿嶄綔鏃ュ織 鏈嶅姟灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysPostService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java similarity index 91% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/ISysPostService.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java index 5696e0835..2fb9a540d 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysPostService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysPostService.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.system.service; +package com.ruoyi.system.service; import java.util.List; -import com.ruoyi.project.system.domain.SysPost; +import com.ruoyi.system.domain.SysPost; /** * 宀椾綅淇℃伅 鏈嶅姟灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysRoleService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/ISysRoleService.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java index fbd561728..4a4bee261 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysRoleService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysRoleService.java @@ -1,8 +1,8 @@ -package com.ruoyi.project.system.service; +package com.ruoyi.system.service; import java.util.List; import java.util.Set; -import com.ruoyi.project.system.domain.SysRole; +import com.ruoyi.common.core.domain.entity.SysRole; /** * 瑙掕壊涓氬姟灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysUserOnlineService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserOnlineService.java similarity index 84% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/ISysUserOnlineService.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserOnlineService.java index 63a4a3a12..12095ff5e 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysUserOnlineService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserOnlineService.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.system.service; +package com.ruoyi.system.service; -import com.ruoyi.framework.security.LoginUser; -import com.ruoyi.project.monitor.domain.SysUserOnline; +import com.ruoyi.common.core.domain.model.LoginUser; +import com.ruoyi.system.domain.SysUserOnline; /** * 鍦ㄧ嚎鐢ㄦ埛 鏈嶅姟灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysUserService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java similarity index 93% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/ISysUserService.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java index 3b79a1d9a..00afa0011 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/ISysUserService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysUserService.java @@ -1,7 +1,7 @@ -package com.ruoyi.project.system.service; +package com.ruoyi.system.service; import java.util.List; -import com.ruoyi.project.system.domain.SysUser; +import com.ruoyi.common.core.domain.entity.SysUser; /** * 鐢ㄦ埛 涓氬姟灞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysConfigServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysConfigServiceImpl.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java index 88f5475d6..1c113fa92 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysConfigServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysConfigServiceImpl.java @@ -1,18 +1,20 @@ -package com.ruoyi.project.system.service.impl; +package com.ruoyi.system.service.impl; import java.util.Collection; import java.util.List; import javax.annotation.PostConstruct; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.ruoyi.common.annotation.DataSource; import com.ruoyi.common.constant.Constants; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.enums.DataSourceType; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.redis.RedisCache; -import com.ruoyi.project.system.domain.SysConfig; -import com.ruoyi.project.system.mapper.SysConfigMapper; -import com.ruoyi.project.system.service.ISysConfigService; +import com.ruoyi.system.domain.SysConfig; +import com.ruoyi.system.mapper.SysConfigMapper; +import com.ruoyi.system.service.ISysConfigService; /** * 鍙傛暟閰嶇疆 鏈嶅姟灞傚疄鐜 @@ -48,6 +50,7 @@ public class SysConfigServiceImpl implements ISysConfigService * @return 鍙傛暟閰嶇疆淇℃伅 */ @Override + @DataSource(DataSourceType.MASTER) public SysConfig selectConfigById(Long configId) { SysConfig config = new SysConfig(); diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index 4e0ef4a2d..ec8113ec1 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDeptServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.service.impl; +package com.ruoyi.system.service.impl; import java.util.ArrayList; import java.util.Iterator; @@ -6,14 +6,14 @@ import java.util.List; import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.TreeSelect; +import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.exception.CustomException; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.aspectj.lang.annotation.DataScope; -import com.ruoyi.framework.web.domain.TreeSelect; -import com.ruoyi.project.system.domain.SysDept; -import com.ruoyi.project.system.mapper.SysDeptMapper; -import com.ruoyi.project.system.service.ISysDeptService; +import com.ruoyi.system.mapper.SysDeptMapper; +import com.ruoyi.system.service.ISysDeptService; /** * 閮ㄩ棬绠$悊 鏈嶅姟瀹炵幇 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictDataServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java similarity index 88% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictDataServiceImpl.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java index 065a2ce80..39d950531 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictDataServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictDataServiceImpl.java @@ -1,12 +1,12 @@ -package com.ruoyi.project.system.service.impl; +package com.ruoyi.system.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import com.ruoyi.common.core.domain.entity.SysDictData; import com.ruoyi.common.utils.DictUtils; -import com.ruoyi.project.system.domain.SysDictData; -import com.ruoyi.project.system.mapper.SysDictDataMapper; -import com.ruoyi.project.system.service.ISysDictDataService; +import com.ruoyi.system.mapper.SysDictDataMapper; +import com.ruoyi.system.service.ISysDictDataService; /** * 瀛楀吀 涓氬姟灞傚鐞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictTypeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java similarity index 90% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictTypeServiceImpl.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java index 10fe23bcb..c38951bc4 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysDictTypeServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.service.impl; +package com.ruoyi.system.service.impl; import java.util.List; import javax.annotation.PostConstruct; @@ -6,14 +6,14 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.entity.SysDictData; +import com.ruoyi.common.core.domain.entity.SysDictType; import com.ruoyi.common.exception.CustomException; import com.ruoyi.common.utils.DictUtils; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.project.system.domain.SysDictData; -import com.ruoyi.project.system.domain.SysDictType; -import com.ruoyi.project.system.mapper.SysDictDataMapper; -import com.ruoyi.project.system.mapper.SysDictTypeMapper; -import com.ruoyi.project.system.service.ISysDictTypeService; +import com.ruoyi.system.mapper.SysDictDataMapper; +import com.ruoyi.system.mapper.SysDictTypeMapper; +import com.ruoyi.system.service.ISysDictTypeService; /** * 瀛楀吀 涓氬姟灞傚鐞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysLogininforServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java similarity index 82% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysLogininforServiceImpl.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java index 5195bb3f7..f69fd1aff 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysLogininforServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysLogininforServiceImpl.java @@ -1,11 +1,11 @@ -package com.ruoyi.project.monitor.service.impl; +package com.ruoyi.system.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.ruoyi.project.monitor.domain.SysLogininfor; -import com.ruoyi.project.monitor.mapper.SysLogininforMapper; -import com.ruoyi.project.monitor.service.ISysLogininforService; +import com.ruoyi.system.domain.SysLogininfor; +import com.ruoyi.system.mapper.SysLogininforMapper; +import com.ruoyi.system.service.ISysLogininforService; /** * 绯荤粺璁块棶鏃ュ織鎯呭喌淇℃伅 鏈嶅姟灞傚鐞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java similarity index 92% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java index e5dda00f9..d3fb074ba 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysMenuServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysMenuServiceImpl.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.service.impl; +package com.ruoyi.system.service.impl; import java.util.ArrayList; import java.util.Arrays; @@ -11,16 +11,16 @@ import java.util.stream.Collectors; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.TreeSelect; +import com.ruoyi.common.core.domain.entity.SysMenu; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.web.domain.TreeSelect; -import com.ruoyi.project.system.domain.SysMenu; -import com.ruoyi.project.system.domain.SysUser; -import com.ruoyi.project.system.domain.vo.MetaVo; -import com.ruoyi.project.system.domain.vo.RouterVo; -import com.ruoyi.project.system.mapper.SysMenuMapper; -import com.ruoyi.project.system.mapper.SysRoleMenuMapper; -import com.ruoyi.project.system.service.ISysMenuService; +import com.ruoyi.system.domain.vo.MetaVo; +import com.ruoyi.system.domain.vo.RouterVo; +import com.ruoyi.system.mapper.SysMenuMapper; +import com.ruoyi.system.mapper.SysRoleMenuMapper; +import com.ruoyi.system.service.ISysMenuService; /** * 鑿滃崟 涓氬姟灞傚鐞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java similarity index 85% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java index 2b0191d4a..8bebd9c69 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysNoticeServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysNoticeServiceImpl.java @@ -1,11 +1,11 @@ -package com.ruoyi.project.system.service.impl; +package com.ruoyi.system.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.ruoyi.project.system.domain.SysNotice; -import com.ruoyi.project.system.mapper.SysNoticeMapper; -import com.ruoyi.project.system.service.ISysNoticeService; +import com.ruoyi.system.domain.SysNotice; +import com.ruoyi.system.mapper.SysNoticeMapper; +import com.ruoyi.system.service.ISysNoticeService; /** * 鍏憡 鏈嶅姟灞傚疄鐜 diff --git a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysOperLogServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java similarity index 83% rename from ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysOperLogServiceImpl.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java index 954bc08f7..785ee1ed7 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/monitor/service/impl/SysOperLogServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysOperLogServiceImpl.java @@ -1,11 +1,11 @@ -package com.ruoyi.project.monitor.service.impl; +package com.ruoyi.system.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import com.ruoyi.project.monitor.domain.SysOperLog; -import com.ruoyi.project.monitor.mapper.SysOperLogMapper; -import com.ruoyi.project.monitor.service.ISysOperLogService; +import com.ruoyi.system.domain.SysOperLog; +import com.ruoyi.system.mapper.SysOperLogMapper; +import com.ruoyi.system.service.ISysOperLogService; /** * 鎿嶄綔鏃ュ織 鏈嶅姟灞傚鐞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysPostServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java similarity index 90% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysPostServiceImpl.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java index b013cbb2e..127ed3fbd 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysPostServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysPostServiceImpl.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.service.impl; +package com.ruoyi.system.service.impl; import java.util.List; import org.springframework.beans.factory.annotation.Autowired; @@ -6,10 +6,10 @@ import org.springframework.stereotype.Service; import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.exception.CustomException; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.project.system.domain.SysPost; -import com.ruoyi.project.system.mapper.SysPostMapper; -import com.ruoyi.project.system.mapper.SysUserPostMapper; -import com.ruoyi.project.system.service.ISysPostService; +import com.ruoyi.system.domain.SysPost; +import com.ruoyi.system.mapper.SysPostMapper; +import com.ruoyi.system.mapper.SysUserPostMapper; +import com.ruoyi.system.service.ISysPostService; /** * 宀椾綅淇℃伅 鏈嶅姟灞傚鐞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysRoleServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysRoleServiceImpl.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java index 71f3c6684..8bfc5a410 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysRoleServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysRoleServiceImpl.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.service.impl; +package com.ruoyi.system.service.impl; import java.util.ArrayList; import java.util.Arrays; @@ -8,19 +8,19 @@ import java.util.Set; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.exception.CustomException; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.spring.SpringUtils; -import com.ruoyi.framework.aspectj.lang.annotation.DataScope; -import com.ruoyi.project.system.domain.SysRole; -import com.ruoyi.project.system.domain.SysRoleDept; -import com.ruoyi.project.system.domain.SysRoleMenu; -import com.ruoyi.project.system.mapper.SysRoleDeptMapper; -import com.ruoyi.project.system.mapper.SysRoleMapper; -import com.ruoyi.project.system.mapper.SysRoleMenuMapper; -import com.ruoyi.project.system.mapper.SysUserRoleMapper; -import com.ruoyi.project.system.service.ISysRoleService; +import com.ruoyi.system.domain.SysRoleDept; +import com.ruoyi.system.domain.SysRoleMenu; +import com.ruoyi.system.mapper.SysRoleDeptMapper; +import com.ruoyi.system.mapper.SysRoleMapper; +import com.ruoyi.system.mapper.SysRoleMenuMapper; +import com.ruoyi.system.mapper.SysUserRoleMapper; +import com.ruoyi.system.service.ISysRoleService; /** * 瑙掕壊 涓氬姟灞傚鐞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysUserOnlineServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java similarity index 89% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysUserOnlineServiceImpl.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java index fb45b8017..2747f6a8b 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysUserOnlineServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserOnlineServiceImpl.java @@ -1,10 +1,10 @@ -package com.ruoyi.project.system.service.impl; +package com.ruoyi.system.service.impl; import org.springframework.stereotype.Service; +import com.ruoyi.common.core.domain.model.LoginUser; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.security.LoginUser; -import com.ruoyi.project.monitor.domain.SysUserOnline; -import com.ruoyi.project.system.service.ISysUserOnlineService; +import com.ruoyi.system.domain.SysUserOnline; +import com.ruoyi.system.service.ISysUserOnlineService; /** * 鍦ㄧ嚎鐢ㄦ埛 鏈嶅姟灞傚鐞 diff --git a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java similarity index 90% rename from ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java rename to ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index b6842e9c3..9c77dd8d1 100644 --- a/ruoyi/src/main/java/com/ruoyi/project/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -1,4 +1,4 @@ -package com.ruoyi.project.system.service.impl; +package com.ruoyi.system.service.impl; import java.util.ArrayList; import java.util.List; @@ -7,23 +7,23 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.constant.UserConstants; +import com.ruoyi.common.core.domain.entity.SysRole; +import com.ruoyi.common.core.domain.entity.SysUser; import com.ruoyi.common.exception.CustomException; import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.StringUtils; -import com.ruoyi.framework.aspectj.lang.annotation.DataScope; -import com.ruoyi.project.system.domain.SysPost; -import com.ruoyi.project.system.domain.SysRole; -import com.ruoyi.project.system.domain.SysUser; -import com.ruoyi.project.system.domain.SysUserPost; -import com.ruoyi.project.system.domain.SysUserRole; -import com.ruoyi.project.system.mapper.SysPostMapper; -import com.ruoyi.project.system.mapper.SysRoleMapper; -import com.ruoyi.project.system.mapper.SysUserMapper; -import com.ruoyi.project.system.mapper.SysUserPostMapper; -import com.ruoyi.project.system.mapper.SysUserRoleMapper; -import com.ruoyi.project.system.service.ISysConfigService; -import com.ruoyi.project.system.service.ISysUserService; +import com.ruoyi.system.domain.SysPost; +import com.ruoyi.system.domain.SysUserPost; +import com.ruoyi.system.domain.SysUserRole; +import com.ruoyi.system.mapper.SysPostMapper; +import com.ruoyi.system.mapper.SysRoleMapper; +import com.ruoyi.system.mapper.SysUserMapper; +import com.ruoyi.system.mapper.SysUserPostMapper; +import com.ruoyi.system.mapper.SysUserRoleMapper; +import com.ruoyi.system.service.ISysConfigService; +import com.ruoyi.system.service.ISysUserService; /** * 鐢ㄦ埛 涓氬姟灞傚鐞 diff --git a/ruoyi/src/main/resources/mybatis/system/SysConfigMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml similarity index 96% rename from ruoyi/src/main/resources/mybatis/system/SysConfigMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml index daf736a76..2f0c8be86 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysConfigMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysConfigMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/mybatis/system/SysDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml similarity index 96% rename from ruoyi/src/main/resources/mybatis/system/SysDeptMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml index 333804636..d78d7da25 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/mybatis/system/SysDictDataMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDictDataMapper.xml similarity index 96% rename from ruoyi/src/main/resources/mybatis/system/SysDictDataMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/SysDictDataMapper.xml index cc15a5141..75d80a157 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysDictDataMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDictDataMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/mybatis/system/SysDictTypeMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysDictTypeMapper.xml similarity index 95% rename from ruoyi/src/main/resources/mybatis/system/SysDictTypeMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/SysDictTypeMapper.xml index 378e9616e..cf7fc06a3 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysDictTypeMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysDictTypeMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/mybatis/monitor/SysLogininforMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysLogininforMapper.xml similarity index 94% rename from ruoyi/src/main/resources/mybatis/monitor/SysLogininforMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/SysLogininforMapper.xml index ba3194dc6..6f0a24115 100644 --- a/ruoyi/src/main/resources/mybatis/monitor/SysLogininforMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysLogininforMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/mybatis/system/SysMenuMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml similarity index 96% rename from ruoyi/src/main/resources/mybatis/system/SysMenuMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml index ac3a9c507..7c97ff5e0 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysMenuMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysMenuMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/mybatis/system/SysNoticeMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml similarity index 95% rename from ruoyi/src/main/resources/mybatis/system/SysNoticeMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml index c12816a2c..76caf2d2c 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysNoticeMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysNoticeMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/mybatis/monitor/SysOperLogMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml similarity index 95% rename from ruoyi/src/main/resources/mybatis/monitor/SysOperLogMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml index 34669145b..e70b7bff3 100644 --- a/ruoyi/src/main/resources/mybatis/monitor/SysOperLogMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysOperLogMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/mybatis/system/SysPostMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml similarity index 95% rename from ruoyi/src/main/resources/mybatis/system/SysPostMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml index 1fb6f4580..e845b0a51 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysPostMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysPostMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/mybatis/system/SysRoleDeptMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml similarity index 90% rename from ruoyi/src/main/resources/mybatis/system/SysRoleDeptMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml index acda24591..700671e15 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysRoleDeptMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleDeptMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/mybatis/system/SysRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml similarity index 96% rename from ruoyi/src/main/resources/mybatis/system/SysRoleMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml index 82524b823..8958c6bad 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysRoleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/mybatis/system/SysRoleMenuMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml similarity index 88% rename from ruoyi/src/main/resources/mybatis/system/SysRoleMenuMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml index b7c5b6b20..5f6c047a5 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysRoleMenuMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysRoleMenuMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/mybatis/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml similarity index 97% rename from ruoyi/src/main/resources/mybatis/system/SysUserMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml index 99c0d50e0..a6aeb6280 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysUserMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/mybatis/system/SysUserPostMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml similarity index 90% rename from ruoyi/src/main/resources/mybatis/system/SysUserPostMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml index d634c8b30..21c40981b 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysUserPostMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserPostMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi/src/main/resources/mybatis/system/SysUserRoleMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml similarity index 91% rename from ruoyi/src/main/resources/mybatis/system/SysUserRoleMapper.xml rename to ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml index 3422b1cfd..95e07adb1 100644 --- a/ruoyi/src/main/resources/mybatis/system/SysUserRoleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/system/SysUserRoleMapper.xml @@ -2,7 +2,7 @@ - + diff --git a/ruoyi-ui/package.json b/ruoyi-ui/package.json index 40a0f4e35..9f0db892b 100644 --- a/ruoyi-ui/package.json +++ b/ruoyi-ui/package.json @@ -1,6 +1,6 @@ { "name": "ruoyi", - "version": "2.3.0", + "version": "3.0.0", "description": "鑻ヤ緷绠$悊绯荤粺", "author": "鑻ヤ緷", "license": "MIT", diff --git a/ruoyi/bin/run-tomcat.bat b/ruoyi/bin/run-tomcat.bat deleted file mode 100644 index 5d38ad0e3..000000000 --- a/ruoyi/bin/run-tomcat.bat +++ /dev/null @@ -1,14 +0,0 @@ -@echo off -echo. -echo [信息] 使用 Spring Boot Tomcat 运行 Web 工程。 -echo. - -%~d0 -cd %~dp0 - -cd .. -title %cd% -set MAVEN_OPTS=%MAVEN_OPTS% -Xms256m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -call mvn clean spring-boot:run -Dmaven.test.skip=true -U - -pause \ No newline at end of file diff --git a/ruoyi/pom.xml b/ruoyi/pom.xml deleted file mode 100644 index bd9af4845..000000000 --- a/ruoyi/pom.xml +++ /dev/null @@ -1,287 +0,0 @@ - - - 4.0.0 - - com.ruoyi - ruoyi - 2.3.0 - jar - - ruoyi - http://www.ruoyi.vip - 鑻ヤ緷绠$悊绯荤粺 - - - org.springframework.boot - spring-boot-starter-parent - 2.1.1.RELEASE - - - - - UTF-8 - UTF-8 - 1.8 - 1.3.2 - 1.2.5 - 1.2.70 - 1.1.14 - 2.5 - 1.3.3 - 1.19 - 0.9.0 - 2.9.2 - 3.17 - 3.9.1 - 1.7 - - - - - - - org.springframework.boot - spring-boot-starter - - - - - org.springframework.boot - spring-boot-starter-test - test - - - - - org.springframework.boot - spring-boot-starter-aop - - - - - org.springframework.boot - spring-boot-starter-web - - - - - org.springframework.boot - spring-boot-devtools - true - - - - - org.springframework.boot - spring-boot-starter-security - - - - - org.springframework.boot - spring-boot-starter-data-redis - - - - - org.apache.commons - commons-pool2 - - - - - mysql - mysql-connector-java - runtime - - - - - org.mybatis.spring.boot - mybatis-spring-boot-starter - ${mybatis.spring.boot.starter.version} - - - - - com.github.pagehelper - pagehelper-spring-boot-starter - ${pagehelper.spring.boot.starter.version} - - - - - com.alibaba - druid-spring-boot-starter - ${druid.version} - - - - - org.apache.commons - commons-lang3 - - - - - commons-io - commons-io - ${commons.io.version} - - - - - commons-fileupload - commons-fileupload - ${commons.fileupload.version} - - - - - eu.bitwalker - UserAgentUtils - ${bitwalker.version} - - - - - com.alibaba - fastjson - ${fastjson.version} - - - - - org.springframework - spring-context-support - - - - - io.jsonwebtoken - jjwt - ${jwt.version} - - - - - io.springfox - springfox-swagger2 - ${swagger.version} - - - io.swagger - swagger-annotations - - - io.swagger - swagger-models - - - - - - - io.swagger - swagger-annotations - 1.5.21 - - - - io.swagger - swagger-models - 1.5.21 - - - - - io.springfox - springfox-swagger-ui - ${swagger.version} - - - - - com.github.oshi - oshi-core - ${oshi.version} - - - - net.java.dev.jna - jna - - - - net.java.dev.jna - jna-platform - - - - - org.apache.poi - poi-ooxml - ${poi.version} - - - - - org.apache.velocity - velocity - ${velocity.version} - - - - - org.quartz-scheduler - quartz - - - com.mchange - c3p0 - - - - - - - - ${project.artifactId} - - - org.springframework.boot - spring-boot-maven-plugin - - true - - - - - - - - public - aliyun nexus - http://maven.aliyun.com/nexus/content/groups/public/ - - true - - - - - - - public - aliyun nexus - http://maven.aliyun.com/nexus/content/groups/public/ - - true - - - false - - - - - \ No newline at end of file diff --git a/ruoyi/ry.sh b/ry.sh similarity index 93% rename from ruoyi/ry.sh rename to ry.sh index 52f80bd24..6558b9785 100644 --- a/ruoyi/ry.sh +++ b/ry.sh @@ -1,6 +1,6 @@ #!/bin/bash -AppName=ruoyi.jar +AppName=ruoyi-admin.jar #JVM鍙傛暟 JVM_OPTS="-Dname=$AppName -Duser.timezone=Asia/Shanghai -Xms512M -Xmx512M -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" diff --git a/ruoyi/sql/quartz.sql b/sql/quartz.sql similarity index 97% rename from ruoyi/sql/quartz.sql rename to sql/quartz.sql index 55665e2b9..52b6a0926 100644 --- a/ruoyi/sql/quartz.sql +++ b/sql/quartz.sql @@ -1,170 +1,170 @@ --- ---------------------------- --- 1銆佸瓨鍌ㄦ瘡涓涓凡閰嶇疆鐨 jobDetail 鐨勮缁嗕俊鎭 --- ---------------------------- -drop table if exists QRTZ_JOB_DETAILS; -create table QRTZ_JOB_DETAILS ( - sched_name varchar(120) not null, - job_name varchar(200) not null, - job_group varchar(200) not null, - description varchar(250) null, - job_class_name varchar(250) not null, - is_durable varchar(1) not null, - is_nonconcurrent varchar(1) not null, - is_update_data varchar(1) not null, - requests_recovery varchar(1) not null, - job_data blob null, - primary key (sched_name,job_name,job_group) -) engine=innodb; - --- ---------------------------- --- 2銆 瀛樺偍宸查厤缃殑 Trigger 鐨勪俊鎭 --- ---------------------------- -drop table if exists QRTZ_TRIGGERS; -create table QRTZ_TRIGGERS ( - sched_name varchar(120) not null, - trigger_name varchar(200) not null, - trigger_group varchar(200) not null, - job_name varchar(200) not null, - job_group varchar(200) not null, - description varchar(250) null, - next_fire_time bigint(13) null, - prev_fire_time bigint(13) null, - priority integer null, - trigger_state varchar(16) not null, - trigger_type varchar(8) not null, - start_time bigint(13) not null, - end_time bigint(13) null, - calendar_name varchar(200) null, - misfire_instr smallint(2) null, - job_data blob null, - primary key (sched_name,trigger_name,trigger_group), - foreign key (sched_name,job_name,job_group) references QRTZ_JOB_DETAILS(sched_name,job_name,job_group) -) engine=innodb; - --- ---------------------------- --- 3銆 瀛樺偍绠鍗曠殑 Trigger锛屽寘鎷噸澶嶆鏁帮紝闂撮殧锛屼互鍙婂凡瑙﹀彂鐨勬鏁 --- ---------------------------- -drop table if exists QRTZ_SIMPLE_TRIGGERS; -create table QRTZ_SIMPLE_TRIGGERS ( - sched_name varchar(120) not null, - trigger_name varchar(200) not null, - trigger_group varchar(200) not null, - repeat_count bigint(7) not null, - repeat_interval bigint(12) not null, - times_triggered bigint(10) not null, - primary key (sched_name,trigger_name,trigger_group), - foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group) -) engine=innodb; - --- ---------------------------- --- 4銆 瀛樺偍 Cron Trigger锛屽寘鎷 Cron 琛ㄨ揪寮忓拰鏃跺尯淇℃伅 --- ---------------------------- -drop table if exists QRTZ_CRON_TRIGGERS; -create table QRTZ_CRON_TRIGGERS ( - sched_name varchar(120) not null, - trigger_name varchar(200) not null, - trigger_group varchar(200) not null, - cron_expression varchar(200) not null, - time_zone_id varchar(80), - primary key (sched_name,trigger_name,trigger_group), - foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group) -) engine=innodb; - --- ---------------------------- --- 5銆 Trigger 浣滀负 Blob 绫诲瀷瀛樺偍(鐢ㄤ簬 Quartz 鐢ㄦ埛鐢 JDBC 鍒涘缓浠栦滑鑷繁瀹氬埗鐨 Trigger 绫诲瀷锛孞obStore 骞朵笉鐭ラ亾濡備綍瀛樺偍瀹炰緥鐨勬椂鍊) --- ---------------------------- -drop table if exists QRTZ_BLOB_TRIGGERS; -create table QRTZ_BLOB_TRIGGERS ( - sched_name varchar(120) not null, - trigger_name varchar(200) not null, - trigger_group varchar(200) not null, - blob_data blob null, - primary key (sched_name,trigger_name,trigger_group), - foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group) -) engine=innodb; - --- ---------------------------- --- 6銆 浠 Blob 绫诲瀷瀛樺偍瀛樻斁鏃ュ巻淇℃伅锛 quartz鍙厤缃竴涓棩鍘嗘潵鎸囧畾涓涓椂闂磋寖鍥 --- ---------------------------- -drop table if exists QRTZ_CALENDARS; -create table QRTZ_CALENDARS ( - sched_name varchar(120) not null, - calendar_name varchar(200) not null, - calendar blob not null, - primary key (sched_name,calendar_name) -) engine=innodb; - --- ---------------------------- --- 7銆 瀛樺偍宸叉殏鍋滅殑 Trigger 缁勭殑淇℃伅 --- ---------------------------- -drop table if exists QRTZ_PAUSED_TRIGGER_GRPS; -create table QRTZ_PAUSED_TRIGGER_GRPS ( - sched_name varchar(120) not null, - trigger_group varchar(200) not null, - primary key (sched_name,trigger_group) -) engine=innodb; - --- ---------------------------- --- 8銆 瀛樺偍涓庡凡瑙﹀彂鐨 Trigger 鐩稿叧鐨勭姸鎬佷俊鎭紝浠ュ強鐩歌仈 Job 鐨勬墽琛屼俊鎭 --- ---------------------------- -drop table if exists QRTZ_FIRED_TRIGGERS; -create table QRTZ_FIRED_TRIGGERS ( - sched_name varchar(120) not null, - entry_id varchar(95) not null, - trigger_name varchar(200) not null, - trigger_group varchar(200) not null, - instance_name varchar(200) not null, - fired_time bigint(13) not null, - sched_time bigint(13) not null, - priority integer not null, - state varchar(16) not null, - job_name varchar(200) null, - job_group varchar(200) null, - is_nonconcurrent varchar(1) null, - requests_recovery varchar(1) null, - primary key (sched_name,entry_id) -) engine=innodb; - --- ---------------------------- --- 9銆 瀛樺偍灏戦噺鐨勬湁鍏 Scheduler 鐨勭姸鎬佷俊鎭紝鍋囧鏄敤浜庨泦缇や腑锛屽彲浠ョ湅鍒板叾浠栫殑 Scheduler 瀹炰緥 --- ---------------------------- -drop table if exists QRTZ_SCHEDULER_STATE; -create table QRTZ_SCHEDULER_STATE ( - sched_name varchar(120) not null, - instance_name varchar(200) not null, - last_checkin_time bigint(13) not null, - checkin_interval bigint(13) not null, - primary key (sched_name,instance_name) -) engine=innodb; - --- ---------------------------- --- 10銆 瀛樺偍绋嬪簭鐨勬偛瑙傞攣鐨勪俊鎭(鍋囧浣跨敤浜嗘偛瑙傞攣) --- ---------------------------- -drop table if exists QRTZ_LOCKS; -create table QRTZ_LOCKS ( - sched_name varchar(120) not null, - lock_name varchar(40) not null, - primary key (sched_name,lock_name) -) engine=innodb; - -drop table if exists QRTZ_SIMPROP_TRIGGERS; -create table QRTZ_SIMPROP_TRIGGERS ( - sched_name varchar(120) not null, - trigger_name varchar(200) not null, - trigger_group varchar(200) not null, - str_prop_1 varchar(512) null, - str_prop_2 varchar(512) null, - str_prop_3 varchar(512) null, - int_prop_1 int null, - int_prop_2 int null, - long_prop_1 bigint null, - long_prop_2 bigint null, - dec_prop_1 numeric(13,4) null, - dec_prop_2 numeric(13,4) null, - bool_prop_1 varchar(1) null, - bool_prop_2 varchar(1) null, - primary key (sched_name,trigger_name,trigger_group), - foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group) -) engine=innodb; - +-- ---------------------------- +-- 1銆佸瓨鍌ㄦ瘡涓涓凡閰嶇疆鐨 jobDetail 鐨勮缁嗕俊鎭 +-- ---------------------------- +drop table if exists QRTZ_JOB_DETAILS; +create table QRTZ_JOB_DETAILS ( + sched_name varchar(120) not null, + job_name varchar(200) not null, + job_group varchar(200) not null, + description varchar(250) null, + job_class_name varchar(250) not null, + is_durable varchar(1) not null, + is_nonconcurrent varchar(1) not null, + is_update_data varchar(1) not null, + requests_recovery varchar(1) not null, + job_data blob null, + primary key (sched_name,job_name,job_group) +) engine=innodb; + +-- ---------------------------- +-- 2銆 瀛樺偍宸查厤缃殑 Trigger 鐨勪俊鎭 +-- ---------------------------- +drop table if exists QRTZ_TRIGGERS; +create table QRTZ_TRIGGERS ( + sched_name varchar(120) not null, + trigger_name varchar(200) not null, + trigger_group varchar(200) not null, + job_name varchar(200) not null, + job_group varchar(200) not null, + description varchar(250) null, + next_fire_time bigint(13) null, + prev_fire_time bigint(13) null, + priority integer null, + trigger_state varchar(16) not null, + trigger_type varchar(8) not null, + start_time bigint(13) not null, + end_time bigint(13) null, + calendar_name varchar(200) null, + misfire_instr smallint(2) null, + job_data blob null, + primary key (sched_name,trigger_name,trigger_group), + foreign key (sched_name,job_name,job_group) references QRTZ_JOB_DETAILS(sched_name,job_name,job_group) +) engine=innodb; + +-- ---------------------------- +-- 3銆 瀛樺偍绠鍗曠殑 Trigger锛屽寘鎷噸澶嶆鏁帮紝闂撮殧锛屼互鍙婂凡瑙﹀彂鐨勬鏁 +-- ---------------------------- +drop table if exists QRTZ_SIMPLE_TRIGGERS; +create table QRTZ_SIMPLE_TRIGGERS ( + sched_name varchar(120) not null, + trigger_name varchar(200) not null, + trigger_group varchar(200) not null, + repeat_count bigint(7) not null, + repeat_interval bigint(12) not null, + times_triggered bigint(10) not null, + primary key (sched_name,trigger_name,trigger_group), + foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group) +) engine=innodb; + +-- ---------------------------- +-- 4銆 瀛樺偍 Cron Trigger锛屽寘鎷 Cron 琛ㄨ揪寮忓拰鏃跺尯淇℃伅 +-- ---------------------------- +drop table if exists QRTZ_CRON_TRIGGERS; +create table QRTZ_CRON_TRIGGERS ( + sched_name varchar(120) not null, + trigger_name varchar(200) not null, + trigger_group varchar(200) not null, + cron_expression varchar(200) not null, + time_zone_id varchar(80), + primary key (sched_name,trigger_name,trigger_group), + foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group) +) engine=innodb; + +-- ---------------------------- +-- 5銆 Trigger 浣滀负 Blob 绫诲瀷瀛樺偍(鐢ㄤ簬 Quartz 鐢ㄦ埛鐢 JDBC 鍒涘缓浠栦滑鑷繁瀹氬埗鐨 Trigger 绫诲瀷锛孞obStore 骞朵笉鐭ラ亾濡備綍瀛樺偍瀹炰緥鐨勬椂鍊) +-- ---------------------------- +drop table if exists QRTZ_BLOB_TRIGGERS; +create table QRTZ_BLOB_TRIGGERS ( + sched_name varchar(120) not null, + trigger_name varchar(200) not null, + trigger_group varchar(200) not null, + blob_data blob null, + primary key (sched_name,trigger_name,trigger_group), + foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group) +) engine=innodb; + +-- ---------------------------- +-- 6銆 浠 Blob 绫诲瀷瀛樺偍瀛樻斁鏃ュ巻淇℃伅锛 quartz鍙厤缃竴涓棩鍘嗘潵鎸囧畾涓涓椂闂磋寖鍥 +-- ---------------------------- +drop table if exists QRTZ_CALENDARS; +create table QRTZ_CALENDARS ( + sched_name varchar(120) not null, + calendar_name varchar(200) not null, + calendar blob not null, + primary key (sched_name,calendar_name) +) engine=innodb; + +-- ---------------------------- +-- 7銆 瀛樺偍宸叉殏鍋滅殑 Trigger 缁勭殑淇℃伅 +-- ---------------------------- +drop table if exists QRTZ_PAUSED_TRIGGER_GRPS; +create table QRTZ_PAUSED_TRIGGER_GRPS ( + sched_name varchar(120) not null, + trigger_group varchar(200) not null, + primary key (sched_name,trigger_group) +) engine=innodb; + +-- ---------------------------- +-- 8銆 瀛樺偍涓庡凡瑙﹀彂鐨 Trigger 鐩稿叧鐨勭姸鎬佷俊鎭紝浠ュ強鐩歌仈 Job 鐨勬墽琛屼俊鎭 +-- ---------------------------- +drop table if exists QRTZ_FIRED_TRIGGERS; +create table QRTZ_FIRED_TRIGGERS ( + sched_name varchar(120) not null, + entry_id varchar(95) not null, + trigger_name varchar(200) not null, + trigger_group varchar(200) not null, + instance_name varchar(200) not null, + fired_time bigint(13) not null, + sched_time bigint(13) not null, + priority integer not null, + state varchar(16) not null, + job_name varchar(200) null, + job_group varchar(200) null, + is_nonconcurrent varchar(1) null, + requests_recovery varchar(1) null, + primary key (sched_name,entry_id) +) engine=innodb; + +-- ---------------------------- +-- 9銆 瀛樺偍灏戦噺鐨勬湁鍏 Scheduler 鐨勭姸鎬佷俊鎭紝鍋囧鏄敤浜庨泦缇や腑锛屽彲浠ョ湅鍒板叾浠栫殑 Scheduler 瀹炰緥 +-- ---------------------------- +drop table if exists QRTZ_SCHEDULER_STATE; +create table QRTZ_SCHEDULER_STATE ( + sched_name varchar(120) not null, + instance_name varchar(200) not null, + last_checkin_time bigint(13) not null, + checkin_interval bigint(13) not null, + primary key (sched_name,instance_name) +) engine=innodb; + +-- ---------------------------- +-- 10銆 瀛樺偍绋嬪簭鐨勬偛瑙傞攣鐨勪俊鎭(鍋囧浣跨敤浜嗘偛瑙傞攣) +-- ---------------------------- +drop table if exists QRTZ_LOCKS; +create table QRTZ_LOCKS ( + sched_name varchar(120) not null, + lock_name varchar(40) not null, + primary key (sched_name,lock_name) +) engine=innodb; + +drop table if exists QRTZ_SIMPROP_TRIGGERS; +create table QRTZ_SIMPROP_TRIGGERS ( + sched_name varchar(120) not null, + trigger_name varchar(200) not null, + trigger_group varchar(200) not null, + str_prop_1 varchar(512) null, + str_prop_2 varchar(512) null, + str_prop_3 varchar(512) null, + int_prop_1 int null, + int_prop_2 int null, + long_prop_1 bigint null, + long_prop_2 bigint null, + dec_prop_1 numeric(13,4) null, + dec_prop_2 numeric(13,4) null, + bool_prop_1 varchar(1) null, + bool_prop_2 varchar(1) null, + primary key (sched_name,trigger_name,trigger_group), + foreign key (sched_name,trigger_name,trigger_group) references QRTZ_TRIGGERS(sched_name,trigger_name,trigger_group) +) engine=innodb; + commit; \ No newline at end of file diff --git a/ruoyi/sql/ry_20200629.sql b/sql/ry_20200629.sql similarity index 100% rename from ruoyi/sql/ry_20200629.sql rename to sql/ry_20200629.sql