feat(face-b): 数据中心五族 + 数据同步(面 B 批次 14,+29 端点)

基准数据类型/控件映射/数据库/字段类型映射/常用字段的增删改查 + getKeyList
+ 数据同步四条 + 接口变量下拉;新表 base_data_type_mapping / base_data_base /
base_data_type_relation / base_data_interface_variate(官方 DDL 逐字)⇒ tables 57。
影响:dataCenter 五个页面能真跑;数据同步四条明确拒绝(本仓内嵌单库,无驱动层),
不再假装成功。回归测试 tests/batch14_it.rs 7 条。

五族形状一致 ⇒ 抽了声明式 Flat(一份声明 + 五个薄壳),不再逐族手抄。
过程中修掉扫描器两个同源缺陷:check-contract-scan / fe-gap 都只认每条 .route()
的**第一个**方法 ⇒ 链式 get().post() 的后半段静默消失(契约写 implemented、
代码被判「没有这条路由」)。现在按 .route( 切块取全部方法。
写路径的两处语义也一并钉住:判重是「每列各自唯一」不是「联合唯一」;
列表把 typeId 覆盖成名称而详情必须返回真 id。
This commit is contained in:
admin committed 2026-11-02 09:13:46 +08:00
1 parent 3bf7f91461
commit e961904252
9 files changed
+2146 -92

No files matched your search

+64 -26
View File
@@ -211,6 +211,26 @@ def _find_fn_body_uncached(masked, fname):
return brace_span(masked, i)
def paren_span(masked, start):
"""从 `start`(`(` 的位置)开始做括号配对 ⇒ 返回 `)` 的下标(失败返回末位)。
🔴 在 `masked` 上跑:字符串字面量已被挖空 ⇒ 参数里的 `(` / `)` 不会干扰配对。
"""
depth = 0
i = start
n = len(masked)
while i < n:
c = masked[i]
if c == "(":
depth += 1
elif c == ")":
depth -= 1
if depth == 0:
return i
i += 1
return n - 1
def scan_routes(path, owner):
"""扫一个源文件里的 `.route(...)` ⇒ [{path, method, handler_mod, handler_fn, closure}]。"""
orig = read(path)
@@ -237,34 +257,52 @@ def scan_routes(path, owner):
p += 1
while p < len(orig) and orig[p] in " \t\r\n":
p += 1
mm = re.match(r"(get|post|put|delete)\s*\(", orig[p:])
if not mm:
continue
if masked[p:p + len(mm.group(1))] != mm.group(1):
continue # 方法名其实落在字符串里(误报)
method = mm.group(1).upper()
after = p + mm.end()
if route.startswith(TEST_PATH_PREFIX):
continue # 仅测试构建存在的端点 ⇒ 不在契约端点表里
rest = orig[after:after + 240]
hm = HANDLER_RE.match(rest)
mod, fn, closure = None, None, True
if hm and hm.group(2):
mod, fn = hm.group(1), hm.group(2)
closure = False
out.append({
"path": route,
"method": method,
"mod": mod,
"fn": fn,
"closure": closure,
"owner": owner,
# 🔴 `source` 区分「路由住在哪」:平台层 / 业务模块(面 A)/ 业务包(面 B)。
# owner 会撞(包与模块同 app_code)⇒ 守卫推导与台账范围**必须**看这个。
"source": "platform" if owner == "platform" else "module",
"const": None,
"file": path,
})
# 🔴 一条 `.route(path, …)` 里可能有**多个**方法:`.route(p, get(a).post(b))`
# —— axum 对同一 path **只准 `.route()` 一次**(重复会 panic
# `Overlapping method route`),所以「列表 GET + 新建 POST」必然链在一起。
# 老实现只取**第一个**方法 ⇒ 后面的方法**静默消失**:契约里写 implemented,
# 却报「代码里没有这条路由」(批次 14 踩到)。
cursor = p
while True:
mm = re.match(r"(get|post|put|delete)\s*\(", orig[cursor:])
if not mm:
break
if masked[cursor:cursor + len(mm.group(1))] != mm.group(1):
break # 方法名其实落在字符串里(误报)
method = mm.group(1).upper()
name_start = cursor + mm.end()
close = paren_span(masked, cursor + mm.end() - 1)
rest = orig[name_start:name_start + 240]
hm = HANDLER_RE.match(rest)
mod, fn, closure = None, None, True
if hm and hm.group(2):
mod, fn = hm.group(1), hm.group(2)
closure = False
out.append({
"path": route,
"method": method,
"mod": mod,
"fn": fn,
"closure": closure,
"owner": owner,
# 🔴 `source` 区分「路由住在哪」:平台层 / 业务模块(面 A)/ 业务包(面 B)。
# owner 会撞(包与模块同 app_code)⇒ 守卫推导与台账范围**必须**看这个。
"source": "platform" if owner == "platform" else "module",
"const": None,
"file": path,
})
# 顺着 `.` 走到下一个方法;遇到 `,` / `)` / 文件尾就停。
cursor = close + 1
while cursor < len(orig) and orig[cursor] in " \t\r\n":
cursor += 1
if cursor < len(orig) and orig[cursor] == ".":
cursor += 1
while cursor < len(orig) and orig[cursor] in " \t\r\n":
cursor += 1
continue
break
return out, orig, masked
+13 -10
View File
@@ -71,20 +71,23 @@ def read_backend() -> tuple[set[tuple[str, str]], list[str]]:
# `.route(\n "/api/x",\n get(h),\n)` 这种折行写法)。
# 🔴 不能见 `"/api/..."` 就收 —— `routes.rs` 里还有大量「期望路径」字符串
# 数组(自检用),照收会把未实现的路由误判成已实现。
lines = text.splitlines()
for i, line in enumerate(lines):
if "route(" not in line:
continue
window = "\n".join(lines[i : i + 4])
m = ROUTE_LIT.search(window)
# 🔴 按 `.route(` **切块**再逐块取路径与方法:一条 `.route()` 里可以链多个方法
# (`.route(p, get(a).post(b))` —— axum 同一个 path 只准注册一次,所以
# 「列表 GET + 新建 POST」必然链在一起)。
# 旧实现只看 4 行窗口里的**第一个**方法 ⇒ 后半段方法被漏掉,
# 已实现的端点仍被报成缺口。
for chunk in text.split(".route(")[1:]:
m = ROUTE_LIT.search(chunk)
if not m:
continue
path = m.group(1)
mm = METHOD_CALL.search(window[m.end() :])
if not mm:
warns.append(f"{f.relative_to(ROOT)}:{i + 1} 路径 {path} 找不到方法")
rest = chunk[m.end() :]
methods = {mm.group(1).upper() for mm in METHOD_CALL.finditer(rest)}
if not methods:
warns.append(f"{f.relative_to(ROOT)} 路径 {path} 找不到方法")
continue
found.add((mm.group(1).upper(), norm(path)))
for meth in methods:
found.add((meth, norm(path)))
return found, warns