package com.goldenwater.web.controller.pms;

import com.goldenwater.slgc.entity.pms.PmsContractBill;
import com.goldenwater.slgc.service.pms.IPmsContractBillService;
import com.goldenwater.common.core.controller.BaseController;
import com.goldenwater.common.core.domain.AjaxResult;
import com.goldenwater.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.goldenwater.common.annotation.Log;
import com.goldenwater.common.enums.BusinessType;
import org.springframework.validation.annotation.Validated;

import java.util.List;

@RestController
@Validated
@RequestMapping("/pms/contract/bill")
public class PmsContractBillController extends BaseController {
    @Autowired
    private IPmsContractBillService pmsContractBillService;

    /**
     * 查询合同开票列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PmsContractBill contractBill) {
        startPage();
        List<PmsContractBill> list = pmsContractBillService.selectList(contractBill);
        return getDataTable(list);
    }

    /**
     * 获取合同开票详细信息
     */
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        return success(pmsContractBillService.selectById(id));
    }

    /**
     * 新增合同开票
     */
    @Log(title = "合同开票管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmsContractBill contractBill) {
        return toAjax(pmsContractBillService.insert(contractBill));
    }

    /**
     * 修改合同开票
     */
    @Log(title = "合同开票管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmsContractBill contractBill) {
        return toAjax(pmsContractBillService.update(contractBill));
    }

    /**
     * 删除合同开票
     */
    @Log(title = "合同开票管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(pmsContractBillService.deleteByIds(ids));
    }
}
