正在显示
1 个修改的文件
包含
11 行增加
和
7 行删除
| @@ -19,6 +19,7 @@ import io.swagger.annotations.ApiImplicitParam; | @@ -19,6 +19,7 @@ import io.swagger.annotations.ApiImplicitParam; | ||
| 19 | import io.swagger.annotations.ApiImplicitParams; | 19 | import io.swagger.annotations.ApiImplicitParams; |
| 20 | import io.swagger.annotations.ApiOperation; | 20 | import io.swagger.annotations.ApiOperation; |
| 21 | import lombok.extern.slf4j.Slf4j; | 21 | import lombok.extern.slf4j.Slf4j; |
| 22 | +import org.apache.commons.lang.StringUtils; | ||
| 22 | import org.springframework.beans.factory.annotation.Autowired; | 23 | import org.springframework.beans.factory.annotation.Autowired; |
| 23 | import org.springframework.security.core.context.SecurityContextHolder; | 24 | import org.springframework.security.core.context.SecurityContextHolder; |
| 24 | import org.springframework.security.core.userdetails.UserDetails; | 25 | import org.springframework.security.core.userdetails.UserDetails; |
| @@ -72,7 +73,7 @@ public class UserController { | @@ -72,7 +73,7 @@ public class UserController { | ||
| 72 | } | 73 | } |
| 73 | @ApiOperation(value = "更新用户信息", notes = "更新用户信息除了用户密码") | 74 | @ApiOperation(value = "更新用户信息", notes = "更新用户信息除了用户密码") |
| 74 | @LogAnnotation(moduleName = "用户管理",operate = "用户编辑") | 75 | @LogAnnotation(moduleName = "用户管理",operate = "用户编辑") |
| 75 | - @PutMapping("/edit") | 76 | + @PostMapping("/edit") |
| 76 | public ResultJson updateUserById(@Validated(UpdateUser.class) @RequestBody USERS user){ | 77 | public ResultJson updateUserById(@Validated(UpdateUser.class) @RequestBody USERS user){ |
| 77 | int i = userService.updateByPrimaryKeySelective(user); | 78 | int i = userService.updateByPrimaryKeySelective(user); |
| 78 | user.setPassword(null); | 79 | user.setPassword(null); |
| @@ -83,7 +84,7 @@ public class UserController { | @@ -83,7 +84,7 @@ public class UserController { | ||
| 83 | 84 | ||
| 84 | @LogAnnotation(moduleName = "用户管理",operate = "用户密码修改") | 85 | @LogAnnotation(moduleName = "用户管理",operate = "用户密码修改") |
| 85 | @UserPasswordSM3 | 86 | @UserPasswordSM3 |
| 86 | - @PutMapping("/password") | 87 | + @PostMapping("/password") |
| 87 | public ResultJson updateUserPassById(@RequestBody USERS user){ | 88 | public ResultJson updateUserPassById(@RequestBody USERS user){ |
| 88 | int i = userService.updateByPrimaryKeySelective(user); | 89 | int i = userService.updateByPrimaryKeySelective(user); |
| 89 | return i==1 ? new ResultJson("200","success") :new ResultJson("500","update faild"); | 90 | return i==1 ? new ResultJson("200","success") :new ResultJson("500","update faild"); |
| @@ -105,7 +106,7 @@ public class UserController { | @@ -105,7 +106,7 @@ public class UserController { | ||
| 105 | } | 106 | } |
| 106 | 107 | ||
| 107 | @LogAnnotation(moduleName = "用户管理",operate = "用户删除") | 108 | @LogAnnotation(moduleName = "用户管理",operate = "用户删除") |
| 108 | - @DeleteMapping("/del") | 109 | + @PostMapping("/del") |
| 109 | public ResultJson delUser(@RequestBody USERS user,HttpServletRequest request,HttpServletResponse response){ | 110 | public ResultJson delUser(@RequestBody USERS user,HttpServletRequest request,HttpServletResponse response){ |
| 110 | //String username = getusername(); | 111 | //String username = getusername(); |
| 111 | int i = userService.deleteByPrimaryKey(user.getUserId()); | 112 | int i = userService.deleteByPrimaryKey(user.getUserId()); |
| @@ -113,7 +114,7 @@ public class UserController { | @@ -113,7 +114,7 @@ public class UserController { | ||
| 113 | return i==1 ? new ResultJson("200","删除账户成功") :new ResultJson("500","delete faild"); | 114 | return i==1 ? new ResultJson("200","删除账户成功") :new ResultJson("500","delete faild"); |
| 114 | } | 115 | } |
| 115 | 116 | ||
| 116 | - @PutMapping("/roleset") | 117 | + @PostMapping("/roleset") |
| 117 | public ResultJson roleSet(@RequestBody Map<String,Object> map,HttpServletRequest request,HttpServletResponse respons){ | 118 | public ResultJson roleSet(@RequestBody Map<String,Object> map,HttpServletRequest request,HttpServletResponse respons){ |
| 118 | Integer id = (Integer) map.get("userId"); | 119 | Integer id = (Integer) map.get("userId"); |
| 119 | List<Integer> roles = (List<Integer>) map.get("roleIds"); | 120 | List<Integer> roles = (List<Integer>) map.get("roleIds"); |
| @@ -128,7 +129,7 @@ public class UserController { | @@ -128,7 +129,7 @@ public class UserController { | ||
| 128 | * 刷新redis权限缓存 | 129 | * 刷新redis权限缓存 |
| 129 | */ | 130 | */ |
| 130 | @ApiOperation(value = "更新用户权限缓存", notes = "重新生成用户的信息到redis") | 131 | @ApiOperation(value = "更新用户权限缓存", notes = "重新生成用户的信息到redis") |
| 131 | - @PutMapping("/resetToken") | 132 | + @PostMapping("/resetToken") |
| 132 | public ResultJson resetToken(HttpServletRequest request,HttpServletResponse respons) { | 133 | public ResultJson resetToken(HttpServletRequest request,HttpServletResponse respons) { |
| 133 | /** | 134 | /** |
| 134 | * 更新目标用户的权限缓存 | 135 | * 更新目标用户的权限缓存 |
| @@ -160,20 +161,23 @@ public class UserController { | @@ -160,20 +161,23 @@ public class UserController { | ||
| 160 | return new ResultJson("500","缓存更新失败"); | 161 | return new ResultJson("500","缓存更新失败"); |
| 161 | } | 162 | } |
| 162 | 163 | ||
| 164 | + @ApiOperation(value = "禁用用户", notes = "禁用用户并踢掉已登录的用户,以及启用用户") | ||
| 163 | @LogAnnotation(moduleName = "用户锁定",operate = "用户锁定") | 165 | @LogAnnotation(moduleName = "用户锁定",operate = "用户锁定") |
| 164 | - @PutMapping("/lock") | 166 | + @PostMapping("/lock") |
| 165 | public ResultJson lockUserById(@Validated(UpdateUser.class) @RequestBody USERS user){ | 167 | public ResultJson lockUserById(@Validated(UpdateUser.class) @RequestBody USERS user){ |
| 166 | USERS lockuser = new USERS(); | 168 | USERS lockuser = new USERS(); |
| 167 | lockuser.setUserId(user.getUserId()); | 169 | lockuser.setUserId(user.getUserId()); |
| 168 | - lockuser.setState(false); | 170 | + lockuser.setState(user.getState()); |
| 169 | 171 | ||
| 170 | int i = userService.updateByPrimaryKeySelective(lockuser); | 172 | int i = userService.updateByPrimaryKeySelective(lockuser); |
| 171 | //删除用户token缓存 及时生效锁定账号 | 173 | //删除用户token缓存 及时生效锁定账号 |
| 172 | if (i>0){ | 174 | if (i>0){ |
| 173 | String userTokenStr = redisUtils.get(Token.USER_TOKEN_KEY + user.getUsername()); | 175 | String userTokenStr = redisUtils.get(Token.USER_TOKEN_KEY + user.getUsername()); |
| 176 | + if (StringUtils.isNotEmpty(userTokenStr)){ | ||
| 174 | redisUtils.del(userTokenStr); | 177 | redisUtils.del(userTokenStr); |
| 175 | redisUtils.del(Token.USER_TOKEN_KEY + user.getUsername()); | 178 | redisUtils.del(Token.USER_TOKEN_KEY + user.getUsername()); |
| 176 | } | 179 | } |
| 180 | + } | ||
| 177 | return i==1 ? new ResultJson("200","success") :new ResultJson("500","lock user faild"); | 181 | return i==1 ? new ResultJson("200","success") :new ResultJson("500","lock user faild"); |
| 178 | 182 | ||
| 179 | } | 183 | } |
-
请 注册 或 登录 后发表评论