refactor(resource): 重构图片相关接口
- 新增 ModelImageCommentController 专门处理图片评论相关功能 - 从 ModelImageController 中移除图片评论相关的代码 - 删除了 ModelImageController 中未使用的上传功能 - 调整了 ModelImageController 的路由前缀feature/my-invitation
parent
bd42786571
commit
40d37e42be
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue