Browse Source

link param setting

shjung 2 years ago
parent
commit
da30f231e1

+ 1 - 1
src/main/java/com/its/op/dao/repository/its/link/TbLinkParaStupRepository.java

@@ -24,7 +24,7 @@ public interface TbLinkParaStupRepository extends JpaRepository<TbLinkParaStup,
     @Query(value = "SELECT NVL(MAX(PARA_ID), 0) + 1 AS NEWID FROM TB_LINK_PARA_STUP", nativeQuery = true)
     Long getNewNmbr();
 
-    @Query("select count(p.paraId) from TbLinkParaStup p where p.paraId = :paraId")
+    @Query("select count(p.paraId) from TbLink p where p.paraId = :paraId")
     Integer findUsageId(@Param("paraId") Long paraId);
 
     @Transactional

+ 5 - 0
src/main/java/com/its/op/service/its/link/TbLinkParaStupService.java

@@ -119,6 +119,11 @@ public class TbLinkParaStupService {
         if (paramId == 1) {
             throw new NoSuchElementException("첫번째 파라미터 정보는 삭제할 수 없습니다.: " + paramId);
         }
+        UsageCountDto usageCount = findUsageId(paramId);
+        if (usageCount.getCount() > 0) {
+            throw new ConcurrentModificationException("사용중인 파라미터 정보 입니다. 삭제할 수 없습니다: " + paramId);
+        }
+
         TbLinkParaStupDto result = findById(paramId);
 
         this.clctRepo.deleteDataById(paramId);