package cn.iocoder.yudao.module.system.controller.app.comment;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.controller.app.comment.dto.CommentDTO;
import cn.iocoder.yudao.module.system.controller.app.comment.vo.CommentPageListVO;
import cn.iocoder.yudao.module.system.controller.app.comment.vo.CommentTypeCountVO;
import cn.iocoder.yudao.module.system.controller.app.comment.vo.WorkLogCommentSaveReqVO;
import cn.iocoder.yudao.module.system.service.comment.WorkLogCommentService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "管理后台 - 工作日志评论")
@RestController
@RequestMapping("/system/work-log-comment")
@Validated
public class WorkLogCommentController {

    @Autowired
    private WorkLogCommentService workLogCommentService;

    @Operation(summary = "用户工作日志评论-分页查询评论列表")
    @GetMapping(value = "/queryCommentPageList")
    public CommonResult<IPage<CommentPageListVO>> queryCommentPageList(CommentDTO dto,
                                                                       @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                       @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
        Page<CommentPageListVO> page = new Page<>(pageNo, pageSize);
        IPage<CommentPageListVO> pageList = workLogCommentService.queryCommentPageList(page, dto);
        return success(pageList);
    }

    @PostMapping("/create")
    @Operation(summary = "创建工作日志评论")
    public CommonResult<Long> createWorkLogComment(@RequestBody WorkLogCommentSaveReqVO createReqVO) {
        return success(workLogCommentService.createWorkLogComment(createReqVO));
    }

    @GetMapping("/queryCommentTypeCount")
    @Operation(summary = "获取评论类型数量")
    public CommonResult<CommentTypeCountVO> queryCommentTypeCount() {
        return success(workLogCommentService.queryCommentTypeCount());
    }

}