From 17f0c20242c6ee3d35b9ee8f677d747ed012423c Mon Sep 17 00:00:00 2001
From: 疯狂的狮子li <15040126243@163.com>
Date: 星期五, 02 九月 2022 16:30:20 +0800
Subject: [PATCH] remove 移除maven docker插件 过于老旧功能缺陷大 使用idea自带的docker插件替代

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java |   30 ++++++++++++++----------------
 1 files changed, 14 insertions(+), 16 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java
index 8feaca9..60c632a 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/common/CaptchaController.java
@@ -5,6 +5,8 @@
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.RandomUtil;
+import com.ruoyi.common.annotation.Anonymous;
+import com.ruoyi.common.constant.CacheConstants;
 import com.ruoyi.common.constant.Constants;
 import com.ruoyi.common.core.domain.R;
 import com.ruoyi.common.enums.CaptchaType;
@@ -17,9 +19,6 @@
 import com.ruoyi.sms.core.SmsTemplate;
 import com.ruoyi.sms.entity.SmsResult;
 import com.ruoyi.system.service.ISysConfigService;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.validation.annotation.Validated;
@@ -36,36 +35,36 @@
  *
  * @author Lion Li
  */
+@Anonymous
 @Slf4j
 @Validated
-@Api(value = "楠岃瘉鐮佹搷浣滃鐞�", tags = {"楠岃瘉鐮佺鐞�"})
 @RequiredArgsConstructor
 @RestController
 public class CaptchaController {
 
     private final CaptchaProperties captchaProperties;
     private final SmsProperties smsProperties;
-    private final SmsTemplate smsTemplate;
     private final ISysConfigService configService;
 
     /**
      * 鐭俊楠岃瘉鐮�
+     *
+     * @param phonenumber 鐢ㄦ埛鎵嬫満鍙�
      */
-    @ApiOperation("鐭俊楠岃瘉鐮�")
     @GetMapping("/captchaSms")
-    public R<Void> smsCaptcha(@ApiParam("鐢ㄦ埛鎵嬫満鍙�")
-                              @NotBlank(message = "{user.phonenumber.not.blank}")
+    public R<Void> smsCaptcha(@NotBlank(message = "{user.phonenumber.not.blank}")
                               String phonenumber) {
-        if (smsProperties.getEnabled()) {
-            R.fail("褰撳墠绯荤粺娌℃湁寮�鍚煭淇″姛鑳斤紒");
+        if (!smsProperties.getEnabled()) {
+            return R.fail("褰撳墠绯荤粺娌℃湁寮�鍚煭淇″姛鑳斤紒");
         }
-        String key = Constants.CAPTCHA_CODE_KEY + phonenumber;
+        String key = CacheConstants.CAPTCHA_CODE_KEY + phonenumber;
         String code = RandomUtil.randomNumbers(4);
         RedisUtils.setCacheObject(key, code, Duration.ofMinutes(Constants.CAPTCHA_EXPIRATION));
         // 楠岃瘉鐮佹ā鏉縤d 鑷澶勭悊 (鏌ユ暟鎹簱鎴栧啓姝诲潎鍙�)
         String templateId = "";
         Map<String, String> map = new HashMap<>(1);
         map.put("code", code);
+        SmsTemplate smsTemplate = SpringUtils.getBean(SmsTemplate.class);
         SmsResult result = smsTemplate.send(phonenumber, templateId, map);
         if (!result.isSuccess()) {
             log.error("楠岃瘉鐮佺煭淇″彂閫佸紓甯� => {}", result);
@@ -77,18 +76,17 @@
     /**
      * 鐢熸垚楠岃瘉鐮�
      */
-    @ApiOperation("鐢熸垚楠岃瘉鐮�")
     @GetMapping("/captchaImage")
     public R<Map<String, Object>> getCode() {
         Map<String, Object> ajax = new HashMap<>();
-        boolean captchaOnOff = configService.selectCaptchaOnOff();
-        ajax.put("captchaOnOff", captchaOnOff);
-        if (!captchaOnOff) {
+        boolean captchaEnabled = configService.selectCaptchaEnabled();
+        ajax.put("captchaEnabled", captchaEnabled);
+        if (!captchaEnabled) {
             return R.ok(ajax);
         }
         // 淇濆瓨楠岃瘉鐮佷俊鎭�
         String uuid = IdUtil.simpleUUID();
-        String verifyKey = Constants.CAPTCHA_CODE_KEY + uuid;
+        String verifyKey = CacheConstants.CAPTCHA_CODE_KEY + uuid;
         // 鐢熸垚楠岃瘉鐮�
         CaptchaType captchaType = captchaProperties.getType();
         boolean isMath = CaptchaType.MATH == captchaType;

--
Gitblit v1.9.3