Skip to content

Commit e17422e

Browse files
committed
Server: 调整 Join 类的 表名 和 请求对象 分别对应的 变量名,避免和其它类不一致导致误解
1 parent fb9c267 commit e17422e

File tree

3 files changed

+19
-19
lines changed

3 files changed

+19
-19
lines changed

APIJSON-Java-Server/APIJSONORM/src/main/java/zuo/biao/apijson/server/AbstractParser.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,12 +1002,12 @@ else if (join != null){
10021002
j.setOriginKey(key);
10031003
j.setOriginValue(targetPath);
10041004
j.setJoinType(joinType);
1005-
j.setName(table);
1005+
j.setTable(table);
10061006
j.setAlias(alias);
10071007
j.setTargetName(targetTable);
10081008
j.setTargetKey(targetKey);
10091009
j.setKeyAndType(key);
1010-
j.setTable(getJoinObject(table, tableObj, key));
1010+
j.setRequest(getJoinObject(table, tableObj, key));
10111011
j.setOutter((JSONObject) e.getValue());
10121012

10131013
joinList.add(j);

APIJSON-Java-Server/APIJSONORM/src/main/java/zuo/biao/apijson/server/AbstractSQLConfig.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,21 +2492,21 @@ public static AbstractSQLConfig parseJoin(RequestMethod method, AbstractSQLConfi
24922492
}
24932493

24942494

2495-
String name;
2495+
String table;
24962496
String alias;
24972497
for (Join j : joinList) {
2498-
name = j.getName();
2498+
table = j.getTable();
24992499
alias = j.getAlias();
25002500
//JOIN子查询不能设置LIMIT,因为ON关系是在子查询后处理的,会导致结果会错误
2501-
SQLConfig joinConfig = newSQLConfig(method, name, alias, j.getTable(), null, false, callback);
2502-
SQLConfig cacheConfig = newSQLConfig(method, name, alias, j.getTable(), null, false, callback).setCount(1);
2501+
SQLConfig joinConfig = newSQLConfig(method, table, alias, j.getRequest(), null, false, callback);
2502+
SQLConfig cacheConfig = newSQLConfig(method, table, alias, j.getRequest(), null, false, callback).setCount(1);
25032503

25042504
if (j.isAppJoin() == false) { //除了 @ APP JOIN,其它都是 SQL JOIN,则副表要这样配置
25052505
if (joinConfig.getDatabase() == null) {
25062506
joinConfig.setDatabase(config.getDatabase()); //解决主表 JOIN 副表,引号不一致
25072507
}
25082508
else if (joinConfig.getDatabase().equals(config.getDatabase()) == false) {
2509-
throw new IllegalArgumentException("主表 " + config.getTable() + " 的 @database:" + config.getDatabase() + " 和它 SQL JOIN 的副表 " + name + " 的 @database:" + joinConfig.getDatabase() + " 不一致!");
2509+
throw new IllegalArgumentException("主表 " + config.getTable() + " 的 @database:" + config.getDatabase() + " 和它 SQL JOIN 的副表 " + table + " 的 @database:" + joinConfig.getDatabase() + " 不一致!");
25102510
}
25112511
if (joinConfig.getSchema() == null) {
25122512
joinConfig.setSchema(config.getSchema()); //主表 JOIN 副表,默认 schema 一致
@@ -2521,7 +2521,7 @@ else if (joinConfig.getDatabase().equals(config.getDatabase()) == false) {
25212521
joinConfig.setMain(false).setKeyPrefix(true);
25222522

25232523
if (j.isLeftOrRightJoin()) {
2524-
SQLConfig outterConfig = newSQLConfig(method, name, alias, j.getOutter(), null, false, callback);
2524+
SQLConfig outterConfig = newSQLConfig(method, table, alias, j.getOutter(), null, false, callback);
25252525
outterConfig.setMain(false).setKeyPrefix(true).setDatabase(joinConfig.getDatabase()).setSchema(joinConfig.getSchema()); //解决主表 JOIN 副表,引号不一致
25262526
j.setOutterConfig(outterConfig);
25272527
}

APIJSON-Java-Server/APIJSONORM/src/main/java/zuo/biao/apijson/server/Join.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public class Join {
3030

3131
private String joinType; // "@" - APP, "&" - INNER, "|" - FULL, "!" - OUTTER, "<" - LEFT, ">" - RIGHT, "^" - SIDE, "*" - CROSS
3232
private String relateType; // "" - 一对一, "{}" - 一对多, "<>" - 多对一
33-
private JSONObject table; // { "id@":"/Moment/userId" }
34-
private String name; //User
33+
private JSONObject request; // { "id@":"/Moment/userId" }
34+
private String table; //User
3535
private String alias; //owner
3636
private String key; //id
3737
private String targetName; // Moment
@@ -76,23 +76,23 @@ public void setRelateType(String relateType) {
7676
this.relateType = relateType;
7777
}
7878

79-
public String getName() {
80-
return name;
79+
public String getTable() {
80+
return table;
8181
}
82-
public void setName(String name) {
83-
this.name = name;
82+
public void setTable(String table) {
83+
this.table = table;
8484
}
8585
public String getAlias() {
8686
return alias;
8787
}
8888
public void setAlias(String alias) {
8989
this.alias = alias;
9090
}
91-
public JSONObject getTable() {
92-
return table;
91+
public JSONObject getRequest() {
92+
return request;
9393
}
94-
public void setTable(JSONObject table) {
95-
this.table = table;
94+
public void setRequest(JSONObject request) {
95+
this.request = request;
9696
}
9797
public String getKey() {
9898
return key;
@@ -146,7 +146,7 @@ public void setKeyAndType(@NotNull String originKey) throws Exception { //id, id
146146
originKey = originKey.substring(0, originKey.length() - 1);
147147
}
148148
else { //TODO 暂时只允许 User.id = Moment.userId 字段关联,不允许 User.id = 82001 这种
149-
throw new IllegalArgumentException(joinType + "/.../" + name + "/" + originKey + " 不合法!join:'.../refKey'" + " 中 refKey 必须以 @ 结尾!");
149+
throw new IllegalArgumentException(joinType + "/.../" + table + "/" + originKey + " 不合法!join:'.../refKey'" + " 中 refKey 必须以 @ 结尾!");
150150
}
151151

152152
if (originKey.endsWith("{}")) {

0 commit comments

Comments
 (0)