瀏覽代碼

修改:<去掉facade层>

张旭锋 3 天之前
父節點
當前提交
e042fe2b04

+ 4 - 4
src/main/java/com/jtzx/crm/module/api/web/auth/AdminAuthController.java

@@ -32,7 +32,7 @@ import com.jtzx.crm.module.api.ratelimit.SmsCodeLoginRateLimitStrategy;
 import com.jtzx.crm.module.api.ratelimit.SmsCodeRateLimitStrategy;
 import com.jtzx.crm.module.api.util.CrmAdminStpUtil;
 import com.jtzx.crm.module.api.util.ReqIpUtil;
-import com.jtzx.crm.module.sms.facade.SmsFacade;
+import com.jtzx.crm.module.sms.service.SmsService;
 import com.jtzx.crm.module.sys.annotation.SysLog;
 import com.jtzx.crm.module.sys.model.request.SysUserLoginDTO;
 import com.jtzx.crm.module.sys.model.response.SysUserLoginBO;
@@ -69,7 +69,7 @@ public class AdminAuthController {
 
     private final RedisTemplate<String, Object> stringSetRedisTemplate;
 
-    private final SmsFacade smsFacade;
+    private final SmsService service;
 
     /**
      * 账号密码登陆,输错5次,账号封禁 1800秒(半个小时),目前测试用 300 秒-5分钟,输错超3次,需要填写动态验证码
@@ -163,7 +163,7 @@ public class AdminAuthController {
         messages.put("code", smsCode);
         SmsResponse smsResponse = SmsFactory.getSmsBlend().sendMessage(mobile, messages);
         if (smsResponse.isSuccess()) {
-            smsFacade.set(RedisConstant.SMS_CODE_PREFIX + mobile, smsCode, RedisConstant.SMS_CODE_DURATION);
+            service.set(RedisConstant.SMS_CODE_PREFIX + mobile, smsCode, RedisConstant.SMS_CODE_DURATION);
             return ApiResult.data("发送成功");
         }
         return ApiResult.fail(406, "发送失败");
@@ -193,7 +193,7 @@ public class AdminAuthController {
                         resultData.getEndDateTime(),
                         LimitConstant.smsCode_login_duration,
                         TimeUnit.SECONDS);
-        Object cacheData = smsFacade.get(RedisConstant.SMS_CODE_PREFIX + userInfo.getPhoneNo());
+        Object cacheData = service.get(RedisConstant.SMS_CODE_PREFIX + userInfo.getPhoneNo());
         if (cacheData == null) {
             resultData.setStatus(false);
             return ApiResult.data("验证码错误", resultData).setCode(406);

+ 3 - 3
src/main/java/com/jtzx/crm/module/api/web/sms/SmsController.java

@@ -8,7 +8,7 @@ import com.google.common.collect.Maps;
 import com.jtzx.crm.module.api.constant.ApiConstant;
 import com.jtzx.crm.module.api.constant.RedisConstant;
 import com.jtzx.crm.module.api.ratelimit.SmsCodeRateLimitStrategy;
-import com.jtzx.crm.module.sms.facade.SmsFacade;
+import com.jtzx.crm.module.sms.service.SmsService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import jakarta.validation.constraints.Pattern;
@@ -33,7 +33,7 @@ import java.util.LinkedHashMap;
 public class SmsController {
 
 
-    private final SmsFacade smsFacade;
+    private final SmsService service;
 
     private final RedisTemplate<String, Object> stringSetRedisTemplate;
 
@@ -62,7 +62,7 @@ public class SmsController {
         messages.put("code", smsCode);
         SmsResponse smsResponse = SmsFactory.getSmsBlend().sendMessage(mobile, messages);
         if (smsResponse.isSuccess()) {
-            smsFacade.set(RedisConstant.SMS_CODE_PREFIX + mobile, smsCode, RedisConstant.SMS_CODE_DURATION);
+            service.set(RedisConstant.SMS_CODE_PREFIX + mobile, smsCode, RedisConstant.SMS_CODE_DURATION);
             return ApiResult.data("发送成功");
         }
         return ApiResult.fail(406, "发送失败");

+ 0 - 38
src/main/java/com/jtzx/crm/module/sms/facade/SmsFacade.java

@@ -1,38 +0,0 @@
-package com.jtzx.crm.module.sms.facade;
-
-public interface SmsFacade {
-
-    /**
-     * 存储
-     *
-     * @param key       键
-     * @param value     值
-     * @param cacheTime 缓存时间(单位:秒)
-     */
-    void set(String key, Object value, long cacheTime);
-
-    /**
-     * 存储
-     *
-     * @param key   键
-     * @param value 值
-     */
-    void set(String key, Object value);
-
-    /**
-     * 读取
-     *
-     * @param key 键
-     * @return 值
-     */
-    Object get(String key);
-
-    /**
-     *  remove
-     * <p> 根据key移除缓存
-     * @param key 缓存键
-     * @return 被删除的value
-     * @author :Wind
-     */
-    Object remove(String key);
-}

+ 0 - 35
src/main/java/com/jtzx/crm/module/sms/facade/impl/SmsFacadeImpl.java

@@ -1,35 +0,0 @@
-package com.jtzx.crm.module.sms.facade.impl;
-
-import com.jtzx.crm.module.sms.facade.SmsFacade;
-import com.jtzx.crm.module.sms.service.SmsService;
-import lombok.RequiredArgsConstructor;
-import lombok.extern.slf4j.Slf4j;
-import org.springframework.stereotype.Service;
-
-@Slf4j
-@Service
-@RequiredArgsConstructor
-public class SmsFacadeImpl implements SmsFacade {
-
-    private final SmsService smsService;
-
-    @Override
-    public void set(String key, Object value, long cacheTime) {
-        smsService.set(key, value, cacheTime);
-    }
-
-    @Override
-    public void set(String key, Object value) {
-        smsService.set(key, value);
-    }
-
-    @Override
-    public Object get(String key) {
-        return smsService.get(key);
-    }
-
-    @Override
-    public Object remove(String key) {
-        return smsService.remove(key);
-    }
-}