JEECG確實是一款實實在在的促進生產力的工具好處我想看到此文章的人應該都有所體會了
言歸正傳 JEECG框架自帶的查詢確實很省事,但是多表聯合查詢 分頁查詢 是我們開發業務系統當中不可避免的這時框架顯得有點不太靠得住了 那我們就自己動手豐衣足食
使用minidao封裝自己得查詢sql吧
Controller
MiniDaoPage<PersonEntity> rlt = this.personService.getpersonInfo(personModel, dataGrid);
ServiceImpl.java
@Override public MiniDaoPage<PersonEntity> getPersonInfo(PersonEntity personModel, DataGrid dataGrid) throws Exception { int page = 0; int queryPage = (dataGrid.getPage() - 1) * dataGrid.getRows(); int rows = dataGrid.getRows(); MiniDaoPage<PersonEntity> rlt = new MiniDaoPage<PersonEntity>(); rlt.setPage(dataGrid.getPage()); rlt.setRows(dataGrid.getRows()); rlt.setTotal(PersonDao.getPersonPageCount(personModel)); rlt.setResults(PersonDao.getPersonInfo(personModel, queryPage, page, rows)); return rlt; }
PersonDao
@Arguments({"personModel", "queryPage", "page", "rows"})
@ResultType(PersonEntity.class)
public List<PersonEntity> getPersonInfo(@Param("personModel") PersonEntity personModel, @Param("queryPage") int queryPage,@Param("page") int page, @Param("rows") int rows);
sql
select * from person where 1=1 <#if personModel.name? exists &&personModel.name ?length gt 0> and name like CONCAT('%', :personModel.name,'%') </#if> order by name limit :queryPage, :rows
