package cn.iocoder.yudao.module.supplier.dal.mysql.product;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.supplier.controller.admin.product.vo.CoreProductPageReqVO;
import cn.iocoder.yudao.module.supplier.dal.dataobject.product.CoreProductDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 供应商核心产品 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CoreProductMapper extends BaseMapperX<CoreProductDO> {

    default PageResult<CoreProductDO> selectPage(CoreProductPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CoreProductDO>()
                .eqIfPresent(CoreProductDO::getSupplierId, reqVO.getSupplierId())
                .eqIfPresent(CoreProductDO::getSupplierName, reqVO.getSupplierName())
                .eqIfPresent(CoreProductDO::getProductId, reqVO.getProductId())
                .likeIfPresent(CoreProductDO::getProductName, reqVO.getProductName())
                .eqIfPresent(CoreProductDO::getAdvantage, reqVO.getAdvantage())
                .betweenIfPresent(CoreProductDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CoreProductDO::getId));
    }

    default List<CoreProductDO> selectListBySupplierId(Long supplierId) {
        return selectList(new LambdaQueryWrapperX<CoreProductDO>()
                .eq(CoreProductDO::getSupplierId, supplierId)
                .orderByDesc(CoreProductDO::getId));

    }

}
