Skip to content

Commit

Permalink
✨ 사업자 등록 번호 진위확인/상태 조회 API 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
allbegray committed Apr 22, 2023
1 parent 9735150 commit 1bd89d0
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 29 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
[행정안전부_행정표준코드_법정동코드 - 법정동코드 조회](https://www.data.go.kr/data/15077871/openapi.do?recommendDataYn=Y)

[국세청_사업자등록정보 진위확인 및 상태조회 서비스](https://www.data.go.kr/data/15081808/openapi.do)
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ plugins {
}

group = 'herbaccara'
version = '0.0.5'
version = '0.0.6'
sourceCompatibility = '1.8'

publishing {
Expand Down
53 changes: 26 additions & 27 deletions src/main/kotlin/herbaccara/datakr/DataKrService.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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,
Expand Down Expand Up @@ -179,13 +176,13 @@ class DataKrService(
}

/**
* 국세청_사업자등록정보 진위확인
* https://www.data.go.kr/data/15081808/openapi.do
* @see <a href="https://www.data.go.kr/data/15081808/openapi.do#/%EC%82%AC%EC%97%85%EC%9E%90%EB%93%B1%EB%A1%9D%EC%A0%95%EB%B3%B4%20%EC%A7%84%EC%9C%84%ED%99%95%EC%9D%B8%20API/validate">국세청_사업자등록정보 진위확인</a>
*
* @param bNo 사업자등록번호
* @param startDt 개업일자
* @param pNm 대표자성명
* @param pNm2 대표자성명2
* @param bNm 상호
* @param corpNo 법인등록번호
* @param bSector 주업태명
* @param bType 주종목명
Expand All @@ -200,41 +197,43 @@ 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 <a href="https://www.data.go.kr/data/15081808/openapi.do#/%EC%82%AC%EC%97%85%EC%9E%90%EB%93%B1%EB%A1%9D%EC%A0%95%EB%B3%B4%20%EC%A7%84%EC%9C%84%ED%99%95%EC%9D%B8%20API/validate">국세청_사업자등록정보 진위확인</a>
*/
fun businessNoValidate(vararg form: BusinessNoValidateForm): BusinessNoValidateResult {
val endpoint = UriComponentsBuilder
.fromHttpUrl("https://api.odcloud.kr/api/nts-businessman/v1/validate")
.queryParam("returnType", "JSON")
.queryParam("serviceKey", URLEncoder.encode(properties.serviceKey, "UTF-8"))
.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 <a href="https://www.data.go.kr/data/15081808/openapi.do#/%EC%82%AC%EC%97%85%EC%9E%90%EB%93%B1%EB%A1%9D%20%EC%83%81%ED%83%9C%EC%A1%B0%ED%9A%8C%20API/status">국세청_사업자등록정보 상태조회</a>
*
* @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")
Expand Down
56 changes: 56 additions & 0 deletions src/main/kotlin/herbaccara/datakr/form/BusinessNoValidateForm.kt
Original file line number Diff line number Diff line change
@@ -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 = ""
)
15 changes: 15 additions & 0 deletions src/main/kotlin/herbaccara/datakr/model/BusinessNoStatus.kt
Original file line number Diff line number Diff line change
@@ -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
)
10 changes: 10 additions & 0 deletions src/main/kotlin/herbaccara/datakr/model/BusinessNoStatusResult.kt
Original file line number Diff line number Diff line change
@@ -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<BusinessNoStatus>
)
Original file line number Diff line number Diff line change
@@ -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>
) {
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?
)
}

0 comments on commit 1bd89d0

Please sign in to comment.