From 8e6510b77525bcce239704e051cedc02912fdfe5 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 24 Aug 2026 15:24:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(load=5Fpath):=20=E5=BA=93=E5=90=8Dsage?= =?UTF-8?q?=E2=86=92pipeline=20+=20=E6=B3=A8=E5=86=8Ctodo=5Fbadge/index=5F?= =?UTF-8?q?tab=E9=9D=99=E6=80=81JS=E6=9D=83=E9=99=90=20+=20=E8=A1=A5role?= =?UTF-8?q?=E5=85=B3=E8=81=94(=E4=BF=AE=E5=A4=8D/**=E6=BC=8F=E5=85=B3?= =?UTF-8?q?=E8=81=94)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/load_path.py | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/scripts/load_path.py b/scripts/load_path.py index 72e36c0..0d7d964 100644 --- a/scripts/load_path.py +++ b/scripts/load_path.py @@ -53,6 +53,8 @@ PERMS = [ # app root (any) ("/**", "app", "any"), ("/index.ui", "app", "any"), + ("/todo_badge.js", "app", "any"), + ("/index_tab.js", "app", "any"), ("/pipeline-sdlc/index.ui", "pipeline_sdlc", "any"), ("/pipeline_core/index.ui", "pipeline_core", "any"), ("/pipeline_ops/index.ui", "pipeline_ops", "any"), @@ -65,34 +67,40 @@ async def register(): DBPools(config.databases) initEnv() env = ServerEnv() - env.get_module_dbname = lambda m: "sage" + env.get_module_dbname = lambda m: "pipeline" - async with DBPools().sqlorContext("sage") as sor: + async with DBPools().sqlorContext("pipeline") as sor: total = 0 for path, module, role_name in PERMS: sql = "SELECT id FROM permission WHERE path=" + repr(path) + " LIMIT 1" existing = await sor.sqlExe(sql, {}) + pid = None if existing: - continue - - pid = getID() - await sor.C("permission", { - "id": pid, "name": module + ":" + path, - "path": path, "permtype": module - }) + pid = existing[0].id + else: + pid = getID() + await sor.C("permission", { + "id": pid, "name": module + ":" + path, + "path": path, "permtype": module + }) + total += 1 + # 补 role 关联(permission 已存在但 rolepermission 缺失时也要补,修复 /** 等历史漏关联) role_sql = "SELECT id FROM role WHERE name=" + repr(role_name) + " LIMIT 1" role_recs = await sor.sqlExe(role_sql, {}) if role_recs: - await sor.C("rolepermission", { - "id": getID(), - "roleid": role_recs[0].id, - "permid": pid - }) - total += 1 + rp_sql = ("SELECT id FROM rolepermission WHERE roleid=" + repr(role_recs[0].id) + + " AND permid=" + repr(pid) + " LIMIT 1") + rp_existing = await sor.sqlExe(rp_sql, {}) + if not rp_existing: + await sor.C("rolepermission", { + "id": getID(), + "roleid": role_recs[0].id, + "permid": pid + }) print(f"Registered {total} new permissions") # Verify - async with DBPools().sqlorContext("sage") as sor: + async with DBPools().sqlorContext("pipeline") as sor: cnt = await sor.sqlExe( "SELECT COUNT(*) as n FROM permission WHERE path LIKE '/pipeline%' OR path LIKE '/showcase%'", {}) print(f"Total pipeline permissions: {cnt[0].n}")