fix: to_dict

This commit is contained in:
ymq 2026-08-12 12:07:41 +08:00
parent a4e7d88993
commit fa9e37af51

View File

@ -2,15 +2,10 @@
dbname = get_module_dbname('rbac') dbname = get_module_dbname('rbac')
async with DBPools().sqlorContext(dbname) as sor: async with DBPools().sqlorContext(dbname) as sor:
# Check all perms recs = await sor.sqlExe("SELECT * FROM rolepermission WHERE roleid='any' LIMIT 3", {})
recs = await sor.sqlExe("SELECT * FROM rolepermission LIMIT 5", {}) result = []
if recs: for r in (recs or []):
cols = [k for k in dir(recs[0]) if not k.startswith('_')] d = r.to_dict() if hasattr(r, 'to_dict') else {}
else: result.append(d)
cols = []
# Check for login path in all perms return json.dumps({"any_perms": result}, ensure_ascii=False, default=str)
count = await sor.sqlExe("SELECT COUNT(*) as c FROM rolepermission", {})
tc = getattr(count[0], "c", 0) if count else 0
return json.dumps({"columns": cols, "total_perms": tc}, ensure_ascii=False)