@Test
public void testComplexSelect() {
QQyOnlineCall onlineCall = QQyOnlineCall.qyOnlineCall;
QClientList clientList = QClientList.clientList;
// page必须从1开始
PageRequest request = PageRequest.of(0, 10);
// 构建复杂查询语句
List<Tuple> result = mFactory.select(onlineCall.id, onlineCall.cUsesign, onlineCall.cYgscode, clientList.cClientname, clientList.cPhone1)
.from(onlineCall)
.leftJoin(clientList)
.on(onlineCall.cClientid.eq(clientList.id))
.where(onlineCall.cCom.eq("C0003"))
.limit(request.getPageSize()) // 单页查询数量
.offset(request.getPageSize() * request.getPageNumber()) // 偏移量
.fetch();
// 获取结果
for (Tuple tuple : result) {
HashMap<String, Object> map = new HashMap<>();
map.put("id", tuple.get(onlineCall.id));
map.put("useSign", tuple.get(onlineCall.cUsesign));
map.put("ygsCode", tuple.get(onlineCall.cYgscode));
map.put("clientName", tuple.get(clientList.cClientname));
map.put("phone", tuple.get(clientList.cPhone1));
System.out.println(JsonUtils.toJson(map));
}
}
来源:CSDN
作者:414丶小哥
链接:https://blog.csdn.net/u010838785/article/details/103954941