package com.sw.mes.store.mapper;


import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sw.mes.store.entity.WarehouseMaterial;
import com.sw.mes.store.entity.WarehouseQueryParam;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author wupeng
 * @Description 针对表【warehouse_material】的数据库操作Mapper
 * @Date 11:15 2023/7/24
 * @Param
 * @return
 **/
@Repository
public interface WarehouseMaterialMapper extends BaseMapper<WarehouseMaterial> {

    @Select("select * from warehouse_material where material_id = #{materialId} order by id desc limit 1")
    WarehouseMaterial getByMaterialId(@Param("materialId") Long materialId);

    @Select({
            "<script>",
            "select * from warehouse_material where material_id in (",
            "<foreach collection='materialIds' index='index' item='materialId' separator=',' >",
            "#{materialId}",
            "</foreach>",
            ")</script>"
    })
    List<WarehouseMaterial> getByMaterialIds(@Param("materialIds") List<Long> materialIds);

    Page<WarehouseMaterial> listByPage(IPage<WarehouseMaterial> iPage, @Param("param") WarehouseQueryParam param);
}




