| | |
| | | import com.ruoyi.study.dto.AppUserQuery; |
| | | import com.ruoyi.study.mapper.TUserMapper; |
| | | import com.ruoyi.study.service.ITUserService; |
| | | import com.ruoyi.study.utils.HWSendSms; |
| | | import com.ruoyi.study.vo.AppUserVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.regex.Matcher; |
| | | import java.util.regex.Pattern; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | return this.baseMapper.listAll(query); |
| | | } |
| | | |
| | | @Autowired |
| | | private HWSendSms hwSendSms; |
| | | |
| | | @Override |
| | | public Boolean phoneCode(String phone) { |
| | | public Boolean phoneCode(String phone) throws Exception { |
| | | // 生成随机 6位数字 验证码 |
| | | String phoneCode = RandomUtil.randomNumbers(6); |
| | | // todo 手机验证码暂时 123456 |
| | | phoneCode = "123456"; |
| | | String regex = Constants.PHONE; |
| | | // 编译正则表达式 |
| | | Pattern pattern = Pattern.compile(regex); |
| | | // 创建Matcher对象 |
| | | Matcher matcher = pattern.matcher(phone); |
| | | // 判断是否匹配 |
| | | if (!matcher.matches()) { |
| | | throw new GlobalException("手机号不合法!"); |
| | | } |
| | | hwSendSms.sendSms(phoneCode, phone); |
| | | // 判断redis中是否存在手机验证码 |
| | | Object phoneCodeRedis = redisTemplate.opsForValue().get(RedisConstants.PHONE_CODE + phone); |
| | | if (phoneCodeRedis == null) { |