tsurumure 5 mesi fa
parent
commit
321cc8d578

+ 44 - 0
db/app_user.sql

@@ -0,0 +1,44 @@
+/**
+Source Server Version: 8.0.31
+Source Database: backendsys
+Date: 2025/03/11 10:40:11
+*/
+
+DROP TABLE IF EXISTS `app_user`;
+CREATE TABLE `app_user` (
+   PRIMARY KEY (`id`),
+   `id` BIGINT AUTO_INCREMENT,
+   `wechat_open_id` VARCHAR(64) COMMENT '微信OpenID',
+   `nickname` VARCHAR(20) COMMENT '昵称',
+   `phone` VARCHAR(20) COMMENT '手机号码',
+   `email` VARCHAR(50) COMMENT '邮箱地址',
+   `password` VARCHAR(100) NOT NULL COMMENT '密码',
+   `gender` TINYINT(1) DEFAULT NULL COMMENT '性别(1男, 2女, 3保密)',
+   `avatar` VARCHAR(1000) DEFAULT NULL COMMENT '头像',
+   `last_login_uuid` VARCHAR(36) COMMENT '最后登录UUID',
+   `last_login_ip` VARCHAR(20) COMMENT '最后登录IP',
+   `last_login_time` DATETIME COMMENT '最后登录时间',
+   `status` TINYINT(1) DEFAULT '1' COMMENT '账号状态 (-1禁用, 1启用)',
+   `create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
+   `update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
+   `del_flag` TINYINT(1) DEFAULT '-1' COMMENT '删除标志 (-1未删除, 1删除)',
+   INDEX `idx_nickname` (`nickname`),
+   INDEX `idx_phone` (`phone`),
+   INDEX `idx_email` (`email`)
+) ENGINE=INNODB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='会员表';
+
+INSERT INTO app_user(wechat_open_id, nickname, phone, email, password, gender) VALUES
+    ('o_FiE5k6Bx9svZ12ZpzegVcOaMfc', 'Mure', '13670511519', '405348097@qq.com', '$2a$10$0cFrGBWCP42iqolPYwH5c.ZfpuawXqMl3NiQI2WArzeNdwJyGwGAy', 1),
+    ('r_VqY5uWtbGiW7vPAQ8VZT6poiRs', '张小红', '13123456781', 'zhangxh@example.com', '$2a$10$0cFrGBWCP42iqolPYwH5c.ZfpuawXqMl3NiQI2WArzeNdwJyGwGAy', 1),
+    ('x_LgT3mZfCvXoQ58AlrWE3r9BkeI', '李建国', '13123456782', 'lijg@example.com', '$2a$10$0cFrGBWCP42iqolPYwH5c.ZfpuawXqMl3NiQI2WArzeNdwJyGwGAy', 1),
+    ('c_PoE7nF95XvAmT4JuReD4wBhsmL', '王丽华', '13123456783', 'wanglh@example.com', '$2a$10$0cFrGBWCP42iqolPYwH5c.ZfpuawXqMl3NiQI2WArzeNdwJyGwGAy', 1),
+    ('s_YsC4qF8thD7BHg1oJEvKxeznU9V', '刘大伟', '13123456784', 'liudw@example.com', '$2a$10$0cFrGBWCP42iqolPYwH5c.ZfpuawXqMl3NiQI2WArzeNdwJyGwGAy', 1),
+    ('m_NdG0sH7jHhKMV1zD9UpWj7h98L', '陈小娟', '13123456785', 'chenxj@example.com', '$2a$10$0cFrGBWCP42iqolPYwH5c.ZfpuawXqMl3NiQI2WArzeNdwJyGwGAy', 1),
+    ('d_SeA8kN9eY6xByC0iQOW7wZ2tjq', '张伟', '13123456786', 'zhangw@example.com', '$2a$10$0cFrGBWCP42iqolPYwH5c.ZfpuawXqMl3NiQI2WArzeNdwJyGwGAy', 1),
+    ('z_KwZ0sG5eO9AuH7MjCeS4fI80vL', '刘小飞', '13123456787', 'liuxf@example.com', '$2a$10$0cFrGBWCP42iqolPYwH5c.ZfpuawXqMl3NiQI2WArzeNdwJyGwGAy', 1),
+    ('f_PlO7mJ9iNnYjM5csEpG4wFhX02', '杨丽', '13123456788', 'yangl@example.com', '$2a$10$0cFrGBWCP42iqolPYwH5c.ZfpuawXqMl3NiQI2WArzeNdwJyGwGAy', 1),
+    ('t_RbP9vC2lUMk5T0O8yZbF6kzG1D', '赵磊', '13123456789', 'zhaol@example.com', '$2a$10$0cFrGBWCP42iqolPYwH5c.ZfpuawXqMl3NiQI2WArzeNdwJyGwGAy', 1),
+    ('n_EfZ3bD6vJiMxHg4LyPbQ8FzK5C', '陈建华', '13123456790', 'chenjh@example.com', '$2a$10$0cFrGBWCP42iqolPYwH5c.ZfpuawXqMl3NiQI2WArzeNdwJyGwGAy', 1),
+    ('y_HlK2vG8eSkV9dT7OxQF6gW3U0Z', '张秀英', '13123456791', 'zhangxy@example.com', '$2a$10$0cFrGBWCP42iqolPYwH5c.ZfpuawXqMl3NiQI2WArzeNdwJyGwGAy', 1),
+    ('l_BvX2zM3dKcJYiF7QeEf6gS4lsN', '王建军', '13123456792', 'wangjj@example.com', '$2a$10$0cFrGBWCP42iqolPYwH5c.ZfpuawXqMl3NiQI2WArzeNdwJyGwGAy', 1)
+;

+ 30 - 0
src/main/java/com/backendsys/modules/app/controller/AppAuthController.java

@@ -0,0 +1,30 @@
+package com.backendsys.modules.app.controller;
+
+import com.backendsys.modules.app.entity.AppUser;
+import com.backendsys.modules.app.service.AppAuthService;
+import com.backendsys.modules.app.service.AppUserService;
+import com.backendsys.modules.common.config.security.annotations.Anonymous;
+import com.backendsys.modules.common.utils.Result;
+import io.swagger.v3.oas.annotations.Operation;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RestController;
+
+@Validated
+@RestController
+@Tag(name = "APP用户登录与注册")
+public class AppAuthController {
+
+    @Autowired
+    private AppAuthService appAuthService;
+
+    @Anonymous
+    @Operation(summary = "APP登录 (用户名登录)")
+    @PostMapping("/api/app/auth/login")
+    public Result login(@Validated(AppUser.Login.class) @RequestBody AppUser appUser) {
+        return Result.success().put("data", appAuthService.login(appUser));
+    }
+}

+ 19 - 0
src/main/java/com/backendsys/modules/app/controller/AppUserController.java

@@ -0,0 +1,19 @@
+package com.backendsys.modules.app.controller;
+
+import com.backendsys.modules.app.service.AppUserService;
+import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.RestController;
+
+@Validated
+@RestController
+@Tag(name = "APP用户管理")
+public class AppUserController {
+
+    @Autowired
+    private AppUserService appUserService;
+
+
+
+}

+ 9 - 0
src/main/java/com/backendsys/modules/app/dao/AppUserDao.java

@@ -0,0 +1,9 @@
+package com.backendsys.modules.app.dao;
+
+import com.backendsys.modules.app.entity.AppUser;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface AppUserDao extends BaseMapper<AppUser> {
+}

+ 41 - 0
src/main/java/com/backendsys/modules/app/entity/AppUser.java

@@ -0,0 +1,41 @@
+package com.backendsys.modules.app.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import jakarta.validation.constraints.NotEmpty;
+import lombok.Data;
+
+@Data
+@TableName("app_user")
+public class AppUser {
+
+    public static interface Login{}
+    public static interface Detail{}
+
+    @TableId(type = IdType.AUTO)
+    private Long id;
+    private String wechat_open_id;
+    private String nickname;
+
+    @NotEmpty(message = "手机号码不能为空", groups = { Login.class })
+    private String phone;
+    private String email;
+    @NotEmpty(message = "密码不能为空", groups = { Login.class })
+    private String password;
+    @TableField(exist = false)
+    @NotEmpty(message = "验证码不能为空", groups = { Login.class })
+    private String captcha;
+
+    private String gender;
+    private String avatar;
+    private String last_login_uuid;
+    private String last_login_ip;
+    private String last_login_time;
+    private Integer status;
+    private String create_time;
+    private String update_time;
+    private String del_flag;
+
+}

+ 12 - 0
src/main/java/com/backendsys/modules/app/service/AppAuthService.java

@@ -0,0 +1,12 @@
+package com.backendsys.modules.app.service;
+
+import com.backendsys.modules.app.entity.AppUser;
+
+import java.util.Map;
+
+public interface AppAuthService {
+
+    // APP登录 (用户名登录)
+    Map<String, Object> login(AppUser appUser);
+
+}

+ 4 - 0
src/main/java/com/backendsys/modules/app/service/AppUserService.java

@@ -0,0 +1,4 @@
+package com.backendsys.modules.app.service;
+
+public interface AppUserService {
+}

+ 90 - 0
src/main/java/com/backendsys/modules/app/service/impl/AppAuthServiceImpl.java

@@ -0,0 +1,90 @@
+package com.backendsys.modules.app.service.impl;
+
+import com.backendsys.exception.CustException;
+import com.backendsys.modules.app.dao.AppUserDao;
+import com.backendsys.modules.app.entity.AppUser;
+import com.backendsys.modules.app.service.AppAuthService;
+import com.backendsys.modules.common.config.redis.utils.RedisUtil;
+import com.backendsys.modules.common.config.security.utils.CaptchaUtil;
+import com.backendsys.modules.common.config.security.utils.HttpRequestUtil;
+import com.backendsys.modules.common.config.security.utils.JwtUtil;
+import com.backendsys.modules.common.config.security.utils.LockStatusUtil;
+import com.backendsys.utils.response.ResultEnum;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+@Service
+public class AppAuthServiceImpl implements AppAuthService {
+
+    @Autowired
+    private JwtUtil jwtUtil;
+    @Autowired
+    private RedisUtil redisUtil;
+    @Autowired
+    private CaptchaUtil captchaUtil;
+    @Autowired
+    private LockStatusUtil lockStatusUtil;
+    @Autowired
+    private HttpRequestUtil httpRequestUtil;
+
+    @Autowired
+    private AppUserDao appUserDao;
+
+    @Value("${tencent.sms.debug}")
+    private String SMS_DEBUG;
+    @Value("${CAPTCHA_DURATION}")
+    private Integer CAPTCHA_DURATION;
+    @Value("${REDIS_LOGIN_TOKEN_PREFIX}")
+    private String REDIS_LOGIN_TOKEN_PREFIX;
+    @Value("${spring.application.name}")
+    private String APPLICATION_NAME;
+    private String redisKeyOfLogin = APPLICATION_NAME + "-app-sms-login";
+    private String redisKeyOfRegister = APPLICATION_NAME + "-app-sms-register";
+    private String redisKeyOfLoginFail = APPLICATION_NAME + "-app-login-error";
+    private String redisKeyOfRegisterFail = APPLICATION_NAME + "-app-register-error";
+
+
+    // [方法] 登录失败 (errMsg: 错误提示文本, phone: 手机号码, intercept: 是否拦截)
+    private void loginFail(String errMsg, String phone, Boolean isIntercept) {
+        // 删除图形验证码
+        redisUtil.delete(httpRequestUtil.getKaptchaKey());
+        // 添加登录错误的冻结标记
+        if (isIntercept) lockStatusUtil.setLockStatus(redisKeyOfLoginFail, phone);
+        throw new CustException(errMsg, ResultEnum.INVALID_CREDENTIALS.getCode());
+    }
+
+    /**
+     * APP登录 (用户名登录)
+     */
+    @Override
+    public Map<String, Object> login(AppUser appUser) {
+
+        String phone = appUser.getPhone();
+        String password = appUser.getPassword();
+        String captcha = appUser.getCaptcha();
+
+        // 判断是否处于登录错误的冻结状态 (2分钟内错误5次,则出现冻结提示)
+        lockStatusUtil.checkLockStatus(redisKeyOfLoginFail, phone);
+
+        // 判断图形验证码是否正确
+        if (!captchaUtil.isCaptchaValid(captcha, httpRequestUtil.getKaptchaKey())) {
+            loginFail("验证码错误", phone, false);
+            return null;
+        }
+
+        /*
+        // [Method] 判断 用户是否存在 && 密码是否正确
+        Map<String, Object> b2cMemberDTOSimple = b2cMemberMapper.queryMemberByIdOrName(null, phone);
+        if (!(b2cMemberDTOSimple != null && isUserPasswordValid(b2cMemberDTOSimple, password))) {
+            return Result.error(ResultEnum.INVALID_CREDENTIALS.getCode(), "用户名或密码错误");
+        }
+         */
+
+        return null;
+    }
+
+
+}

+ 8 - 0
src/main/java/com/backendsys/modules/app/service/impl/AppUserServiceImpl.java

@@ -0,0 +1,8 @@
+package com.backendsys.modules.app.service.impl;
+
+import com.backendsys.modules.app.service.AppUserService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class AppUserServiceImpl implements AppUserService {
+}

+ 49 - 0
src/main/java/com/backendsys/modules/common/config/security/utils/CaptchaUtil.java

@@ -1,10 +1,20 @@
 package com.backendsys.modules.common.config.security.utils;
 
 import com.backendsys.modules.common.config.redis.utils.RedisUtil;
+import com.google.code.kaptcha.Producer;
+import jakarta.servlet.ServletOutputStream;
+import jakarta.servlet.http.HttpServletResponse;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Component;
 
+import javax.imageio.ImageIO;
+import java.awt.image.BufferedImage;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.concurrent.TimeUnit;
+
 @Component
 public class CaptchaUtil {
 
@@ -13,7 +23,16 @@ public class CaptchaUtil {
 
     @Autowired
     private RedisUtil redisUtil;
+    @Autowired
+    private HttpRequestUtil httpRequestUtil;
+    @Autowired
+    private Producer captchaProducer;
+    @Value("${CAPTCHA_DURATION}")
+    private Integer CAPTCHA_DURATION;
 
+    /**
+     * 校验 验证码
+     */
     public Boolean isCaptchaValid(String captcha, String captchaRedisKey) {
         // 如果不是本地开发环境,则执行以下判断
         String profileActive = env.getProperty("spring.profiles.active");
@@ -27,4 +46,34 @@ public class CaptchaUtil {
         return true;
     }
 
+    /**
+     * 生成 验证码
+     */
+    public void renderCaptcha(HttpServletResponse response) throws IOException {
+        byte[] captchaChallengeAsJpeg;
+        ByteArrayOutputStream jpegOutputStream = new ByteArrayOutputStream();
+        try {
+            String createText = captchaProducer.createText();
+            // 获得当前 (UA + IP) 生成的 Key
+            String captchaRedisKey = httpRequestUtil.getKaptchaKey();
+            // 保存 验证码字符串 到 redis 中
+            redisUtil.setCacheObject(captchaRedisKey, createText, this.CAPTCHA_DURATION, TimeUnit.MILLISECONDS);
+            // 返回 BufferedImage 对象并转为 byte 写入到 byte 数组中
+            BufferedImage challenge = captchaProducer.createImage(createText);
+            ImageIO.write(challenge, "jpg", jpegOutputStream);
+        } catch (Exception e) {
+            response.sendError(HttpServletResponse.SC_NOT_FOUND);
+        }
+        // 定义response输出类型为image/jpeg类型,使用response输出流输出图片的byte数组
+        captchaChallengeAsJpeg = jpegOutputStream.toByteArray();
+        response.setHeader("Cache-Control", "no-store");
+        response.setHeader("Pragma", "no-cache");
+        response.setDateHeader("Expires", 0);
+        response.setContentType("image/jpeg");
+        ServletOutputStream responseOutputStream = response.getOutputStream();
+        responseOutputStream.write(captchaChallengeAsJpeg);
+        responseOutputStream.flush();
+        responseOutputStream.close();
+    }
+
 }

+ 14 - 13
src/main/java/com/backendsys/modules/common/config/security/utils/CountUtilV2.java → src/main/java/com/backendsys/modules/common/config/security/utils/LockStatusUtil.java

@@ -1,5 +1,6 @@
 package com.backendsys.modules.common.config.security.utils;
 
+import cn.hutool.core.convert.Convert;
 import com.backendsys.exception.CustException;
 import com.backendsys.modules.common.config.redis.utils.RedisUtil;
 import com.backendsys.utils.response.ResultEnum;
@@ -9,37 +10,37 @@ import org.springframework.stereotype.Component;
 import java.util.concurrent.TimeUnit;
 
 @Component
-public class CountUtilV2 {
+public class LockStatusUtil {
 
     @Autowired
     private RedisUtil redisUtil;
 
+    private Integer TIMEOUT = 1;        // 1分钟内
+    private Integer TRIGGER_COUNT = 5;  // 错误5次触发
+
     /**
-     * 判断 2分钟内错误 5次,则出现提示
+     * 判断 1分钟内错误 5次,则出现提示
      */
-    public void setErrorCount(String prefix, String suffix) {
-        Integer timeout = 1;
+    public void setLockStatus(String prefix, String suffix) {
         String redisKey = prefix + "-" + suffix;
         String redisValue = redisUtil.getCacheObject(redisKey);
-
         if (redisValue == null) {
             redisValue = "1";
-        } else if (Integer.valueOf(redisValue) >= 5) {
-            throw new CustException("错误次数过多,为账号安全,请等待" + timeout + "分钟后重新尝试", ResultEnum.LOCK_CREDENTIALS.getCode());
+        } else if (Convert.toInt(redisValue) >= TRIGGER_COUNT) {
+            throw new CustException("错误次数过多,为账号安全,请等待" + TIMEOUT + "分钟后重新尝试", ResultEnum.LOCK_CREDENTIALS.getCode());
         } else {
-            redisValue = String.valueOf((Integer.valueOf(redisValue) + 1));
+            redisValue = Convert.toStr((Convert.toInt(redisValue) + 1));
         }
-        redisUtil.setCacheObject(redisKey, redisValue, timeout, TimeUnit.MINUTES);
+        redisUtil.setCacheObject(redisKey, redisValue, TIMEOUT, TimeUnit.MINUTES);
     }
     /**
      * 判断是否处于 5次的错误状态
      */
-    public void checkErrorStatus(String prefix, String suffix) {
-        Integer timeout = 2;
+    public void checkLockStatus(String prefix, String suffix) {
         String redisKey = prefix + "-" + suffix;
         String redisValue = redisUtil.getCacheObject(redisKey);
-        if (redisValue != null && Integer.valueOf(redisValue) >= 5) {
-            throw new CustException("错误次数过多,为账号安全,请等待" + timeout + "分钟后重新尝试", ResultEnum.LOCK_CREDENTIALS.getCode());
+        if (redisValue != null && Convert.toInt(redisValue) >= TRIGGER_COUNT) {
+            throw new CustException("错误次数过多,为账号安全,请等待" + TIMEOUT + "分钟后重新尝试", ResultEnum.LOCK_CREDENTIALS.getCode());
         }
     }
 

+ 6 - 9
src/main/java/com/backendsys/modules/system/service/impl/SysAuthServiceImpl.java

@@ -3,7 +3,6 @@ package com.backendsys.modules.system.service.impl;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.date.DateUnit;
 import cn.hutool.core.date.DateUtil;
-import cn.hutool.core.util.NumberUtil;
 import cn.hutool.json.JSONUtil;
 import com.backendsys.exception.CustException;
 import com.backendsys.modules.common.config.redis.utils.RedisUtil;
@@ -47,7 +46,7 @@ public class SysAuthServiceImpl implements SysAuthService {
     @Autowired
     private HttpRequestUtil httpRequestUtil;
     @Autowired
-    private CountUtilV2 countUtilV2;
+    private LockStatusUtil lockStatusUtil;
     @Autowired
     private CaptchaUtil captchaUtil;
     @Autowired
@@ -70,10 +69,8 @@ public class SysAuthServiceImpl implements SysAuthService {
     private String SMS_DEBUG;
     @Value("${CAPTCHA_DURATION}")
     private Integer CAPTCHA_DURATION;
-
     @Value("${REDIS_LOGIN_TOKEN_PREFIX}")
     private String REDIS_LOGIN_TOKEN_PREFIX;
-
     @Value("${spring.application.name}")
     private String APPLICATION_NAME;
     private String redisKeyOfLogin = APPLICATION_NAME + "-sms-login";
@@ -121,7 +118,7 @@ public class SysAuthServiceImpl implements SysAuthService {
         // 删除图形验证码
         redisUtil.delete(httpRequestUtil.getKaptchaKey());
         // 添加登录错误的冻结标记
-        if (isIntercept) countUtilV2.setErrorCount(redisKeyOfLoginFail, username);
+        if (isIntercept) lockStatusUtil.setLockStatus(redisKeyOfLoginFail, username);
         throw new CustException(errMsg, ResultEnum.INVALID_CREDENTIALS.getCode());
     }
 
@@ -198,7 +195,7 @@ public class SysAuthServiceImpl implements SysAuthService {
         String captcha = sysAuth.getCaptcha();
 
         // 判断是否处于登录错误的冻结状态 (2分钟内错误5次,则出现冻结提示)
-        countUtilV2.checkErrorStatus(redisKeyOfLoginFail, username);
+        lockStatusUtil.checkLockStatus(redisKeyOfLoginFail, username);
 
         // 判断图形验证码是否正确
         if (!captchaUtil.isCaptchaValid(captcha, httpRequestUtil.getKaptchaKey())) {
@@ -238,7 +235,7 @@ public class SysAuthServiceImpl implements SysAuthService {
         Integer phoneValidCode = sysAuthPhone.getPhone_valid_code();
 
         // 判断是否处于登录错误的冻结状态 (2分钟内错误5次,则出现冻结提示)
-        countUtilV2.checkErrorStatus(redisKeyOfLoginFail, phone);
+        lockStatusUtil.checkLockStatus(redisKeyOfLoginFail, phone);
 
         // 判断短信验证码是否正确
         String redisKey = redisKeyOfLogin + "-" + phone;
@@ -284,8 +281,8 @@ public class SysAuthServiceImpl implements SysAuthService {
         Integer phoneValidCode = sysUserDTO.getPhone_valid_code();
 
         // 判断是否处于登录错误的冻结状态 (2分钟内错误5次,则出现冻结提示)
-        countUtilV2.checkErrorStatus(redisKeyOfRegisterFail, username);
-        countUtilV2.checkErrorStatus(redisKeyOfRegisterFail, phone);
+        lockStatusUtil.checkLockStatus(redisKeyOfRegisterFail, username);
+        lockStatusUtil.checkLockStatus(redisKeyOfRegisterFail, phone);
 
         // 判断图形验证码是否正确
         if (!captchaUtil.isCaptchaValid(captcha, httpRequestUtil.getKaptchaKey())) {

+ 45 - 45
src/main/java/com/backendsys/utils/CountUtil.java

@@ -1,45 +1,45 @@
-package com.backendsys.utils;
-
-import com.backendsys.exception.CustException;
-import com.backendsys.utils.response.ResultEnum;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.StringRedisTemplate;
-import org.springframework.stereotype.Component;
-
-import java.util.concurrent.TimeUnit;
-
-@Component
-public class CountUtil {
-
-    @Autowired
-    private StringRedisTemplate stringRedisTemplate;
-
-    /**
-     * 判断 2分钟内错误 5次,则出现提示
-     */
-    public void setErrorCount(String key, String tag) {
-        Integer timeout = 2;
-        String errKey = key + "-" + tag;
-        String errValue = stringRedisTemplate.opsForValue().get(errKey);
-        if (errValue == null) {
-            errValue = "1";
-        } else if (Integer.valueOf(errValue) >= 5) {
-            throw new CustException("错误次数过多,为账号安全,请等待" + timeout + "分钟后重新尝试", ResultEnum.LOCK_CREDENTIALS.getCode());
-        } else {
-            errValue = String.valueOf((Integer.valueOf(errValue) + 1));
-        }
-        stringRedisTemplate.opsForValue().set(errKey, errValue, timeout, TimeUnit.MINUTES);
-    }
-    /**
-     * 判断是否处于 5次的错误状态
-     */
-    public void checkErrorStatus(String key, String tag) {
-        Integer timeout = 2;
-        String errKey = key + "-" + tag;
-        String errValue = stringRedisTemplate.opsForValue().get(errKey);
-        if (errValue != null && Integer.valueOf(errValue) >= 5) {
-            throw new CustException("错误次数过多,为账号安全,请等待" + timeout + "分钟后重新尝试", ResultEnum.LOCK_CREDENTIALS.getCode());
-        }
-    }
-
-}
+//package com.backendsys.utils;
+//
+//import com.backendsys.exception.CustException;
+//import com.backendsys.utils.response.ResultEnum;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.data.redis.core.StringRedisTemplate;
+//import org.springframework.stereotype.Component;
+//
+//import java.util.concurrent.TimeUnit;
+//
+//@Component
+//public class CountUtil {
+//
+//    @Autowired
+//    private StringRedisTemplate stringRedisTemplate;
+//
+//    /**
+//     * 判断 2分钟内错误 5次,则出现提示
+//     */
+//    public void setErrorCount(String key, String tag) {
+//        Integer timeout = 2;
+//        String errKey = key + "-" + tag;
+//        String errValue = stringRedisTemplate.opsForValue().get(errKey);
+//        if (errValue == null) {
+//            errValue = "1";
+//        } else if (Integer.valueOf(errValue) >= 5) {
+//            throw new CustException("错误次数过多,为账号安全,请等待" + timeout + "分钟后重新尝试", ResultEnum.LOCK_CREDENTIALS.getCode());
+//        } else {
+//            errValue = String.valueOf((Integer.valueOf(errValue) + 1));
+//        }
+//        stringRedisTemplate.opsForValue().set(errKey, errValue, timeout, TimeUnit.MINUTES);
+//    }
+//    /**
+//     * 判断是否处于 5次的错误状态
+//     */
+//    public void checkErrorStatus(String key, String tag) {
+//        Integer timeout = 2;
+//        String errKey = key + "-" + tag;
+//        String errValue = stringRedisTemplate.opsForValue().get(errKey);
+//        if (errValue != null && Integer.valueOf(errValue) >= 5) {
+//            throw new CustException("错误次数过多,为账号安全,请等待" + timeout + "分钟后重新尝试", ResultEnum.LOCK_CREDENTIALS.getCode());
+//        }
+//    }
+//
+//}