You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.4 KiB
36 lines
1.4 KiB
|
1 day ago
|
# -*- coding: utf-8 -*-
|
||
|
|
"""票14 API 复现:check-name 对库内存量同名客户的真实行为。"""
|
||
|
|
import io, sys, json, urllib.request, urllib.parse
|
||
|
|
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
|
||
|
|
|
||
|
|
BASE = "http://localhost:8080"
|
||
|
|
ADMIN = "739564171091247104"
|
||
|
|
|
||
|
|
def get_json(url, token=None):
|
||
|
|
req = urllib.request.Request(url)
|
||
|
|
if token: req.add_header("Authorization", "Bearer " + token)
|
||
|
|
with urllib.request.urlopen(req, timeout=20) as r:
|
||
|
|
return json.loads(r.read().decode())
|
||
|
|
|
||
|
|
tok = get_json(f"{BASE}/api/auth/debug/token?userId={ADMIN}").get("data")
|
||
|
|
if isinstance(tok, dict): tok = tok.get("token")
|
||
|
|
print("token:", (tok or "")[:20], "...")
|
||
|
|
|
||
|
|
def ck(name):
|
||
|
|
u = f"{BASE}/api/customer/check-name?name={urllib.parse.quote(name)}"
|
||
|
|
try:
|
||
|
|
d = get_json(u, tok)
|
||
|
|
print(f"check-name[{name}] code={d.get('code')} data={json.dumps(d.get('data'), ensure_ascii=False)[:300]}")
|
||
|
|
except Exception as e:
|
||
|
|
print(f"check-name[{name}] EXC {e}")
|
||
|
|
|
||
|
|
# 1) 库内现存 13 条同名:EXACT 模式应命中
|
||
|
|
ck("e2c-恒信达科技有限公司")
|
||
|
|
# 2) sweep 已清的 seed 名:应空(无同名)
|
||
|
|
ck("e2c-dr-恒信达科技有限责任公司")
|
||
|
|
# 3) 部分词:EXACT 模式不命中
|
||
|
|
ck("e2c-恒信达")
|
||
|
|
# 4) dedup 设置现状
|
||
|
|
d = get_json(f"{BASE}/api/rule/customer/dedup", tok)
|
||
|
|
print("dedup:", json.dumps(d.get("data"), ensure_ascii=False))
|