| | |
| | | package com.ruoyi.project.system.controller;
|
| | |
|
| | | import java.util.Map;
|
| | | import org.springframework.beans.factory.annotation.Autowired;
|
| | | import org.springframework.web.bind.annotation.GetMapping;
|
| | | import org.springframework.web.bind.annotation.PostMapping;
|
| | |
| | | currentUser.setSex(user.getSex());
|
| | | if (StringUtils.isNotEmpty(user.getPhonenumber()) && !userService.checkPhoneUnique(currentUser))
|
| | | {
|
| | | return error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
|
| | | return error("修改用户'" + loginUser.getUsername() + "'失败,手机号码已存在");
|
| | | }
|
| | | if (StringUtils.isNotEmpty(user.getEmail()) && !userService.checkEmailUnique(currentUser))
|
| | | {
|
| | | return error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
| | | return error("修改用户'" + loginUser.getUsername() + "'失败,邮箱账号已存在");
|
| | | }
|
| | | if (userService.updateUserProfile(currentUser) > 0)
|
| | | {
|
| | |
| | | */
|
| | | @Log(title = "个人信息", businessType = BusinessType.UPDATE)
|
| | | @PutMapping("/updatePwd")
|
| | | public AjaxResult updatePwd(String oldPassword, String newPassword)
|
| | | public AjaxResult updatePwd(@RequestBody Map<String, String> params)
|
| | | {
|
| | | String oldPassword = params.get("oldPassword");
|
| | | String newPassword = params.get("newPassword");
|
| | | LoginUser loginUser = getLoginUser();
|
| | | String userName = loginUser.getUsername();
|
| | | String password = loginUser.getPassword();
|
| | |
| | | {
|
| | | return error("新密码不能与旧密码相同");
|
| | | }
|
| | | if (userService.resetUserPwd(userName, SecurityUtils.encryptPassword(newPassword)) > 0)
|
| | | newPassword = SecurityUtils.encryptPassword(newPassword);
|
| | | if (userService.resetUserPwd(userName, newPassword) > 0)
|
| | | {
|
| | | // 更新缓存用户密码
|
| | | loginUser.getUser().setPassword(SecurityUtils.encryptPassword(newPassword));
|
| | | loginUser.getUser().setPassword(newPassword);
|
| | | tokenService.setLoginUser(loginUser);
|
| | | return success();
|
| | | }
|