摘要: public Map loginVerification(String mobile, String code) { //1. 从Redis中获取验证码 String redisCode = redisTemplate.opsForValue().get("CHECK_CODE_" + mobile 阅读全文
posted @ 2022-04-29 10:31 twb_QAQZ 阅读(81) 评论(0) 推荐(0)
摘要: 调用spring的自动装配 application.yml tanhua: msg: smsSignId: templateId: appcode: 配置类 @ConfigurationProperties(prefix = "tanhua.msg") @Data public class MsgP 阅读全文
posted @ 2022-04-29 10:30 twb_QAQZ 阅读(442) 评论(0) 推荐(0)
摘要: 阅读全文
posted @ 2022-04-29 10:24 twb_QAQZ 阅读(64) 评论(0) 推荐(0)
摘要: 登陆完成:通过JWT令牌存储用户信息,并随请求在app和服务器间传输 public class JwtUtils { /** * TOKEN的有效期1小时(S) */ private static final int TOKEN_TIME_OUT = 1 * 3600; /** * 加密KEY */ 阅读全文
posted @ 2022-04-29 10:22 twb_QAQZ 阅读(144) 评论(0) 推荐(0)
摘要: package com.tanhua.commons.utils;//常量定义public class Constants { //冻结用户 redis前缀 public static final String FREEZE_USER = "FREEZE_USER_"; //手机APP短信验证码CH 阅读全文
posted @ 2022-04-26 08:57 twb_QAQZ 阅读(82) 评论(0) 推荐(0)
摘要: 1.冻结用户,将数据存入Redis,并设置key的失效时间。2.解冻用户,删除Redis数据3.探花系统在用户登录,评论,发布动态时判断其冻结状态,如果被冻结抛出异常 用户状态枚举 public enum UserStatusEnum { FREEZE_LOGIN("1","冻结登录"), FREE 阅读全文
posted @ 2022-04-25 21:56 twb_QAQZ 阅读(434) 评论(0) 推荐(0)
摘要: @ControllerAdvice public class ExceptionAdvice { // 处理业务异常 @ExceptionHandler(BusinessException.class) public ResponseEntity handaleException(BusinessE 阅读全文
posted @ 2022-04-25 21:51 twb_QAQZ 阅读(88) 评论(0) 推荐(0)
摘要: 问题: 前面已经实现了移动端手机验证码登录,随机生成的验证码我们是保存在HttpSession中的,但是存在HttpSession中就无法设置过期时间,就需要对这一块的功能进行优化。 优化步骤: 1. 在UserController中注入RedisTemplate对象,用于操作Redis @Auto 阅读全文
posted @ 2022-04-09 19:58 twb_QAQZ 阅读(79) 评论(0) 推荐(0)
摘要: 1.引依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-cache</artifactId> </dependency> 2.在yml中设置缓存过期时间 spring 阅读全文
posted @ 2022-04-09 19:51 twb_QAQZ 阅读(142) 评论(0) 推荐(0)
摘要: 1.依赖: <dependency> <groupId>org.apache.shardingsphere</groupId> <artifactId>sharding-jdbc-spring-boot-starter</artifactId> <version>4.0.0-RC1</version 阅读全文
posted @ 2022-04-09 19:31 twb_QAQZ 阅读(67) 评论(0) 推荐(0)