|
|
@ -26,6 +26,7 @@ import com.epmet.commons.tools.constant.EpmetRoleKeyConstant; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
@ -343,4 +344,56 @@ public class UserResiInfoServiceImpl extends BaseServiceImpl<UserResiInfoDao, Us |
|
|
|
userBaseInfoService.insertOrUpdate(baseInfo); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 获取验证码 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return void |
|
|
|
* @author zhaoqifeng |
|
|
|
* @date 2020/11/10 10:50 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void sendCode(SendCodeFormDTO formDTO) { |
|
|
|
//1:判断手机号是否可用
|
|
|
|
if (!getResiInfoByMobile(formDTO.getMobile(), formDTO.getCustomerId())) { |
|
|
|
throw new RenException(EpmetErrorCode.THE_MOBILE_HAS_BEEN_USED.getCode()); |
|
|
|
} |
|
|
|
//2:调用短信服务 生成验证码发送短信
|
|
|
|
SendVerificationCodeFormDTO sendVerificationCodeFormDTO = new SendVerificationCodeFormDTO(); |
|
|
|
sendVerificationCodeFormDTO.setMobile(formDTO.getMobile()); |
|
|
|
sendVerificationCodeFormDTO.setAliyunTemplateCode(SmsTemplateConstant.USER_REGISTER); |
|
|
|
Result<SendVerificationCodeResultDTO> result = epmetMessageOpenFeignClient.sendVerificationCode(sendVerificationCodeFormDTO); |
|
|
|
if (!result.success() || null == result.getData() || StringUtils.isBlank(result.getData().getCode())) { |
|
|
|
throw new RenException(EpmetErrorCode.MOBILE_GET_CODE_ERROR.getCode()); |
|
|
|
} |
|
|
|
//3:删除缓存中可能存在的旧验证码
|
|
|
|
userResiInfoRedis.deleteOldUserMobileCode(formDTO.getUserId(), formDTO.getMobile()); |
|
|
|
//4:将验证码存入redis
|
|
|
|
userResiInfoRedis.setUserResiMobileCode(formDTO.getUserId(),formDTO.getMobile(),result.getData().getCode()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 修改手机号 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return void |
|
|
|
* @author zhaoqifeng |
|
|
|
* @date 2020/11/11 8:59 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public void editMobile(EditMobileFormDTO formDTO) { |
|
|
|
//手机验证码数据校验
|
|
|
|
String verificationCode = userResiInfoRedis.getUserResiMobileCode(formDTO.getUserId(), formDTO.getMobile(), formDTO.getCode()); |
|
|
|
if (null == verificationCode || StringUtils.isBlank(verificationCode)) { |
|
|
|
throw new RenException(EpmetErrorCode.MOBILE_GET_CODE_ERROR.getCode()); |
|
|
|
} |
|
|
|
//更新手机号
|
|
|
|
UserResiInfoDTO dto = baseDao.selectByUserId(formDTO.getUserId()); |
|
|
|
dto.setRegMobile(formDTO.getMobile()); |
|
|
|
update(dto); |
|
|
|
//更新baseInfo
|
|
|
|
UserBaseInfoEntity baseInfo = ConvertUtils.sourceToTarget(formDTO, UserBaseInfoEntity.class); |
|
|
|
userBaseInfoService.insertOrUpdate(baseInfo); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|