package com.fjhx.controller.contract;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fjhx.base.Condition;
import com.fjhx.entity.contract.Contract;
import com.fjhx.params.contract.ContractVo;
import com.fjhx.service.contract.ContractService;
import org.springblade.core.tool.api.R;
import org.springframework.beans.factory.annotation.Autowired;
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 ${author}
 * @since 2022-10-25
 */
@RestController
@RequestMapping("/contract")
public class ContractController {

    @Autowired
    private ContractService contractService;

    @PostMapping("/page")
    public R page(@RequestBody Condition condition) {
        Page<Contract> result = contractService.getPage(condition);
        return R.success(result);
    }

    @PostMapping("/add")
    public R add(@RequestBody ContractVo contractVo) {
        contractService.add(contractVo);
        return R.success();
    }

    @PostMapping("/edit")
    public R edit(@RequestBody ContractVo contractVo) {
        contractService.edit(contractVo);
        return R.success();
    }

    @PostMapping("/delete")
    public R delete(@RequestBody ContractVo contractVo) {
        contractService.delete(contractVo);
        return R.success();
    }

    @PostMapping("/details")
    public R details(@RequestBody Contract contract) {
        ContractVo contractVo = contractService.details(contract.getId());
        return R.success(contractVo);
    }

}

