shjung 2 năm trước cách đây
mục cha
commit
38b7f36b2d

+ 6 - 0
src/main/java/com/its/op/controller/its/facility/TbFcltSubjController.java

@@ -57,4 +57,10 @@ public class TbFcltSubjController {
         return this.service.getNewNmbr();
     }
 
+    @ApiOperation(value = "신규 SUBJ ID 조회", response = NewIdLongDto.class)
+    @GetMapping(value = "/new-id/subj/{fcltType}", produces = {"application/json; charset=utf8"})
+    public NewIdLongDto getNewSubjId(@PathVariable("fcltType") final String fcltType) {
+        return this.service.getNewSubjId(fcltType);
+    }
+
 }

+ 3 - 0
src/main/java/com/its/op/dao/repository/its/facility/TbFcltSubjRepository.java

@@ -21,6 +21,9 @@ public interface TbFcltSubjRepository extends JpaRepository<TbFcltSubj, Long>, J
     @Query(value = "SELECT NVL(MAX(SUBJ_NMBR), 0) + 1 AS NEWID FROM TB_FCLT_SUBJ", nativeQuery = true)
     Long getNewNmbr();
 
+    @Query(value = "SELECT NVL(MAX(SUBJ_ID), 0) + 1 AS NEWID FROM TB_FCLT_SUBJ where FCLT_TYPE = :fcltType", nativeQuery = true)
+    Long getNewSubjId(@Param("fcltType") String fcltType);
+
     @Query("select p from TbFcltSubj p where p.fcltType = :fcltType")
     List<TbFcltSubj> findAllByFcltType(@Param("fcltType") String fcltType);
 

+ 6 - 0
src/main/java/com/its/op/service/its/facility/TbFcltSubjService.java

@@ -72,6 +72,12 @@ public class TbFcltSubjService {
         return NewIdLongDto.builder().newId(newId).build();
     }
 
+    @Transactional(readOnly = true)
+    public NewIdLongDto getNewSubjId(String fcltType) {
+        Long newId = this.repo.getNewSubjId(fcltType);
+        return NewIdLongDto.builder().newId(newId).build();
+    }
+
     @Transactional(readOnly = true)
     public List<TbFcltSubjDto> findAllByFcltType(String fcltType) {
         List<TbFcltSubjDto> result = new ArrayList<>();