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

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.noticeRuleVO.ProductNoticeRulePageReqVO;
import com.yc.ship.module.product.dal.dataobject.productNoticeRule.ProductNoticeRuleDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 产品通知规则 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface ProductNoticeRuleMapper extends BaseMapperX<ProductNoticeRuleDO> {

    default PageResult<ProductNoticeRuleDO> selectPage(ProductNoticeRulePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProductNoticeRuleDO>()
                .eqIfPresent(ProductNoticeRuleDO::getIsBookNotice, reqVO.getIsBookNotice())
                .eqIfPresent(ProductNoticeRuleDO::getBookNoticeContent, reqVO.getBookNoticeContent())
                .eqIfPresent(ProductNoticeRuleDO::getIsRefundNotice, reqVO.getIsRefundNotice())
                .eqIfPresent(ProductNoticeRuleDO::getRefundNoticeContent, reqVO.getRefundNoticeContent())
                .eqIfPresent(ProductNoticeRuleDO::getExpireNoticeDay, reqVO.getExpireNoticeDay())
                .eqIfPresent(ProductNoticeRuleDO::getExpireNoticeContent, reqVO.getExpireNoticeContent())
                .betweenIfPresent(ProductNoticeRuleDO::getCreateTime, reqVO.getCreateTime())
                .eqIfPresent(ProductNoticeRuleDO::getBookNoticeType, reqVO.getBookNoticeType())
                .eqIfPresent(ProductNoticeRuleDO::getRefundNoticeType, reqVO.getRefundNoticeType())
                .eqIfPresent(ProductNoticeRuleDO::getExpireNoticeType, reqVO.getExpireNoticeType())
                .orderByDesc(ProductNoticeRuleDO::getId));
    }

}