From 40d37e42be149a9d89eaad1ba32618baf2370120 Mon Sep 17 00:00:00 2001 From: yang <2119157836@qq.com> Date: Tue, 14 Jan 2025 18:28:20 +0800 Subject: [PATCH] =?UTF-8?q?refactor(resource):=20=E9=87=8D=E6=9E=84?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E7=9B=B8=E5=85=B3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 ModelImageCommentController 专门处理图片评论相关功能 - 从 ModelImageController 中移除图片评论相关的代码 - 删除了 ModelImageController 中未使用的上传功能 - 调整了 ModelImageController 的路由前缀 --- .../resource/ModelImageCommentController.java | 69 +++++++++++++++++++ .../resource/ModelImageController.java | 61 +--------------- 2 files changed, 70 insertions(+), 60 deletions(-) create mode 100644 mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageCommentController.java diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageCommentController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageCommentController.java new file mode 100644 index 0000000..5048111 --- /dev/null +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageCommentController.java @@ -0,0 +1,69 @@ +package com.mcwl.web.controller.resource; + +import com.mcwl.common.annotation.RepeatSubmit; +import com.mcwl.common.core.domain.AjaxResult; +import com.mcwl.resource.domain.dto.ModelImageCommentRes; +import com.mcwl.resource.domain.vo.ModelImageCommentVo; +import com.mcwl.resource.service.ModelImageCommentLikeService; +import com.mcwl.resource.service.ModelImageCommentService; +import com.mcwl.resource.service.ModelImageService; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.*; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * 图片 + */ +@RestController +@RequestMapping("/imageComment") +@RequiredArgsConstructor +public class ModelImageCommentController { + + private final ModelImageService modelImageService; + + private final ModelImageCommentLikeService modelImageCommentLikeService; + + private final ModelImageCommentService modelImageCommentService; + + + /** + * 图片评论发布 + */ + @PostMapping("/comment") + public AjaxResult comment(@RequestBody ModelImageCommentRes modelImageCommentRes) { + modelImageService.comment(modelImageCommentRes); + return AjaxResult.success(); + } + + /** + * 图片评论点赞/取消 + */ + @RepeatSubmit + @GetMapping("/commentLike/{commentId}") + public AjaxResult commentLike(@PathVariable @NotNull(message = "评论id不能为空") Long commentId) { + modelImageCommentLikeService.like(commentId); + return AjaxResult.success(); + } + + /** + * 删除图片评论 + */ + @GetMapping("/commentDelete/{commentId}") + public AjaxResult commentDelete(@PathVariable @NotNull(message = "评论id不能为空") Long commentId) { + modelImageCommentService.removeById(commentId); + return AjaxResult.success(); + } + + /** + * 获取图片评论 + */ + @GetMapping("/comment/{imageId}") + public AjaxResult getComment(@PathVariable @NotNull(message = "图片id不能为空") Long imageId) { + List modelImageCommentVoList = modelImageService.getComment(imageId); + return AjaxResult.success(modelImageCommentVoList); + } + + +} diff --git a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageController.java b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageController.java index dbd2543..3e0ab9a 100644 --- a/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageController.java +++ b/mcwl-admin/src/main/java/com/mcwl/web/controller/resource/ModelImageController.java @@ -7,31 +7,24 @@ import com.mcwl.common.core.domain.entity.SysUser; import com.mcwl.common.core.page.PageDomain; import com.mcwl.common.core.page.TableDataInfo; import com.mcwl.common.utils.SecurityUtils; -import com.mcwl.common.utils.oss.OssUtil; import com.mcwl.resource.domain.ModelImage; -import com.mcwl.resource.domain.dto.ModelImageCommentRes; import com.mcwl.resource.domain.dto.ModelImagePageRes; import com.mcwl.resource.domain.dto.ModelImageRes; -import com.mcwl.resource.domain.vo.ModelImageCommentVo; import com.mcwl.resource.domain.vo.ModelImageVo; -import com.mcwl.resource.service.ModelImageCommentLikeService; -import com.mcwl.resource.service.ModelImageCommentService; import com.mcwl.resource.service.ModelImageLikeService; import com.mcwl.resource.service.ModelImageService; import com.mcwl.system.service.ISysUserService; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; -import org.springframework.web.multipart.MultipartFile; import javax.validation.constraints.NotNull; -import java.util.List; import java.util.Objects; /** * 图片 */ @RestController -@RequestMapping("/modelImage") +@RequestMapping("/image") @RequiredArgsConstructor public class ModelImageController { @@ -39,10 +32,6 @@ public class ModelImageController { private final ModelImageLikeService modelImageLikeService; - private final ModelImageCommentLikeService modelImageCommentLikeService; - - private final ModelImageCommentService modelImageCommentService; - private final ISysUserService sysUserService; @@ -92,17 +81,6 @@ public class ModelImageController { } - /** - * 图片上传 - */ - @GetMapping("/upload") - public AjaxResult upload(MultipartFile file) { - - return AjaxResult.success("上传成功", OssUtil.uploadMultipartFile(file)); - - } - - /** * 图片发布 */ @@ -123,42 +101,5 @@ public class ModelImageController { } - /** - * 图片评论发布 - */ - @PostMapping("/comment") - public AjaxResult comment(@RequestBody ModelImageCommentRes modelImageCommentRes) { - modelImageService.comment(modelImageCommentRes); - return AjaxResult.success(); - } - - /** - * 图片评论点赞/取消 - */ - @RepeatSubmit - @GetMapping("/commentLike/{commentId}") - public AjaxResult commentLike(@PathVariable @NotNull(message = "评论id不能为空") Long commentId) { - modelImageCommentLikeService.like(commentId); - return AjaxResult.success(); - } - - /** - * 删除图片评论 - */ - @GetMapping("/commentDelete/{commentId}") - public AjaxResult commentDelete(@PathVariable @NotNull(message = "评论id不能为空") Long commentId) { - modelImageCommentService.removeById(commentId); - return AjaxResult.success(); - } - - /** - * 获取图片评论 - */ - @GetMapping("/comment/{imageId}") - public AjaxResult getComment(@PathVariable @NotNull(message = "图片id不能为空") Long imageId) { - List modelImageCommentVoList = modelImageService.getComment(imageId); - return AjaxResult.success(modelImageCommentVoList); - } - }