From cd74dbf45c829d197c2b808ee19b1d124d87479e Mon Sep 17 00:00:00 2001 From: "apan_youxiang@163.com" Date: Fri, 12 Aug 2022 17:28:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=9D=A1=E7=9B=AE=E6=95=B0?= =?UTF-8?q?=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/drug_form/views.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/apps/drug_form/views.py b/apps/drug_form/views.py index d23e034..b87caa7 100644 --- a/apps/drug_form/views.py +++ b/apps/drug_form/views.py @@ -54,14 +54,19 @@ def add_update_drug_form(): setattr(obj, 'is_del', 0) bll_obj.update(obj) else: - obj = EntityMedicamentExtend() - for i in finds: - setattr(obj, i, request.values.get(i)) - sort_index = bll_obj.execute( - "select max(sort_index) sort_index from rms_medicament_extend").fetchone() - setattr(obj, "sort_index", int(sort_index.sort_index or '0') + 1) - bll_obj.insert(obj) - return jsonify(Utils.true_return()) + count_num = bll_obj.execute( + "select count(id) count_num from rms_medicament_extend").fetchone() + if count_num.count_num < 30: + obj = EntityMedicamentExtend() + for i in finds: + setattr(obj, i, request.values.get(i)) + sort_index = bll_obj.execute( + "select max(sort_index) sort_index from rms_medicament_extend").fetchone() + setattr(obj, "sort_index", int(sort_index.sort_index or '0') + 1) + bll_obj.insert(obj) + return jsonify(Utils.true_return()) + else: + return jsonify(Utils.false_return()) @drug_form_router.route("/del", methods=["GET", "POST"]) @token_auth.login_required