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

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.couponpackagecode.vo.CouponPackageCodePageReqVO;
import com.yc.ship.module.marketing.dal.dataobject.couponpackagecode.CouponPackageCodeDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 优惠券-券包领取码 Mapper
 *
 * @author lfy
 */
@Mapper
public interface CouponPackageCodeMapper extends BaseMapperX<CouponPackageCodeDO> {

    default PageResult<CouponPackageCodeDO> selectPage(CouponPackageCodePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CouponPackageCodeDO>()
                .eqIfPresent(CouponPackageCodeDO::getPackageId, reqVO.getPackageId())
                .eqIfPresent(CouponPackageCodeDO::getCouponId, reqVO.getCouponId())
                .eqIfPresent(CouponPackageCodeDO::getQrCode, reqVO.getQrCode())
                .betweenIfPresent(CouponPackageCodeDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CouponPackageCodeDO::getId));
    }
    default List<CouponPackageCodeDO> selectListByPackageId(Long packageId) {
        return selectList(new LambdaQueryWrapperX<CouponPackageCodeDO>()
                .eq(CouponPackageCodeDO::getPackageId, packageId));
    }
}