|
@@ -1,12 +1,12 @@
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.Data;
|
|
|
+import org.dromara.system.domain.SysDept;
|
|
|
import org.example.DromaraApplication;
|
|
|
-import org.example.join.model.query.function.DefaultFunction;
|
|
|
import org.example.join.model.query.column.QueryColumn;
|
|
|
import org.example.join.model.query.column.QueryColumnField;
|
|
|
import org.example.join.model.query.column.QueryColumnFields;
|
|
|
+import org.example.join.model.query.function.DefaultFunction;
|
|
|
import org.example.join.model.table.Table;
|
|
|
-import org.example.join.model.table.SubqueryTable;
|
|
|
import org.example.join.sql.Sql;
|
|
|
import org.junit.Test;
|
|
|
import org.junit.runner.RunWith;
|
|
@@ -25,7 +25,7 @@ public class MySpringBootTest implements DefaultFunction {
|
|
|
public final QueryColumnField parent_id = sys_dept.field("parent_id");
|
|
|
public final QueryColumnField ancestors = sys_dept.field("ancestors");
|
|
|
public final QueryColumnField status = sys_dept.field("status");
|
|
|
- public final QueryColumnFields sysDeptAll = new QueryColumnFields(dept_id, tenant_id, parent_id, ancestors);
|
|
|
+ public final QueryColumnFields sysDeptAll = new QueryColumnFields(dept_id, tenant_id, parent_id, ancestors, status);
|
|
|
|
|
|
public static final Table sys_user = new Table("sys_user");
|
|
|
public final QueryColumnField user_id = sys_user.field("user_id");
|
|
@@ -37,31 +37,25 @@ public class MySpringBootTest implements DefaultFunction {
|
|
|
@Test
|
|
|
public void testCache() {
|
|
|
|
|
|
- SubqueryTable subqueryTable = Sql.create()
|
|
|
- .select(
|
|
|
- sysDeptAll,
|
|
|
- status
|
|
|
- )
|
|
|
- .from(sys_dept)
|
|
|
- .tableAs(sys_dept);
|
|
|
+ Table subquery = new Table("subquery");
|
|
|
|
|
|
List<TestEntity> list = Sql.create()
|
|
|
//.logic()
|
|
|
//.distinct()
|
|
|
.select(
|
|
|
dept_id.as(TestEntity::getAaa),
|
|
|
- subqueryTable.field(tenant_id).as(TestEntity::getBbb),
|
|
|
- subqueryTable.field("status").as("ccc"),
|
|
|
- Sql.create().select(groupConcat(new QueryColumn("{0} order by {0} asc", dept_id))).from(sys_dept).as("ddd"),
|
|
|
- concat("ssss", 333).as("eee")
|
|
|
+ subquery.field(tenant_id).as(TestEntity::getBbb),
|
|
|
+ subquery.field(SysDept::getStatus).as(TestEntity::getCcc),
|
|
|
+ Sql.create().select(groupConcat(new QueryColumn("{0} order by {0} asc", dept_id))).from(sys_dept).as(TestEntity::getDdd),
|
|
|
+ concat("ssss", 333).as(TestEntity::getEee)
|
|
|
)
|
|
|
- .from(subqueryTable)
|
|
|
- .leftJoin(sys_user).on(subqueryTable.field(dept_id).eq(user_id))
|
|
|
+ .from(Sql.create().select(sysDeptAll).from(sys_dept).tableAs(subquery))
|
|
|
+ .leftJoin(sys_user).on(subquery.field(dept_id).eq(user_id))
|
|
|
.where(
|
|
|
dept_id.in(Sql.create().select(dept_id).from(sys_dept)),
|
|
|
Sql.create().select(dept_id).from(sys_dept).limit(1).eq(100)
|
|
|
)
|
|
|
- .orderBy(new QueryColumn("aaa").desc())
|
|
|
+ .orderBy(new QueryColumn(TestEntity::getAaa).desc())
|
|
|
.list(TestEntity.class);
|
|
|
|
|
|
System.out.println(JSONObject.toJSONString(list));
|