package com.tanpu.community.controller; import com.tanpu.common.api.CommonResp; import com.tanpu.common.auth.AuthLogin; import com.tanpu.common.auth.UserHolder; import com.tanpu.community.api.beans.qo.CommentQo; import com.tanpu.community.api.beans.req.comment.CreateCommentReq; import com.tanpu.community.api.beans.req.comment.LikeCommentReq; import com.tanpu.community.api.beans.req.comment.QueryCommentReq; import com.tanpu.community.api.beans.req.page.Page; import com.tanpu.community.manager.CommentManager; import com.tanpu.community.util.PageUtils; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import java.util.List; @RestController @Slf4j @RequestMapping(value = "/api/theme") public class CommentController { @Autowired private CommentManager commentManager; @Resource private UserHolder userHolder; @ApiOperation("发表评论") @AuthLogin @PostMapping(value = "/publishComment") @ResponseBody public CommonResp<Void> publishCommet(@Validated @RequestBody CreateCommentReq req) { String userId = userHolder.getUserId(); commentManager.comment(req, userId); return CommonResp.success(); } @ApiOperation("评论列表") @AuthLogin @PostMapping(value = "/queryComment") @ResponseBody public CommonResp<Page<CommentQo>> queryComment(@Validated @RequestBody QueryCommentReq req) { String userId = userHolder.getUserId(); List<CommentQo> result = commentManager.queryComments(req.getThemeId(), userId); return CommonResp.success(PageUtils.page(req.getPage(), result)); } @ApiOperation("点赞评论") @PostMapping(value = "/likeComment") @AuthLogin @ResponseBody public CommonResp<Void> likeComment(@Validated @RequestBody LikeCommentReq req) { String userId = userHolder.getUserId(); commentManager.likeComment(req, userId); return CommonResp.success(); } @ApiOperation("举报评论") @GetMapping(value = "/reportComment") @AuthLogin @ResponseBody public CommonResp<Void> reportComment(@RequestParam String commentId) { //todo String userId = userHolder.getUserId(); return CommonResp.failed("功能暂未开放"); } }