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");
if (!ObjectUtil.isEmpty(key)) {
queryWrapper.like("username", key)
queryWrapper.lambda()
.like(AppUserEntity::getUsername, key)
.or()
.like("mobile", key);
.like(AppUserEntity::getMobile, key);
}
queryWrapper.lambda().orderByDesc(AppUserEntity::getUid);
IPage<AppUserEntity> page = this.page(

View File

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