package com.mcwl.web.controller.communityCenter;


import com.mcwl.common.core.domain.AjaxResult;
import com.mcwl.common.core.domain.R;
import com.mcwl.common.core.page.TableDataInfo;
import com.mcwl.communityCenter.domain.dto.*;
import com.mcwl.communityCenter.service.QuestionCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * 提问评论
 */
@Api(tags = "社区提问评论")
@RestController
@RequestMapping("questionComment")
@RequiredArgsConstructor
public class QuestionCommentController {

    private final QuestionCommentService questionCommentService;


    /**
     * 提问评论
     */
    @PostMapping("comment")
    @ApiOperation(value = "新增提问评论")
    public R<Object> comment(@Valid @RequestBody QuestionCommentRes questionCommentRes) {
        return questionCommentService.comment(questionCommentRes);
    }

    /**
     * 获取提问评论列表
     * @param questionCommentPageRes 请求参数
     * @return 评论列表
     */
    @PostMapping("list")
    @ApiOperation(value = "获取提问评论列表")
    public TableDataInfo list(@RequestBody @Valid QuestionCommentPageRes questionCommentPageRes) {
        return questionCommentService.listByPage(questionCommentPageRes);
    }

    /**
     * 采纳评论
     */
    @PostMapping("adopt")
    @ApiOperation(value = "采纳评论")
    public R<Object> adopt(@Valid @RequestBody QuestionCommentAdoptRes questionCommentAdoptRes) {
        return questionCommentService.adopt(questionCommentAdoptRes);
    }





}
