|
@@ -51,7 +51,7 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
-import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
|
|
|
|
|
|
+import org.springframework.security.crypto.password.PasswordEncoder;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
@@ -106,37 +106,12 @@ public class MaTechnicianController extends BaseController {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private WxTokenService wxTokenService;
|
|
private WxTokenService wxTokenService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private PasswordEncoder passwordEncoder;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
public static final String PHONE_THREEUSERPARTCLIENT_CODE_KEY = "sys:clientLogin:phone:";
|
|
public static final String PHONE_THREEUSERPARTCLIENT_CODE_KEY = "sys:clientLogin:phone:";
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 发送短信验证码
|
|
|
|
|
- *
|
|
|
|
|
- * @param phone 手机号
|
|
|
|
|
- * @param request
|
|
|
|
|
- * @return Result
|
|
|
|
|
- */
|
|
|
|
|
- @GetMapping("/sendMsg")
|
|
|
|
|
- @ApiOperation(value = "短信发送", notes = "短信发送")
|
|
|
|
|
- public Result sendMsg(@RequestParam String phone, HttpServletRequest request) {
|
|
|
|
|
- if (org.apache.commons.lang3.StringUtils.isEmpty(phone)) {
|
|
|
|
|
- return Result.error("手机号不能为空");
|
|
|
|
|
- }
|
|
|
|
|
- Random rand = new Random();
|
|
|
|
|
- // randNumber 将被赋值为一个 MIN 和 MAX 范围内的随机数
|
|
|
|
|
- int randNumber = rand.nextInt(9999 - 1000 + 1) + 1000;
|
|
|
|
|
- // 保存验证码到redis中,过期时间为5分钟
|
|
|
|
|
- redisTemplate.opsForValue().set(PHONE_THREEUSERPARTCLIENT_CODE_KEY + phone, String.valueOf(randNumber), 5L, TimeUnit.MINUTES);
|
|
|
|
|
- try {
|
|
|
|
|
- SMSVerificationCode smsVerificationCode = new SMSVerificationCode(String.valueOf(randNumber));
|
|
|
|
|
- String jsonString = JSON.toJSONString(smsVerificationCode);
|
|
|
|
|
- sendSms.sendSms(phone, SendSmsEnum.SMS_220650024, jsonString);
|
|
|
|
|
- return Result.ok("发送成功");
|
|
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }
|
|
|
|
|
- return Result.ok("发送成功");
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 商户手机号密码登录
|
|
* 商户手机号密码登录
|
|
@@ -177,9 +152,8 @@ public class MaTechnicianController extends BaseController {
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
// 初始化加密工具
|
|
// 初始化加密工具
|
|
|
- BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
|
|
|
|
|
// 验证:比对是否匹配
|
|
// 验证:比对是否匹配
|
|
|
- boolean isOk = encoder.matches(thirdPartyLoginsVo.getPassWord(), maTechnician.getTePassword());
|
|
|
|
|
|
|
+ boolean isOk = passwordEncoder.matches(thirdPartyLoginsVo.getPassWord(), maTechnician.getTePassword());
|
|
|
/*if (!isOk) {
|
|
/*if (!isOk) {
|
|
|
return Result.error("密码错误");
|
|
return Result.error("密码错误");
|
|
|
}*/
|
|
}*/
|
|
@@ -240,9 +214,8 @@ public class MaTechnicianController extends BaseController {
|
|
|
// 重置密码逻辑
|
|
// 重置密码逻辑
|
|
|
LambdaUpdateWrapper<MaTechnician> updateWrapper = new LambdaUpdateWrapper<>();
|
|
LambdaUpdateWrapper<MaTechnician> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
updateWrapper.eq(MaTechnician::getTePhone, thirdPartyLoginsVo.getPhone());
|
|
updateWrapper.eq(MaTechnician::getTePhone, thirdPartyLoginsVo.getPhone());
|
|
|
- BCryptPasswordEncoder encoder = new BCryptPasswordEncoder();
|
|
|
|
|
// 对密码进行加密
|
|
// 对密码进行加密
|
|
|
- String encryptedPassword = encoder.encode(thirdPartyLoginsVo.getPassWord());
|
|
|
|
|
|
|
+ String encryptedPassword = passwordEncoder.encode(thirdPartyLoginsVo.getPassWord());
|
|
|
updateWrapper.set(MaTechnician::getTePassword, encryptedPassword);
|
|
updateWrapper.set(MaTechnician::getTePassword, encryptedPassword);
|
|
|
maTechnicianService.update(updateWrapper);
|
|
maTechnicianService.update(updateWrapper);
|
|
|
// 重置密码成功删除验证码
|
|
// 重置密码成功删除验证码
|