lambda处理

This commit is contained in:
linfeng 2023-11-15 09:55:53 +08:00
parent d47c451584
commit 0f28c392dc
2 changed files with 6 additions and 5 deletions

View File

@ -83,9 +83,10 @@ public class AppUserServiceImpl extends ServiceImpl<AppUserDao, AppUserEntity> i
//模糊查询 //模糊查询
String key = (String) params.get("key"); String key = (String) params.get("key");
if (!ObjectUtil.isEmpty(key)) { if (!ObjectUtil.isEmpty(key)) {
queryWrapper.like("username", key) queryWrapper.lambda()
.like(AppUserEntity::getUsername, key)
.or() .or()
.like("mobile", key); .like(AppUserEntity::getMobile, key);
} }
queryWrapper.lambda().orderByDesc(AppUserEntity::getUid); queryWrapper.lambda().orderByDesc(AppUserEntity::getUid);
IPage<AppUserEntity> page = this.page( IPage<AppUserEntity> page = this.page(

View File

@ -62,10 +62,10 @@ public class PostServiceImpl extends ServiceImpl<PostDao, PostEntity> implements
QueryWrapper<PostEntity> queryWrapper=new QueryWrapper<>(); QueryWrapper<PostEntity> queryWrapper=new QueryWrapper<>();
String key = (String)params.get("key"); String key = (String)params.get("key");
String status = (String)params.get("status"); String status = (String)params.get("status");
queryWrapper queryWrapper.lambda()
.like(!ObjectUtil.isEmpty(status),"content", key) .like(!ObjectUtil.isEmpty(status),PostEntity::getContent, key)
.or() .or()
.like(!ObjectUtil.isEmpty(status),"title",key); .like(!ObjectUtil.isEmpty(status),PostEntity::getTitle,key);
queryWrapper.lambda().orderByDesc(PostEntity::getId); queryWrapper.lambda().orderByDesc(PostEntity::getId);
IPage<PostEntity> page = this.page( IPage<PostEntity> page = this.page(
new Query<PostEntity>().getPage(params), new Query<PostEntity>().getPage(params),