async def appCodesAdd(ns={}): """ add new app code `id` VARCHAR(32) 'id', `name` VARCHAR(255) '编码名称', `hierarchy_flg` VARCHAR(1) '多级标志', `del_flg` VARCHAR(1) DEFAULT '0' comment '删除标志', `create_at` TIMESTAMP comment '创建时间戳' :param ns: :return: """ db = DBPools() # if add kv table and id exists if ns.get('kv'): ns['id'] = uuid() async with db.sqlorContext('kboss') as sor: try: await sor.C('appcodes_kv', ns) return { "status": True, "msg": "appcodes_kv add success" } except Exception as e: return { "status": False, "msg": "appcodes_kv add failed" } app_code = { 'id': ns.get('id'), 'name': ns.get('name'), 'hierarchy_flg': ns.get('hierarchy_flg') } async with db.sqlorContext('kboss') as sor: try: if not ns.get('id'): return { "status": False, "msg": "app code id is empty" } # insert into appcodes await sor.C('appcodes', app_code) return { "status": True, "msg": "app codes add success" } except Exception as e: return { "status": False, "msg": "app codes add failed" } ret = await appCodesAdd(params_kw) return ret