lambda化

This commit is contained in:
linfeng 2023-02-20 15:29:56 +08:00
parent 34a2f412d1
commit 18b9c514a3
2 changed files with 6 additions and 14 deletions

View File

@ -65,15 +65,6 @@ public class CommentController {
}
@PostMapping("/save")
@RequiresPermissions("admin:comment:save")
@ApiOperation("评论保存")
public R save(@RequestBody CommentEntity comment){
commentService.save(comment);
return R.ok();
}
@PostMapping("/update")
@RequiresPermissions("admin:comment:update")

View File

@ -54,9 +54,11 @@ public class CommentServiceImpl extends ServiceImpl<CommentDao, CommentEntity> i
@Override
public PageUtils queryPage(Map<String, Object> params) {
QueryWrapper<CommentEntity> queryWrapper=new QueryWrapper<>();
queryWrapper.lambda().orderByDesc(CommentEntity::getId);
IPage<CommentEntity> page = this.page(
new Query<CommentEntity>().getPage(params),
new QueryWrapper<>()
queryWrapper
);
return new PageUtils(page);
@ -90,10 +92,9 @@ public class CommentServiceImpl extends ServiceImpl<CommentDao, CommentEntity> i
@Override
public Integer getCountByPostId(Integer id) {
return baseMapper.selectCount(
new LambdaQueryWrapper<CommentEntity>()
.eq(CommentEntity::getStatus, Constant.COMMENT_NORMAL)
.eq(CommentEntity::getPostId, id));
return this.lambdaQuery()
.eq(CommentEntity::getStatus, Constant.COMMENT_NORMAL)
.eq(CommentEntity::getPostId, id).count();
}
@Override