Просмотр исходного кода

预览增删改查代码提交

pans 8 месяцев назад
Родитель
Сommit
b8268da5a1

+ 13 - 1
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/controller/UserCommentController.java

@@ -129,7 +129,19 @@ public class UserCommentController {
     }
 
 
-
+    /**
+     * 取消点赞
+     *
+     * @author pans
+     * @date  2025/06/27 11:07
+     */
+    @ApiOperationSupport(order = 3)
+    @ApiOperation("点赞")
+    @CommonLog("点赞")
+    @GetMapping("/disk/comment/giveCancel")
+    public CommonResult<String> giveCancel(@Valid @NotNull(message="评论id不能为空") Integer id) {
+        return CommonResult.ok(userCommentService.giveCancel(id));
+    }
 
 
 }

+ 2 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/service/UserCommentService.java

@@ -75,4 +75,6 @@ public interface UserCommentService extends IService<UserComment> {
 
 
     void give(@Valid @NotNull(message="评论id不能为空") Integer id);
+
+    String giveCancel(@Valid @NotNull(message="评论id不能为空") Integer id);
 }

+ 12 - 0
snowy-plugin/snowy-plugin-disk/snowy-plugin-disk-func/src/main/java/vip/xiaonuo/disk/service/impl/UserCommentServiceImpl.java

@@ -104,6 +104,18 @@ public class UserCommentServiceImpl extends ServiceImpl<UserCommentMapper, UserC
         this.updateById(userComment);
     }
 
+    @Override
+    public String giveCancel(Integer id) {
+        UserComment userComment=queryEntity(id);
+        if(userComment.getGiveNum()>1){
+            userComment.setGiveNum(userComment.getGiveNum()-1);
+            this.updateById(userComment);
+            return "取消点赞成功";
+        }else{
+            return "点赞数量为0,无法取消点赞!";
+        }
+    }
+
 
     public UserComment queryEntity(Integer id) {
         UserComment userComment = this.getById(id);