package com.yc.ship.module.marketing.dal.mysql.couponpackage;

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.marketing.controller.admin.couponpackage.vo.CouponPackagePageReqVO;
import com.yc.ship.module.marketing.dal.dataobject.couponpackage.CouponPackageDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 优惠券-券包 Mapper
 *
 * @author lfy
 */
@Mapper
public interface CouponPackageMapper extends BaseMapperX<CouponPackageDO> {

    default PageResult<CouponPackageDO> selectPage(CouponPackagePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CouponPackageDO>()
                .likeIfPresent(CouponPackageDO::getPackageName, reqVO.getPackageName())
                .eqIfPresent(CouponPackageDO::getCouponId, reqVO.getCouponId())
                .eqIfPresent(CouponPackageDO::getCanReceiveNum, reqVO.getCanReceiveNum())
                .eqIfPresent(CouponPackageDO::getCodeNum, reqVO.getCodeNum())
                .betweenIfPresent(CouponPackageDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CouponPackageDO::getId));
    }

}