|
@@ -1,5 +1,4 @@
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import org.dromara.system.domain.SysDept;
|
|
|
import org.dromara.system.service.ISysUserService;
|
|
|
import org.example.DromaraApplication;
|
|
@@ -12,6 +11,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.boot.test.context.SpringBootTest;
|
|
|
import org.springframework.test.context.junit4.SpringRunner;
|
|
|
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+import static org.example.join.domain.QueryMethods._if;
|
|
|
+import static org.example.join.domain.QueryMethods.concat;
|
|
|
+import static org.example.join.domain.QueryMethods.ifNull;
|
|
|
+
|
|
|
@RunWith(SpringRunner.class)
|
|
|
@SpringBootTest(classes = DromaraApplication.class)
|
|
|
public class MySpringBootTest {
|
|
@@ -35,12 +40,13 @@ public class MySpringBootTest {
|
|
|
@Test
|
|
|
public void testCache() {
|
|
|
|
|
|
- Page<SysDept> list = Sql.create(SysDept.class)
|
|
|
+ List<SysDept> list = Sql.create(SysDept.class)
|
|
|
//.logic()
|
|
|
.select(
|
|
|
parent_id,
|
|
|
- tenant_id,
|
|
|
- dept_id
|
|
|
+ _if(tenant_id.eq("000000"), "999999", "888888").as(SysDept::getTenantId),
|
|
|
+ dept_id,
|
|
|
+ concat(0).as(SysDept::getAncestors)
|
|
|
)
|
|
|
.from(sys_dept)
|
|
|
.leftJoin(sys_user).on(user_id.eq(dept_id))
|
|
@@ -66,25 +72,14 @@ public class MySpringBootTest {
|
|
|
//create_by.in(1, 2, 3, 4),
|
|
|
//create_by.notIn(1, 2, 3, 4)
|
|
|
)
|
|
|
- .orderByAsc()
|
|
|
- .groupBy()
|
|
|
|
|
|
.union()
|
|
|
|
|
|
- .logic()
|
|
|
- .select(
|
|
|
- parent_id,
|
|
|
- tenant_id,
|
|
|
- dept_id
|
|
|
- )
|
|
|
+ .select(parent_id, tenant_id, ifNull(dept_id, 0), concat(1).as(SysDept::getAncestors))
|
|
|
.from(sys_dept)
|
|
|
.leftJoin(sys_user).on(user_id.eq(dept_id))
|
|
|
- .where(
|
|
|
- )
|
|
|
- .orderByAsc()
|
|
|
- .groupBy()
|
|
|
+ .list();
|
|
|
|
|
|
- .page(new Page<>(1, 10));
|
|
|
|
|
|
System.out.println(JSONObject.toJSONString(list));
|
|
|
|