| | |
| | | import com.ruoyi.im.service.ImApiServcie; |
| | | import com.ruoyi.im.util.ConverterUtil; |
| | | import com.ruoyi.im.util.PhoneNumberValidatorUtil; |
| | | import com.ruoyi.im.util.SymmetricCryptoUtil; |
| | | import com.ruoyi.system.domain.UserAccount; |
| | | import com.ruoyi.system.domain.vo.UserAccountUpdateVo; |
| | | import com.ruoyi.system.domain.vo.UserAccountVo; |
| | |
| | | public AjaxResult updateUserAccount(UserAccountUpdateVo vo) { |
| | | |
| | | try { |
| | | UserAccount userAccount = userAccountService.getById(vo.getId()); |
| | | UserAccount userAccount = userAccountService.getOne(new LambdaQueryWrapper<UserAccount>() |
| | | .eq(UserAccount::getAccount,vo.getAccount()) |
| | | ); |
| | | if(ObjectUtil.isEmpty(userAccount)){ |
| | | return AjaxResult.error("会员不存在!"); |
| | | } |
| | | PhoneNumberValidatorUtil.ValidationResult result = PhoneNumberValidatorUtil.validatePhoneNumber(vo.getPhoneNumber()); |
| | | if(!result.isValid()){ |
| | | return AjaxResult.error("手机号格式不正确!"); |
| | | if(StringUtils.isNotEmpty(vo.getPhoneNumber())){ |
| | | PhoneNumberValidatorUtil.ValidationResult result = PhoneNumberValidatorUtil.validatePhoneNumber(vo.getPhoneNumber()); |
| | | if(!result.isValid()){ |
| | | return AjaxResult.error("手机号格式不正确!"); |
| | | } |
| | | } |
| | | vo.setAccountId(userAccount.getCloudMessageAccount()); |
| | | if(StringUtils.isNotEmpty(vo.getPassword()) && StringUtils.isEmpty(vo.getOldPassword())){ |
| | | return AjaxResult.error("旧密码不能为空!"); |
| | | } |
| | | if(StringUtils.isNotEmpty(vo.getPassword())){ |
| | | String s = SymmetricCryptoUtil.decryptPassword(userAccount.getPassword()); |
| | | if(!vo.getOldPassword().equals(s)){ |
| | | return AjaxResult.error("旧密码不正确!"); |
| | | } |
| | | } |
| | | vo.setAccount(userAccount.getCloudMessageAccount()); |
| | | return imApiServcie.updateUserAccount(vo); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | if(StringUtils.isEmpty(dto.getPassword())){ |
| | | return Result.error("密码不能为空"); |
| | | } |
| | | if(StringUtils.isEmpty(dto.getNickname())){ |
| | | if(StringUtils.isEmpty(dto.getNikeName())){ |
| | | return Result.error("昵称不能为空"); |
| | | } |
| | | }else if (dto.getType() == 1){ |