package com.ruoyi.web.work.api;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.work.api.config.BaseController;
import com.ruoyi.web.work.domain.dto.ContractDto;
import com.ruoyi.web.work.service.IContractService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.rmi.ServerException;

/**
 * 合同模板
 *
 * @author lsw
 * @date 2024-04-22
 */
@RestController
@RequestMapping("/app/contract")
public class Api_ContractController extends BaseController {
    @Autowired
    private IContractService contractService;

    @GetMapping(value = "/detail")
    public AjaxResult detail() {
        return AjaxResult.success(contractService.selectContract());
    }

    @PostMapping(value = "/add")
    public AjaxResult add(@Validated @RequestBody ContractDto dto) throws ServerException {
        return contractService.add(dto);
    }

    @GetMapping("/look")
    public void look(HttpServletResponse response) throws IOException {
        contractService.look(response, getUser().getId());
    }
}
