From ea97720427fd5ea10459327aa736bbdc68c7847d Mon Sep 17 00:00:00 2001 From: 13693261870 <252740454@qq.com> Date: 星期五, 14 十月 2022 17:18:00 +0800 Subject: [PATCH] 1 --- src/main/java/com/lf/server/controller/sys/UserController.java | 115 ++++++++++++++++++++++++++++++++++++++++----------------- 1 files changed, 81 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/lf/server/controller/sys/UserController.java b/src/main/java/com/lf/server/controller/sys/UserController.java index 92a70b7..b679e79 100644 --- a/src/main/java/com/lf/server/controller/sys/UserController.java +++ b/src/main/java/com/lf/server/controller/sys/UserController.java @@ -37,7 +37,7 @@ @SysLog() @ApiOperation(value = "鏌ヨ璁板綍鏁�") @ApiImplicitParams({ - @ApiImplicitParam(name = "uname", value = "鐢ㄦ埛鍚�", dataType = "String", paramType = "query", required = false, example = "sys_user") + @ApiImplicitParam(name = "uname", value = "鐢ㄦ埛鍚�", dataType = "String", paramType = "query", required = false, example = "瀹�") }) @GetMapping({"/selectCount"}) public ResponseMsg<Integer> selectCount(String uname) { @@ -53,7 +53,7 @@ @SysLog() @ApiOperation(value = "鍒嗛〉鏌ヨ") @ApiImplicitParams({ - @ApiImplicitParam(name = "uname", value = "鐢ㄦ埗鍚�", dataType = "String", paramType = "query", example = "sys_user"), + @ApiImplicitParam(name = "uname", value = "鐢ㄦ埗鍚�", dataType = "String", paramType = "query", example = "瀹�"), @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"), @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", dataType = "Integer", paramType = "query", example = "1") }) @@ -75,7 +75,7 @@ @SysLog() @ApiOperation(value = "鍒嗛〉鏌ヨ骞惰繑鍥炶褰曟暟") @ApiImplicitParams({ - @ApiImplicitParam(name = "uname", value = "鐢ㄦ埛鍚�", dataType = "String", paramType = "query", example = "sys_dict"), + @ApiImplicitParam(name = "uname", value = "鐢ㄦ埛鍚�", dataType = "String", paramType = "query", example = "瀹�"), @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"), @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", dataType = "Integer", paramType = "query", example = "1") }) @@ -98,6 +98,63 @@ } @SysLog() + @ApiOperation(value = "鏍规嵁瑙掕壊+鍗曚綅鍒嗛〉鏌ヨ骞惰繑鍥炶褰曟暟") + @ApiImplicitParams({ + @ApiImplicitParam(name = "uname", value = "鐢ㄦ埛鍚�", dataType = "String", paramType = "query", example = "瀹�"), + @ApiImplicitParam(name = "roleid", value = "瑙掕壊ID", dataType = "Integer", paramType = "query", example = "1"), + @ApiImplicitParam(name = "depid", value = "鍗曚綅ID", dataType = "Integer", paramType = "query", example = "1"), + @ApiImplicitParam(name = "pageSize", value = "姣忛〉鏉℃暟", dataType = "Integer", paramType = "query", example = "10"), + @ApiImplicitParam(name = "pageIndex", value = "鍒嗛〉鏁帮紙浠�1寮�濮嬶級", dataType = "Integer", paramType = "query", example = "1") + }) + @GetMapping(value = "/selectByPageForRole") + public ResponseMsg<List<UserEntity>> selectByPageForRole(String uname, Integer roleid, Integer depid, Integer pageSize, Integer pageIndex) { + try { + if (pageSize < 1 || pageIndex < 1) { + return fail("姣忛〉椤垫暟鎴栧垎椤垫暟灏忎簬1", null); + } + int count = userService.selectCountForRole(uname, roleid, depid); + if (count == 0) { + return success(0, null); + } + + List<UserEntity> rs = userService.selectByPageForRole(uname, roleid, depid, pageSize, pageSize * (pageIndex - 1)); + + return success(count, rs); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } + } + + @SysLog() + @ApiOperation(value = "鏍规嵁ID鏌ヨ") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") + }) + @GetMapping(value = "/selectUser") + public ResponseMsg<UserEntity> selectUser(int id) { + try { + UserEntity userEntity = userService.selectUser(id); + + return success(userEntity); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } + } + + @SysLog() + @ApiOperation(value = "鏌ヨ鎵�鏈�") + @GetMapping(value = "/selectUserAll") + public ResponseMsg<List<UserEntity>> selectUserAll() { + try { + List<UserEntity> list = userService.selectUserAll(); + + return success(list); + } catch (Exception ex) { + return fail(ex.getMessage(), null); + } + } + + @SysLog() @ApiOperation(value = "鎻掑叆涓�鏉�") @ApiImplicitParams({ @ApiImplicitParam(name = "entity", value = "瀹炰綋绫�", dataType = "com.lf.server.entity.data.UserEntity", paramType = "body", example = "") @@ -105,6 +162,11 @@ @PostMapping(value = "/insertUser", produces = "application/json; charset=UTF-8") public ResponseMsg<Integer> insertUser(@RequestBody UserEntity entity, HttpServletRequest req) { try { + String str = userService.ValidateNewPwd(entity); + if (str != null) { + return fail(str, -1); + } + UserEntity ue = tokenService.getCurrentUser(req); if (ue != null) { entity.setCreateUser(ue.getId()); @@ -126,9 +188,18 @@ @PostMapping(value = "/insertUsers", produces = "application/json; charset=UTF-8") public ResponseMsg<Integer> insertUsers(@RequestBody List<UserEntity> list, HttpServletRequest req) { try { + if (list == null || list.isEmpty()) { + return fail("瀹炰綋绫婚泦鍚堜负绌�", -1); + } + UserEntity ue = tokenService.getCurrentUser(req); - if (ue != null) { - for (UserEntity entity : list) { + for (UserEntity entity : list) { + String str = userService.ValidateNewPwd(entity); + if (str != null) { + return fail(str, -1); + } + + if (ue != null) { entity.setCreateUser(ue.getId()); } } @@ -186,6 +257,11 @@ @PostMapping(value = "/updateUser", produces = "application/json; charset=UTF-8") public ResponseMsg<Integer> updateUser(@RequestBody UserEntity entity, HttpServletRequest req) { try { + String str = userService.ValidateOldPwd(entity); + if (str != null) { + return fail(str, -1); + } + UserEntity ue = tokenService.getCurrentUser(req); if (ue != null) { entity.setUpdateUser(ue.getId()); @@ -196,35 +272,6 @@ return success(count); } catch (Exception ex) { return fail(ex.getMessage(), -1); - } - } - - @SysLog() - @ApiOperation(value = "鏍规嵁ID鏌ヨ") - @ApiImplicitParams({ - @ApiImplicitParam(name = "id", value = "ID", dataType = "Integer", paramType = "query", example = "1") - }) - @GetMapping(value = "/selectUser") - public ResponseMsg<UserEntity> selectUser(int id) { - try { - UserEntity userEntity = userService.selectUser(id); - - return success(userEntity); - } catch (Exception ex) { - return fail(ex.getMessage(), null); - } - } - - @SysLog() - @ApiOperation(value = "鏌ヨ鎵�鏈�") - @GetMapping(value = "/selectUserAll") - public ResponseMsg<List<UserEntity>> selectUserAll() { - try { - List<UserEntity> list = userService.selectUserAll(); - - return success(list); - } catch (Exception ex) { - return fail(ex.getMessage(), null); } } -- Gitblit v1.9.3