diff --git a/luoo_comment/src/main/java/com/luoo/comment/controller/CmsCommentController.java b/luoo_comment/src/main/java/com/luoo/comment/controller/CmsCommentController.java new file mode 100644 index 0000000..5c88c34 --- /dev/null +++ b/luoo_comment/src/main/java/com/luoo/comment/controller/CmsCommentController.java @@ -0,0 +1,90 @@ +package com.luoo.comment.controller; + + +import api.PageResult; +import api.Result; +import api.StatusCode; +import com.luoo.comment.pojo.Comment; +import com.luoo.comment.pojo.CommentVo; +import com.luoo.comment.service.CommentService; +import constants.Constants; +import controller.BaseController; +import dto.UserLoginDto; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.data.domain.Page; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletRequest; +import java.util.concurrent.TimeUnit; + +@RestController +@CrossOrigin +@RequestMapping("/commentCms") +@Api(tags = "评论后台管理") +public class CmsCommentController extends BaseController { + + + + @Autowired + private CommentService commentService; + + + @Autowired + private RedisTemplate redisTemplate; + + + @Autowired + private HttpServletRequest request; + + + + @GetMapping + public Result findAll(){ + return Result.success(commentService.findAll()); + } + + + + + @GetMapping("/{page}/{size}") + public Result search(@PathVariable int page,@PathVariable int size){ + Page pageData = commentService.search(page,size); + return Result.success(new PageResult(pageData.getTotalElements(),pageData.getContent())); + } + + + @GetMapping("/{commentId}") + public Result findById(@PathVariable String commentId){ + return Result.success(commentService.findById(commentId)); + } + + + + + + @PutMapping("/{commentId}") + public Result update(@PathVariable String commentId,@RequestBody Comment comment) { + + comment.set_id(commentId); + commentService.update(comment); + return Result.success(); + } + + @DeleteMapping("/{commentId}") + public Result delete(@PathVariable String commentId) { + commentService.deleteById(commentId); + return Result.success(); + } + + + + + + +}