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); - } - }