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

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.skuVO.ProductSkuPageReqVO;
import com.yc.ship.module.product.dal.dataobject.productSku.ProductSkuDO;
import org.apache.ibatis.annotations.Mapper;

/**
 * 产品sku Mapper
 *
 * @author 管理员
 */
@Mapper
public interface ProductSkuMapper extends BaseMapperX<ProductSkuDO> {

    default PageResult<ProductSkuDO> selectPage(ProductSkuPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProductSkuDO>()
                .eqIfPresent(ProductSkuDO::getProductId, reqVO.getProductId())
                .eqIfPresent(ProductSkuDO::getCostPrice, reqVO.getCostPrice())
                .eqIfPresent(ProductSkuDO::getSalePrice, reqVO.getSalePrice())
                .eqIfPresent(ProductSkuDO::getSpecType, reqVO.getSpecType())
                .eqIfPresent(ProductSkuDO::getStock, reqVO.getStock())
                .betweenIfPresent(ProductSkuDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProductSkuDO::getId));
    }

}