MySpringBootTest.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. import static org.example.join.domain.QueryMethods.now;
  16. @RunWith(SpringRunner.class)
  17. @SpringBootTest(classes = DromaraApplication.class)
  18. public class MySpringBootTest {
  19. public static final Table sys_dept = new Table("sys_dept");
  20. public final QueryColumn dept_id = new QueryColumn(sys_dept, "dept_id");
  21. public final QueryColumn tenant_id = new QueryColumn(sys_dept, "tenant_id");
  22. public final QueryColumn parent_id = new QueryColumn(sys_dept, "parent_id");
  23. public final QueryColumn ancestors = new QueryColumn(sys_dept, "ancestors");
  24. public static final Table sys_user = new Table("sys_user");
  25. public final QueryColumn user_id = new QueryColumn(sys_user, "user_id");
  26. public final QueryColumn user_name = new QueryColumn(sys_user, "user_name");
  27. public final QueryColumn nick_name = new QueryColumn(sys_user, "nick_name");
  28. public final QueryColumn sex = new QueryColumn(sys_user, "sex");
  29. public final QueryColumn create_by = new QueryColumn(sys_user, "create_by");
  30. @Autowired
  31. private ISysUserService service;
  32. @Test
  33. public void testCache() {
  34. List<SysDept> list = Sql.create(SysDept.class)
  35. //.logic()
  36. .select(
  37. //dept_id,
  38. //abs(parent_id).as(SysDept::getUpdateTime),
  39. //replace(dept_id, "2", "3"),
  40. now(),
  41. concat("@", "1"),
  42. concat("777", "555").add(777).as(SysDept::getDeptId),
  43. concat(dept_id, parent_id)
  44. //concat(dept_id,"sdasdsa"),
  45. //dateFormat(now(), "%Y%m"),
  46. //ifNull("2", "2")
  47. )
  48. .from(sys_dept)
  49. .leftJoin(sys_user).on(user_id.eq(dept_id))
  50. .where(
  51. create_by.eq(777),
  52. create_by.ne(concat("777", "555").add(777)).and(concat("777", "555").eq("sss"))
  53. //create_by.gt(98),
  54. //create_by.lt(98),
  55. //create_by.ge(98),
  56. //create_by.le(98),
  57. //create_by.between(1, 2),
  58. //create_by.notBetween(1, 2),
  59. //create_by.like(1),
  60. //create_by.notLike(1),
  61. //create_by.likeLeft(1),
  62. //create_by.notLikeLeft(1),
  63. //create_by.likeRight(1),
  64. //create_by.notLikeRight(1),
  65. //create_by.isNull(),
  66. //create_by.isNotNull(),
  67. //create_by.in(1, 2, 3, 4),
  68. //create_by.notIn(1, 2, 3, 4)
  69. )
  70. .list();
  71. System.out.println(JSONObject.toJSONString(list));
  72. }
  73. }