查询构造器 QueryWrapper
- 查询固定字段、条件
wrapper.select()
@Override
@Cached(name="manuscript:list:organizationId:",key = "#organizationId+'-'+#pageNum+'-'+#pageSize",
expire = 300,cacheNullValue=true)
@CacheRefresh(refresh = 60, stopRefreshAfterLastAccess = 300)
public Page<Manuscript> getList(long organizationId, int pageNum, int pageSize) {
QueryWrapper<Manuscript> wrapper = new QueryWrapper<>();
// Manuscript.class中所有字段,除了'content'
wrapper.select(Manuscript.class, tableFieldInfo -> !tableFieldInfo.getColumn().equals("content")).
isNull("deleted_time").
eq("organization_id",organizationId).
orderByDesc("top_at").
orderByDesc("created_time");
Page<Manuscript> manuscriptPage = page(new Page<>(pageNum, pageSize), wrapper);
/* 迭代处理数据
List<Manuscript> records = manuscriptPage.getRecords();
Iterator iterator = records.iterator();
while(iterator.hasNext()) {
Manuscript manuscript = (Manuscript) iterator.next();
manuscript.setTitle("迭代修改引用数据");
}
*/
return manuscriptPage;
}
模型方式
赞赏支持
本文由 litblc 创作,采用 知识共享署名4.0 国际许可协议进行许可
本站文章除注明转载/出处外,均为本站原创或翻译,转载前请务必署名
最后编辑时间为: Oct 20, 2021 at 06:10 am