package com.goldenwater.web.controller.pms;

import com.goldenwater.slgc.entity.pms.PmsContractLog;
import com.goldenwater.slgc.service.pms.IPmsContractLogService;
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/log")
public class PmsContractLogController extends BaseController {
    @Autowired
    private IPmsContractLogService pmsContractLogService;

    /**
     * 查询合同变更日志列表
     */
    @GetMapping("/list")
    public TableDataInfo list(PmsContractLog contractLog) {
        startPage();
        List<PmsContractLog> list = pmsContractLogService.selectList(contractLog);
        return getDataTable(list);
    }

    /**
     * 获取合同变更日志详细信息
     */
    @GetMapping("/{id}")
    public AjaxResult getInfo(@PathVariable Long id) {
        return success(pmsContractLogService.selectById(id));
    }

    /**
     * 新增合同变更日志
     */
    @Log(title = "合同日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PmsContractLog contractLog) {
        return toAjax(pmsContractLogService.insert(contractLog));
    }

    /**
     * 修改合同变更日志
     */
    @Log(title = "合同日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PmsContractLog contractLog) {
        return toAjax(pmsContractLogService.update(contractLog));
    }

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