feat: 공통코드 조회 API 추가

This commit is contained in:
yoosangwook 2024-10-21 15:30:51 +09:00
parent 1275b8a8c0
commit 8899634b42
4 changed files with 75 additions and 16 deletions

View File

@ -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<CommCodeRes> selectQcastCommCode() {
return commCodeService.selectQcastCommCode();
}
}

View File

@ -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<CodeRes> selectQcastCommCode() {
return commCodeMapper.selectQcastCommCode();
public List<CommCodeRes> selectQcastCommCode() {
List<CodeRes> result = commCodeMapper.selectQcastCommCode();
List<CommCodeRes> 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;
}
}

View File

@ -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;
}

View File

@ -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<CommCodeRes> result = commCodeService.selectQcastCommCode();
//when
//then
assertNotNull(result);
}
}