Skip to content

Commit a91d1d8

Browse files
committed
增加说明
1 parent e662d60 commit a91d1d8

File tree

4 files changed

+49
-18
lines changed

4 files changed

+49
-18
lines changed

hsweb-examples/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#系统演示模块
2+
3+
1. [hsweb-examples-simple](hsweb-examples-simple)基本演示
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# 演示
2+
简单示例,无页面
3+
4+
## 运行
5+
6+
1. IDE
7+
导入项目后,运行: `org.hswebframework.web.example.simple.SpringBootExample.main`
8+
9+
2. maven
10+
先安装 `hsweb-framework`
11+
```bash
12+
/hsweb-framework $ mvn install
13+
/hsweb-framework $ cd hsweb-examples/hsweb-examples-simple
14+
/hsweb-examples-simple $ mvn spring-boot:run
15+
16+
```
17+
18+
启动成功后,浏览器打开: [swagger-ui](http://localhost:8080/swagger-ui.html) 试试
19+
20+
如果不想使用权限控制,请注释掉 pom.xml的
21+
```xml
22+
<dependency>
23+
<groupId>org.hswebframework.web</groupId>
24+
<artifactId>hsweb-authorization-shiro</artifactId>
25+
<version>${project.version}</version>
26+
</dependency>
27+
28+
```

hsweb-examples/hsweb-examples-simple/src/main/java/org/hswebframework/web/example/simple/TestController.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
package org.hswebframework.web.example.simple;
22

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;
65
import org.hswebframework.web.authorization.Authorization;
76
import org.hswebframework.web.authorization.AuthorizationHolder;
87
import org.hswebframework.web.authorization.Permission;
@@ -13,10 +12,10 @@
1312
import org.hswebframework.web.commons.entity.PagerResult;
1413
import org.hswebframework.web.commons.entity.param.QueryParamEntity;
1514
import org.hswebframework.web.controller.QueryController;
16-
import org.hswebframework.web.controller.authorization.UserController;
1715
import org.hswebframework.web.controller.message.ResponseMessage;
1816
import org.hswebframework.web.entity.authorization.SimpleUserEntity;
1917
import org.hswebframework.web.entity.authorization.UserEntity;
18+
import org.hswebframework.web.model.authorization.UserModel;
2019
import org.hswebframework.web.service.QueryByEntityService;
2120
import org.hswebframework.web.service.QueryService;
2221
import org.springframework.web.bind.annotation.*;
@@ -39,29 +38,30 @@ public ResponseMessage testSimple(Authorization authorization) {
3938
return ResponseMessage.ok(authorization);
4039
}
4140

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-
5041
@GetMapping("/testQuery")
51-
@RequiresUser
42+
@Authorize
5243
@RequiresDataAccess(permission = "test", action = Permission.ACTION_QUERY)
5344
@RequiresFieldAccess(permission = "test", action = Permission.ACTION_QUERY)
5445
@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+
*/
5656
return ResponseMessage.ok(entity);
5757
}
5858

5959
@PutMapping("/testUpdate/{id}")
60-
@RequiresUser
6160
@RequiresDataAccess(permission = "test", action = Permission.ACTION_UPDATE)
6261
@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);
6565
}
6666

6767
@Override

hsweb-system/hsweb-system-authorization/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@
44

55
## 授权
66
[AuthorizationController](hsweb-system-authorization-controller/src/main/java/org/hswebframework/web/controller/authorization/AuthorizationController.java)
7-
仅进行基础授权,通过触发`AuthorizationListener`,进行自定义控制逻辑.详细方式见:[hsweb-authorization-api](../../hsweb-authorization/hsweb-authorization-api)
7+
仅进行基础授权,通过触发`AuthorizationListener`,进行自定义控制逻辑.详细方式见:[hsweb-authorization-api](../../hsweb-authorization/hsweb-authorization-api#listener)

0 commit comments

Comments
 (0)