package cn.lihongjie.coal.warehouse.repository;

import cn.lihongjie.coal.base.dao.BaseRepository;
import cn.lihongjie.coal.warehouse.entity.WarehouseEntity;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface WarehouseRepository extends BaseRepository<WarehouseEntity> {
    @Query("select exists (select 1 from WarehouseGoodsEntity e where e.defaultWarehouse.id in :ids union all select 1 from WarehouseReceiptDetailEntity d where d.warehouse.id in :ids or d.warehouse2.id in :ids)     ")
    boolean isLinked(@Param("ids") List<String> ids);

}
