1
1
package org .hswebframework .web .example .simple ;
2
2
3
- import io .swagger .annotations .*;
4
- import org .apache .shiro .authz .annotation .RequiresPermissions ;
5
- import org .apache .shiro .authz .annotation .RequiresUser ;
3
+ import io .swagger .annotations .ApiOperation ;
4
+ import io .swagger .annotations .ApiResponse ;
6
5
import org .hswebframework .web .authorization .Authorization ;
7
6
import org .hswebframework .web .authorization .AuthorizationHolder ;
8
7
import org .hswebframework .web .authorization .Permission ;
13
12
import org .hswebframework .web .commons .entity .PagerResult ;
14
13
import org .hswebframework .web .commons .entity .param .QueryParamEntity ;
15
14
import org .hswebframework .web .controller .QueryController ;
16
- import org .hswebframework .web .controller .authorization .UserController ;
17
15
import org .hswebframework .web .controller .message .ResponseMessage ;
18
16
import org .hswebframework .web .entity .authorization .SimpleUserEntity ;
19
17
import org .hswebframework .web .entity .authorization .UserEntity ;
18
+ import org .hswebframework .web .model .authorization .UserModel ;
20
19
import org .hswebframework .web .service .QueryByEntityService ;
21
20
import org .hswebframework .web .service .QueryService ;
22
21
import org .springframework .web .bind .annotation .*;
@@ -39,29 +38,30 @@ public ResponseMessage testSimple(Authorization authorization) {
39
38
return ResponseMessage .ok (authorization );
40
39
}
41
40
42
- @ GetMapping ("/test" )
43
- @ RequiresPermissions ("test:*" )
44
- @ ApiOperation ("测试" )
45
- @ ApiResponse (code = 200 , message = "成功" )
46
- public ResponseMessage testShiro (Authorization authorization ) {
47
- return ResponseMessage .ok (authorization );
48
- }
49
-
50
41
@ GetMapping ("/testQuery" )
51
- @ RequiresUser
42
+ @ Authorize
52
43
@ RequiresDataAccess (permission = "test" , action = Permission .ACTION_QUERY )
53
44
@ RequiresFieldAccess (permission = "test" , action = Permission .ACTION_QUERY )
54
45
@ ApiOperation ("测试查询" )
55
- public ResponseMessage testQuery (QueryParamEntity entity ) {
46
+ public ResponseMessage <QueryParamEntity > testQuery (QueryParamEntity entity ) {
47
+ /*
48
+ @RequiresFieldAccess 字段级别权限控制
49
+ entity.getExcludes() 自动填充不能访问的字段
50
+ */
51
+
52
+ /*
53
+ @RequiresDataAccess 数据级别权限控制
54
+ entity.terms 被嵌入查询条件
55
+ */
56
56
return ResponseMessage .ok (entity );
57
57
}
58
58
59
59
@ PutMapping ("/testUpdate/{id}" )
60
- @ RequiresUser
61
60
@ RequiresDataAccess (permission = "test" , action = Permission .ACTION_UPDATE )
62
61
@ RequiresFieldAccess (permission = "test" , action = Permission .ACTION_UPDATE )
63
- public ResponseMessage testUpdate (@ PathVariable String id , @ RequestBody UserEntity entity ) {
64
- return ResponseMessage .ok (entity );
62
+ public ResponseMessage <UserModel > testUpdate (@ PathVariable String id , @ RequestBody UserModel model ) {
63
+
64
+ return ResponseMessage .ok (model );
65
65
}
66
66
67
67
@ Override
0 commit comments