package com.yc.ship.module.resource.dal.mysql.guide;

import com.yc.ship.framework.common.enums.CommonStatusEnum;
import com.yc.ship.framework.common.pojo.PageResult;
import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yc.ship.module.resource.controller.admin.guide.vo.GuidePageReqVO;
import com.yc.ship.module.resource.controller.admin.guide.vo.GuideSimpleRespVO;
import com.yc.ship.module.resource.dal.dataobject.guide.GuideDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 导游管理 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface GuideMapper extends BaseMapperX<GuideDO> {

    default PageResult<GuideDO> selectPage(GuidePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<GuideDO>()
                .likeIfPresent(GuideDO::getName, reqVO.getName())
                .eqIfPresent(GuideDO::getGuideCode, reqVO.getGuideCode())
                .eqIfPresent(GuideDO::getGuideCardCode, reqVO.getGuideCardCode())
                .eqIfPresent(GuideDO::getId, reqVO.getId())
                .eqIfPresent(GuideDO::getIdCard, reqVO.getIdCard())
                .eqIfPresent(GuideDO::getSex, reqVO.getSex())
                .eqIfPresent(GuideDO::getBirthday, reqVO.getBirthday())
                .eqIfPresent(GuideDO::getPhone, reqVO.getPhone())
                .eqIfPresent(GuideDO::getTechniLevel, reqVO.getTechniLevel())
                .eqIfPresent(GuideDO::getCompanyId, reqVO.getCompanyId())
                .eqIfPresent(GuideDO::getGuideType, reqVO.getGuideType())
                .eqIfPresent(GuideDO::getEduType, reqVO.getEduType())
                .eqIfPresent(GuideDO::getNation, reqVO.getNation())
                .eqIfPresent(GuideDO::getAddress, reqVO.getAddress())
                .eqIfPresent(GuideDO::getEmergentPhone, reqVO.getEmergentPhone())
                .likeIfPresent(GuideDO::getLanguageType, reqVO.getLanguageType())
                .eqIfPresent(GuideDO::getGroupCode, reqVO.getGroupCode())
                .inIfPresent(GuideDO::getGroupCode, reqVO.getGroupList())
                .eqIfPresent(GuideDO::getAuthStatus, reqVO.getAuthStatus())
                .eqIfPresent(GuideDO::getUseStatus, reqVO.getUseStatus())
                .eqIfPresent(GuideDO::getGuideSpeciality, reqVO.getGuideSpeciality())
                .eqIfPresent(GuideDO::getGuideCardImgUrl1, reqVO.getGuideCardImgUrl1())
                .eqIfPresent(GuideDO::getGuideCardImgUrl2, reqVO.getGuideCardImgUrl2())
                .eqIfPresent(GuideDO::getIdCardImgUrl1, reqVO.getIdCardImgUrl1())
                .eqIfPresent(GuideDO::getIdCardImgUrl2, reqVO.getIdCardImgUrl2())
                .likeIfPresent(GuideDO::getBankName, reqVO.getBankName())
                .eqIfPresent(GuideDO::getBankUserCode, reqVO.getBankUserCode())
                .likeIfPresent(GuideDO::getBankUserName, reqVO.getBankUserName())
                .eqIfPresent(GuideDO::getBankUserLink, reqVO.getBankUserLink())
                .betweenIfPresent(GuideDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(GuideDO::getUpdateTime));
    }

    default List<GuideDO> selectList(GuideSimpleRespVO reqVO) {
        return selectList(new LambdaQueryWrapperX<GuideDO>()
            .likeIfPresent(GuideDO::getName, reqVO.getName())
            .eqIfPresent(GuideDO::getUseStatus, reqVO.getUseStatus())
            .eqIfPresent(GuideDO::getId, reqVO.getId())
            .eqIfPresent(GuideDO::getDeleted, CommonStatusEnum.ENABLE.getStatus())
            .eqIfPresent(GuideDO::getTenantId, reqVO.getTenantId()));
    }

}
