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

import cn.iocoder.yudao.framework.common.pojo.PageParam;
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.dal.dataobject.customercontract.CustomerContractHistoryDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 销售合同历史信息 Mapper
 *
 * @author dp
 */
@Mapper
public interface CustomerContractHistoryMapper extends BaseMapperX<CustomerContractHistoryDO> {

    default PageResult<CustomerContractHistoryDO> selectPage(PageParam reqVO, String customerContractCode) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CustomerContractHistoryDO>()
            .eq(CustomerContractHistoryDO::getCustomerContractCode, customerContractCode)
            .orderByDesc(CustomerContractHistoryDO::getId));
    }

    default int deleteByCode(String code) {
        return delete(CustomerContractHistoryDO::getCustomerContractCode, code);
    }

    long getPageCount(@Param("page") PageParam pageReqVO, @Param("code") String code);

    List<CustomerContractHistoryDO> getPageList(@Param("page") PageParam pageReqVO, @Param("code") String code);

}