فهرست منبع

Merge remote-tracking branch 'origin/master'

zsl 2 سال پیش
والد
کامیت
0daa0333e1

+ 1 - 0
tr-modules/pom.xml

@@ -16,6 +16,7 @@
         <module>tr-module-system</module>
         <module>tr-module-gen</module>
         <module>tr-module-export</module>
+        <module>tr-module-job</module>
     </modules>
 
 

+ 1 - 1
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/config/SysConfigProperties.java

@@ -38,7 +38,7 @@ public class SysConfigProperties implements Serializable {
     private String copyRightUrl;
 
     @ApiModelProperty(value = "登录验证码开关",position = 6)
-    private boolean captchaOpen;
+    private Boolean captchaOpen=false;
 
     @ApiModelProperty(value = "默认快捷方式",position = 7)
     private String defaultWorkBenchData;

+ 0 - 1
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/core/mq/consumer/sms/SmsChannelRefreshConsumer.java

@@ -25,5 +25,4 @@ public class SmsChannelRefreshConsumer {
         log.info("[execute][收到 SmsChannel 刷新消息]");
         smsChannelService.initLocalCache();
     }
-
 }

+ 11 - 4
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/dict/controller/SysDictController.java

@@ -17,10 +17,10 @@ import lombok.AllArgsConstructor;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
-import java.util.Collection;
+import java.util.*;
 
 /**
- * @ClassName : SysOperLogController
+ * @ClassName : SysDictController
  * @Description :
  * @Author : LF
  * @Date: 2023年03月24日
@@ -32,10 +32,17 @@ import java.util.Collection;
 public class SysDictController extends BaseController {
     private final ISysDictService dictService;
 
+    @PostMapping("/query/list")
+    @ApiOperationSupport(author = "lf")
+    @ApiOperation(value = "根据条件查询字典(列表)",notes = "权限: 无")
+    public CommonResult<List<SysDictDTO>> selectList(@RequestBody SysDictQueryDTO query){
+        return CommonResult.success(dictService.selectDictDataList(query));
+    }
+
     @PostMapping("/query/page")
     @ApiOperationSupport(author = "lf")
-    @ApiOperation(value = "根据条件查询字典",notes = "权限: 无")
-    public TableDataInfo<SysDictDTO> selectList(@RequestBody SysDictQueryDTO query){
+    @ApiOperation(value = "根据条件查询字典(分页)",notes = "权限: 无")
+    public TableDataInfo<SysDictDTO> selectPage(@RequestBody SysDictQueryDTO query){
         startPage();
         return getDataTable(dictService.selectDictDataList(query));
     }

+ 12 - 14
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/oauth2/config/CaptchaOperator.java

@@ -5,13 +5,13 @@ import cn.tr.core.exception.ServiceException;
 import cn.tr.core.exception.TRExcCode;
 import com.wf.captcha.base.Captcha;
 import com.wf.captcha.utils.CaptchaUtil;
-import org.springframework.data.redis.core.BoundValueOperations;
-import org.springframework.data.redis.core.RedisTemplate;
+import org.redisson.api.RMap;
+import org.redisson.api.RedissonClient;
 import org.springframework.stereotype.Component;
-
-import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.time.Duration;
+import java.time.temporal.ChronoUnit;
 import java.util.Objects;
 
 /**
@@ -23,38 +23,36 @@ import java.util.Objects;
  */
 @Component
 public class CaptchaOperator {
-    private RedisTemplate<String,String> redisTemplate;
-    public CaptchaOperator(RedisTemplate redisTemplate) {
-        this.redisTemplate=redisTemplate;
+    private  RMap<String, String>  captchaMap;
+    public CaptchaOperator(RedissonClient redissonClient) {
+        captchaMap = redissonClient.getMap("captcha:");
+        captchaMap.expire(Duration.of(30, ChronoUnit.MINUTES));
     }
 
     /**
      * 输出验证码
      * @param key
      * @param captcha  Captcha
-     * @param request  HttpServletRequest
      * @param response HttpServletResponse
      * @throws IOException IO异常
      */
-    public void out(String key, Captcha captcha, int expire, HttpServletRequest request, HttpServletResponse response)
+    public void out(String key, Captcha captcha, HttpServletResponse response)
             throws IOException {
         CaptchaUtil.setHeader(response);
         //验证码放入缓存30分钟
-        redisTemplate.boundValueOps("captcha:"+key).set(captcha.text().toLowerCase(), expire);
+        captchaMap.put(key,captcha.text().toLowerCase());
         captcha.out(response.getOutputStream());
     }
 
 
     public boolean ver(String key,String code){
-        BoundValueOperations<String, String> operations = redisTemplate.boundValueOps("captcha:" + key);
+        String cacheCode = captchaMap.get(key);
         if(StrUtil.isBlank(code)){
             throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"验证码不能为空");
         }
-
-        Object cacheCode = operations.get();
         if (Objects.nonNull(cacheCode)) {
             if (Objects.equals(cacheCode,code)) {
-                operations.getAndDelete();
+                captchaMap.remove(key);
                 return true;
             }
             throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"验证码错误");

+ 1 - 1
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/oauth2/controller/CaptchaController.java

@@ -35,7 +35,7 @@ public class CaptchaController {
         ArithmeticCaptcha captcha = new ArithmeticCaptcha(140,38);
         try {
             new Font("Verdana", Font.PLAIN, 32);
-            captchaTool.out(key,captcha,300,request,response);
+            captchaTool.out(key,captcha,response);
         } catch (IOException e) {
             throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"系统繁忙,请稍后再试");
         }

+ 3 - 3
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/oauth2/dto/OAuth2PswReqDTO.java

@@ -23,7 +23,7 @@ public class OAuth2PswReqDTO extends OAuth2DTO {
 	@NotEmpty(message = "账号不能为空")
 	@Length(min = 4, max = 16, message = "账号长度为 4-16 位")
 	@Pattern(regexp = "^[A-Za-z0-9]+$", message = "账号格式为数字以及字母")
-	protected String username;
+	private String username;
 
 	@ApiModelProperty(value = "授权范围,可传空字符串",required = true)
 	@NotNull(message = "授权范围不能null")
@@ -36,8 +36,8 @@ public class OAuth2PswReqDTO extends OAuth2DTO {
 	private String password;
 
 	@ApiModelProperty("验证码")
-	String captchaCode;
+    private String captchaCode;
 
 	@ApiModelProperty("验证码key")
-	String captchaKey;
+    private String captchaKey;
 }

+ 6 - 1
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/oauth2/psw/OAuth2PswModelConfig.java

@@ -1,5 +1,7 @@
 package cn.tr.module.sys.oauth2.psw;
 
+import cn.dev33.satoken.context.SaHolder;
+import cn.dev33.satoken.context.model.SaRequest;
 import cn.dev33.satoken.oauth2.config.SaOAuth2Config;
 import cn.dev33.satoken.util.SaResult;
 import cn.hutool.core.util.StrUtil;
@@ -41,9 +43,12 @@ public class OAuth2PswModelConfig {
             if(operator==null){
                 throw new ServiceException(TRExcCode.USER_ERROR_A0200,String.format("账号体系[{%s}]不存在",stpType));
             }
+            SaRequest request = SaHolder.getRequest();
             OAuth2PswReqDTO parm = new OAuth2PswReqDTO()
                     .setPassword(psw)
-                    .setUsername(username);
+                    .setUsername(username)
+                    .setCaptchaCode(request.getParam("captchaCode"))
+                    .setCaptchaKey(request.getParam("captchaKey"));
             return SaResult.ok(operator.auth(parm));
         });
     }

+ 1 - 1
tr-modules/tr-module-system/src/main/java/cn/tr/module/sys/oauth2/psw/operator/LoginOAuth2PswUserOperator.java

@@ -71,7 +71,7 @@ public class LoginOAuth2PswUserOperator extends AbstractOAuth2PswUserOperator{
         }
         //验证码校验
         SysConfigProperties current = configManager.getCurrent();
-        if (Boolean.TRUE.equals(current.isCaptchaOpen())) {
+        if (Boolean.TRUE.equals(current.getCaptchaOpen())) {
             String captchaCode = source.getCaptchaCode();
             if(StrUtil.isEmpty(captchaCode)){
                 throw new ServiceException(TRExcCode.SYSTEM_ERROR_B0001,"验证码不能为空");

+ 6 - 1
tr-test/pom.xml

@@ -17,7 +17,6 @@
             <groupId>cn.tr</groupId>
             <artifactId>tr-spring-boot-starter-plugin-web</artifactId>
         </dependency>
-
         <!--<dependency>-->
             <!--<groupId>cn.tr</groupId>-->
             <!--<artifactId>tr-spring-boot-starter-plugin-mp-enhance-actable</artifactId>-->
@@ -85,6 +84,12 @@
             <version>0.0.9</version>
         </dependency>
 
+        <dependency>
+            <groupId>cn.tr</groupId>
+            <artifactId>tr-module-job</artifactId>
+            <version>0.0.9</version>
+        </dependency>
+
         <dependency>
             <groupId>cn.tr</groupId>
             <artifactId>tr-module-gen</artifactId>

+ 1 - 1
tr-test/src/main/resources/application-stream.yml

@@ -16,4 +16,4 @@ spring:
       definition: smsSupplier;smsConsumer
     bus:
       enabled: true # 是否开启,默认为 true
-      id: ${spring.application.name}:${server.port} # 编号,Spring Cloud Alibaba 建议使用“应用:端口”的格式
+#      id: ${spring.application.name}:${server.port} # 编号,Spring Cloud Alibaba 建议使用“应用:端口”的格式