package com.njcn.cssystem.controller.feedback;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.cssystem.pojo.param.CsFeedbackAddParm;
import com.njcn.cssystem.pojo.param.CsFeedbackAuditParm;
import com.njcn.cssystem.pojo.param.CsFeedbackQueryParm;
import com.njcn.cssystem.pojo.vo.CsFeedbackDetailVO;
import com.njcn.cssystem.pojo.vo.CsFeedbackVO;
import com.njcn.cssystem.service.CsFeedbackService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * Description:
 * 接口文档访问地址：http://serverIP:port/swagger-ui.html
 * Date: 2023/3/27  10:54【需求编号】
 *
 * @author clam
 * @version V1.0.0
 */
@Slf4j
@RestController
@RequestMapping("/feedback")
@Api(tags = "问题反馈")
@AllArgsConstructor
public class FeedBackController extends BaseController {


    private final CsFeedbackService csFeedbackService;


    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/addFeedBack")
    @ApiOperation("新增反馈")
    public HttpResult<Boolean> addFeedBack(@Validated CsFeedbackAddParm csFeedbackAddParm){
        String methodDescribe = getMethodDescribe("addFeedBack");

        Boolean flag = csFeedbackService.addFeedBack(csFeedbackAddParm);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/auditFeedBack")
    @ApiOperation("更新反馈")
    public HttpResult<Boolean> auditFeedBack(@Validated CsFeedbackAuditParm csFeedbackAuditParm){
        String methodDescribe = getMethodDescribe("auditFeedBack");

        Boolean flag = csFeedbackService.auditFeedBack(csFeedbackAuditParm);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/queryFeedBackPage")
    @ApiOperation("查询反馈列表")
    @ApiImplicitParam(name = "csFeedbackQueryParm", value = "新增反馈聊天参数", required = true)
    public HttpResult<Page<CsFeedbackVO>> queryFeedBackPage(@Validated @RequestBody CsFeedbackQueryParm csFeedbackQueryParm){
        String methodDescribe = getMethodDescribe("queryFeedBackPage");

        Page<CsFeedbackVO> csFeedbackVOIPage  = csFeedbackService.queryFeedBackPage(csFeedbackQueryParm);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csFeedbackVOIPage, methodDescribe);
    }

    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/queryFeedBackDetail")
    @ApiOperation("查询反馈详情")
    public HttpResult<CsFeedbackDetailVO> queryFeedBackDetail(@RequestParam("id")String id){
        String methodDescribe = getMethodDescribe("queryFeedBackDetail");

        CsFeedbackDetailVO csFeedbackDetailVO  = csFeedbackService.queryFeedBackDetail(id);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csFeedbackDetailVO, methodDescribe);
    }

}
