# 安全:只允许查询登录用户本人的余额。 # 历史问题:外部传任意 username 即可查询他人余额(且原文件有 swait 拼写错误,一调用就 500)。 userid = await get_user() env = request._run_ns async with get_sor_context(env, 'accounting') as sor: sql = """select d.username, c.name, a.balance from account a, subject c, users d where a.orgid = d.orgid and a.subjectid = c.id and d.id = ${userid}$ """ recs = await sor.sqlExe(sql, {'userid': userid}) return { 'status': 'ok', 'data': recs } return { 'status': 'error', 'data': { 'message': 'system error' } }