1
luodangjia
2025-01-21 68ee18438e99995d2d108cccb36e75f77ea96d76
ruoyi-modules/ruoyi-company/src/main/java/com/ruoyi/company/controller/front/UserController.java
@@ -9,6 +9,7 @@
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;
@@ -35,7 +36,6 @@
    private final CompanyService companyService;
    private final RedisService redisService;
    @PostMapping("/register")
    public R register(@RequestBody MgtCompanyDTO mgtCompanyDTO) {
        companyService.saveCompany(mgtCompanyDTO);
@@ -47,8 +47,11 @@
    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);
    }
@@ -97,7 +100,7 @@
        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("验证码已失效");
@@ -124,8 +127,7 @@
    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())){