package com.goldenwater.web.controller.pms;

import com.goldenwater.slgc.entity.pms.PmsContractRef;
import com.goldenwater.slgc.service.pms.IPmsContractRefService;
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/ref")
public class PmsContractRefController extends BaseController {
    @Autowired
    private IPmsContractRefService pmsContractRefService;

    /**
     * 查询合同参考文件列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PmsContractRef contractRef) {
        startPage();
        List<PmsContractRef> list = pmsContractRefService.selectList(contractRef);
        return getDataTable(list);
    }

    /**
     * 获取合同参考文件详细信息
     */
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        return success(pmsContractRefService.selectById(id));
    }

    /**
     * 新增合同参考文件
     */
    @Log(title = "合同参考文件管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmsContractRef contractRef) {
        return toAjax(pmsContractRefService.insert(contractRef));
    }

    /**
     * 修改合同参考文件
     */
    @Log(title = "合同参考文件管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmsContractRef contractRef) {
        return toAjax(pmsContractRefService.update(contractRef));
    }

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