From 18b9c514a332541a0d1d1ab333dd3e541046340c Mon Sep 17 00:00:00 2001 From: linfeng <2445465217@qq.com> Date: Mon, 20 Feb 2023 15:29:56 +0800 Subject: [PATCH] =?UTF-8?q?lambda=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/admin/controller/CommentController.java | 9 --------- .../admin/service/impl/CommentServiceImpl.java | 11 ++++++----- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/src/main/java/io/linfeng/modules/admin/controller/CommentController.java b/src/main/java/io/linfeng/modules/admin/controller/CommentController.java index ec84279..d9c4cec 100644 --- a/src/main/java/io/linfeng/modules/admin/controller/CommentController.java +++ b/src/main/java/io/linfeng/modules/admin/controller/CommentController.java @@ -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") diff --git a/src/main/java/io/linfeng/modules/admin/service/impl/CommentServiceImpl.java b/src/main/java/io/linfeng/modules/admin/service/impl/CommentServiceImpl.java index aff1cd5..ecb8a93 100644 --- a/src/main/java/io/linfeng/modules/admin/service/impl/CommentServiceImpl.java +++ b/src/main/java/io/linfeng/modules/admin/service/impl/CommentServiceImpl.java @@ -54,9 +54,11 @@ public class CommentServiceImpl extends ServiceImpl i @Override public PageUtils queryPage(Map params) { + QueryWrapper queryWrapper=new QueryWrapper<>(); + queryWrapper.lambda().orderByDesc(CommentEntity::getId); IPage page = this.page( new Query().getPage(params), - new QueryWrapper<>() + queryWrapper ); return new PageUtils(page); @@ -90,10 +92,9 @@ public class CommentServiceImpl extends ServiceImpl i @Override public Integer getCountByPostId(Integer id) { - return baseMapper.selectCount( - new LambdaQueryWrapper() - .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