|
@@ -15,14 +15,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
-import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.PutMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import com.boman.domain.constant.UserConstants;
|
|
|
import com.boman.domain.dto.R;
|
|
@@ -39,6 +32,8 @@ import com.boman.domain.SysRole;
|
|
|
import com.boman.domain.SysUser;
|
|
|
import com.boman.system.api.model.LoginUser;
|
|
|
|
|
|
+import static com.boman.common.core.utils.SecurityUtils.checkStrongPwd;
|
|
|
+
|
|
|
/**
|
|
|
* 用户信息
|
|
|
*
|
|
@@ -246,7 +241,7 @@ public class SysUserController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize(hasPermi = "system:user:edit")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
- @PutMapping
|
|
|
+ @PostMapping("/put")
|
|
|
public AjaxResult edit(@Validated @RequestBody SysUser user)
|
|
|
{
|
|
|
//userService.checkUserAllowed(user);
|
|
@@ -269,7 +264,7 @@ public class SysUserController extends BaseController
|
|
|
*/
|
|
|
@PreAuthorize(hasPermi = "system:user:remove")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.DELETE)
|
|
|
- @DeleteMapping("/{ids}")
|
|
|
+ @GetMapping(value = "/delete/{ids}")
|
|
|
public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
{
|
|
|
return toAjax(userService.deleteUserByIds(ids));
|
|
@@ -284,17 +279,47 @@ public class SysUserController extends BaseController
|
|
|
public AjaxResult resetPwd(@RequestBody SysUser user)
|
|
|
{
|
|
|
//userService.checkUserAllowed(user);
|
|
|
+ if ("1".equals(checkStrongPwd(user.getPassword()))) {
|
|
|
+ return AjaxResult.error("密码必须包含数字、大小写字母、特殊符号且大于8位");
|
|
|
+ }
|
|
|
user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
|
|
|
user.setUpdateBy(SecurityUtils.getUsername());
|
|
|
return toAjax(userService.resetPwd(user));
|
|
|
}
|
|
|
+ @PostMapping("/resetPwdLogin")
|
|
|
+ public AjaxResult resetPwdLogin(@RequestParam("userName") String userName, @RequestParam("oldPassword") String oldPassword, @RequestParam("newPassword") String newPassword) {
|
|
|
+ //userService.checkUserAllowed(user);
|
|
|
+ if ("admin".equals(userName)){
|
|
|
+ return AjaxResult.success("不允许操作超级管理员");
|
|
|
+ }
|
|
|
+ SysUser user = userService.selectUserByUserName(userName);
|
|
|
+ if (user == null){
|
|
|
+ return AjaxResult.success("当前用户不存在");
|
|
|
+ }
|
|
|
+ String password = user.getPassword();
|
|
|
+ if (!SecurityUtils.matchesPassword(oldPassword, password))
|
|
|
+ {
|
|
|
+ return AjaxResult.success("修改密码失败,旧密码错误");
|
|
|
+ }
|
|
|
+ if (SecurityUtils.matchesPassword(newPassword, password))
|
|
|
+ {
|
|
|
+ return AjaxResult.success("新密码不能与旧密码相同");
|
|
|
+ }
|
|
|
+
|
|
|
+ if ("1".equals(checkStrongPwd(newPassword))) {
|
|
|
+ return AjaxResult.success("密码必须包含数字、大小写字母、特殊符号且大于8位");
|
|
|
+ }
|
|
|
+ user.setPassword(SecurityUtils.encryptPassword(newPassword));
|
|
|
+ user.setUpdateBy(userName);
|
|
|
+ return toAjax(userService.resetPwdLogin(user));
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 状态修改
|
|
|
*/
|
|
|
@PreAuthorize(hasPermi = "system:user:edit")
|
|
|
@Log(title = "用户管理", businessType = BusinessType.UPDATE)
|
|
|
- @PutMapping("/changeStatus")
|
|
|
+ @PostMapping("/changeStatus")
|
|
|
public AjaxResult changeStatus(@RequestBody SysUser user)
|
|
|
{
|
|
|
userService.checkUserAllowed(user);
|