package com.yc.ship.module.resource.dal.mysql.baseprice;

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.resource.controller.admin.baseprice.vo.ProductBasePricePageReqVO;
import com.yc.ship.module.resource.controller.admin.baseprice.vo.ProductBasePriceRespVO;
import com.yc.ship.module.resource.dal.dataobject.baseprice.ProductBasePriceDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;


/**
 * 基础产品价格 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface ProductBasePriceMapper extends BaseMapperX<ProductBasePriceDO> {

    default PageResult<ProductBasePriceDO> selectPage(ProductBasePricePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ProductBasePriceDO>()
                .eqIfPresent(ProductBasePriceDO::getProductBaseId, reqVO.getProductBaseId())
                .eqIfPresent(ProductBasePriceDO::getProjectId, reqVO.getProjectId())
                .eqIfPresent(ProductBasePriceDO::getSpecificationId, reqVO.getSpecificationId())
                .eqIfPresent(ProductBasePriceDO::getCostPrice, reqVO.getCostPrice())
                .eqIfPresent(ProductBasePriceDO::getSalePrice, reqVO.getSalePrice())
                .eqIfPresent(ProductBasePriceDO::getSpecType, reqVO.getSpecType())
                .betweenIfPresent(ProductBasePriceDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ProductBasePriceDO::getId));
    }

    List<ProductBasePriceRespVO> selectByBaseId(@Param("baseId") Long baseId);

}