package cn.iocoder.yudao.module.contract.dal.mysql.suppliercontract;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.contract.controller.admin.suppliercontract.vo.SupplierContractPageReqVO;
import cn.iocoder.yudao.module.contract.controller.admin.suppliercontract.vo.SupplierContractRespVO;
import cn.iocoder.yudao.module.contract.dal.dataobject.suppliercontract.SupplierContractDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 采购合同信息 Mapper
 *
 * @author dp
 */
@Mapper
public interface SupplierContractMapper extends BaseMapperX<SupplierContractDO> {

    default PageResult<SupplierContractDO> selectPage(SupplierContractPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<SupplierContractDO>()
                .eqIfPresent(SupplierContractDO::getSupplierContractCode, reqVO.getSupplierContractCode())
                .likeIfPresent(SupplierContractDO::getSupplierContractName, reqVO.getSupplierContractName())
                .eqIfPresent(SupplierContractDO::getIsFrameContract, reqVO.getIsFrameContract())
                .likeIfPresent(SupplierContractDO::getSupplierName, reqVO.getSupplierName())
                .betweenIfPresent(SupplierContractDO::getStartDate, reqVO.getStartDate())
                .betweenIfPresent(SupplierContractDO::getEndDate, reqVO.getEndDate())
                .eqIfPresent(SupplierContractDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(SupplierContractDO::getContractStatus, reqVO.getContractStatus())
                .eqIfPresent(SupplierContractDO::getClosed, reqVO.getClosed())
                .eqIfPresent(SupplierContractDO::getTerminate, reqVO.getTerminate())
                .orderByDesc(SupplierContractDO::getId));
    }

    /**
     * 获取采购合同信息总数量
     *
     * @param pageReqVO 分页参数
     * @return 采购合同信息分页总数量
     */
    long getPageCount(@Param("page") SupplierContractPageReqVO pageReqVO);

    /**
     * 获取采购合同信息分页列表
     *
     * @param pageReqVO 分页参数
     * @return 采购合同信息分页列表
     */
    List<SupplierContractRespVO> getPageList(@Param("page") SupplierContractPageReqVO pageReqVO);

    /**
     * 物理删除采购合同信息
     *
     * @param id 编号
     * @return 是否删除成功
     */
    Integer deleteSupplierContractOriginal(Long id);
}