Skip to content

Commit 8bebd9f

Browse files
committed
fix 3.3.45
1 parent c562f71 commit 8bebd9f

File tree

16 files changed

+45
-20
lines changed

16 files changed

+45
-20
lines changed

example/example-application/pom.xml

+1-1
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.44</version>
8+
<version>3.3.45</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/example-domain/pom.xml

+1-1
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.44</version>
8+
<version>3.3.45</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/example-infra-flow/pom.xml

+1-1
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.44</version>
8+
<version>3.3.45</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/example-infra-jpa/pom.xml

+1-1
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.44</version>
8+
<version>3.3.45</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/example-server/pom.xml

+1-1
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.44</version>
8+
<version>3.3.45</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

example/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
</parent>
1818

1919
<artifactId>springboot-example</artifactId>
20-
<version>3.3.44</version>
20+
<version>3.3.45</version>
2121

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

pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
<groupId>com.codingapi.springboot</groupId>
1717
<artifactId>springboot-parent</artifactId>
18-
<version>3.3.44</version>
18+
<version>3.3.45</version>
1919

2020
<url>https://github.com/codingapi/springboot-framewrok</url>
2121
<name>springboot-parent</name>

springboot-starter-data-authorization/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>com.codingapi.springboot</groupId>
88
<artifactId>springboot-parent</artifactId>
9-
<version>3.3.44</version>
9+
<version>3.3.45</version>
1010
</parent>
1111

1212
<artifactId>springboot-starter-data-authorization</artifactId>

springboot-starter-data-authorization/src/main/java/com/codingapi/springboot/authorization/enhancer/TableColumnAliasHolder.java

+11-7
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,15 @@ private void searchSubSelect(String parent, PlainSelect plainSelect) {
4242
// FROM 项是表
4343
if (fromItem instanceof Table) {
4444
this.appendTableAlias(fromItem);
45-
this.appendColumnAlias(parent, plainSelect.getSelectItems());
45+
Table table = (Table) fromItem;
46+
this.appendColumnAlias(parent, table.getName(), plainSelect.getSelectItems());
4647
}
4748

4849

4950
// FROM是子查询
5051
if (fromItem instanceof Select) {
5152
PlainSelect subPlainSelect = ((Select) fromItem).getPlainSelect();
52-
this.appendColumnAlias(parent, plainSelect.getSelectItems());
53+
this.appendColumnAlias(parent, null, plainSelect.getSelectItems());
5354
parent = fromItem.getAlias().getName();
5455
this.searchSubSelect(parent, subPlainSelect);
5556
}
@@ -60,14 +61,15 @@ private void searchSubSelect(String parent, PlainSelect plainSelect) {
6061
if (join.getRightItem() instanceof Select) {
6162
FromItem currentItem = join.getRightItem();
6263
PlainSelect subPlainSelect = ((Select) currentItem).getPlainSelect();
63-
this.appendColumnAlias(parent, plainSelect.getSelectItems());
64+
this.appendColumnAlias(parent, null, plainSelect.getSelectItems());
6465
parent = currentItem.getAlias().getName();
6566
this.searchSubSelect(parent, subPlainSelect);
6667
}
6768
if (join.getRightItem() instanceof Table) {
6869
FromItem currentItem = join.getRightItem();
6970
this.appendTableAlias(currentItem);
70-
this.appendColumnAlias(parent, plainSelect.getSelectItems());
71+
Table table = (Table) currentItem;
72+
this.appendColumnAlias(parent, table.getName(), plainSelect.getSelectItems());
7173
}
7274
}
7375
}
@@ -82,7 +84,7 @@ private void searchSubSelect(String parent, PlainSelect plainSelect) {
8284
private void appendTableAlias(FromItem fromItem) {
8385
Table table = (Table) fromItem;
8486
Alias alias = table.getAlias();
85-
String aliasName = alias!=null?alias.getName():table.getName();
87+
String aliasName = alias != null ? alias.getName() : table.getName();
8688
aliasContext.addTable(aliasName, table.getName());
8789
}
8890

@@ -93,12 +95,14 @@ private void appendTableAlias(FromItem fromItem) {
9395
* @param parent 父表别名
9496
* @param selectItems 列
9597
*/
96-
private void appendColumnAlias(String parent, List<SelectItem<?>> selectItems) {
98+
private void appendColumnAlias(String parent, String tableName, List<SelectItem<?>> selectItems) {
9799
if (selectItems != null) {
98100
for (SelectItem<?> selectItem : selectItems) {
99101
if (selectItem.getExpression() instanceof Column) {
100102
Column column = (Column) selectItem.getExpression();
101-
String tableName = column.getTable().getName();
103+
if (column.getTable() != null) {
104+
tableName = column.getTable().getName();
105+
}
102106
String columnName = column.getColumnName();
103107
Alias columnAlias = selectItem.getAlias();
104108
String aliasName = columnAlias != null ? selectItem.getAlias().getName() : columnName;

springboot-starter-data-authorization/src/test/java/com/codingapi/springboot/authorization/DataAuthorizationContextTest.java

+4
Original file line numberDiff line numberDiff line change
@@ -369,4 +369,8 @@ public boolean supportRowAuthorization(String tableName, String tableAlias) {
369369
List<Map<String, Object>> data = jdbcTemplate.queryForList(sql);
370370
// System.out.println(data);
371371
}
372+
373+
374+
375+
372376
}

springboot-starter-data-authorization/src/test/java/com/codingapi/springboot/authorization/analyzer/SelectSQLAnalyzerTest.java

+17
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.codingapi.springboot.authorization.enhancer.DataPermissionSQLEnhancer;
44
import com.codingapi.springboot.authorization.handler.Condition;
55
import com.codingapi.springboot.authorization.handler.RowHandler;
6+
import org.junit.jupiter.api.Order;
67
import org.junit.jupiter.api.Test;
78

89
import java.sql.SQLException;
@@ -145,4 +146,20 @@ void test4() throws SQLException{
145146
System.out.println(builder.getNewSQL());
146147
System.out.println(builder.getTableAlias());;
147148
}
149+
150+
@Test
151+
@Order(5)
152+
void test5() throws Exception{
153+
String sql = "SELECT next_val AS id_val FROM t_league_seq FOR UPDATE";
154+
RowHandler rowHandler = (subSql, tableName, tableAlias) -> {
155+
if (tableName.equalsIgnoreCase("t_league")) {
156+
String conditionTemplate = "%s.id < 100 ";
157+
return Condition.formatCondition(conditionTemplate, tableAlias);
158+
}
159+
return null;
160+
};
161+
DataPermissionSQLEnhancer builder = new DataPermissionSQLEnhancer(sql, rowHandler);
162+
System.out.println(builder.getNewSQL());
163+
System.out.println(builder.getTableAlias());;
164+
}
148165
}

springboot-starter-data-fast/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<artifactId>springboot-parent</artifactId>
77
<groupId>com.codingapi.springboot</groupId>
8-
<version>3.3.44</version>
8+
<version>3.3.45</version>
99
</parent>
1010
<modelVersion>4.0.0</modelVersion>
1111

springboot-starter-flow/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>3.3.44</version>
9+
<version>3.3.45</version>
1010
</parent>
1111

1212
<name>springboot-starter-flow</name>

springboot-starter-security/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<artifactId>springboot-parent</artifactId>
88
<groupId>com.codingapi.springboot</groupId>
9-
<version>3.3.44</version>
9+
<version>3.3.45</version>
1010
</parent>
1111

1212
<artifactId>springboot-starter-security</artifactId>

springboot-starter/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<parent>
66
<groupId>com.codingapi.springboot</groupId>
77
<artifactId>springboot-parent</artifactId>
8-
<version>3.3.44</version>
8+
<version>3.3.45</version>
99
</parent>
1010
<artifactId>springboot-starter</artifactId>
1111

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
------------------------------------------------------
2-
CodingApi SpringBoot-Starter 3.3.44
2+
CodingApi SpringBoot-Starter 3.3.45
33
springboot version (${spring-boot.version})
44
------------------------------------------------------

0 commit comments

Comments
 (0)