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

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.distributorDiscount.vo.DistributorDiscountPageReqVO;
import com.yc.ship.module.product.dal.dataobject.distributorDiscount.DistributorDiscountDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 分销商专属折扣 Mapper
 *
 * @author lsq
 */
@Mapper
public interface DistributorDiscountMapper extends BaseMapperX<DistributorDiscountDO> {

    default PageResult<DistributorDiscountDO> selectPage(DistributorDiscountPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DistributorDiscountDO>()
                .likeIfPresent(DistributorDiscountDO::getDistributorId, reqVO.getDistributorId())
                .likeIfPresent(DistributorDiscountDO::getDistributorName, reqVO.getDistributorName())
                .eqIfPresent(DistributorDiscountDO::getAreaId, reqVO.getAreaId())
                .eqIfPresent(DistributorDiscountDO::getShipId, reqVO.getShipId())
                .betweenIfPresent(DistributorDiscountDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DistributorDiscountDO::getId));
    }

}