|
|
@ -12,8 +12,9 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
|
import com.ruoyi.common.annotation.Log;
|
|
|
|
import com.ruoyi.common.base.AjaxResult;
|
|
|
|
|
|
|
|
import com.ruoyi.common.config.Global;
|
|
|
|
import com.ruoyi.common.config.Global;
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.controller.BaseController;
|
|
|
|
|
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
|
import com.ruoyi.common.enums.BusinessType;
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
|
import com.ruoyi.common.utils.file.FileUploadUtils;
|
|
|
@ -22,7 +23,6 @@ import com.ruoyi.framework.util.ShiroUtils;
|
|
|
|
import com.ruoyi.system.domain.SysUser;
|
|
|
|
import com.ruoyi.system.domain.SysUser;
|
|
|
|
import com.ruoyi.system.service.ISysDictDataService;
|
|
|
|
import com.ruoyi.system.service.ISysDictDataService;
|
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
|
import com.ruoyi.system.service.ISysUserService;
|
|
|
|
import com.ruoyi.framework.web.base.BaseController;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 个人信息 业务处理
|
|
|
|
* 个人信息 业务处理
|
|
|
@ -52,7 +52,7 @@ public class SysProfileController extends BaseController
|
|
|
|
@GetMapping()
|
|
|
|
@GetMapping()
|
|
|
|
public String profile(ModelMap mmap)
|
|
|
|
public String profile(ModelMap mmap)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SysUser user = getSysUser();
|
|
|
|
SysUser user = ShiroUtils.getSysUser();
|
|
|
|
user.setSex(dictDataService.selectDictLabel("sys_user_sex", user.getSex()));
|
|
|
|
user.setSex(dictDataService.selectDictLabel("sys_user_sex", user.getSex()));
|
|
|
|
mmap.put("user", user);
|
|
|
|
mmap.put("user", user);
|
|
|
|
mmap.put("roleGroup", userService.selectUserRoleGroup(user.getUserId()));
|
|
|
|
mmap.put("roleGroup", userService.selectUserRoleGroup(user.getUserId()));
|
|
|
@ -64,7 +64,7 @@ public class SysProfileController extends BaseController
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
public boolean checkPassword(String password)
|
|
|
|
public boolean checkPassword(String password)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SysUser user = getSysUser();
|
|
|
|
SysUser user = ShiroUtils.getSysUser();
|
|
|
|
if (passwordService.matches(user, password))
|
|
|
|
if (passwordService.matches(user, password))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
@ -75,7 +75,7 @@ public class SysProfileController extends BaseController
|
|
|
|
@GetMapping("/resetPwd")
|
|
|
|
@GetMapping("/resetPwd")
|
|
|
|
public String resetPwd(ModelMap mmap)
|
|
|
|
public String resetPwd(ModelMap mmap)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SysUser user = getSysUser();
|
|
|
|
SysUser user = ShiroUtils.getSysUser();
|
|
|
|
mmap.put("user", userService.selectUserById(user.getUserId()));
|
|
|
|
mmap.put("user", userService.selectUserById(user.getUserId()));
|
|
|
|
return prefix + "/resetPwd";
|
|
|
|
return prefix + "/resetPwd";
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -85,14 +85,14 @@ public class SysProfileController extends BaseController
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
public AjaxResult resetPwd(String oldPassword, String newPassword)
|
|
|
|
public AjaxResult resetPwd(String oldPassword, String newPassword)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SysUser user = getSysUser();
|
|
|
|
SysUser user = ShiroUtils.getSysUser();
|
|
|
|
if (StringUtils.isNotEmpty(newPassword) && passwordService.matches(user, oldPassword))
|
|
|
|
if (StringUtils.isNotEmpty(newPassword) && passwordService.matches(user, oldPassword))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
user.setSalt(ShiroUtils.randomSalt());
|
|
|
|
user.setSalt(ShiroUtils.randomSalt());
|
|
|
|
user.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt()));
|
|
|
|
user.setPassword(passwordService.encryptPassword(user.getLoginName(), newPassword, user.getSalt()));
|
|
|
|
if (userService.resetUserPwd(user) > 0)
|
|
|
|
if (userService.resetUserPwd(user) > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setSysUser(userService.selectUserById(user.getUserId()));
|
|
|
|
ShiroUtils.setSysUser(userService.selectUserById(user.getUserId()));
|
|
|
|
return success();
|
|
|
|
return success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return error();
|
|
|
|
return error();
|
|
|
@ -109,7 +109,7 @@ public class SysProfileController extends BaseController
|
|
|
|
@GetMapping("/edit")
|
|
|
|
@GetMapping("/edit")
|
|
|
|
public String edit(ModelMap mmap)
|
|
|
|
public String edit(ModelMap mmap)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SysUser user = getSysUser();
|
|
|
|
SysUser user = ShiroUtils.getSysUser();
|
|
|
|
mmap.put("user", userService.selectUserById(user.getUserId()));
|
|
|
|
mmap.put("user", userService.selectUserById(user.getUserId()));
|
|
|
|
return prefix + "/edit";
|
|
|
|
return prefix + "/edit";
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -120,7 +120,7 @@ public class SysProfileController extends BaseController
|
|
|
|
@GetMapping("/avatar")
|
|
|
|
@GetMapping("/avatar")
|
|
|
|
public String avatar(ModelMap mmap)
|
|
|
|
public String avatar(ModelMap mmap)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SysUser user = getSysUser();
|
|
|
|
SysUser user = ShiroUtils.getSysUser();
|
|
|
|
mmap.put("user", userService.selectUserById(user.getUserId()));
|
|
|
|
mmap.put("user", userService.selectUserById(user.getUserId()));
|
|
|
|
return prefix + "/avatar";
|
|
|
|
return prefix + "/avatar";
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -133,14 +133,14 @@ public class SysProfileController extends BaseController
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
public AjaxResult update(SysUser user)
|
|
|
|
public AjaxResult update(SysUser user)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SysUser currentUser = getSysUser();
|
|
|
|
SysUser currentUser = ShiroUtils.getSysUser();
|
|
|
|
currentUser.setUserName(user.getUserName());
|
|
|
|
currentUser.setUserName(user.getUserName());
|
|
|
|
currentUser.setEmail(user.getEmail());
|
|
|
|
currentUser.setEmail(user.getEmail());
|
|
|
|
currentUser.setPhonenumber(user.getPhonenumber());
|
|
|
|
currentUser.setPhonenumber(user.getPhonenumber());
|
|
|
|
currentUser.setSex(user.getSex());
|
|
|
|
currentUser.setSex(user.getSex());
|
|
|
|
if (userService.updateUserInfo(currentUser) > 0)
|
|
|
|
if (userService.updateUserInfo(currentUser) > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setSysUser(userService.selectUserById(currentUser.getUserId()));
|
|
|
|
ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId()));
|
|
|
|
return success();
|
|
|
|
return success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return error();
|
|
|
|
return error();
|
|
|
@ -154,7 +154,7 @@ public class SysProfileController extends BaseController
|
|
|
|
@ResponseBody
|
|
|
|
@ResponseBody
|
|
|
|
public AjaxResult updateAvatar(@RequestParam("avatarfile") MultipartFile file)
|
|
|
|
public AjaxResult updateAvatar(@RequestParam("avatarfile") MultipartFile file)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
SysUser currentUser = getSysUser();
|
|
|
|
SysUser currentUser = ShiroUtils.getSysUser();
|
|
|
|
try
|
|
|
|
try
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (!file.isEmpty())
|
|
|
|
if (!file.isEmpty())
|
|
|
@ -163,7 +163,7 @@ public class SysProfileController extends BaseController
|
|
|
|
currentUser.setAvatar(avatar);
|
|
|
|
currentUser.setAvatar(avatar);
|
|
|
|
if (userService.updateUserInfo(currentUser) > 0)
|
|
|
|
if (userService.updateUserInfo(currentUser) > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
setSysUser(userService.selectUserById(currentUser.getUserId()));
|
|
|
|
ShiroUtils.setSysUser(userService.selectUserById(currentUser.getUserId()));
|
|
|
|
return success();
|
|
|
|
return success();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|