Skip to content

Commit

Permalink
feat-ICustomSelectSqlAbility-优化自定义sql逻辑,可以继续参与IReferenceAbility的关联
Browse files Browse the repository at this point in the history
  • Loading branch information
aruis committed Dec 12, 2024
1 parent 6918f7f commit cd3f0bb
Showing 1 changed file with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.QueryParam;
import net.ximatai.muyun.ability.IAuthAbility;
import net.ximatai.muyun.ability.IDatabaseAbilityStd;
import net.ximatai.muyun.ability.IDesensitizationAbility;
import net.ximatai.muyun.ability.IMetadataAbility;
import net.ximatai.muyun.ability.IReferenceAbility;
import net.ximatai.muyun.ability.ISecurityAbility;
import net.ximatai.muyun.ability.ISoftDeleteAbility;
import net.ximatai.muyun.ability.ISortAbility;
import net.ximatai.muyun.ability.*;
import net.ximatai.muyun.core.exception.QueryException;
import net.ximatai.muyun.database.builder.TableBase;
import net.ximatai.muyun.database.tool.DateTool;
Expand Down Expand Up @@ -65,10 +58,6 @@ default String getSelectOneRowSql() {
}

default String getSelectSql() {
if (this instanceof ICustomSelectSqlAbility ability) {
return ability.getCustomSql();
}

StringBuilder starSql = new StringBuilder("%s.*".formatted(getMainTable()));
StringBuilder joinSql = new StringBuilder();
String softDeleteSql = "";
Expand Down Expand Up @@ -104,7 +93,12 @@ referenceTableTempName, getMainTable(), info.getRelationColumn(),

}

return "select %s from %s %s where 1=1 %s ".formatted(starSql, getSchemaDotTable(), joinSql, softDeleteSql);
String mainTable = getSchemaDotTable();
if (this instanceof ICustomSelectSqlAbility ability) {
mainTable = "(%s) as %s ".formatted(ability.getCustomSql(), getMainTable());
}

return "select %s from %s %s where 1=1 %s ".formatted(starSql, mainTable, joinSql, softDeleteSql);
}

default void processEachRow(Map row) {
Expand Down

0 comments on commit cd3f0bb

Please sign in to comment.