package com.sckw.manage.controller;

import com.sckw.core.web.constant.HttpStatus;
import com.sckw.core.web.response.HttpResult;
import com.sckw.manage.model.vo.req.CooperateApplyQueryReqVo;
import com.sckw.manage.model.vo.req.CooperateApproveReqVo;
import com.sckw.manage.model.vo.req.IdsReqVo;
import com.sckw.manage.model.vo.req.InitiateReqVo;
import com.sckw.manage.service.KwmCooperateApplyService;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
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;

/**
 * @author czh
 * @desc 合作申请
 * @date 2023/7/10
 */
@RestController
@RequestMapping("/cooperateApply")
public class KwmCooperateApplyController {

    @Autowired
    private KwmCooperateApplyService kwmCooperateApplyService;

    /**
     * @param reqVo 分页入参
     * @return HttpResult
     * @desc: 查询合作企业列表
     * @author: czh
     * @date: 2023/7/10
     */
    @PostMapping("/queryByPage")
    public HttpResult queryByPage(@Valid @RequestBody CooperateApplyQueryReqVo reqVo) {
        return HttpResult.ok(kwmCooperateApplyService.queryByPage(reqVo));
    }

    /**
     * @param reqVo 申请入参
     * @return HttpResult
     * @desc: 发起申请
     * @author: czh
     * @date: 2023/7/11
     */
    @PostMapping("/initiate")
    public HttpResult initiate(@Valid @RequestBody InitiateReqVo reqVo) {
        kwmCooperateApplyService.initiate(reqVo);
        return HttpResult.ok(HttpStatus.MSG_017);
    }

    /**
     * @param reqVo ids
     * @return HttpResult
     * @desc: 撤销
     * @author: czh
     * @date: 2023/7/11
     */
    @PostMapping("/cancel")
    public HttpResult cancel(@Valid @RequestBody IdsReqVo reqVo) {
        kwmCooperateApplyService.cancel(reqVo);
        return HttpResult.ok(HttpStatus.MSG_018);
    }

    /**
     * @param reqVo 入参
     * @return HttpResult
     * @desc: 审核
     * @author: czh
     * @date: 2023/7/11
     */
    @PostMapping("/approve")
    public HttpResult approve(@Valid @RequestBody CooperateApproveReqVo reqVo) {
        kwmCooperateApplyService.approve(reqVo);
        return HttpResult.ok(HttpStatus.MSG_004);
    }

    /**
     * @param reqVo 全量入参
     * @desc: 导出
     * @author: czh
     * @date: 2023/7/11
     */
    @PostMapping(value = "export", produces = MediaType.APPLICATION_JSON_VALUE)
    public void export(@Valid @RequestBody CooperateApplyQueryReqVo reqVo, HttpServletResponse response) {
        kwmCooperateApplyService.export(reqVo, response);
    }


    /**
     * @param reqVo 查询入参
     * @return HttpResult
     * @desc: 分组查询
     * @author: czh
     * @date: 2023/7/17
     */
    @PostMapping("/findListGroup")
    public HttpResult findListGroup(@Valid @RequestBody CooperateApplyQueryReqVo reqVo) {
        return HttpResult.ok(kwmCooperateApplyService.findListGroup(reqVo));
    }

}
