Merge pull request '260923_01_ENH: kon, kiwi 매핑테이블에 컨택 실행환경을 추가' (#26) from develop into master

Reviewed-on: #26
This commit is contained in:
2026-09-23 08:27:14 +09:00
3 changed files with 27 additions and 3 deletions

View File

@@ -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<String, String> headers() {
Map<String, String> headers = new HashMap<>();
headers.put(apiKeyHeaderName, apiKey);

View File

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

View File

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