package cn.ey.biz.module.system.controller.admin.contract.v2;

import cn.ey.biz.common.pojo.R;
import cn.ey.biz.module.system.controller.admin.contract.v2.vo.ContractArchivedVO;
import cn.ey.biz.module.system.service.contract.ContractArchivedService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "合同管理 - 合同归档信息")
@RestController
@RequestMapping("/system/contract/archived")
@Validated
public class ContractArchivedController {

    @Resource
    private ContractArchivedService contractArchivedService;

    @PostMapping("")
    @ApiOperation("添加修改合同归档信息")
    @PreAuthorize("@ss.hasPermission('system:contract:modify')")
    public R<?> saveContractArchivedField(@RequestBody ContractArchivedVO info) {
        contractArchivedService.saveContractArchived(info);
        return R.success(null);
    }

    @GetMapping("")
    @ApiOperation("获取合同归档信息")
    @PreAuthorize("@ss.hasPermission('system:contract:get')")
    public R<?> saveContractArchivedField(@RequestParam("sl") String sl,
                                          @RequestParam("mr") String mr,
                                          @RequestParam("geo") String geo,
                                          @RequestParam("type") String type) {
        return R.success(contractArchivedService.getContractArchived(sl, mr, geo, type));
    }

}
