| | |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | import com.ruoyi.common.security.annotation.InnerAuth; |
| | | import com.ruoyi.common.security.utils.SecurityUtils; |
| | | 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; |
| | |
| | | private final CompanyService companyService; |
| | | private final RedisService redisService; |
| | | |
| | | |
| | | @PostMapping("/register") |
| | | public R register(@RequestBody MgtCompanyDTO mgtCompanyDTO) { |
| | | companyService.saveCompany(mgtCompanyDTO); |
| | |
| | | public R<UserDetail> getUserDetail() { |
| | | AppUser appLoginUser = SecurityUtils.getAppLoginUser(); |
| | | User user = userService.getById(appLoginUser.getUserId()); |
| | | Company company = companyService.getOne(new LambdaQueryWrapper<Company>() |
| | | .eq(Company::getUserId, user.getUserId())); |
| | | UserDetail userDetail = new UserDetail(); |
| | | BeanUtils.copyProperties(user, userDetail); |
| | | BeanUtils.copyProperties(company, userDetail); |
| | | return R.ok(userDetail); |
| | | } |
| | | |
| | |
| | | if (!user.getPhone().equals(updatePhone.getOldPhone())) { |
| | | return R.fail("旧手机号错误"); |
| | | } |
| | | String verifyKey = CacheConstants.PHONE_CODE_KEY + StringUtils.nvl(user.getPhone(), ""); |
| | | String verifyKey = CacheConstants.PHONE_CODE_KEY + StringUtils.nvl(updatePhone.getNewPhone(), ""); |
| | | String captcha = redisService.getCacheObject(verifyKey); |
| | | if (captcha == null) { |
| | | throw new CaptchaException("验证码已失效"); |
| | |
| | | public R<Void> updatePassword(@RequestBody UpdatePassword updatePassword) { |
| | | AppUser appLoginUser = SecurityUtils.getAppLoginUser(); |
| | | User user = userService.getById(appLoginUser.getUserId()); |
| | | String oldPassword = SecurityUtils.encryptPassword(updatePassword.getOldPassword()); |
| | | if (!user.getPassword().equals(oldPassword)) { |
| | | if (!SecurityUtils.matchesPassword(updatePassword.getOldPassword(), user.getPassword())) { |
| | | return R.fail("旧密码错误"); |
| | | } |
| | | if (!updatePassword.getNewPassword().equals(updatePassword.getConfirmPassword())){ |