dev:app端扫码入职流程代码修改

main
SondonYong 2025-12-04 15:07:10 +08:00
parent 9ae0caad52
commit e786fecd88
4 changed files with 39 additions and 37 deletions

View File

@ -26,11 +26,11 @@ import org.springframework.web.bind.annotation.*;
public class AppUserController {
private final UserServiceI userService;
@ApiOperation("验证手机号是否已注册")
@PostMapping("/verifyPhone")
public Response verifyPhone(@Validated @RequestBody UserVerifyPhoneCmd cmd) {
return userService.verifyPhone(cmd);
}
// @ApiOperation("验证手机号是否已注册")
// @PostMapping("/verifyPhone")
// public Response verifyPhone(@Validated @RequestBody UserVerifyPhoneCmd cmd) {
// return userService.verifyPhone(cmd);
// }
@ApiOperation("发送验证码")
@PostMapping("/sendPhoneCode")

View File

@ -60,7 +60,7 @@ public class UserAddExe {
private final UserCorpRepository userCorpRepository;
private final UserChangeRecordGateway userChangeRecordGateway;
private final UserCorpRecordGateway userCorpRecordGateway;
private ZcloudRedisUtil zcloudRedisUtil;
// private ZcloudRedisUtil zcloudRedisUtil;
@Transactional(rollbackFor = Exception.class)
@ -109,11 +109,11 @@ public class UserAddExe {
UserE userE = new UserE();
userE.checkPassword(cmd.getPassword(), cmd.getConfirmPassword());
// 获取redis验证码
Object phoneCodeObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
if(phoneCodeObj == null || !phoneCodeObj.toString().equals(cmd.getPhoneCode())){
throw new BizException("验证码已过期或错误");
}
zcloudRedisUtil.del(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
// Object phoneCodeObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
// if(phoneCodeObj == null || !phoneCodeObj.toString().equals(cmd.getPhoneCode())){
// throw new BizException("验证码已过期或错误");
// }
// zcloudRedisUtil.del(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
CorpInfoDO corpInfoDO = corpInfoRepository.getCorpInfoByCorpName("相关方通用租户");
if(corpInfoDO == null){
@ -121,6 +121,7 @@ public class UserAddExe {
}
BeanUtils.copyProperties(cmd, userE);
userE.setCorpinfoId(corpInfoDO.getId());
userE.setDepartmentId(corpInfoDO.getId());
userGateway.register(userE);
return true;
@ -185,27 +186,28 @@ public class UserAddExe {
public boolean executeSendPhoneCode(UserVerifyPhoneCmd cmd) {
// 生成6位验证码
String phoneCode = RandomUtil.randomNumbers(6);
Object phoneCodeCountObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_COUNT + DateUtil.getDays() + ":" + cmd.getPhone());
if(phoneCodeCountObj != null){
Integer phoneCodeCount = (Integer) phoneCodeCountObj;
if(phoneCodeCount >= 20){
throw new BizException("今天验证码已发送次数已超过20次");
}
}
// Object phoneCodeCountObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_COUNT + DateUtil.getDays() + ":" + cmd.getPhone());
// if(phoneCodeCountObj != null){
// Integer phoneCodeCount = (Integer) phoneCodeCountObj;
// if(phoneCodeCount >= 20){
// throw new BizException("今天验证码已发送次数已超过20次");
// }
// }
boolean sendFlag = sendMessage(cmd.getPhone(), phoneCode);
if(sendFlag){
// 发送成功
// 放入到redis里
zcloudRedisUtil.set(RedisConstant.PHONE_CODE_KEY + cmd.getPhone(), phoneCode, 60 * 15);
// 设置新的验证码发送次数
zcloudRedisUtil.set(RedisConstant.PHONE_CODE_COUNT + DateUtil.getDays() + ":" + cmd.getPhone(),
phoneCodeCountObj == null ? 1 : (Integer)phoneCodeCountObj + 1,
60 * 60 * 24);
return true;
}
// boolean sendFlag = sendMessage(cmd.getPhone(), phoneCode);
// if(sendFlag){
// // 发送成功
// // 放入到redis里
// zcloudRedisUtil.set(RedisConstant.PHONE_CODE_KEY + cmd.getPhone(), phoneCode, 60 * 15);
// // 设置新的验证码发送次数
// zcloudRedisUtil.set(RedisConstant.PHONE_CODE_COUNT + DateUtil.getDays() + ":" + cmd.getPhone(),
// phoneCodeCountObj == null ? 1 : (Integer)phoneCodeCountObj + 1,
// 60 * 60 * 24);
// return true;
// }
return false;
// return false;
return true;
}
// 组装发送短信

View File

@ -123,11 +123,11 @@ public class UserUpdateExe {
userE.checkPassword(cmd.getPassword(), cmd.getConfirmPassword());
// 获取redis验证码
Object phoneCodeObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
if(phoneCodeObj == null || !phoneCodeObj.toString().equals(cmd.getPhoneCode())){
throw new BizException("验证码已过期或错误");
}
zcloudRedisUtil.del(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
// Object phoneCodeObj = zcloudRedisUtil.get(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
// if(phoneCodeObj == null || !phoneCodeObj.toString().equals(cmd.getPhoneCode())){
// throw new BizException("验证码已过期或错误");
// }
// zcloudRedisUtil.del(RedisConstant.PHONE_CODE_KEY + cmd.getPhone());
BeanUtils.copyProperties(cmd, userE);
userE.encryptionPassword();

View File

@ -226,8 +226,8 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
userAddCmd.setAccount(userDO.getPhone());
userAddCmd.setMobile(userDO.getPhone());
RoleDeptAddCmd roleDeptAddCmd = new RoleDeptAddCmd();
roleDeptAddCmd.setRoleId(0L);
roleDeptAddCmd.setDeptId(0L);
roleDeptAddCmd.setRoleId(1994326788804837377L);
roleDeptAddCmd.setDeptId(userDO.getDepartmentId());
List<RoleDeptAddCmd> roleDeptAddCmdList = Collections.singletonList(roleDeptAddCmd);
userAddCmd.setRoleDepts(roleDeptAddCmdList);
userAddCmd.setTenantId(userDO.getCorpinfoId());