package com.jeeplus.test.workContract.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jeeplus.common.utils.ResponseUtil;
import com.jeeplus.core.query.QueryWrapperGenerator;
import com.jeeplus.test.workContract.domain.WorkContractFile;
import com.jeeplus.test.workContract.domain.WorkContractInfo;
import com.jeeplus.test.workContract.service.WorkContractFileService;
import com.jeeplus.test.workContract.service.WorkContractService;
import com.jeeplus.test.workContract.service.dto.WorkContractFileDto;
import com.jeeplus.test.workContract.service.dto.WorkContractInfoDto;
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 = "/workContract/workContractFile")
public class WorkContractFileController {

    @Resource
    private WorkContractFileService workContractFileService;

    /**
     * 合同登记新增/修改
     */
    @ApiOperation(value = "合同登记归档新增/修改")
    @PostMapping(value = "save")
    public ResponseEntity<String> save(@RequestBody WorkContractFileDto workContractFileDto) throws Exception{
        String id = workContractFileService.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 WorkContractFileDto workContractFileDto) {
        workContractFileService.updateStatusById(workContractFileDto);
    }

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

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