From 8c881276dc7911d6a14f1e97846b2a7e986eadb0 Mon Sep 17 00:00:00 2001 From: luijp Date: Sat, 20 Jul 2024 01:15:07 +0800 Subject: [PATCH] Fix: comment id auto increase --- .../java/cn/luijp/escserver/controller/CommentController.java | 2 +- src/main/java/cn/luijp/escserver/model/entity/Comment.java | 3 +++ .../service/controller/impl/CommentControllerServiceImpl.java | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main/java/cn/luijp/escserver/controller/CommentController.java b/src/main/java/cn/luijp/escserver/controller/CommentController.java index 064d072..9c7e1d4 100644 --- a/src/main/java/cn/luijp/escserver/controller/CommentController.java +++ b/src/main/java/cn/luijp/escserver/controller/CommentController.java @@ -78,7 +78,7 @@ public ResponseDto deny(@PathVariable Long id) { if (status) { return ResponseDto.success(); } else { - return ResponseDto.error(-1, "Comment pass failed"); + return ResponseDto.error(-1, "Comment deny failed"); } } } diff --git a/src/main/java/cn/luijp/escserver/model/entity/Comment.java b/src/main/java/cn/luijp/escserver/model/entity/Comment.java index 3e26e4b..bde3ac1 100644 --- a/src/main/java/cn/luijp/escserver/model/entity/Comment.java +++ b/src/main/java/cn/luijp/escserver/model/entity/Comment.java @@ -1,7 +1,9 @@ package cn.luijp.escserver.model.entity; import com.baomidou.mybatisplus.annotation.FieldFill; +import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; import lombok.Data; import java.time.LocalDateTime; @@ -9,6 +11,7 @@ @Data public class Comment { + @TableId(type = IdType.AUTO) private Long id; private Long postId; diff --git a/src/main/java/cn/luijp/escserver/service/controller/impl/CommentControllerServiceImpl.java b/src/main/java/cn/luijp/escserver/service/controller/impl/CommentControllerServiceImpl.java index 65daf3f..7b67d7a 100644 --- a/src/main/java/cn/luijp/escserver/service/controller/impl/CommentControllerServiceImpl.java +++ b/src/main/java/cn/luijp/escserver/service/controller/impl/CommentControllerServiceImpl.java @@ -53,13 +53,13 @@ public CommentListDto getComment(Long postId, Integer pageNum, Integer pageSize, public Boolean passComment(Long id) { LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); - updateWrapper.eq(Comment::getId, id).set(Comment::getVisible, true); + updateWrapper.eq(Comment::getId, id).set(Comment::getVisible, 1); return commentService.update(updateWrapper); } public Boolean denyComment(Long id) { LambdaUpdateWrapper updateWrapper = new LambdaUpdateWrapper<>(); - updateWrapper.eq(Comment::getId, id).set(Comment::getVisible, false); + updateWrapper.eq(Comment::getId, id).set(Comment::getVisible, 0); return commentService.update(updateWrapper); } }