260923_01_ENH: kon, kiwi 매핑테이블에 컨택 실행환경을 추가
This commit is contained in:
@@ -7,9 +7,11 @@ import com.kri.contact.server.common.enums.SurveyType;
|
|||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@@ -21,6 +23,7 @@ public class ContactSurveyApiClient {
|
|||||||
private static final int MAX_PKEY_LENGTH = 20;
|
private static final int MAX_PKEY_LENGTH = 20;
|
||||||
|
|
||||||
private final ExternalApiClient externalApiClient = new ExternalApiClient();
|
private final ExternalApiClient externalApiClient = new ExternalApiClient();
|
||||||
|
private final Environment environment;
|
||||||
|
|
||||||
@Value("${kri.contact-survey.enabled:false}")
|
@Value("${kri.contact-survey.enabled:false}")
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
@@ -37,6 +40,10 @@ public class ContactSurveyApiClient {
|
|||||||
@Value("${kri.auth.apikey.key}")
|
@Value("${kri.auth.apikey.key}")
|
||||||
private String apiKey;
|
private String apiKey;
|
||||||
|
|
||||||
|
public ContactSurveyApiClient(Environment environment) {
|
||||||
|
this.environment = environment;
|
||||||
|
}
|
||||||
|
|
||||||
public void insert(SurveyType surveyType, String pkey, Long psidx) {
|
public void insert(SurveyType surveyType, String pkey, Long psidx) {
|
||||||
request(surveyType, ContactSurveyCrud.INSERT, pkey, psidx);
|
request(surveyType, ContactSurveyCrud.INSERT, pkey, psidx);
|
||||||
}
|
}
|
||||||
@@ -60,7 +67,8 @@ public class ContactSurveyApiClient {
|
|||||||
String body = "CRUD=" + crud
|
String body = "CRUD=" + crud
|
||||||
+ "&COMMAND=" + CONTACT_SURVEY_COMMAND
|
+ "&COMMAND=" + CONTACT_SURVEY_COMMAND
|
||||||
+ "&PKEY=" + encode(pkey)
|
+ "&PKEY=" + encode(pkey)
|
||||||
+ "&PSIDX=" + psidx;
|
+ "&PSIDX=" + psidx
|
||||||
|
+ "&TARGET=" + target();
|
||||||
|
|
||||||
externalApiClient.post(url, headers(), body);
|
externalApiClient.post(url, headers(), body);
|
||||||
}
|
}
|
||||||
@@ -97,6 +105,22 @@ public class ContactSurveyApiClient {
|
|||||||
return URLEncoder.encode(value, StandardCharsets.UTF_8);
|
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() {
|
private Map<String, String> headers() {
|
||||||
Map<String, String> headers = new HashMap<>();
|
Map<String, String> headers = new HashMap<>();
|
||||||
headers.put(apiKeyHeaderName, apiKey);
|
headers.put(apiKeyHeaderName, apiKey);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ kri:
|
|||||||
short-url: https://short-url.kric.com/api/v1
|
short-url: https://short-url.kric.com/api/v1
|
||||||
|
|
||||||
contact-survey:
|
contact-survey:
|
||||||
enabled: false
|
enabled: true
|
||||||
kon-url: https://kon.kric.com
|
kon-url: https://kon.kric.com
|
||||||
kiwi-url: https://kon.kiwisurvey.kr
|
kiwi-url: https://kon.kiwisurvey.kr
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ kri:
|
|||||||
short-url: https://short-url.kric.com/api/v1
|
short-url: https://short-url.kric.com/api/v1
|
||||||
|
|
||||||
contact-survey:
|
contact-survey:
|
||||||
enabled: false
|
enabled: true
|
||||||
kon-url: http://localhost:8088
|
kon-url: http://localhost:8088
|
||||||
kiwi-url: http://localhost:8099
|
kiwi-url: http://localhost:8099
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user