时间:2021-07-01 10:21:17 帮助过:248人阅读
然后在视图层中
@api.route(‘/company_goods‘, methods=[‘GET‘, ‘POST‘]) def company_goods(): if request.method == ‘GET‘: company_id = request.args.get(‘company_id‘, ‘‘) category_id = request.args.get(‘category_id‘, ‘‘) data=CompanyGoodsModel.get_info_by_id(company_id, category_id) result=[] for d in data: d.goods_info=eval(d[‘goods_info‘]) result.append(d.to_json()) if not result: return json_response(‘0001‘, {}, ‘数据获取失败 ‘) return json_response(‘0000‘, result, ‘数据获取成功‘)
将sqlalchemy 查询结果转化成json格式
标签:json格式 company route for base val model app 一个