package com.fjhx.common.controller.contract;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.common.entity.contract.dto.ContractTemplateDto;
import com.fjhx.common.entity.contract.dto.ContractTemplateSelectDto;
import com.fjhx.common.entity.contract.vo.ContractTemplateVo;
import com.fjhx.common.service.contract.ContractTemplateService;
import com.ruoyi.common.core.domain.BaseSelectDto;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * <p>
 * 合同模板 前端控制器
 * </p>
 *
 * @author
 * @since 2023-04-14
 */
@RestController
@RequestMapping("/contractTemplate")
public class ContractTemplateController {

    @Autowired
    private ContractTemplateService contractTemplateService;

    /**
     * 合同模板分页
     */
    @PostMapping("/page")
    public Page<ContractTemplateVo> page(@Validated @RequestBody ContractTemplateSelectDto dto) {
        return contractTemplateService.getPage(dto);
    }

    /**
     * 合同模板明细
     */
    @PostMapping("/detail")
    public ContractTemplateVo detail(@RequestBody BaseSelectDto dto) {
        return contractTemplateService.detail(dto.getId());
    }

    /**
     * 合同模板新增
     */
    @PostMapping("/add")
    public void add(@RequestBody ContractTemplateDto contractTemplateDto) {
        contractTemplateService.add(contractTemplateDto);
    }

    /**
     * 合同模板编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody ContractTemplateDto contractTemplateDto) {
        contractTemplateService.edit(contractTemplateDto);
    }

    /**
     * 合同模板删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        contractTemplateService.delete(dto.getId());
    }

}
