From a3da3538781ef486be5a38bd3252f915a7856c5c Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Wed, 23 Sep 2026 08:24:01 +0900 Subject: [PATCH] =?UTF-8?q?260923=5F01=5FENH:=20kon,=20kiwi=20=EB=A7=A4?= =?UTF-8?q?=ED=95=91=ED=85=8C=EC=9D=B4=EB=B8=94=EC=97=90=20=EC=BB=A8?= =?UTF-8?q?=ED=83=9D=20=EC=8B=A4=ED=96=89=ED=99=98=EA=B2=BD=EC=9D=84=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../contactsurvey/ContactSurveyApiClient.java | 26 ++++++++++++++++++- src/main/resources/application-dev.yml | 2 +- src/main/resources/application-local.yml | 2 +- 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/kri/contact/server/common/external/contactsurvey/ContactSurveyApiClient.java b/src/main/java/com/kri/contact/server/common/external/contactsurvey/ContactSurveyApiClient.java index e79f7d2..d5ae1ee 100644 --- a/src/main/java/com/kri/contact/server/common/external/contactsurvey/ContactSurveyApiClient.java +++ b/src/main/java/com/kri/contact/server/common/external/contactsurvey/ContactSurveyApiClient.java @@ -7,9 +7,11 @@ import com.kri.contact.server.common.enums.SurveyType; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.HashMap; +import java.util.Locale; import java.util.Map; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Value; +import org.springframework.core.env.Environment; import org.springframework.stereotype.Component; @Slf4j @@ -21,6 +23,7 @@ public class ContactSurveyApiClient { private static final int MAX_PKEY_LENGTH = 20; private final ExternalApiClient externalApiClient = new ExternalApiClient(); + private final Environment environment; @Value("${kri.contact-survey.enabled:false}") private boolean enabled; @@ -37,6 +40,10 @@ public class ContactSurveyApiClient { @Value("${kri.auth.apikey.key}") private String apiKey; + public ContactSurveyApiClient(Environment environment) { + this.environment = environment; + } + public void insert(SurveyType surveyType, String pkey, Long psidx) { request(surveyType, ContactSurveyCrud.INSERT, pkey, psidx); } @@ -60,7 +67,8 @@ public class ContactSurveyApiClient { String body = "CRUD=" + crud + "&COMMAND=" + CONTACT_SURVEY_COMMAND + "&PKEY=" + encode(pkey) - + "&PSIDX=" + psidx; + + "&PSIDX=" + psidx + + "&TARGET=" + target(); externalApiClient.post(url, headers(), body); } @@ -97,6 +105,22 @@ public class ContactSurveyApiClient { return URLEncoder.encode(value, StandardCharsets.UTF_8); } + private String target() { + String[] profiles = environment.getActiveProfiles(); + if (profiles.length == 0) { + profiles = environment.getDefaultProfiles(); + } + + for (String profile : profiles) { + String target = profile.toUpperCase(Locale.ROOT); + if (target.equals("PROD") || target.equals("DEV") || target.equals("LOCAL")) { + return target; + } + } + + throw new IllegalStateException("Unsupported contact survey target profile"); + } + private Map headers() { Map headers = new HashMap<>(); headers.put(apiKeyHeaderName, apiKey); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index d0d6181..9b70dc0 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -5,7 +5,7 @@ kri: short-url: https://short-url.kric.com/api/v1 contact-survey: - enabled: false + enabled: true kon-url: https://kon.kric.com kiwi-url: https://kon.kiwisurvey.kr diff --git a/src/main/resources/application-local.yml b/src/main/resources/application-local.yml index 44ab57e..59c6b1d 100644 --- a/src/main/resources/application-local.yml +++ b/src/main/resources/application-local.yml @@ -7,7 +7,7 @@ kri: short-url: https://short-url.kric.com/api/v1 contact-survey: - enabled: false + enabled: true kon-url: http://localhost:8088 kiwi-url: http://localhost:8099 -- 2.49.0.windows.1