package com.yc.ship.module.product.dal.mysql.productSaleRule;

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.product.controller.admin.productSpu.saleRuleVO.ProductSaleRulePageReqVO;
import com.yc.ship.module.product.dal.dataobject.productSaleRule.ProductSaleRuleDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 产品销售规则 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface ProductSaleRuleMapper extends BaseMapperX<ProductSaleRuleDO> {

    default PageResult<ProductSaleRuleDO> selectPage(ProductSaleRulePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProductSaleRuleDO>()
                .eqIfPresent(ProductSaleRuleDO::getIsLimitType, reqVO.getIdLimitType())
                .betweenIfPresent(ProductSaleRuleDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ProductSaleRuleDO::getPrebuyLimitDay, reqVO.getPrebuyLimitDay())
                .eqIfPresent(ProductSaleRuleDO::getOneLimitNum, reqVO.getOneLimitNum())
                .eqIfPresent(ProductSaleRuleDO::getMinNum, reqVO.getMinNum())
                .eqIfPresent(ProductSaleRuleDO::getMaxNum, reqVO.getMaxNum())
                .eqIfPresent(ProductSaleRuleDO::getLimitCertificate, reqVO.getIdLimitCertificate())
                .eqIfPresent(ProductSaleRuleDO::getNeedVisitorPhone, reqVO.getNeedVisitorPhone())
                .eqIfPresent(ProductSaleRuleDO::getNeedContact, reqVO.getNeedContact())
                .eqIfPresent(ProductSaleRuleDO::getAllowArea, reqVO.getIdArea())
                .eqIfPresent(ProductSaleRuleDO::getLimitArea, reqVO.getIdLimitArea())
                .eqIfPresent(ProductSaleRuleDO::getLimitAge, reqVO.getIdAgeLimit())
                .eqIfPresent(ProductSaleRuleDO::getBirthdayVerifyType, reqVO.getBirthdayVerifyType())
                .eqIfPresent(ProductSaleRuleDO::getNeedActivate, reqVO.getNeedActivate())
                .eqIfPresent(ProductSaleRuleDO::getActivateType, reqVO.getActivateType())
                .eqIfPresent(ProductSaleRuleDO::getActivateDayNum, reqVO.getActivateDayNum())
                .orderByDesc(ProductSaleRuleDO::getId));
    }

}