package com.goldenwater.web.controller.pms;

import com.goldenwater.slgc.entity.pms.PmsContractPayment;
import com.goldenwater.slgc.service.pms.IPmsContractPaymentService;
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/payment")
public class PmsContractPaymentController extends BaseController {
    @Autowired
    private IPmsContractPaymentService pmsContractPaymentService;

    /**
     * 查询合同付款列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PmsContractPayment contractPayment) {
        startPage();
        List<PmsContractPayment> list = pmsContractPaymentService.selectList(contractPayment);
        return getDataTable(list);
    }

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

    /**
     * 新增合同付款
     */
    @Log(title = "合同付款", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmsContractPayment contractPayment) {
        return toAjax(pmsContractPaymentService.insert(contractPayment));
    }

    /**
     * 修改合同付款
     */
    @Log(title = "合同付款", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmsContractPayment contractPayment) {
        return toAjax(pmsContractPaymentService.update(contractPayment));
    }

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