From 8899634b423410feac1d651a2c6d7a396ce1627d Mon Sep 17 00:00:00 2001 From: yoosangwook Date: Mon, 21 Oct 2024 15:30:51 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EA=B3=B5=ED=86=B5=EC=BD=94=EB=93=9C=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20=20API=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../biz/commCode/CommCodeController.java | 26 ++++++++++++------- .../qcast/biz/commCode/CommCodeService.java | 26 ++++++++++++++----- .../qcast/biz/commCode/dto/CommCodeRes.java | 14 ++++++++++ .../biz/commCode/CommCodeServiceTest.java | 25 ++++++++++++++++++ 4 files changed, 75 insertions(+), 16 deletions(-) create mode 100644 src/main/java/com/interplug/qcast/biz/commCode/dto/CommCodeRes.java create mode 100644 src/test/java/com/interplug/qcast/biz/commCode/CommCodeServiceTest.java diff --git a/src/main/java/com/interplug/qcast/biz/commCode/CommCodeController.java b/src/main/java/com/interplug/qcast/biz/commCode/CommCodeController.java index 3a188768..d65e78c4 100644 --- a/src/main/java/com/interplug/qcast/biz/commCode/CommCodeController.java +++ b/src/main/java/com/interplug/qcast/biz/commCode/CommCodeController.java @@ -1,17 +1,15 @@ package com.interplug.qcast.biz.commCode; -import org.springframework.http.HttpStatus; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseStatus; -import org.springframework.web.bind.annotation.RestController; import com.interplug.qcast.biz.commCode.dto.CodeReq; import com.interplug.qcast.biz.commCode.dto.CommCodeApiResponse; +import com.interplug.qcast.biz.commCode.dto.CommCodeRes; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; +import java.util.List; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.HttpStatus; +import org.springframework.web.bind.annotation.*; @Slf4j @RestController @@ -27,12 +25,20 @@ public class CommCodeController { public CommCodeApiResponse setQcCommCdYn(@RequestBody CodeReq codeReq) { CommCodeApiResponse codeResponse = new CommCodeApiResponse(); int resultCnt = commCodeService.setCommHUpdate(codeReq); - if (resultCnt > 0) - codeResponse.setCode("200"); - else - codeResponse.setCode("500"); + if (resultCnt > 0) codeResponse.setCode("200"); + else codeResponse.setCode("500"); return codeResponse; + } + /** + * QCast에서 사용하는 공통코드를 조회 한다. + * + * @return + */ + @Operation(description = "QCast에서 사용하는 공통코드를 조회 한다.") + @GetMapping("/qc-comm-code") + public List selectQcastCommCode() { + return commCodeService.selectQcastCommCode(); } } diff --git a/src/main/java/com/interplug/qcast/biz/commCode/CommCodeService.java b/src/main/java/com/interplug/qcast/biz/commCode/CommCodeService.java index 37b99bd4..739dfb73 100644 --- a/src/main/java/com/interplug/qcast/biz/commCode/CommCodeService.java +++ b/src/main/java/com/interplug/qcast/biz/commCode/CommCodeService.java @@ -1,10 +1,12 @@ package com.interplug.qcast.biz.commCode; -import java.util.List; -import org.springframework.stereotype.Service; import com.interplug.qcast.biz.commCode.dto.CodeReq; import com.interplug.qcast.biz.commCode.dto.CodeRes; +import com.interplug.qcast.biz.commCode.dto.CommCodeRes; +import java.util.ArrayList; +import java.util.List; import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; @Service @RequiredArgsConstructor @@ -34,7 +36,6 @@ public class CommCodeService { codeRes.setClDelFlg(1); } resultCnt += commCodeMapper.setCommLUpdate(codeRes); - } } return resultCnt; @@ -42,10 +43,23 @@ public class CommCodeService { /** * QCast에서 사용하는 공통코드 조회 - * + * * @return */ - public List selectQcastCommCode() { - return commCodeMapper.selectQcastCommCode(); + public List selectQcastCommCode() { + List result = commCodeMapper.selectQcastCommCode(); + List commCodeList = new ArrayList<>(); + result.forEach( + cr -> { + commCodeList.add( + CommCodeRes.builder() + .clHeadCd(cr.getClHeadCd()) + .clCode(cr.getClCode()) + .clCodeNm(cr.getClCodeNm()) + .clCodeJp(cr.getClCodeJp()) + .clPriority(cr.getClPriority()) + .build()); + }); + return commCodeList; } } diff --git a/src/main/java/com/interplug/qcast/biz/commCode/dto/CommCodeRes.java b/src/main/java/com/interplug/qcast/biz/commCode/dto/CommCodeRes.java new file mode 100644 index 00000000..541404bb --- /dev/null +++ b/src/main/java/com/interplug/qcast/biz/commCode/dto/CommCodeRes.java @@ -0,0 +1,14 @@ +package com.interplug.qcast.biz.commCode.dto; + +import lombok.Builder; +import lombok.Getter; + +@Getter +@Builder +public class CommCodeRes { + private String clHeadCd; + private String clCode; + private String clCodeNm; + private String clCodeJp; + private Integer clPriority; +} diff --git a/src/test/java/com/interplug/qcast/biz/commCode/CommCodeServiceTest.java b/src/test/java/com/interplug/qcast/biz/commCode/CommCodeServiceTest.java new file mode 100644 index 00000000..7760c1fd --- /dev/null +++ b/src/test/java/com/interplug/qcast/biz/commCode/CommCodeServiceTest.java @@ -0,0 +1,25 @@ +package com.interplug.qcast.biz.commCode; + +import static org.junit.jupiter.api.Assertions.*; + +import com.interplug.qcast.biz.commCode.dto.CommCodeRes; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class CommCodeServiceTest { + + @Autowired + private CommCodeService commCodeService; + + @Test + void selectQcastCommCode() { + //given + List result = commCodeService.selectQcastCommCode(); + //when + //then + assertNotNull(result); + } +}