package co.yixiang.yshop.module.member.dal.mysql.userlevelconfig;

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.member.dal.dataobject.userlevelconfig.UserLevelConfigDO;
import org.apache.ibatis.annotations.Mapper;
import co.yixiang.yshop.module.member.controller.admin.userlevelconfig.vo.*;

/**
 * 会员等级配置 Mapper
 *
 * @author admin
 */
@Mapper
public interface UserLevelConfigMapper extends BaseMapperX<UserLevelConfigDO> {

    default PageResult<UserLevelConfigDO> selectPage(UserLevelConfigPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<UserLevelConfigDO>()
                .likeIfPresent(UserLevelConfigDO::getLevelName, reqVO.getLevelName())
                .eqIfPresent(UserLevelConfigDO::getLevel, reqVO.getLevel())
                .eqIfPresent(UserLevelConfigDO::getGrowthValue, reqVO.getGrowthValue())
                .eqIfPresent(UserLevelConfigDO::getIconUrl, reqVO.getIconUrl())
                .eqIfPresent(UserLevelConfigDO::getBackgroundUrl, reqVO.getBackgroundUrl())
                .eqIfPresent(UserLevelConfigDO::getStatus, reqVO.getStatus())
                .eqIfPresent(UserLevelConfigDO::getRemarks, reqVO.getRemarks())
                .betweenIfPresent(UserLevelConfigDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(UserLevelConfigDO::getLevel));
    }

    default List<UserLevelConfigDO> selectList(UserLevelConfigExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<UserLevelConfigDO>()
                .likeIfPresent(UserLevelConfigDO::getLevelName, reqVO.getLevelName())
                .eqIfPresent(UserLevelConfigDO::getLevel, reqVO.getLevel())
                .eqIfPresent(UserLevelConfigDO::getGrowthValue, reqVO.getGrowthValue())
                .eqIfPresent(UserLevelConfigDO::getIconUrl, reqVO.getIconUrl())
                .eqIfPresent(UserLevelConfigDO::getBackgroundUrl, reqVO.getBackgroundUrl())
                .eqIfPresent(UserLevelConfigDO::getStatus, reqVO.getStatus())
                .eqIfPresent(UserLevelConfigDO::getRemarks, reqVO.getRemarks())
                .betweenIfPresent(UserLevelConfigDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(UserLevelConfigDO::getLevel));
    }

}
