123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- import com.alibaba.fastjson.JSONObject;
- import org.dromara.system.domain.SysDept;
- import org.dromara.system.service.ISysUserService;
- import org.example.DromaraApplication;
- import org.example.join.domain.QueryColumn;
- import org.example.join.domain.Table;
- import org.example.join.sql.Sql;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- 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.concat;
- import static org.example.join.domain.QueryMethods.now;
- @RunWith(SpringRunner.class)
- @SpringBootTest(classes = DromaraApplication.class)
- public class MySpringBootTest {
- public static final Table sys_dept = new Table("sys_dept");
- public final QueryColumn dept_id = new QueryColumn(sys_dept, "dept_id");
- public final QueryColumn tenant_id = new QueryColumn(sys_dept, "tenant_id");
- public final QueryColumn parent_id = new QueryColumn(sys_dept, "parent_id");
- public final QueryColumn ancestors = new QueryColumn(sys_dept, "ancestors");
- public static final Table sys_user = new Table("sys_user");
- public final QueryColumn user_id = new QueryColumn(sys_user, "user_id");
- public final QueryColumn user_name = new QueryColumn(sys_user, "user_name");
- public final QueryColumn nick_name = new QueryColumn(sys_user, "nick_name");
- public final QueryColumn sex = new QueryColumn(sys_user, "sex");
- public final QueryColumn create_by = new QueryColumn(sys_user, "create_by");
- @Autowired
- private ISysUserService service;
- @Test
- public void testCache() {
- List<SysDept> list = Sql.create(SysDept.class)
- //.logic()
- .select(
- //dept_id,
- //abs(parent_id).as(SysDept::getUpdateTime),
- //replace(dept_id, "2", "3"),
- now(),
- concat("@", "1"),
- concat("777", "555").add(777).as(SysDept::getDeptId),
- concat(dept_id, parent_id)
- //concat(dept_id,"sdasdsa"),
- //dateFormat(now(), "%Y%m"),
- //ifNull("2", "2")
- )
- .from(sys_dept)
- .leftJoin(sys_user).on(user_id.eq(dept_id))
- .where(
- create_by.eq(777),
- create_by.ne(concat("777", "555").add(777)).and(concat("777", "555").eq("sss"))
- //create_by.gt(98),
- //create_by.lt(98),
- //create_by.ge(98),
- //create_by.le(98),
- //create_by.between(1, 2),
- //create_by.notBetween(1, 2),
- //create_by.like(1),
- //create_by.notLike(1),
- //create_by.likeLeft(1),
- //create_by.notLikeLeft(1),
- //create_by.likeRight(1),
- //create_by.notLikeRight(1),
- //create_by.isNull(),
- //create_by.isNotNull(),
- //create_by.in(1, 2, 3, 4),
- //create_by.notIn(1, 2, 3, 4)
- )
- .list();
- System.out.println(JSONObject.toJSONString(list));
- }
- }
|