From a804307892456432827cd2aa1a08f2908dd623f2 Mon Sep 17 00:00:00 2001 From: "apan_youxiang@163.com" Date: Fri, 9 Sep 2022 09:57:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=95=E5=89=82=E8=AF=A6=E6=83=85bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Common/Utils.py | 3 +++ apps/drug/views.py | 7 +++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Common/Utils.py b/Common/Utils.py index b0bdd1b..90a4ee1 100644 --- a/Common/Utils.py +++ b/Common/Utils.py @@ -42,6 +42,9 @@ class Utils(object): def classify(num, all_num, fl=2): return str(round(float(round(float(num) / all_num, fl)) * 100)) + "%" # return str(round(float(round(math.ceil(num) / all_num, fl)) * 100)) + "%" + + def model_to_dict(cls): + return {c.name: getattr(cls, c.name, None) for c in cls.__table__.columns} #获取唯一识别码 def UUID(): diff --git a/apps/drug/views.py b/apps/drug/views.py index 871dbb0..9484206 100644 --- a/apps/drug/views.py +++ b/apps/drug/views.py @@ -128,10 +128,9 @@ def drug_use_retur_list(): @token_auth.login_required def get_drug_info(): bar_code = request.values.get("bar_code") - data_list = BllMedicament().get_bar_code_drug_info(bar_code=bar_code) - if data_list: - data_info = data_list[0] - return jsonify(Utils.true_return(data=Utils.msyql_table_model(data_info))) + data = BllMedicament().findEntity(EntityMedicament.bar_code == bar_code) + if data: + return jsonify(Utils.true_return(data=Utils.model_to_dict(data))) else: return jsonify(Utils.false_return(msg="条码有误"))