package co.yixiang.yshop.module.order.dal.mysql.rechargepackage;

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

/**
 * 充值套餐配置 Mapper
 *
 * @author admin
 */
@Mapper
public interface RechargePackageMapper extends BaseMapperX<RechargePackageDO> {

    default PageResult<RechargePackageDO> selectPage(RechargePackagePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<RechargePackageDO>()
                .eqIfPresent(RechargePackageDO::getRechargeAmount, reqVO.getRechargeAmount())
                .eqIfPresent(RechargePackageDO::getGiftAmount, reqVO.getGiftAmount())
                .eqIfPresent(RechargePackageDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(RechargePackageDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(RechargePackageDO::getId));
    }

    default List<RechargePackageDO> selectList(RechargePackageExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<RechargePackageDO>()
                .eqIfPresent(RechargePackageDO::getRechargeAmount, reqVO.getRechargeAmount())
                .eqIfPresent(RechargePackageDO::getGiftAmount, reqVO.getGiftAmount())
                .eqIfPresent(RechargePackageDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(RechargePackageDO::getCreateTime, reqVO.getCreateTime())
                .orderByAsc(RechargePackageDO::getId));
    }

}
