package cn.iocoder.hake.module.agent.dal.mysql.agent;

import cn.iocoder.hake.framework.common.pojo.PageResult;
import cn.iocoder.hake.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.hake.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.hake.module.agent.dal.dataobject.agent.AgentDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.hake.module.agent.controller.admin.agent.vo.*;

/**
 * 代理商管理 Mapper
 *
 * @author hake
 */
@Mapper
public interface AgentMapper extends BaseMapperX<AgentDO> {

    default PageResult<AgentDO> selectPage(AgentPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AgentDO>()
                .likeIfPresent(AgentDO::getAgentName, reqVO.getAgentName())
                .eqIfPresent(AgentDO::getAgentCode, reqVO.getAgentCode())
                .likeIfPresent(AgentDO::getAgentNickname, reqVO.getAgentNickname())
                .likeIfPresent(AgentDO::getAgentShortNickname, reqVO.getAgentShortNickname())
                .eqIfPresent(AgentDO::getStatus, reqVO.getStatus())
                .eqIfPresent(AgentDO::getChildAgentFlag, reqVO.getChildAgentFlag())
                .eqIfPresent(AgentDO::getChildMchFlag, reqVO.getChildMchFlag())
                .eqIfPresent(AgentDO::getInformFlag, reqVO.getInformFlag())
                .eqIfPresent(AgentDO::getAgentType, reqVO.getAgentType())
                .eqIfPresent(AgentDO::getAgentLevel, reqVO.getAgentLevel())
                .eqIfPresent(AgentDO::getParentAgentId, reqVO.getParentAgentId())
                .eqIfPresent(AgentDO::getContactPerson, reqVO.getContactPerson())
                .eqIfPresent(AgentDO::getContactPhone, reqVO.getContactPhone())
                .eqIfPresent(AgentDO::getContactEmail, reqVO.getContactEmail())
                .eqIfPresent(AgentDO::getCardFrontPhoto, reqVO.getCardFrontPhoto())
                .eqIfPresent(AgentDO::getCardReversePhoto, reqVO.getCardReversePhoto())
                .eqIfPresent(AgentDO::getCommitmentPhoto, reqVO.getCommitmentPhoto())
                .eqIfPresent(AgentDO::getBusinessLicensePhoto, reqVO.getBusinessLicensePhoto())
                .eqIfPresent(AgentDO::getBankAccountPermit, reqVO.getBankAccountPermit())
                .eqIfPresent(AgentDO::getCooperationStatus, reqVO.getCooperationStatus())
                .eqIfPresent(AgentDO::getReceiveAccountType, reqVO.getReceiveAccountType())
                .likeIfPresent(AgentDO::getAccountName, reqVO.getAccountName())
                .eqIfPresent(AgentDO::getAlipayAccount, reqVO.getAlipayAccount())
                .likeIfPresent(AgentDO::getBankName, reqVO.getBankName())
                .eqIfPresent(AgentDO::getBankAccount, reqVO.getBankAccount())
                .eqIfPresent(AgentDO::getBankBranch, reqVO.getBankBranch())
                .betweenIfPresent(AgentDO::getSignDate, reqVO.getSignDate())
                .betweenIfPresent(AgentDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AgentDO::getId));
    }

}