package com.jeeplus.test.cw.contractRegistration.controller;

import com.jeeplus.common.utils.ResponseUtil;
import com.jeeplus.test.cw.contractRegistration.domain.ContractFile;
import com.jeeplus.test.cw.contractRegistration.domain.ContractInfo;
import com.jeeplus.test.cw.contractRegistration.service.ContractFileService;
import com.jeeplus.test.workContract.domain.WorkContractFile;
import com.jeeplus.test.workContract.service.dto.WorkContractFileDto;
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-10 16:13
 **/
@RestController
@Api(tags ="财务合同登记归档管理")
@RequestMapping(value = "/contract/contractFile")
public class ContractFileController {

    @Autowired
    private ContractFileService service;

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

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

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

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