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


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

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 合同费用 前端控制器
 * </p>
 *
 * @author Gdc
 * @since 2022-03-01
 */
@RestController
@RequestMapping("/contractCostInfo")
public class ContractCostInfoController {
    @Autowired
    private IContractCostInfoService contractCostInfoService;

    /**
     * 新增合同费用信息
     */
    @PostMapping("/api/addInfo")
    public String addInfo(@RequestBody @Valid ContractCostInfo contractCostInfo) {
        return contractCostInfoService.addInfo(contractCostInfo);
    }

    /**
     * 编辑
     */
    @PostMapping("/editInfo")
    public String editInfo(@RequestBody ContractCostInfo contractCostInfo) {
        return contractCostInfoService.editInfo(contractCostInfo);
    }

    /**
     * 查看合同费用信息
     */
    @GetMapping("/getInfo")
    public ContractCostInfo getInfo(@RequestParam String id) {
        return contractCostInfoService.getInfo(id);
    }

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

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

    /**
     * 付款
     */
    @PostMapping("/payment")
    public String payment(@RequestBody ContractCostInfo contractCostInfo) {
        return contractCostInfoService.payment(contractCostInfo);
    }

}

