| | |
| | | import com.ruoyi.company.api.RemoteCompanyUserService; |
| | | import com.ruoyi.company.api.domain.Company; |
| | | import com.ruoyi.company.api.domain.User; |
| | | import com.ruoyi.company.api.domain.dto.MgtCompanyDTO; |
| | | import com.ruoyi.company.api.model.RegisterUser; |
| | | import com.ruoyi.system.api.RemoteUserService; |
| | | import com.ruoyi.system.api.domain.SysUser; |
| | |
| | | recordLogService.recordLogininfor(username, Constants.REGISTER, "注册成功"); |
| | | } |
| | | |
| | | public void companyRegister(RegisterUser registerUser) { |
| | | public void companyRegister(MgtCompanyDTO registerUser) { |
| | | String accountName = registerUser.getAccountName(); |
| | | String password = registerUser.getPassword(); |
| | | // 用户名或密码为空 错误 |
| | |
| | | |
| | | |
| | | public void resetPwd(RegisterUser registerUser) { |
| | | R<User> userR = resetPwdCheck(registerUser); |
| | | User user = userR.getData(); |
| | | String password = SecurityUtils.encryptPassword(registerUser.getPassword()); |
| | | user.setPassword(password); |
| | | R<Void> r = remoteCompanyUserService.updateUser(user); |
| | | if (R.isError(r)) { |
| | | throw new ServiceException(userR.getMsg()); |
| | | } |
| | | } |
| | | |
| | | public R<User> resetPwdCheck(RegisterUser registerUser) { |
| | | String accountName = registerUser.getAccountName(); |
| | | R<User> userByPhoneR = remoteCompanyUserService.getUserByPhone(accountName, SecurityConstants.INNER); |
| | | if (R.isError(userByPhoneR)) { |
| | |
| | | } |
| | | check = check(userR.getData(), registerUser.getCompanyName(), registerUser.getIdCardNumber()); |
| | | } |
| | | |
| | | if (!check) { |
| | | throw new ServiceException("账号不存在"); |
| | | } |
| | | String password = SecurityUtils.encryptPassword(registerUser.getPassword()); |
| | | User user = userR.getData(); |
| | | user.setPassword(password); |
| | | R<Void> r = remoteCompanyUserService.updateUser(user); |
| | | if (R.isError(r)) { |
| | | throw new ServiceException(userR.getMsg()); |
| | | } |
| | | return userR; |
| | | } |
| | | |
| | | public boolean check(User user, String companyName, String idCardNumber) { |
| | |
| | | if (Objects.isNull(sysUser)){ |
| | | throw new ServiceException("用户不存在"); |
| | | } |
| | | if (!SecurityUtils.matchesPassword(SecurityUtils.encryptPassword(dto.getOldPassword()), sysUser.getPassword())){ |
| | | if (!SecurityUtils.matchesPassword(dto.getOldPassword(), sysUser.getPassword())){ |
| | | throw new ServiceException("原密码错误"); |
| | | } |
| | | sysUser.setPassword(SecurityUtils.encryptPassword(dto.getNewPassword())); |