package co.yixiang.yshop.module.distributor.dal.mysql.distributorlevel;

import java.util.*;

import co.yixiang.yshop.framework.common.pojo.PageResult;
import co.yixiang.yshop.framework.mybatis.core.query.LambdaQueryWrapperX;
import co.yixiang.yshop.framework.mybatis.core.mapper.BaseMapperX;
import co.yixiang.yshop.module.distributor.dal.dataobject.distributorlevel.DistributorLevelDO;
import org.apache.ibatis.annotations.Mapper;
import co.yixiang.yshop.module.distributor.controller.admin.distributorlevel.vo.*;

/**
 * 分销商等级 Mapper
 *
 * @author admin
 */
@Mapper
public interface DistributorLevelMapper extends BaseMapperX<DistributorLevelDO> {

    default PageResult<DistributorLevelDO> selectPage(DistributorLevelPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DistributorLevelDO>()
                .eqIfPresent(DistributorLevelDO::getLevel, reqVO.getLevel())
                .likeIfPresent(DistributorLevelDO::getName, reqVO.getName())
                .eqIfPresent(DistributorLevelDO::getFirstWages, reqVO.getFirstWages())
                .eqIfPresent(DistributorLevelDO::getSecondWages, reqVO.getSecondWages())
                .eqIfPresent(DistributorLevelDO::getUpType, reqVO.getUpType())
                .eqIfPresent(DistributorLevelDO::getUserCount, reqVO.getUserCount())
                .eqIfPresent(DistributorLevelDO::getAmount, reqVO.getAmount())
                .eqIfPresent(DistributorLevelDO::getWages, reqVO.getWages())
                .betweenIfPresent(DistributorLevelDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DistributorLevelDO::getId));
    }

    default List<DistributorLevelDO> selectList(DistributorLevelExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<DistributorLevelDO>()
                .eqIfPresent(DistributorLevelDO::getLevel, reqVO.getLevel())
                .likeIfPresent(DistributorLevelDO::getName, reqVO.getName())
                .eqIfPresent(DistributorLevelDO::getFirstWages, reqVO.getFirstWages())
                .eqIfPresent(DistributorLevelDO::getSecondWages, reqVO.getSecondWages())
                .eqIfPresent(DistributorLevelDO::getUpType, reqVO.getUpType())
                .eqIfPresent(DistributorLevelDO::getUserCount, reqVO.getUserCount())
                .eqIfPresent(DistributorLevelDO::getAmount, reqVO.getAmount())
                .eqIfPresent(DistributorLevelDO::getWages, reqVO.getWages())
                .betweenIfPresent(DistributorLevelDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DistributorLevelDO::getId));
    }

}
