|
|
|
@ -19,7 +19,6 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
|
|
import com.ruoyi.common.core.domain.model.LoginUser;
|
|
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
|
import com.ruoyi.common.utils.ServletUtils;
|
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
|
|
import com.ruoyi.framework.web.service.TokenService;
|
|
|
|
@ -46,7 +45,7 @@ public class SysProfileController extends BaseController
|
|
|
|
|
@GetMapping
|
|
|
|
|
public AjaxResult profile()
|
|
|
|
|
{
|
|
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
|
|
LoginUser loginUser = getLoginUser();
|
|
|
|
|
SysUser user = loginUser.getUser();
|
|
|
|
|
AjaxResult ajax = AjaxResult.success(user);
|
|
|
|
|
ajax.put("roleGroup", userService.selectUserRoleGroup(loginUser.getUsername()));
|
|
|
|
@ -71,17 +70,17 @@ public class SysProfileController extends BaseController
|
|
|
|
|
{
|
|
|
|
|
return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
|
|
|
|
|
}
|
|
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
|
|
LoginUser loginUser = getLoginUser();
|
|
|
|
|
SysUser sysUser = loginUser.getUser();
|
|
|
|
|
user.setUserId(sysUser.getUserId());
|
|
|
|
|
user.setPassword(null);
|
|
|
|
|
if (userService.updateUserProfile(user) > 0)
|
|
|
|
|
{
|
|
|
|
|
// 更新缓存用户信息
|
|
|
|
|
loginUser.getUser().setNickName(user.getNickName());
|
|
|
|
|
loginUser.getUser().setPhonenumber(user.getPhonenumber());
|
|
|
|
|
loginUser.getUser().setEmail(user.getEmail());
|
|
|
|
|
loginUser.getUser().setSex(user.getSex());
|
|
|
|
|
sysUser.setNickName(user.getNickName());
|
|
|
|
|
sysUser.setPhonenumber(user.getPhonenumber());
|
|
|
|
|
sysUser.setEmail(user.getEmail());
|
|
|
|
|
sysUser.setSex(user.getSex());
|
|
|
|
|
tokenService.setLoginUser(loginUser);
|
|
|
|
|
return AjaxResult.success();
|
|
|
|
|
}
|
|
|
|
@ -95,7 +94,7 @@ public class SysProfileController extends BaseController
|
|
|
|
|
@PutMapping("/updatePwd")
|
|
|
|
|
public AjaxResult updatePwd(String oldPassword, String newPassword)
|
|
|
|
|
{
|
|
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
|
|
LoginUser loginUser = getLoginUser();
|
|
|
|
|
String userName = loginUser.getUsername();
|
|
|
|
|
String password = loginUser.getPassword();
|
|
|
|
|
if (!SecurityUtils.matchesPassword(oldPassword, password))
|
|
|
|
@ -125,7 +124,7 @@ public class SysProfileController extends BaseController
|
|
|
|
|
{
|
|
|
|
|
if (!file.isEmpty())
|
|
|
|
|
{
|
|
|
|
|
LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
|
|
|
|
|
LoginUser loginUser = getLoginUser();
|
|
|
|
|
String avatar = FileUploadUtils.upload(RuoYiConfig.getAvatarPath(), file);
|
|
|
|
|
if (userService.updateUserAvatar(loginUser.getUsername(), avatar))
|
|
|
|
|
{
|
|
|
|
|