async def delOrganization(ns,sor=None): """删除机构""" if not sor: db = DBPools() async with db.sqlorContext('kboss') as sor: if ns: ns['del_flg'] = '1' await sor.U('organization', ns) sql_user = """update users set del_flg = 1 where orgid = '%s'""" % ns.get('id') await sor.sqlExe(sql_user,{}) sql_customer = """update customer set del_flg = 1 where customerid = '%s'""" % ns.get('id') await sor.sqlExe(sql_customer,{}) dictns = {'parentid': ns['id']} reacs = await sor.R('organization', dictns) for i in reacs: await delOrganization({'id': i['id']},sor) return {'status': True, 'msg': '删除成功'} else: if ns: ns['del_flg'] = '1' await sor.U('organization', ns) sql_user = """update users set del_flg = 1 where orgid = '%s'""" % ns.get('id') await sor.sqlExe(sql_user, {}) sql_customer = """update customer set del_flg = 1 where customerid = '%s'""" % ns.get('id') await sor.sqlExe(sql_customer, {}) dictns = {'parentid': ns['id']} reacs = await sor.R('organization', dictns) for i in reacs: await delOrganization({'id': i['id']}, sor) return {'status': True, 'msg': '删除成功'} return {'status': False, 'msg': '删除失败'} ret = await delOrganization(params_kw) return ret