diff --git a/include/ajax_contact.asp b/include/ajax_contact.asp index fd32a9e..08c7c2d 100644 --- a/include/ajax_contact.asp +++ b/include/ajax_contact.asp @@ -6,7 +6,8 @@ Dim CRUD : CRUD = Request("CRUD") Dim PKEY : PKEY = Request("PKEY") Dim PSIDX : PSIDX = Request("PSIDX") - Dim PSIDX_CHECK, PSIDX_DIGITS, PSIDX_LIMIT + Dim TARGET : TARGET = Request("TARGET") + Dim PSIDX_CHECK Const KON_CONTACT_API_KEY = "4B726963-436F6E74616374-53657276696365-402531213230" @@ -31,6 +32,15 @@ Response.End END IF + IF CRUD = "INSERT" OR CRUD = "DELETE" THEN + IF Len(TARGET) = 0 OR Len(TARGET) > 32 THEN + Response.Status = "400 Bad Request" + Response.ContentType = "application/json; charset=utf-8" + Response.Write "{""message"":""Invalid TARGET""}" + Response.End + END IF + END IF + IF CRUD = "INSERT" OR CRUD = "DELETE" THEN Set PSIDX_CHECK = Server.CreateObject("VBScript.RegExp") PSIDX_CHECK.Pattern = "^-?[0-9]{1,19}$" @@ -57,7 +67,7 @@ CASE "CONTACT_SURVEY" response.ContentType = "application/json" SQL = "" - SQL = SQL & " SELECT IDX, PKEY, PSIDX, REG_DT FROM KON_CONTACT_MAPPING WHERE PKEY = ? ORDER BY IDX " + SQL = SQL & " SELECT IDX, PKEY, PSIDX, TARGET_SYSTEM, REG_DT FROM KON_CONTACT_MAPPING WHERE PKEY = ? ORDER BY IDX " With ObjCmd .ActiveConnection = DBConn .CommandText = SQL @@ -82,15 +92,17 @@ SELECT CASE COMMAND CASE "CONTACT_SURVEY" SQL = "" - SQL = SQL & " INSERT INTO KON_CONTACT_MAPPING (PKEY, PSIDX) VALUES (?, CAST(? AS BIGINT)) " + SQL = SQL & " INSERT INTO KON_CONTACT_MAPPING (PKEY, PSIDX, TARGET_SYSTEM) VALUES (?, CAST(? AS BIGINT), ?) " With ObjCmd .ActiveConnection = DBConn .CommandText = SQL .CommandType = adCmdText .Parameters.Append .CreateParameter("@PKEY", adVarChar, adParamInput, 20) .Parameters.Append .CreateParameter("@PSIDX", adVarChar, adParamInput, 20) + .Parameters.Append .CreateParameter("@TARGET", adVarChar, adParamInput, 32) .Parameters("@PKEY") = PKEY .Parameters("@PSIDX") = PSIDX + .Parameters("@TARGET") = TARGET .Execute , , adExecuteNoRecords End With END SELECT @@ -99,15 +111,17 @@ SELECT CASE COMMAND CASE "CONTACT_SURVEY" SQL = "" - SQL = SQL & " DELETE FROM KON_CONTACT_MAPPING WHERE PKEY = ? AND PSIDX = CAST(? AS BIGINT) " + SQL = SQL & " DELETE FROM KON_CONTACT_MAPPING WHERE PKEY = ? AND PSIDX = CAST(? AS BIGINT) AND TARGET_SYSTEM = ? " With ObjCmd .ActiveConnection = DBConn .CommandText = SQL .CommandType = adCmdText .Parameters.Append .CreateParameter("@PKEY", adVarChar, adParamInput, 20) .Parameters.Append .CreateParameter("@PSIDX", adVarChar, adParamInput, 20) + .Parameters.Append .CreateParameter("@TARGET", adVarChar, adParamInput, 32) .Parameters("@PKEY") = PKEY .Parameters("@PSIDX") = PSIDX + .Parameters("@TARGET") = TARGET .Execute , , adExecuteNoRecords End With END SELECT diff --git a/module/survey.js b/module/survey.js index a6fb1a5..f824f73 100644 --- a/module/survey.js +++ b/module/survey.js @@ -154,12 +154,33 @@ kon.survey = (function () { }) } - function callContactStatusApi(contactMappingList, idkey, status){ - var contactBaseUrl = "https://contact.kric.com/api/external/"; - //contactBaseUrl = "http://localhost:4000/api/external/"; + function callContactStatusApi(contactMappingList, idkey, status) { + var contactRouteUrl = "/api/external/"; + contactMappingList.forEach(function (mapping) { + var targetSystem = String(mapping.TARGET_SYSTEM || "").toUpperCase(); + var contactBaseUrl; + + switch (targetSystem) { + case "PROD": + contactBaseUrl = "https://contact.kric.com"; + break; + + case "DEV": + contactBaseUrl = "https://test-contact.kric.com"; + break; + + case "LOCAL": + contactBaseUrl = "http://localhost:4000"; + break; + + default: + console.error("지원하지 않는 TARGET_SYSTEM:", mapping.TARGET_SYSTEM); + return; + } + $.ajax({ - url: contactBaseUrl + status + url: contactBaseUrl + contactRouteUrl + status + "?psidx=" + encodeURIComponent(mapping.PSIDX) + "&sid=" + encodeURIComponent(idkey), type: "POST",