MySpringBootTest.java 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. import com.alibaba.fastjson.JSONObject;
  2. import org.dromara.system.domain.SysDept;
  3. import org.dromara.system.service.ISysUserService;
  4. import org.example.DromaraApplication;
  5. import org.example.join.domain.QueryColumn;
  6. import org.example.join.domain.Table;
  7. import org.example.join.sql.Sql;
  8. import org.junit.Test;
  9. import org.junit.runner.RunWith;
  10. import org.springframework.beans.factory.annotation.Autowired;
  11. import org.springframework.boot.test.context.SpringBootTest;
  12. import org.springframework.test.context.junit4.SpringRunner;
  13. import java.util.List;
  14. import static org.example.join.domain.QueryMethods.concat;
  15. @RunWith(SpringRunner.class)
  16. @SpringBootTest(classes = DromaraApplication.class)
  17. public class MySpringBootTest {
  18. public static final Table sys_dept = new Table("sys_dept");
  19. public final QueryColumn dept_id = new QueryColumn(sys_dept, "dept_id");
  20. public final QueryColumn tenant_id = new QueryColumn(sys_dept, "tenant_id");
  21. public final QueryColumn parent_id = new QueryColumn(sys_dept, "parent_id");
  22. public final QueryColumn ancestors = new QueryColumn(sys_dept, "ancestors");
  23. public static final Table sys_user = new Table("sys_user");
  24. public final QueryColumn user_id = new QueryColumn(sys_user, "user_id");
  25. public final QueryColumn user_name = new QueryColumn(sys_user, "user_name");
  26. public final QueryColumn nick_name = new QueryColumn(sys_user, "nick_name");
  27. public final QueryColumn sex = new QueryColumn(sys_user, "sex");
  28. public final QueryColumn create_by = new QueryColumn(sys_user, "create_by");
  29. @Autowired
  30. private ISysUserService service;
  31. @Test
  32. public void testCache() {
  33. List<SysDept> list = Sql.create(SysDept.class)
  34. //.logicIgnore()
  35. .select(
  36. //dept_id,
  37. //abs(parent_id).as(SysDept::getUpdateTime),
  38. //replace(dept_id, "2", "3"),
  39. //concat("@", "1"),
  40. concat(dept_id, 1, "',(select config_value from sys_config where config_id = 1749335361951907842),'").as(SysDept::getEmail)
  41. //concat(dept_id, parent_id),
  42. //concat(dept_id,"sdasdsa"),
  43. //dateFormat(now(), "%Y%m"),
  44. //ifNull("2", "2")
  45. )
  46. .from(sys_dept)
  47. .leftJoin(sys_user).on(user_id.eq(dept_id))
  48. .where(
  49. //dept_id.add(parent_id).eq(parent_id)
  50. //create_by.eq(concat("dept_id", "@", "',(select config_value from sys_config where config_id = 1749335361951907842),'").as(SysDept::getEmail))
  51. //create_by.ne(98),
  52. //create_by.gt(98),
  53. //create_by.lt(98),
  54. //create_by.ge(98),
  55. //create_by.le(98),
  56. //create_by.between(1, 2),
  57. //create_by.notBetween(1, 2),
  58. //create_by.like(1),
  59. //create_by.notLike(1),
  60. //create_by.likeLeft(1),
  61. //create_by.notLikeLeft(1),
  62. //create_by.likeRight(1),
  63. //create_by.notLikeRight(1),
  64. //create_by.isNull(),
  65. //create_by.isNotNull(),
  66. //create_by.in(1, 2, 3, 4),
  67. //create_by.notIn(1, 2, 3, 4)
  68. )
  69. .list();
  70. System.out.println(JSONObject.toJSONString(list));
  71. }
  72. }