From 71e17ad4948acb383acbb14564c5918d17e36fbd Mon Sep 17 00:00:00 2001 From: yumoqing Date: Fri, 20 Mar 2026 15:57:23 +0800 Subject: [PATCH] bugfix --- set_role_perm.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/set_role_perm.py b/set_role_perm.py index a660423..9652fd0 100644 --- a/set_role_perm.py +++ b/set_role_perm.py @@ -10,25 +10,18 @@ async def delete_anonymous_perm(sor, permid): 'permid': permid }) -async def add_roleperm(sor, roleid, path, permid=None): - if permid is None: - perms = await sor.R('permission', {'path': path}) - if perms: - permid = perms[0].id +async def add_roleperm(sor, roleid, permid): ns = { 'roleid': roleid, 'permid': permid } - recs = await sor.R('rolepermission', ns) + recs = await sor.R('rolepermission', ns.copy()) if recs: - print(f'{role}, {path} 已经存在') + print(f'{role}, {permid} 已经存在') return - await sor.C('rolepermission', { - 'id': getID(), - 'roleid': 'anonymous', - 'perid': p.id - }) - print(f'{role}, {path} perm add') + ns['id'] = getID() + await sor.C('rolepermission', ns) + print(f'{role}, {permid} perm add') return async def main():