package com.sckw.contract.controller;

import com.sckw.contract.model.vo.req.IdReqVo;
import com.sckw.contract.model.vo.req.QueryListReqVo;
import com.sckw.contract.service.operateService.KwcContractLogisticsService;
import com.sckw.core.model.enums.EntTypeEnum;
import com.sckw.core.web.response.HttpResult;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
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/18
 */
@RestController
@RequestMapping("kwcCarrier")
public class KwcCarrierController {

    @Autowired
    private KwcContractLogisticsService kwcContractLogisticsService;

    /**
     * @desc 分页查询
     * @param reqVo 分页入参
     * @author czh
     * @date 2023/7/17
     * @return HttpResult
     */
    @RequestMapping("queryListByPage")
    public HttpResult queryListByPage(@RequestBody QueryListReqVo reqVo) {
        reqVo.setEntType(EntTypeEnum.LOGISTICS4.getCode());
        return HttpResult.ok(kwcContractLogisticsService.queryListByPage(reqVo));
    }

    /**
     * @desc: 合同详情
     * @param reqVo id
     * @author: czh
     * @date 2023/7/16
     * @return HttpResult
     */
    @PostMapping("detail")
    public HttpResult detail(@Valid @RequestBody IdReqVo reqVo) {
        return HttpResult.ok(kwcContractLogisticsService.detail(reqVo.getId()));
    }

    /**
     * @desc: 导出
     * @param reqVo 查询入参
     * @author: czh
     * @date 2023/7/17
     */
    @PostMapping("export")
    public void export(@Valid @RequestBody QueryListReqVo reqVo, HttpServletResponse response) {
        reqVo.setEntType(EntTypeEnum.LOGISTICS4.getCode());
        kwcContractLogisticsService.export(reqVo, response);
    }


    /**
     * @return HttpResult
     * @desc: 分组查询
     * @author: czh
     * @date: 2023/7/18
     */
    @PostMapping("findListGroup")
    public HttpResult findListGroup(@RequestBody QueryListReqVo reqVo) {
        reqVo.setEntType(EntTypeEnum.LOGISTICS4.getCode());
        return HttpResult.ok(kwcContractLogisticsService.findListGroup(reqVo));
    }

}
