From 6376092bb7927e4f6eb721c0902ba29209b205dc Mon Sep 17 00:00:00 2001 From: king Date: Wed, 30 Sep 2026 00:40:40 +0900 Subject: [PATCH] =?UTF-8?q?fix(performance):=2011=EB=B2=88=EA=B0=80=20?= =?UTF-8?q?=EC=97=B0=EA=B2=B0=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=E2=80=94=20?= =?UTF-8?q?XML=20=EC=95=84=EB=8B=8C=20=EC=9D=91=EB=8B=B5=EC=9D=80=20?= =?UTF-8?q?=EC=8B=A4=ED=8C=A8,=20=EC=84=B1=EA=B3=B5=20=EC=95=8C=EB=A6=BC?= =?UTF-8?q?=EC=9D=80=20=EC=B4=88=EB=A1=9D=20=EC=B2=B4=ED=81=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 11번가가 200 으로 웹페이지(IP 차단 안내 등)나 XML 아닌 응답을 주면 "0건 정상"으로 오판할 수 있어 실패로 처리 - 공용 알림 창 erpAlert(msg, { tone: "ok" }) — 경고 삼각형 대신 초록 체크. 기존 호출은 그대로. 실적 연결 테스트 성공 알림에 적용 Co-Authored-By: Claude Opus 5.5 --- app/modules/performance/adapters/elevenst.py | 8 ++++++-- .../performance/templates/performance/index.html | 2 +- .../performance/templates/performance/settings.html | 2 +- app/modules/performance/tests/test_performance.py | 5 +++-- app/static/erp-dialog.css | 5 +++++ app/static/erp-dialog.js | 13 +++++++++++-- app/static/performance.js | 4 ++-- app/templates/erp_base.html | 4 ++-- 8 files changed, 31 insertions(+), 12 deletions(-) diff --git a/app/modules/performance/adapters/elevenst.py b/app/modules/performance/adapters/elevenst.py index f1eea47..43bb46d 100644 --- a/app/modules/performance/adapters/elevenst.py +++ b/app/modules/performance/adapters/elevenst.py @@ -33,11 +33,13 @@ def _xml_text(content: bytes) -> str: def xml_result(content: bytes) -> tuple[str, str, int]: - """(결과코드, 결과문구, 주문 수). 네임스페이스와 무관하게 태그 끝 이름으로 찾는다.""" + """(결과코드, 결과문구, 주문 수). 네임스페이스와 무관하게 태그 끝 이름으로 찾는다. XML 이 아니면 코드 "not-xml".""" try: root = ET.fromstring(_xml_text(content)) except ET.ParseError: - return "", "", 0 + return "not-xml", "", 0 + if root.tag.rsplit("}", 1)[-1].lower() == "html": # 오류 안내 웹페이지(IP 차단 등) + return "not-xml", "", 0 code = text = "" orders = 0 for el in root.iter(): @@ -78,6 +80,8 @@ class ElevenstAdapter(MarketplaceAdapter): raise AuthFailed(f"11번가 인증 거부({res.status_code}): {detail}. 키와 등록 IP(이 서버 외부 IP)를 확인하세요.") if res.status_code >= 400: raise ApiError(f"11번가 API 오류({res.status_code}): {detail}") + if code == "not-xml": + raise ApiError(f"11번가가 예상하지 못한 응답을 돌려줬습니다(XML 아님): {res.text[:120].strip()}") if code and code not in ("0", "200", "00"): raise ApiError(f"11번가 API 오류(코드 {code}): {detail}") return res.content diff --git a/app/modules/performance/templates/performance/index.html b/app/modules/performance/templates/performance/index.html index ac3c821..0fc29ca 100644 --- a/app/modules/performance/templates/performance/index.html +++ b/app/modules/performance/templates/performance/index.html @@ -239,4 +239,4 @@ } | tojson }} {% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/performance/templates/performance/settings.html b/app/modules/performance/templates/performance/settings.html index df7fc22..71a95e3 100644 --- a/app/modules/performance/templates/performance/settings.html +++ b/app/modules/performance/templates/performance/settings.html @@ -155,4 +155,4 @@ {% endblock %} -{% block scripts %}{% endblock %} +{% block scripts %}{% endblock %} diff --git a/app/modules/performance/tests/test_performance.py b/app/modules/performance/tests/test_performance.py index ec5ce5b..618f950 100644 --- a/app/modules/performance/tests/test_performance.py +++ b/app/modules/performance/tests/test_performance.py @@ -842,13 +842,14 @@ def test_elevenst_connection(): assert "연결 정상" in msg and "2건" in msg and seen["key"] == "KEY-11ST-SECRET" assert "/rest/ordservices/complete/" in seen["url"] err = '-1허용되지 않은 IP' - for status, body, kind in ((200, err.encode(), ApiError), (403, b"Forbidden", AuthFailed)): + for status, body, kind in ((200, err.encode(), ApiError), (403, b"Forbidden", AuthFailed), + (200, b"IP not allowed", ApiError)): httpx.get = fake(status, body) try: ev.ElevenstAdapter().test_connection(ctx) except kind as exc: assert "KEY-11ST-SECRET" not in exc.message - assert status == 403 or "허용되지 않은 IP" in exc.message + assert status == 403 or "허용되지 않은 IP" in exc.message or "XML 아님" in exc.message else: raise AssertionError("오류여야 합니다") finally: diff --git a/app/static/erp-dialog.css b/app/static/erp-dialog.css index 8c3debb..5bdfb42 100644 --- a/app/static/erp-dialog.css +++ b/app/static/erp-dialog.css @@ -54,6 +54,11 @@ color: var(--color-callout-red, #c22b10); } +/* 성공 알림(erpAlert(msg, { tone: "ok" })) — 초록 체크 */ +.erp-dialog-icon.is-ok { + color: #0f8a3a; +} + /* 확인(질문)용은 붉은 경고색 대신 차분한 검정으로 */ .erp-dialog-ask .erp-dialog-icon { color: var(--color-rich-black, #0a0a0a); diff --git a/app/static/erp-dialog.js b/app/static/erp-dialog.js index 57ef137..bebf855 100644 --- a/app/static/erp-dialog.js +++ b/app/static/erp-dialog.js @@ -8,6 +8,7 @@ erpConfirm("지울까요?").then(function (ok) { if (ok) ... }); erpAlert("실패했습니다.").then(...) erpPrompt("주소를 입력하세요", "https://").then(function (v) { if (v) ... }); // 취소면 null + erpAlert("저장했습니다.", { tone: "ok" }) // 성공 알림 — 경고 삼각형 대신 초록 체크 창 제목은 기본 "No.1 King ERP 프로그램". 화면마다 바꾸려면 그 화면 스크립트에서 window.ERP_DIALOG_TITLE = "..." 를 두거나, 한 번만 options.title 로 넘긴다. @@ -31,6 +32,14 @@ '' + ""; + // 성공(tone: "ok") — 원 안의 체크. + var ICON_OK = + '"; + function titleOf(options) { return options.title || window.ERP_DIALOG_TITLE || TITLE; } @@ -54,8 +63,8 @@ body.className = "erp-dialog-body"; var icon = document.createElement("span"); - icon.className = "erp-dialog-icon"; - icon.innerHTML = ICON; + icon.className = "erp-dialog-icon" + (options.tone === "ok" ? " is-ok" : ""); + icon.innerHTML = options.tone === "ok" ? ICON_OK : ICON; var text = document.createElement("p"); text.className = "erp-dialog-message"; diff --git a/app/static/performance.js b/app/static/performance.js index 14fbeb3..94fcfc4 100644 --- a/app/static/performance.js +++ b/app/static/performance.js @@ -31,7 +31,7 @@ if (a >= 10000) return s + Math.round(a / 10000).toLocaleString("ko-KR") + "만"; return s + fmt(a); } - function alertMsg(msg) { return window.erpAlert ? window.erpAlert(msg) : Promise.resolve(window.alert(msg)); } + function alertMsg(msg, opts) { return window.erpAlert ? window.erpAlert(msg, opts) : Promise.resolve(window.alert(msg)); } function confirmMsg(msg) { return window.erpConfirm ? window.erpConfirm(msg) : Promise.resolve(window.confirm(msg)); } async function api(method, url, body) { @@ -466,7 +466,7 @@ btn.textContent = "확인 중…"; try { const res = await api("POST", "/performance/api/marketplaces/" + code + "/test", {}); - await alertMsg(name + " — " + (res.ok ? "정상 연결\n" : res.label + "\n") + res.message); + await alertMsg(name + " — " + (res.ok ? "정상 연결\n" : res.label + "\n") + res.message, res.ok ? { tone: "ok" } : undefined); location.reload(); } catch (err) { alertMsg(err.message); diff --git a/app/templates/erp_base.html b/app/templates/erp_base.html index 6c4ce15..e657643 100644 --- a/app/templates/erp_base.html +++ b/app/templates/erp_base.html @@ -7,7 +7,7 @@ - + {% block head_extra %}{% endblock %} @@ -177,7 +177,7 @@ {# 공용 확인/경고 창. defer 를 쓰지 않는다 — 아래 {% block scripts %} 의 인라인 스크립트가 곧바로 erpConfirm/erpAlert 을 쓸 수 있어야 한다. #} - + {% block scripts %}{% endblock %}