refactor(resource): 重构图片相关接口

- 新增 ModelImageCommentController 专门处理图片评论相关功能
- 从 ModelImageController 中移除图片评论相关的代码
- 删除了 ModelImageController 中未使用的上传功能
- 调整了 ModelImageController 的路由前缀
feature/my-invitation
yang 2025-01-14 18:28:20 +08:00
parent bd42786571
commit 40d37e42be
2 changed files with 70 additions and 60 deletions

View File

@ -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<ModelImageCommentVo> modelImageCommentVoList = modelImageService.getComment(imageId);
return AjaxResult.success(modelImageCommentVoList);
}
}

View File

@ -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<ModelImageCommentVo> modelImageCommentVoList = modelImageService.getComment(imageId);
return AjaxResult.success(modelImageCommentVoList);
}
}