diff --git a/apps/drug/views.py b/apps/drug/views.py index 73f780b..7584b4f 100644 --- a/apps/drug/views.py +++ b/apps/drug/views.py @@ -154,7 +154,7 @@ def get_drug_manage(): # 编辑数据 @drug_router.route("/update", methods=["GET", "POST"]) @token_auth.login_required -def drug_add_update(): +def drug_update(): finds_list = [ "name", "english_name", "bar_code", "cas_number", "purity", "shelf_life", "production_date", "expiration_date", @@ -177,6 +177,19 @@ def drug_add_update(): return jsonify(Utils.true_return(msg="条码不能重复")) return jsonify(Utils.true_return(msg="试剂id不能为空")) + +# 编辑数据 +@drug_router.route("/del", methods=["GET", "POST"]) +@token_auth.login_required +def drug_del(): + drug_id = request.values.get("medicament_id") + try: + BllMedicament().delete(EntityMedicament.medicament_id==drug_id) + return jsonify(Utils.true_return()) + except Exception: + return jsonify(Utils.except_return(msg="删除失败")) + + # 流转记录 @drug_router.route("/get_durg_record", methods=["GET", "POST"]) @token_auth.login_required diff --git a/db_logic/dangerous.py b/db_logic/dangerous.py index 979e8d2..fd76100 100644 --- a/db_logic/dangerous.py +++ b/db_logic/dangerous.py @@ -21,9 +21,11 @@ class BllDangerous(Repository): filter_base = "" if seach_word: seach_word = f"'%{seach_word}%'" - filter_base += f" name like {seach_word} or english_name like {seach_word}" + filter_base += f" name like {seach_word} or english_name like {seach_word} " + if filter_base: + filter_base = f" where {filter_base} " sql_all = f""" - select * from rms_msds {filter_base} + select * from rms_dangerous {filter_base} """ try: count_number = len(self.execute(sql_all).fetchall()) diff --git a/db_logic/meidcament_variety.py b/db_logic/meidcament_variety.py index 264ea03..ae895eb 100644 --- a/db_logic/meidcament_variety.py +++ b/db_logic/meidcament_variety.py @@ -114,3 +114,23 @@ class BllMedicamentVariety(Repository): # new_data = dict(data_dict, **med) # new_data_list.append(new_data) # return new_data_list +# def inster_type_drug(self): +# name_list = ["氧化钠", "砷", "硫酸"] +# for i in name_list: +# obj = EntityMedicamentVariety( +# name=i, +# purity='国标', +# inventory_warning_value=10, +# shelf_life_warning_value=10, +# use_days_warning_value=10, +# empty_count=0, +# use_count=0, +# normal_count=10, +# total_count=10, +# create_date=Utils.get_str_datetime(), +# create_user_id='4cea74ee-0d8b-11ed-943e-f47b094925e1' +# ) +# self.insert(obj) + +# if __name__ == '__main__': +# BllMedicamentVariety().inster_type_drug() \ No newline at end of file diff --git a/db_logic/msds.py b/db_logic/msds.py index 77d4d20..a5d2db9 100644 --- a/db_logic/msds.py +++ b/db_logic/msds.py @@ -23,7 +23,9 @@ class BllMsDs(Repository): filter_base = "" if seach_word: seach_word = f"'%{seach_word}%'" - filter_base += f" name like {seach_word} or english_name like {seach_word}" + filter_base += f" name like {seach_word} or english_name like {seach_word} " + if filter_base: + filter_base = f" where {filter_base} " sql_all = f""" select * from rms_msds {filter_base} """