package cn.lihongjie.coal.coalInfo.repository;

import cn.lihongjie.coal.base.dao.BaseRepository;
import cn.lihongjie.coal.coalInfo.entity.CoalInfoEntity;

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 CoalInfoRepository extends BaseRepository<CoalInfoEntity> {

    @Query("""
            select exists(
                select 1 from CoalAnalysisEntity e where e.coalInfo.id in :ids 
                union all 
                select 1 from PurchaseOrderEntity p where p.coalInfo.id in :ids 
                union all 
                select 1 from InventoryCheckDetailEntity d where d.coalInfo.id in :ids)""")
    boolean isLinked(@Param("ids") List<String> ids);
}
