package com.jeeplus.business.workContractInfo.controller;


import com.jeeplus.business.workContractInfo.domain.JyWorkContractFile;
import com.jeeplus.business.workContractInfo.service.JyWorkContractFileService;
import com.jeeplus.business.workContractInfo.service.dto.JyWorkContractFileDto;
import com.jeeplus.common.utils.ResponseUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@Api(tags ="嘉溢合同登记")
@RestController
@RequestMapping(value = "/jy/workContract/workContractFile")
public class JyWorkContractFileController {

    @Resource
    private JyWorkContractFileService jyWorkContractFileService;

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

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

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

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