| | |
| | | @RequestMapping("user") |
| | | @Api(tags = "用户管理-用户") |
| | | @Slf4j |
| | | public class UserController { |
| | | public class UserController extends BaseController{ |
| | | |
| | | @Resource |
| | | private UserService userService; |
| | |
| | | return new Response().set(1,userService.getAllWithPage(pageNum,pageSize)); |
| | | } |
| | | |
| | | @PutMapping |
| | | @PostMapping("update") |
| | | @ApiOperation(value = "编辑") |
| | | public Response update(@RequestBody UserInf user){ |
| | | return userService.update(user); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @PostMapping("delete") |
| | | @ApiOperation(value = "删除") |
| | | public Response delete(@RequestParam int id){ |
| | | userService.delete(id); |
| | | boolean deleteFlag = userService.delete(id); |
| | | if (!deleteFlag){ |
| | | return new Response().setII(0,"删除失败,当前用户没有用户编辑权限"); |
| | | } |
| | | return new Response().setII(1,"删除成功"); |
| | | } |
| | | @GetMapping("/searchUKeyToUName") |
| | |
| | | |
| | | @GetMapping("/searchUNameToUKey") |
| | | @ApiOperation(value = "根据用户名查绑定的Ukey") |
| | | public Response getUserByUserName(@RequestParam String uKeyId){ |
| | | UserInf userInf = userService.getUserByUKeyId(uKeyId); |
| | | public Response getUserByUserName(@RequestParam String userName){ |
| | | UserInf userInf = userService.getUserByUserName(userName); |
| | | Response response = new Response(); |
| | | if (userInf!=null){ |
| | | if (StringUtils.isEmpty(userInf.getUkeyId())){ |
| | | response.set(0,"该用户没有绑定Ukey"); |
| | | response.set(-1,false,"该用户没有绑定Ukey"); |
| | | }else { |
| | | response.set(1,userInf); |
| | | response.setII(1,true,userInf,"该用户有绑定Ukey"); |
| | | } |
| | | }else{ |
| | | response.set(0,"该用户不存在"); |
| | | response.set(0,false,"该用户不存在"); |
| | | } |
| | | return response; |
| | | } |
| | |
| | | return new Response().set(0); |
| | | } |
| | | } |
| | | |
| | | @GetMapping("/checkAndUpdatePasswordByRSA") |
| | | @ApiOperation(value = "检查并修改用户RSA密码") |
| | | public Response checkAndUpdatePasswordByRSA(@RequestParam String oldPwd,@RequestParam String newPwd){ |
| | | UserInf userInf = ActionUtil.getUser(); |
| | | String passwordEncrypt = oldPwd; |
| | | String password = RSAUtil.decryptFront(passwordEncrypt, RSAUtil.fontSeparator)[0]; |
| | | String passwordDB = RSAUtil.decrypt(userInf.getUpassword(),RSAUtil.getPrivateKey()); |
| | | if(passwordDB.equals(password)){ |
| | | return userService.updatePasswordByRSA(userInf,newPwd); |
| | | }else { |
| | | return new Response().set(0,false,"原密码不正确"); |
| | | } |
| | | } |
| | | |
| | | @PostMapping("/updatePassword") |
| | | @ApiOperation(value = "修改密码") |
| | |
| | | return userService.updatePasswordByRSA(userInf,password); |
| | | } |
| | | |
| | | @GetMapping("updatePasswordByValidity") |
| | | @ApiOperation(value = "修改密码-密码失效") |
| | | public Response updatePasswordByValidity(@RequestParam String uname,@RequestParam String oldPwd,@RequestParam String newPwd) throws UnsupportedEncodingException { |
| | | return userService.updatePasswordByValidity(uname,oldPwd,newPwd); |
| | | } |
| | | |
| | | /** |
| | | * 1.首次登录,请先修改初始化口令 |
| | | * 2.超过3个月没有修改口令,请修改口令后重新登录 |
| | | */ |
| | | @PutMapping("updatePassword2") |
| | | @PostMapping("updatePassword2") |
| | | @ApiOperation(value = "修改密码-3个月未登录") |
| | | public Response updatePassword2(@RequestParam String passwordOld,String passwordNew){ |
| | | //校验老密码 |
| | |
| | | * 账号解锁 |
| | | */ |
| | | @ApiOperation(value = "账号解锁",notes = "unLockType=1为失败锁定解锁,2为上个月未登录锁定解锁") |
| | | @PutMapping("unLock") |
| | | @PostMapping("unLock") |
| | | public Response unLock(@RequestParam int uId,@RequestParam int unLockType){ |
| | | userService.unLock(uId,unLockType); |
| | | return new Response().setII(1,"解锁成功"); |