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

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.baseRuleVO.ProductBasicRulePageReqVO;
import com.yc.ship.module.product.dal.dataobject.productBasicRule.ProductBasicRuleDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 产品基础规则 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface ProductBasicRuleMapper extends BaseMapperX<ProductBasicRuleDO> {

    default PageResult<ProductBasicRuleDO> selectPage(ProductBasicRulePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProductBasicRuleDO>()
                .betweenIfPresent(ProductBasicRuleDO::getCreateTime, reqVO.getCreateTime())
                .betweenIfPresent(ProductBasicRuleDO::getNeedPlayDate, reqVO.getNeedPlayDate())
                .eqIfPresent(ProductBasicRuleDO::getValidityType, reqVO.getValidityType())
                .eqIfPresent(ProductBasicRuleDO::getValidityNum, reqVO.getValidityNum())
                .betweenIfPresent(ProductBasicRuleDO::getValidityDate, reqVO.getValidityDate())
                .betweenIfPresent(ProductBasicRuleDO::getSaleStartDate, reqVO.getSaleStartDate())
                .betweenIfPresent(ProductBasicRuleDO::getSaleEndDate, reqVO.getSaleEndDate())
                .betweenIfPresent(ProductBasicRuleDO::getCheckStartDate, reqVO.getCheckStartDate())
                .betweenIfPresent(ProductBasicRuleDO::getCheckEndDate, reqVO.getCheckEndDate())
                .betweenIfPresent(ProductBasicRuleDO::getSaleStartTime, reqVO.getSaleStartTime())
                .betweenIfPresent(ProductBasicRuleDO::getSaleEndTime, reqVO.getSaleEndTime())
                .betweenIfPresent(ProductBasicRuleDO::getCheckStartTime, reqVO.getCheckStartTime())
                .betweenIfPresent(ProductBasicRuleDO::getCheckEndTime, reqVO.getCheckEndTime())
                .eqIfPresent(ProductBasicRuleDO::getStock, reqVO.getStock())
                .orderByDesc(ProductBasicRuleDO::getId));
    }

}