package com.yc.ship.module.otc.dal.mysql.otclevel;

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.otc.controller.admin.otclevel.vo.OtcLevelPageReqVO;
import com.yc.ship.module.otc.dal.dataobject.otclevel.OtcLevelDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 旅行社等级管理 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface OtcLevelMapper extends BaseMapperX<OtcLevelDO> {

    default PageResult<OtcLevelDO> selectPage(OtcLevelPageReqVO reqVO) {
        if(reqVO.getHotelRoomType()!=null) {
            return selectPage(reqVO, new LambdaQueryWrapperX<OtcLevelDO>()
                    .likeIfPresent(OtcLevelDO::getLevelName, reqVO.getLevelName())
                    .likeIfPresent(OtcLevelDO::getHotelRoomType, reqVO.getHotelRoomType() + "")
                    .betweenIfPresent(OtcLevelDO::getCreateTime, reqVO.getCreateTime())
                    .orderByDesc(OtcLevelDO::getId));
        }else {
            return selectPage(reqVO, new LambdaQueryWrapperX<OtcLevelDO>()
                    .likeIfPresent(OtcLevelDO::getLevelName, reqVO.getLevelName())
                    .betweenIfPresent(OtcLevelDO::getCreateTime, reqVO.getCreateTime())
                    .orderByDesc(OtcLevelDO::getId));
        }
    }

}