From 1bd89d00c304c898caf9bfb8da2dccc25355d725 Mon Sep 17 00:00:00 2001 From: allbegray Date: Sat, 22 Apr 2023 16:10:02 +0900 Subject: [PATCH] =?UTF-8?q?:sparkles:=20=EC=82=AC=EC=97=85=EC=9E=90=20?= =?UTF-8?q?=EB=93=B1=EB=A1=9D=20=EB=B2=88=ED=98=B8=20=EC=A7=84=EC=9C=84?= =?UTF-8?q?=ED=99=95=EC=9D=B8/=EC=83=81=ED=83=9C=20=EC=A1=B0=ED=9A=8C=20AP?= =?UTF-8?q?I=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 4 +- build.gradle | 2 +- .../kotlin/herbaccara/datakr/DataKrService.kt | 53 +++++++++--------- .../datakr/form/BusinessNoValidateForm.kt | 56 +++++++++++++++++++ .../datakr/model/BusinessNoStatus.kt | 15 +++++ .../datakr/model/BusinessNoStatusResult.kt | 10 ++++ .../datakr/model/BusinessNoValidateResult.kt | 18 ++++++ 7 files changed, 129 insertions(+), 29 deletions(-) create mode 100644 src/main/kotlin/herbaccara/datakr/form/BusinessNoValidateForm.kt create mode 100644 src/main/kotlin/herbaccara/datakr/model/BusinessNoStatus.kt create mode 100644 src/main/kotlin/herbaccara/datakr/model/BusinessNoStatusResult.kt create mode 100644 src/main/kotlin/herbaccara/datakr/model/BusinessNoValidateResult.kt diff --git a/README.md b/README.md index dbd76f4..86fd1dc 100644 --- a/README.md +++ b/README.md @@ -6,4 +6,6 @@ spring boot starter datakr. data.go.kr 공공데이터 스프링부트용 라이 [한국천문연구원_특일 정보 - 공휴일 정보 조회](https://www.data.go.kr/tcs/dss/selectApiDataDetailView.do?publicDataPk=15012690) -[행정안전부_행정표준코드_법정동코드 - 법정동코드 조회](https://www.data.go.kr/data/15077871/openapi.do?recommendDataYn=Y) \ No newline at end of file +[행정안전부_행정표준코드_법정동코드 - 법정동코드 조회](https://www.data.go.kr/data/15077871/openapi.do?recommendDataYn=Y) + +[국세청_사업자등록정보 진위확인 및 상태조회 서비스](https://www.data.go.kr/data/15081808/openapi.do) \ No newline at end of file diff --git a/build.gradle b/build.gradle index 3e0df8d..7ef405d 100644 --- a/build.gradle +++ b/build.gradle @@ -11,7 +11,7 @@ plugins { } group = 'herbaccara' -version = '0.0.5' +version = '0.0.6' sourceCompatibility = '1.8' publishing { diff --git a/src/main/kotlin/herbaccara/datakr/DataKrService.kt b/src/main/kotlin/herbaccara/datakr/DataKrService.kt index 16d9433..c10d036 100644 --- a/src/main/kotlin/herbaccara/datakr/DataKrService.kt +++ b/src/main/kotlin/herbaccara/datakr/DataKrService.kt @@ -1,12 +1,10 @@ package herbaccara.datakr -import com.fasterxml.jackson.databind.JsonNode import com.fasterxml.jackson.databind.ObjectMapper import com.fasterxml.jackson.dataformat.xml.XmlMapper import herbaccara.boot.autoconfigure.datakr.DataKrProperties -import herbaccara.datakr.model.HolidayResult -import herbaccara.datakr.model.HopitalResult -import herbaccara.datakr.model.StanReginCd +import herbaccara.datakr.form.BusinessNoValidateForm +import herbaccara.datakr.model.* import kotlinx.coroutines.* import org.springframework.util.LinkedMultiValueMap import org.springframework.web.client.RestTemplate @@ -16,7 +14,6 @@ import org.springframework.web.util.UriComponentsBuilder import java.net.URI import java.net.URLEncoder import java.time.LocalDate -import java.time.format.DateTimeFormatter class DataKrService( private val restTemplate: RestTemplate, @@ -179,13 +176,13 @@ class DataKrService( } /** - * 국세청_사업자등록정보 진위확인 - * https://www.data.go.kr/data/15081808/openapi.do + * @see 국세청_사업자등록정보 진위확인 * * @param bNo 사업자등록번호 * @param startDt 개업일자 * @param pNm 대표자성명 * @param pNm2 대표자성명2 + * @param bNm 상호 * @param corpNo 법인등록번호 * @param bSector 주업태명 * @param bType 주종목명 @@ -200,7 +197,25 @@ class DataKrService( corpNo: String? = null, bSector: String? = null, bType: String? = null - ): JsonNode { + ): BusinessNoValidateResult { + return businessNoValidate( + BusinessNoValidateForm( + bNo.replace("-", ""), + startDt, + pNm, + pNm2 ?: "", + bNm ?: "", + corpNo?.replace("-", "") ?: "", + bSector ?: "", + bType ?: "" + ) + ) + } + + /** + * @see 국세청_사업자등록정보 진위확인 + */ + fun businessNoValidate(vararg form: BusinessNoValidateForm): BusinessNoValidateResult { val endpoint = UriComponentsBuilder .fromHttpUrl("https://api.odcloud.kr/api/nts-businessman/v1/validate") .queryParam("returnType", "JSON") @@ -208,33 +223,17 @@ class DataKrService( .build(false) .toUriString() - val dateFormatter = DateTimeFormatter.ofPattern("yyyyMMdd") - - val map = mapOf( - "businesses" to listOf( - mapOf( - "b_no" to bNo.replace("-", ""), - "start_dt" to startDt.format(dateFormatter), - "p_nm" to pNm, - "p_nm2" to (pNm2 ?: ""), - "b_nm" to (bNm ?: ""), - "corp_no" to (corpNo?.replace("-", "") ?: ""), - "b_sector" to (bSector ?: ""), - "b_type" to (bType ?: "") - ) - ) - ) + val map = mapOf("businesses" to form.toList()) return restTemplate.postForObject(URI(endpoint), map) } /** - * 국세청_사업자등록정보 상태조회 - * https://www.data.go.kr/data/15081808/openapi.do + * @see 국세청_사업자등록정보 상태조회 * * @param bNo 사업자등록번호 */ - fun businessNoStatus(vararg bNo: String): JsonNode { + fun businessNoStatus(vararg bNo: String): BusinessNoStatusResult { val endpoint = UriComponentsBuilder .fromHttpUrl("https://api.odcloud.kr/api/nts-businessman/v1/status") .queryParam("returnType", "JSON") diff --git a/src/main/kotlin/herbaccara/datakr/form/BusinessNoValidateForm.kt b/src/main/kotlin/herbaccara/datakr/form/BusinessNoValidateForm.kt new file mode 100644 index 0000000..c836c04 --- /dev/null +++ b/src/main/kotlin/herbaccara/datakr/form/BusinessNoValidateForm.kt @@ -0,0 +1,56 @@ +package herbaccara.datakr.form + +import com.fasterxml.jackson.annotation.JsonFormat +import com.fasterxml.jackson.annotation.JsonProperty +import java.time.LocalDate + +data class BusinessNoValidateForm @JvmOverloads constructor( + /** + * 사업자등록번호 + */ + @field:JsonProperty("b_no") + val bNo: String, + + /** + * 개업일자 + */ + @field:JsonProperty("start_dt") + @field:JsonFormat(pattern = "yyyyMMdd") + val startDt: LocalDate, + + /** + * 대표자성명 + */ + @field:JsonProperty("p_nm") + val pNm: String, + + /** + * 대표자성명2 + */ + @field:JsonProperty("p_nm2") + val pNm2: String = "", + + /** + * 상호 + */ + @field:JsonProperty("b_nm") + val bNm: String = "", + + /** + * 법인등록번호 + */ + @field:JsonProperty("corp_no") + val corpNo: String = "", + + /** + * 주업태명 + */ + @field:JsonProperty("b_sector") + val bSector: String = "", + + /** + * 주종목명 + */ + @field:JsonProperty("b_type") + val bType: String = "" +) diff --git a/src/main/kotlin/herbaccara/datakr/model/BusinessNoStatus.kt b/src/main/kotlin/herbaccara/datakr/model/BusinessNoStatus.kt new file mode 100644 index 0000000..1bc9d7a --- /dev/null +++ b/src/main/kotlin/herbaccara/datakr/model/BusinessNoStatus.kt @@ -0,0 +1,15 @@ +package herbaccara.datakr.model + +import com.fasterxml.jackson.annotation.JsonProperty + +data class BusinessNoStatus( + @field:JsonProperty("b_no") val bNo: String, + @field:JsonProperty("b_stt") val bStt: String, + @field:JsonProperty("b_stt_cd") val bSttCd: String, + @field:JsonProperty("tax_type") val taxType: String, + @field:JsonProperty("tax_type_cd") val taxTypeCd: String, + @field:JsonProperty("end_dt") val endDt: String, + @field:JsonProperty("utcc_yn") val utccYn: String, + @field:JsonProperty("tax_type_change_dt") val taxTypeChangeDt: String, + @field:JsonProperty("invoice_apply_dt") val invoiceApplyDt: String +) diff --git a/src/main/kotlin/herbaccara/datakr/model/BusinessNoStatusResult.kt b/src/main/kotlin/herbaccara/datakr/model/BusinessNoStatusResult.kt new file mode 100644 index 0000000..ef114f5 --- /dev/null +++ b/src/main/kotlin/herbaccara/datakr/model/BusinessNoStatusResult.kt @@ -0,0 +1,10 @@ +package herbaccara.datakr.model + +import com.fasterxml.jackson.annotation.JsonProperty + +data class BusinessNoStatusResult( + @field:JsonProperty("request_cnt") val requestCnt: Int, + @field:JsonProperty("match_cnt") val matchCnt: Int, + @field:JsonProperty("status_code") val statusCode: String, + @field:JsonProperty("data") val data: List +) diff --git a/src/main/kotlin/herbaccara/datakr/model/BusinessNoValidateResult.kt b/src/main/kotlin/herbaccara/datakr/model/BusinessNoValidateResult.kt new file mode 100644 index 0000000..6495c1c --- /dev/null +++ b/src/main/kotlin/herbaccara/datakr/model/BusinessNoValidateResult.kt @@ -0,0 +1,18 @@ +package herbaccara.datakr.model + +import com.fasterxml.jackson.annotation.JsonProperty +import herbaccara.datakr.form.BusinessNoValidateForm + +data class BusinessNoValidateResult( + @field:JsonProperty("request_cnt") val requestCnt: Int, + @field:JsonProperty("valid_cnt") val validCnt: Int, + @field:JsonProperty("status_code") val statusCode: String, + @field:JsonProperty("data") val data: List +) { + data class Data( + @field:JsonProperty("b_no") val bNo: String, + @field:JsonProperty("valid") val valid: String, + @field:JsonProperty("request_param") val requestParam: BusinessNoValidateForm, + @field:JsonProperty("status") val status: BusinessNoStatus? + ) +}