Skip to content

Commit 6506e92

Browse files
authored
Merge pull request #81 from codingapi/dev
Dev
2 parents a441008 + 9210fea commit 6506e92

File tree

58 files changed

+4951
-18
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+4951
-18
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ v.3.x 为springboot 3.x版本,使用jdk17版本
1818

1919
* springboot-starter | Springboot领域驱动框架
2020
* springboot-starter-data-fast | 快速数据呈现框架
21+
* springboot-starter-data-authorization | 数据权限框架
2122
* springboot-starter-flow | 流程引擎框架
2223
* springboot-starter-security | security权限框架支持基于JWT的无状态权限认证与Redis的有状态权限认证
2324

@@ -42,6 +43,13 @@ v.3.x 为springboot 3.x版本,使用jdk17版本
4243
<version>${last.version}</version>
4344
</dependency>
4445
46+
<!-- 数据权限框架 -->
47+
<dependency>
48+
<groupId>com.codingapi.springboot</groupId>
49+
<artifactId>springboot-starter-data-authorization</artifactId>
50+
<version>${last.version}</version>
51+
</dependency>
52+
4553
<!-- 流程引擎框架 -->
4654
<dependency>
4755
<groupId>com.codingapi.springboot</groupId>

admin-ui/src/components/Flow/flow/data.ts

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,24 +97,36 @@ export class FlowData extends FlowWorkData {
9797
this.formParams = formParams;
9898
}
9999

100+
// 是否可以审批
100101
canHandle = () => {
101102
return this.data.canHandle;
102103
}
103104

105+
// 是否是开始节点
104106
isStartFlow = () => {
105107
if (this.data) {
106108
return this.data.flowNode.startNode;
107109
}
108110
return false;
109111
}
110112

113+
// 获取当前节点的code
114+
getNodeCode = () => {
115+
if (this.data) {
116+
return this.data.flowNode.code;
117+
}
118+
return null;
119+
}
120+
121+
// 获取当前节点的按钮
111122
getNodeButtons = () => {
112123
if (this.data) {
113124
return this.data.flowNode.buttons;
114125
}
115126
return null;
116127
}
117128

129+
// 获取当前节点的标题
118130
getCurrentNodeTitle = () => {
119131
if (this.data) {
120132
const node = this.data.flowNode;
@@ -125,6 +137,7 @@ export class FlowData extends FlowWorkData {
125137
return null;
126138
}
127139

140+
// 获取当前节点的视图 (内部使用)
128141
getFlowFormView(view: React.ComponentType<FlowFormViewProps> | FlowFormView) {
129142
if (typeof view === 'object') {
130143
const nodeView = this.data.flowNode.view;
@@ -133,7 +146,7 @@ export class FlowData extends FlowWorkData {
133146
return view;
134147
}
135148

136-
149+
// 获取当前节点是否可编辑
137150
getFlowNodeEditable = () => {
138151
if (this.data) {
139152
const node = this.data.flowNode;
@@ -144,14 +157,15 @@ export class FlowData extends FlowWorkData {
144157
return false
145158
}
146159

160+
// 获取当前节点的表单数据
147161
getFlowData = () => {
148162
return {
149163
...this.data.bindData,
150164
...this.formParams
151165
}
152166
}
153167

154-
168+
// 获取当前节点的表单数据 (内部使用)
155169
getNodeState = (code: string) => {
156170
const historyRecords = this.data.historyRecords || [];
157171

@@ -160,9 +174,9 @@ export class FlowData extends FlowWorkData {
160174
return "done";
161175
}
162176

163-
for(const record of historyRecords){
164-
if(record.nodeCode === code){
165-
if(record.flowType==='TODO'){
177+
for (const record of historyRecords) {
178+
if (record.nodeCode === code) {
179+
if (record.flowType === 'TODO') {
166180
return "wait";
167181
}
168182
return "done";
@@ -172,6 +186,7 @@ export class FlowData extends FlowWorkData {
172186
return "wait";
173187
}
174188

189+
// 获取当前节点的流程图
175190
getFlowSchema = () => {
176191

177192
if (this.data.flowWork.schema) {
@@ -186,39 +201,46 @@ export class FlowData extends FlowWorkData {
186201
return null;
187202
}
188203

204+
// 是否存在数据
189205
hasData() {
190206
return !!this.data;
191207
}
192208

209+
// 获取当前的详情的记录数据
193210
getCurrentFlowRecord = () => {
194211
return this.data.flowRecord;
195212
}
196213

214+
// 获取历史记录
197215
getHistoryRecords = () => {
198216
return this.data.historyRecords;
199217
}
200218

219+
// 是否是审批完成
201220
isDone() {
202221
if (this.data.flowRecord) {
203222
return this.data.flowRecord.flowStatus === 'FINISH' || this.data.flowRecord.flowType === 'DONE';
204223
}
205224
return false;
206225
}
207226

227+
// 是否是结束节点
208228
private isFinished() {
209229
if (this.data.flowRecord) {
210230
return this.data.flowRecord.flowStatus === 'FINISH';
211231
}
212232
return false;
213233
}
214234

235+
// 是否需要展示流转记录 (内部使用)
215236
showHistory() {
216-
if(this.isDone()){
237+
if (this.isDone()) {
217238
return true;
218239
}
219240
return !this.isStartFlow();
220241
}
221242

243+
// 是否展示审批意见 (内部使用)
222244
showOpinion() {
223245
return this.canHandle() && !this.isStartFlow();
224246
}

docs/wiki/home.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ maven install
1818
<version>${last.version}</version>
1919
</dependency>
2020
21+
<!-- 数据权限框架 -->
22+
<dependency>
23+
<groupId>com.codingapi.springboot</groupId>
24+
<artifactId>springboot-starter-data-authorization</artifactId>
25+
<version>${last.version}</version>
26+
</dependency>
2127
2228
<!-- security&jwt权限框架 -->
2329
<dependency>
@@ -31,4 +37,4 @@ maven install
3137
[springboot-starter](./springboot-starter)
3238
[springboot-starter-security](./springboot-starter-security)
3339
[springboot-starter-data-fast](./springboot-starter-data-fast.md)
34-
40+
[springboot-starter-data-authorization](./springboot-starter-data-authorization.md)
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
springboot-starter-data-authorization
2+
3+
数据权限框架
4+
5+
## 框架介绍
6+
7+
基于JDBC的拦截机制实现对数据表列与行的数据查询权限控制。
8+
9+
## 使用教程
10+
11+
1. 配置数据库的JDBC驱动地址为 `com.codingapi.springboot.authorization.jdbc.AuthorizationJdbcDriver`
12+
```
13+
spring.datasource.driver-class-name=com.codingapi.springboot.authorization.jdbc.AuthorizationJdbcDriver
14+
spring.datasource.url=jdbc:h2:file:./test.db
15+
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
16+
spring.jpa.hibernate.ddl-auto=create-drop
17+
spring.jpa.show-sql=true
18+
19+
```
20+
2. 配置数据权限DataAuthorizationFilter的实现
21+
接口定义
22+
```java
23+
24+
/**
25+
* 数据权限过滤器
26+
*/
27+
public interface DataAuthorizationFilter {
28+
29+
/**
30+
* 列权限过滤
31+
* @param tableName 表名
32+
* @param columnName 列名
33+
* @param value 值
34+
* @return 过滤后的值
35+
* @param <T> T
36+
*/
37+
<T> T columnAuthorization(String tableName, String columnName,T value);
38+
39+
/**
40+
* 行权限过滤
41+
* @param tableName 表名
42+
* @param tableAlias 表别名
43+
* @return 过滤后拦截sql条件
44+
*/
45+
Condition rowAuthorization(String tableName, String tableAlias);
46+
47+
/**
48+
* 是否支持列权限过滤
49+
* @param tableName 表名
50+
* @param columnName 列名
51+
* @param value 值
52+
* @return 是否支持
53+
*/
54+
boolean supportColumnAuthorization(String tableName, String columnName, Object value);
55+
56+
/**
57+
* 是否支持行权限过滤
58+
* @param tableName 表名
59+
* @param tableAlias 表别名
60+
* @return 是否支持
61+
*/
62+
boolean supportRowAuthorization(String tableName, String tableAlias);
63+
}
64+
65+
66+
```
67+
实例实现:
68+
```
69+
70+
ColumnMaskContext.getInstance().addColumnMask(new IDCardMask());
71+
ColumnMaskContext.getInstance().addColumnMask(new PhoneMask());
72+
ColumnMaskContext.getInstance().addColumnMask(new BankCardMask());
73+
74+
DataAuthorizationContext.getInstance().addDataAuthorizationFilter(new DataAuthorizationFilter() {
75+
@Override
76+
public <T> T columnAuthorization(String tableName, String columnName, T value) {
77+
return ColumnMaskContext.getInstance().mask(value);
78+
}
79+
80+
@Override
81+
public Condition rowAuthorization(String tableName, String tableAlias) {
82+
if (tableName.equalsIgnoreCase("t_user")) {
83+
String conditionTemplate = "%s.id > 1 ";
84+
return Condition.formatCondition(conditionTemplate, tableAlias);
85+
}
86+
return null;
87+
}
88+
89+
@Override
90+
public boolean supportColumnAuthorization(String tableName, String columnName, Object value) {
91+
return true;
92+
}
93+
94+
@Override
95+
public boolean supportRowAuthorization(String tableName, String tableAlias) {
96+
return true;
97+
}
98+
});
99+
```
100+
101+
实现的拦截器,需要添加到DataAuthorizationContext.getInstance()中才可以使用。可以通过上述实例的手动模式添加,
102+
也可以通过定义DataAuthorizationFilter的@Bean方式添加,当设置为@Bean时既可以自动加入到DataAuthorizationContext.getInstance()中。
103+

example/example-application/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.26</version>
8+
<version>3.3.27</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/example-domain/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.26</version>
8+
<version>3.3.27</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/example-infra-flow/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.26</version>
8+
<version>3.3.27</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/example-infra-jpa/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.26</version>
8+
<version>3.3.27</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/example-server/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-example</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.26</version>
8+
<version>3.3.27</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</parent>
1818

1919
<artifactId>springboot-example</artifactId>
20-
<version>3.3.26</version>
20+
<version>3.3.27</version>
2121

2222
<name>springboot-example</name>
2323
<description>springboot-example project for Spring Boot</description>

pom.xml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
44
<modelVersion>4.0.0</modelVersion>
55
<packaging>pom</packaging>
6+
<modules>
7+
<module>springboot-starter-data-authorization</module>
8+
</modules>
69
<parent>
710
<groupId>org.springframework.boot</groupId>
811
<artifactId>spring-boot-starter-parent</artifactId>
@@ -12,7 +15,7 @@
1215

1316
<groupId>com.codingapi.springboot</groupId>
1417
<artifactId>springboot-parent</artifactId>
15-
<version>3.3.26</version>
18+
<version>3.3.27</version>
1619

1720
<url>https://github.com/codingapi/springboot-framewrok</url>
1821
<name>springboot-parent</name>
@@ -45,6 +48,7 @@
4548
<apache-groovy.version>4.0.24</apache-groovy.version>
4649
<h2.version>2.3.232</h2.version>
4750
<esotericsoftware.kryo.version>5.6.2</esotericsoftware.kryo.version>
51+
<jsqlparser.version>5.0</jsqlparser.version>
4852
</properties>
4953

5054
<dependencies>
@@ -206,6 +210,13 @@
206210
<version>${apache-groovy.version}</version>
207211
</dependency>
208212

213+
<dependency>
214+
<groupId>com.github.jsqlparser</groupId>
215+
<artifactId>jsqlparser</artifactId>
216+
<version>${jsqlparser.version}</version>
217+
</dependency>
218+
219+
209220
</dependencies>
210221
</dependencyManagement>
211222

0 commit comments

Comments
 (0)