package com.yh.saas.plugin.yiliangyiyun.controller;



import com.yh.saas.plugin.yiliangyiyun.entity.ContractManagementInfo;
import com.yh.saas.plugin.yiliangyiyun.service.IContractManagementInfoService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.plugins.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 合同管理 前端控制器
 * </p>
 *
 * @author Gongdc
 * @since 2021-05-17
 */
@RestController
@RequestMapping("/contractManagementInfo")
public class ContractManagementInfoController {

    @Autowired
    private IContractManagementInfoService contractManagementInfoService;

    /**
     * 新增合同信息
     */
    @PostMapping("/api/addInfo")
    public String addInfo(@RequestBody @Valid ContractManagementInfo contractManagementInfo) {
        return contractManagementInfoService.addInfo(contractManagementInfo);
    }
    /**
     * 查对应的合同
     */
    @GetMapping("/selectContract")
    public List<ContractManagementInfo> selectContract(ContractManagementInfo contractManagementInfo) {
        return contractManagementInfoService.selectContract(contractManagementInfo);
    }

    /**
     * 编辑合同信息
     */
    @PostMapping("/editInfo")
    public String editInfo(@RequestBody ContractManagementInfo contractManagementInfo) {
        return contractManagementInfoService.editInfo(contractManagementInfo);
    }

    /**
     * 查看合同信息
     */
    @GetMapping("/getInfo")
    public ContractManagementInfo getInfo(@RequestParam String id) {
        return contractManagementInfoService.getInfo(id);
    }

    /**
     * 信息分页列表查询
     *
     * @param contractManagementInfo
     * @return
     */
    @GetMapping("/selectInfo")
    public Page<ContractManagementInfo> selectInfo(ContractManagementInfo contractManagementInfo) {
        return contractManagementInfoService.selectInfo(contractManagementInfo);
    }

    /**
     * 更改状态
     *
     * @param contractManagementInfo
     * @return
     */
    @PostMapping("/editStatus")
    public String editStatus(@RequestBody ContractManagementInfo contractManagementInfo) {
        return contractManagementInfoService.editStatus(contractManagementInfo.getId(),contractManagementInfo.getEndFlag());
    }

    /**
     * 删除
     *
     * @param example
     * @return
     */
    @PostMapping("/deleteInfo")
    public void deleteInfo(@RequestBody  ContractManagementInfo example) {
        contractManagementInfoService.deleteInfo(example.getId());
    }


    /**
     * 导出
     *
     * @return
     * @throws Exception
     */
    @GetMapping("export")
    public void export(ContractManagementInfo example, HttpServletResponse response) throws Exception {
        contractManagementInfoService.export(example,response);
    }
    /**
     * 导出代收合同
     *
     * @return
     * @throws Exception
     */
    @GetMapping("/exportCollection")
    public void exportCollection(ContractManagementInfo example, HttpServletResponse response) throws Exception {
        contractManagementInfoService.exportCollection(example,response);
    }
    /**
     * 导出代储合同
     *
     * @return
     * @throws Exception
     */
    @GetMapping("/exportStorageFee")
    public void exportStorageFee(ContractManagementInfo example, HttpServletResponse response) throws Exception {
        contractManagementInfoService.exportStorageFee(example,response);
    }

    }

