|
@@ -1,8 +1,9 @@
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import org.dromara.system.domain.SysDept;
|
|
import org.dromara.system.domain.SysDept;
|
|
import org.example.DromaraApplication;
|
|
import org.example.DromaraApplication;
|
|
-import org.example.join.model.IQueryColumn;
|
|
|
|
import org.example.join.model.QueryColumn;
|
|
import org.example.join.model.QueryColumn;
|
|
|
|
+import org.example.join.model.QueryColumnField;
|
|
|
|
+import org.example.join.model.QueryColumnFields;
|
|
import org.example.join.model.Table;
|
|
import org.example.join.model.Table;
|
|
import org.example.join.model.TableSublist;
|
|
import org.example.join.model.TableSublist;
|
|
import org.example.join.sql.Sql;
|
|
import org.example.join.sql.Sql;
|
|
@@ -18,28 +19,27 @@ import java.util.List;
|
|
public class MySpringBootTest {
|
|
public class MySpringBootTest {
|
|
|
|
|
|
public static final Table sys_dept = new Table("sys_dept");
|
|
public static final Table sys_dept = new Table("sys_dept");
|
|
- public final QueryColumn dept_id = sys_dept.field("dept_id");
|
|
|
|
- public final QueryColumn tenant_id = sys_dept.field("tenant_id");
|
|
|
|
- public final QueryColumn parent_id = sys_dept.field("parent_id");
|
|
|
|
- public final QueryColumn ancestors = sys_dept.field("ancestors");
|
|
|
|
- public final QueryColumn status = sys_dept.field("status");
|
|
|
|
|
|
+ public final QueryColumnField dept_id = sys_dept.field("dept_id");
|
|
|
|
+ public final QueryColumnField tenant_id = sys_dept.field("tenant_id");
|
|
|
|
+ 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 static final Table sys_user = new Table("sys_user");
|
|
public static final Table sys_user = new Table("sys_user");
|
|
- public final QueryColumn user_id = sys_user.field("user_id");
|
|
|
|
- public final QueryColumn user_name = sys_user.field("user_name");
|
|
|
|
- public final QueryColumn nick_name = sys_user.field("nick_name");
|
|
|
|
- public final QueryColumn sex = sys_user.field("sex");
|
|
|
|
- public final QueryColumn create_by = sys_user.field("create_by");
|
|
|
|
|
|
+ public final QueryColumnField user_id = sys_user.field("user_id");
|
|
|
|
+ public final QueryColumnField user_name = sys_user.field("user_name");
|
|
|
|
+ public final QueryColumnField nick_name = sys_user.field("nick_name");
|
|
|
|
+ public final QueryColumnField sex = sys_user.field("sex");
|
|
|
|
+ public final QueryColumnField create_by = sys_user.field("create_by");
|
|
|
|
|
|
@Test
|
|
@Test
|
|
public void testCache() {
|
|
public void testCache() {
|
|
|
|
|
|
TableSublist childTable = Sql.create()
|
|
TableSublist childTable = Sql.create()
|
|
.select(
|
|
.select(
|
|
- dept_id,
|
|
|
|
- tenant_id,
|
|
|
|
- status,
|
|
|
|
- ancestors
|
|
|
|
|
|
+ sysDeptAll,
|
|
|
|
+ status
|
|
)
|
|
)
|
|
.from(sys_dept)
|
|
.from(sys_dept)
|
|
.tableAs(sys_dept);
|
|
.tableAs(sys_dept);
|
|
@@ -48,11 +48,11 @@ public class MySpringBootTest {
|
|
//.logic()
|
|
//.logic()
|
|
//.distinct()
|
|
//.distinct()
|
|
.select(
|
|
.select(
|
|
- dept_id,
|
|
|
|
|
|
+ dept_id.as("aaa"),
|
|
childTable.field(tenant_id),
|
|
childTable.field(tenant_id),
|
|
childTable.field("status"),
|
|
childTable.field("status"),
|
|
- IQueryColumn.field("sys_dept.ancestors ancestors"),
|
|
|
|
- Sql.create().select(dept_id).from(sys_dept).limit(1).as("ccc")
|
|
|
|
|
|
+ Sql.create().select(dept_id).from(sys_dept).limit(1).as("ccc"),
|
|
|
|
+ new QueryColumn("{0}", "ancestors").as("sss")
|
|
)
|
|
)
|
|
.from(childTable)
|
|
.from(childTable)
|
|
.leftJoin(sys_user).on(childTable.field(dept_id).eq(user_id))
|
|
.leftJoin(sys_user).on(childTable.field(dept_id).eq(user_id))
|
|
@@ -60,6 +60,7 @@ public class MySpringBootTest {
|
|
dept_id.in(Sql.create().select(dept_id).from(sys_dept)),
|
|
dept_id.in(Sql.create().select(dept_id).from(sys_dept)),
|
|
Sql.create().select(dept_id).from(sys_dept).limit(1).eq(100)
|
|
Sql.create().select(dept_id).from(sys_dept).limit(1).eq(100)
|
|
)
|
|
)
|
|
|
|
+ .orderBy(new QueryColumn("aaa").asc())
|
|
.list(SysDept.class);
|
|
.list(SysDept.class);
|
|
|
|
|
|
System.out.println(JSONObject.toJSONString(list));
|
|
System.out.println(JSONObject.toJSONString(list));
|