赞
踩
展示:
def xtree(data):
list = []
dict = {}
if data:
for i in data:
dict[i['id']] = i
for j in data:
if j['pid'] == 0:
list.append(j)
else:
if 'son' not in dict[j['pid']]:
dict[j['pid']]['son'] = []
dict[j['pid']]['son'].append(j)
return list
删除:
async def delpermission(ns): db = DBPools() async with db.sqlorContext('kboss') as sor: if ns: ns['del_flg'] = '1' await sor.U('permission', ns) dictns = {'parentid': ns['id']} reacs = await sor.R('permission', dictns) for i in reacs: await delpermission({'id':i['id']}) return {'status': True, 'msg': '删除成功'} return {'status': False, 'msg': '删除失败'}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。