shjung 2 years ago
parent
commit
dab7cd6e49

+ 7 - 1
src/main/java/com/its/op/controller/its/database/CodeTableController.java

@@ -29,7 +29,7 @@ public class CodeTableController {
         return this.cmmnClsfCdService.findAll();
     }
 
-    @ApiOperation(value = "대분류코드-전체조회(TB_CMMN_CLSF_CD)", response = TbCmmnClsfCdDto.class, responseContainer = "ArrayList")
+    @ApiOperation(value = "대분류코드-전체조회(사용하는 정보만 조회-TB_CMMN_CLSF_CD)", response = TbCmmnClsfCdDto.class, responseContainer = "ArrayList")
     @GetMapping(value = "/clsf-cd/list", produces = {"application/json; charset=utf8"})
     public List<TbCmmnClsfCdDto> findAllCmmnClsfCdList() {
         return this.cmmnClsfCdService.findAllList();
@@ -76,6 +76,12 @@ public class CodeTableController {
         return this.cmmnCdService.findAllByCmmnClsfCd(id);
     }
 
+    @ApiOperation(value = "소분류코드-개별조회-목록(사용하는 정보만 조회-TB_CMMN_CD)", response = TbCmmnCdDto.class, responseContainer = "ArrayList")
+    @GetMapping(value = "/cmmn-cd/list/{id}", produces = {"application/json; charset=utf8"})
+    public List<TbCmmnCdDto> findByIdCmmnCdList(@PathVariable final String id) {
+        return this.cmmnCdService.findAllByCmmnClsfCdList(id);
+    }
+
     /*@ApiOperation(value = "소분류코드-개별조회-단일(TB_CMMN_CD)", response = CmmnCdDto.CmmnCdInfo.class)
     @GetMapping(value = "/cmmn-cd/{id}/{sub}", produces = {"application/json; charset=utf8"})
     public CmmnCdDto.CmmnCdInfo findByIdCmmnCd(@PathVariable final String id, @PathVariable final String sub) {

+ 3 - 0
src/main/java/com/its/op/dao/repository/its/code/TbCmmnCdRepository.java

@@ -21,6 +21,9 @@ public interface TbCmmnCdRepository extends JpaRepository<TbCmmnCd, TbCmmnCdKey>
     @Query("select p from TbCmmnCd p where p.cmmnClsfCd = :cmmnClsfCd")
     List<TbCmmnCd> findAllByCmmnClsfCd(@Param("cmmnClsfCd") String cmmnClsfCd);
 
+    @Query("select p from TbCmmnCd p where p.cmmnClsfCd = :cmmnClsfCd and p.useYn = 'Y'")
+    List<TbCmmnCd> findAllByCmmnClsfCdList(@Param("cmmnClsfCd") String cmmnClsfCd);
+
 //    @Query("select p from TbCmmnCd p where p.cmmnClsfCd = :cmmnClsfCd and  p.cmmnCd = :cmmnCd")
 //    TbCmmnCd findAllByCmmnClsfCdCmmnCd(@Param("cmmnClsfCd") String cmmnClsfCd, @Param("cmmnCd") String cmmnCd);
 

+ 12 - 1
src/main/java/com/its/op/service/its/code/TbCmmnCdService.java

@@ -102,7 +102,7 @@ public class TbCmmnCdService {
     }
 
     // 세부 코드 목록 조회
-    @Transactional
+    @Transactional(readOnly = true)
     public List<TbCmmnCdDto> findAllByCmmnClsfCd(String cmmnClsfCd) {
         List<TbCmmnCdDto> result = new ArrayList<>();
         List<TbCmmnCd> data = this.repo.findAllByCmmnClsfCd(cmmnClsfCd);
@@ -113,6 +113,16 @@ public class TbCmmnCdService {
         return result;
     }
 
+    @Transactional(readOnly = true)
+    public List<TbCmmnCdDto> findAllByCmmnClsfCdList(String cmmnClsfCd) {
+        List<TbCmmnCdDto> result = new ArrayList<>();
+        List<TbCmmnCd> data = this.repo.findAllByCmmnClsfCdList(cmmnClsfCd);
+        for (TbCmmnCd entity : data) {
+            result.add(entity.toDto());
+        }
+        return result;
+    }
+
     /**
      * 시설물 유형 코드 목롲 조회
      */
@@ -129,4 +139,5 @@ public class TbCmmnCdService {
         }
         return result;
     }
+
 }