4646 * @author pedro@TaleLin
4747 * @author Juzi@TaleLin
4848 */
49+ @ Validated
4950@ RestController
5051@ RequestMapping ("/cms/admin" )
5152@ PermissionModule (value = "管理员" )
52- @ Validated
5353public class AdminController {
5454
5555 @ Autowired
@@ -58,18 +58,17 @@ public class AdminController {
5858 @ Autowired
5959 private GroupService groupService ;
6060
61- @ GetMapping ("/permission" )
6261 @ AdminRequired
62+ @ GetMapping ("/permission" )
6363 @ PermissionMeta (value = "查询所有可分配的权限" , mount = false )
6464 public Map <String , List <PermissionDO >> getAllPermissions () {
6565 return adminService .getAllStructuralPermissions ();
6666 }
6767
68-
69- @ GetMapping ("/users" )
7068 @ AdminRequired
69+ @ GetMapping ("/users" )
7170 @ PermissionMeta (value = "查询所有用户" , mount = false )
72- public PageResponseVO getUsers (
71+ public PageResponseVO < UserInfoVO > getUsers (
7372 @ RequestParam (name = "group_id" , required = false )
7473 @ Min (value = 1 , message = "{group.id.positive}" ) Integer groupId ,
7574 @ RequestParam (name = "count" , required = false , defaultValue = "10" )
@@ -85,34 +84,34 @@ public PageResponseVO getUsers(
8584 return PageUtil .build (iPage , userInfos );
8685 }
8786
88- @ PutMapping ("/user/{id}/password" )
8987 @ AdminRequired
88+ @ PutMapping ("/user/{id}/password" )
9089 @ PermissionMeta (value = "修改用户密码" , mount = false )
9190 public UpdatedVO changeUserPassword (@ PathVariable @ Positive (message = "{id.positive}" ) Integer id , @ RequestBody @ Validated ResetPasswordDTO validator ) {
9291 adminService .changeUserPassword (id , validator );
9392 return new UpdatedVO (4 );
9493 }
9594
96- @ DeleteMapping ("/user/{id}" )
9795 @ AdminRequired
96+ @ DeleteMapping ("/user/{id}" )
9897 @ PermissionMeta (value = "删除用户" , mount = false )
9998 public DeletedVO deleteUser (@ PathVariable @ Positive (message = "{id.positive}" ) Integer id ) {
10099 adminService .deleteUser (id );
101100 return new DeletedVO (5 );
102101 }
103102
104- @ PutMapping ("/user/{id}" )
105103 @ AdminRequired
104+ @ PutMapping ("/user/{id}" )
106105 @ PermissionMeta (value = "管理员更新用户信息" , mount = false )
107106 public UpdatedVO updateUser (@ PathVariable @ Positive (message = "{id.positive}" ) Integer id , @ RequestBody @ Validated UpdateUserInfoDTO validator ) {
108107 adminService .updateUserInfo (id , validator );
109108 return new UpdatedVO (6 );
110109 }
111110
112- @ GetMapping ("/group" )
113111 @ AdminRequired
112+ @ GetMapping ("/group" )
114113 @ PermissionMeta (value = "查询所有权限组及其权限" , mount = false )
115- public PageResponseVO getGroups (
114+ public PageResponseVO < GroupDO > getGroups (
116115 @ RequestParam (name = "count" , required = false , defaultValue = "10" )
117116 @ Min (value = 1 , message = "{page.count.min}" )
118117 @ Max (value = 30 , message = "{page.count.max}" ) Integer count ,
@@ -122,65 +121,63 @@ public PageResponseVO getGroups(
122121 return PageUtil .build (iPage );
123122 }
124123
125- @ GetMapping ("/group/all" )
126124 @ AdminRequired
125+ @ GetMapping ("/group/all" )
127126 @ PermissionMeta (value = "查询所有权限组" , mount = false )
128127 public List <GroupDO > getAllGroup () {
129- List <GroupDO > groups = adminService .getAllGroups ();
130- return groups ;
128+ return adminService .getAllGroups ();
131129 }
132130
133- @ GetMapping ("/group/{id}" )
134131 @ AdminRequired
132+ @ GetMapping ("/group/{id}" )
135133 @ PermissionMeta (value = "查询一个权限组及其权限" , mount = false )
136134 public GroupPermissionBO getGroup (@ PathVariable @ Positive (message = "{id.positive}" ) Integer id ) {
137- GroupPermissionBO groupPermissions = adminService .getGroup (id );
138- return groupPermissions ;
135+ return adminService .getGroup (id );
139136 }
140137
141- @ PostMapping ("/group" )
142138 @ AdminRequired
139+ @ PostMapping ("/group" )
143140 @ PermissionMeta (value = "新建权限组" , mount = false )
144141 public CreatedVO createGroup (@ RequestBody @ Validated NewGroupDTO validator ) {
145142 adminService .createGroup (validator );
146143 return new CreatedVO (15 );
147144 }
148145
149- @ PutMapping ("/group/{id}" )
150146 @ AdminRequired
147+ @ PutMapping ("/group/{id}" )
151148 @ PermissionMeta (value = "更新一个权限组" , mount = false )
152149 public UpdatedVO updateGroup (@ PathVariable @ Positive (message = "{id.positive}" ) Integer id ,
153- @ RequestBody @ Validated UpdateGroupDTO validator ) {
150+ @ RequestBody @ Validated UpdateGroupDTO validator ) {
154151 adminService .updateGroup (id , validator );
155152 return new UpdatedVO (7 );
156153 }
157154
158- @ DeleteMapping ("/group/{id}" )
159155 @ AdminRequired
156+ @ DeleteMapping ("/group/{id}" )
160157 @ PermissionMeta (value = "删除一个权限组" , mount = false )
161158 public DeletedVO deleteGroup (@ PathVariable @ Positive (message = "{id.positive}" ) Integer id ) {
162159 adminService .deleteGroup (id );
163160 return new DeletedVO (8 );
164161 }
165162
166- @ PostMapping ("/permission/dispatch" )
167163 @ AdminRequired
164+ @ PostMapping ("/permission/dispatch" )
168165 @ PermissionMeta (value = "分配单个权限" , mount = false )
169166 public CreatedVO dispatchPermission (@ RequestBody @ Validated DispatchPermissionDTO validator ) {
170167 adminService .dispatchPermission (validator );
171168 return new CreatedVO (9 );
172169 }
173170
174- @ PostMapping ("/permission/dispatch/batch" )
175171 @ AdminRequired
172+ @ PostMapping ("/permission/dispatch/batch" )
176173 @ PermissionMeta (value = "分配多个权限" , mount = false )
177174 public CreatedVO dispatchPermissions (@ RequestBody @ Validated DispatchPermissionsDTO validator ) {
178175 adminService .dispatchPermissions (validator );
179176 return new CreatedVO (9 );
180177 }
181178
182- @ PostMapping ("/permission/remove" )
183179 @ AdminRequired
180+ @ PostMapping ("/permission/remove" )
184181 @ PermissionMeta (value = "删除多个权限" , mount = false )
185182 public DeletedVO removePermissions (@ RequestBody @ Validated RemovePermissionsDTO validator ) {
186183 adminService .removePermissions (validator );
0 commit comments