This commit is contained in:
yumoqing 2026-03-20 15:57:23 +08:00
parent 8d5af5cad2
commit 71e17ad494

View File

@ -10,25 +10,18 @@ async def delete_anonymous_perm(sor, permid):
'permid': permid 'permid': permid
}) })
async def add_roleperm(sor, roleid, path, permid=None): async def add_roleperm(sor, roleid, permid):
if permid is None:
perms = await sor.R('permission', {'path': path})
if perms:
permid = perms[0].id
ns = { ns = {
'roleid': roleid, 'roleid': roleid,
'permid': permid 'permid': permid
} }
recs = await sor.R('rolepermission', ns) recs = await sor.R('rolepermission', ns.copy())
if recs: if recs:
print(f'{role}, {path} 已经存在') print(f'{role}, {permid} 已经存在')
return return
await sor.C('rolepermission', { ns['id'] = getID()
'id': getID(), await sor.C('rolepermission', ns)
'roleid': 'anonymous', print(f'{role}, {permid} perm add')
'perid': p.id
})
print(f'{role}, {path} perm add')
return return
async def main(): async def main():