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

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.customercontract.vo.CustomerContractPageReqVO;
import cn.iocoder.yudao.module.contract.controller.admin.customercontract.vo.CustomerContractRespVO;
import cn.iocoder.yudao.module.contract.dal.dataobject.customercontract.CustomerContractDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 销售合同信息 Mapper
 *
 * @author dp
 */
@Mapper
public interface CustomerContractMapper extends BaseMapperX<CustomerContractDO> {

    default PageResult<CustomerContractDO> selectPage(CustomerContractPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CustomerContractDO>()
                .eqIfPresent(CustomerContractDO::getCustomerContractCode, reqVO.getCustomerContractCode())
                .likeIfPresent(CustomerContractDO::getCustomerContractName, reqVO.getCustomerContractName())
                .eqIfPresent(CustomerContractDO::getIsFrameContract, reqVO.getIsFrameContract())
                .eqIfPresent(CustomerContractDO::getCustomerId, reqVO.getCustomerId())
                .betweenIfPresent(CustomerContractDO::getStartDate, reqVO.getStartDate())
                .betweenIfPresent(CustomerContractDO::getEndDate, reqVO.getEndDate())
                .eqIfPresent(CustomerContractDO::getDeptId, reqVO.getDeptId())
                .eqIfPresent(CustomerContractDO::getContractStatus, reqVO.getContractStatus())
                .eqIfPresent(CustomerContractDO::getClosed, reqVO.getClosed())
                .eqIfPresent(CustomerContractDO::getTerminate, reqVO.getTerminate())
                .orderByDesc(CustomerContractDO::getId));
    }


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

    /**
     * 获取销售合同信息分页列表
     *
     * @param pageReqVO 分页参数
     * @return 销售合同信息分页列表
     */
    List<CustomerContractRespVO> getPageList(@Param("page") CustomerContractPageReqVO pageReqVO);

    /**
     * 物理删除销售合同信息
     *
     * @param id 编号
     * @return 是否删除成功
     */
    Integer deleteCustomerContractOriginal(Long id);

}