package com.jy.business.contract.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jy.business.contract.model.dto.ContractInfoDto;
import com.jy.business.contract.model.dto.ContractInfoSelectDto;
import com.jy.business.contract.model.vo.ContractInfoVo;
import com.jy.business.contract.service.ContractInfoService;
import com.jy.framework.model.base.BaseSelectDto;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
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 2025-01-07
 */
@RestController
@RequestMapping("/contractInfo")
public class ContractInfoController {

    @Resource
    private ContractInfoService contractInfoService;

    /**
     * 合同分页
     */
    @GetMapping("/getPage")
    public Page<ContractInfoVo> getPage(ContractInfoSelectDto dto) {
        return contractInfoService.getPage(dto);
    }

    /**
     * 合同明细
     */
    @GetMapping("/getDetail")
    public ContractInfoVo getDetail(BaseSelectDto dto) {
        return contractInfoService.getDetail(dto.getId());
    }

    /**
     * 根据资金流水id合同明细
     */
    @GetMapping("/getDetailByCapitalTransactionsId")
    public ContractInfoVo getDetailByCapitalTransactionsId(BaseSelectDto dto) {
        return contractInfoService.getDetailByCapitalTransactionsId(dto.getId());
    }

    /**
     * 合同新增
     */
    @PostMapping("/add")
    public void add(@RequestBody ContractInfoDto dto) {
        contractInfoService.add(dto);
    }

    /**
     * 合同编辑
     */
    @PostMapping("/edit")
    public void edit(@RequestBody ContractInfoDto dto) {
        contractInfoService.edit(dto);
    }

    /**
     * 合同删除
     */
    @PostMapping("/delete")
    public void delete(@RequestBody BaseSelectDto dto) {
        contractInfoService.delete(dto.getIdList());
    }

}
