package com.jeeplus.finance.contractRegistration.controller;

import com.jeeplus.common.utils.ResponseUtil;
import com.jeeplus.finance.contractRegistration.domain.ContractFilePaper;
import com.jeeplus.finance.contractRegistration.service.ContractFilePaperService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * @author: 王强
 * @create: 2022-11-29 14:22
 **/
@RestController
@Api(tags ="财务合同登记纸质归档管理")
@RequestMapping(value = "/contract/contractPaperFile")
public class ContractFilePaperController {

    @Autowired
    private ContractFilePaperService service;

    /**
     * 合同登记纸质归档新增/修改
     */
    @ApiOperation(value = "合同登记纸质归档新增/修改")
    @PostMapping(value = "save")
    public ResponseEntity<String> save(@RequestBody ContractFilePaper contractFilePaper) throws Exception{
        String id = service.saveInfo(contractFilePaper);
        return ResponseUtil.newInstance().add("businessTable", "cw_work_contract_file_paper").add("businessId", id).ok ("操作成功");
    }

    /**
     * 根据id修改状态status
     */
    @ApiOperation(value = "根据id修改状态status")
    @PostMapping(value = "updateStatusById")
    public void updateStatusById(@RequestBody ContractFilePaper filePaper) {
        service.updateStatusById(filePaper);
    }

    /**
     * 根据contractInfoId查询
     */
    @ApiOperation(value = "根据contractInfoId查询")
    @GetMapping(value = "findByContractInfoId")
    public ContractFilePaper findByContractInfoId(@RequestParam String id) {
        return service.findByContractInfoId(id);
    }


}
