fix: check rolepermission columns

This commit is contained in:
ymq 2026-08-12 12:07:31 +08:00
parent 99cb2ad8f8
commit a4e7d88993

View File

@ -2,12 +2,15 @@
dbname = get_module_dbname('rbac')
async with DBPools().sqlorContext(dbname) as sor:
recs = await sor.sqlExe(
"SELECT path, roleid FROM rolepermission WHERE path LIKE '%%login%%'", {})
perms = [{"path": getattr(r, "path", ""), "roleid": getattr(r, "roleid", "")} for r in (recs or [])]
# Check all perms
recs = await sor.sqlExe("SELECT * FROM rolepermission LIMIT 5", {})
if recs:
cols = [k for k in dir(recs[0]) if not k.startswith('_')]
else:
cols = []
recs2 = await sor.sqlExe(
"SELECT path, roleid FROM rolepermission WHERE path LIKE '%%up_login%%' OR path LIKE '%%login.ui%%'", {})
perms2 = [{"path": getattr(r, "path", ""), "roleid": getattr(r, "roleid", "")} for r in (recs2 or [])]
# Check for login path in all perms
count = await sor.sqlExe("SELECT COUNT(*) as c FROM rolepermission", {})
tc = getattr(count[0], "c", 0) if count else 0
return json.dumps({"login_perms": perms, "up_login_perms": perms2}, ensure_ascii=False)
return json.dumps({"columns": cols, "total_perms": tc}, ensure_ascii=False)