修改禁用逻辑及参数

duizhaopin
apan 2 years ago
parent 86e4dd32ed
commit 29494e15c0

@ -198,10 +198,14 @@ def get_durg_record():
@token_auth.login_required @token_auth.login_required
def drug_ban_user_list(): def drug_ban_user_list():
seach_user = request.values.get("seach_user") seach_user = request.values.get("seach_user")
drug_id = request.values.get("drug_id")
page = int(request.values.get("page", 1)) page = int(request.values.get("page", 1))
page_size = int(request.values.get("page_size", 10)) page_size = int(request.values.get("page_size", 10))
page_param = PageParam(page, page_size) page_param = PageParam(page, page_size)
data_list = BllUserMedicament().get_user_jin_medicament(seach_user=seach_user, page_param=page_param) data_list = BllUserMedicament().get_user_jin_medicament(
seach_user=seach_user, page_param=page_param,
drug_id=drug_id
)
return jsonify(Utils.true_return(data={"data": Utils.msyql_table_model(data_list), "total_count": page_param.totalRecords})) return jsonify(Utils.true_return(data={"data": Utils.msyql_table_model(data_list), "total_count": page_param.totalRecords}))
# 确认禁用 # 确认禁用
@ -216,21 +220,21 @@ def drug_ban_user_confirm():
else: else:
return jsonify(Utils.false_return()) return jsonify(Utils.false_return())
# 获取用户禁用试剂列表 # # 获取用户禁用试剂列表
@drug_router.route("/user_ban_drug_list", methods=["GET", "POST"]) # @drug_router.route("/user_ban_drug_list", methods=["GET", "POST"])
@token_auth.login_required # @token_auth.login_required
def get_user_ban_drug_list(): # def get_user_ban_drug_list():
user_id = request.values.get("user_id") # user_id = request.values.get("user_id")
data_list = BllUserMedicament().get_user_drug_name(user_id) # data_list = BllUserMedicament().get_user_drug_name(user_id)
return jsonify(Utils.true_return(data=Utils.msyql_table_model(data_list))) # return jsonify(Utils.true_return(data=Utils.msyql_table_model(data_list)))
# 取消禁用试剂 # 取消禁用试剂
@drug_router.route("/user_ban_relieve", methods=["GET", "POST"]) @drug_router.route("/user_ban_relieve", methods=["GET", "POST"])
@token_auth.login_required @token_auth.login_required
def user_ban_relieve(): def user_ban_relieve():
user_id = request.values.get("user_id") user_id = request.values.get("user_id")
drug_list = request.values.get("drug_list") drug_id = request.values.get("drug_id")
data = BllUserMedicament().del_user_ban_drug(user_id=user_id, drug_list=drug_list) data = BllUserMedicament().del_user_ban_drug(user_id=user_id, drug_id=drug_id)
if data: if data:
return jsonify(Utils.true_return(msg="删除成功")) return jsonify(Utils.true_return(msg="删除成功"))
else: else:

@ -32,7 +32,7 @@ class BllUserMedicament(Repository):
else: else:
return True return True
def get_user_jin_medicament(self, seach_user, page_param): def get_user_jin_medicament(self, seach_user, drug_id, page_param):
filter_base = "" filter_base = ""
if seach_user: if seach_user:
filter_base += f" real_name like '%{seach_user}%'" filter_base += f" real_name like '%{seach_user}%'"
@ -41,12 +41,11 @@ class BllUserMedicament(Repository):
sql_all = f""" sql_all = f"""
select select
a.user_id, b.real_name, b.role_name, group_concat(c.`name`) drug_name a.user_id, a.real_name, a.role_name,
from rms_user_medicament as a CASE WHEN b.id is not null THEN 1 else 0 END status_type
LEFT JOIN (select real_name, user_id, role_name from rms_user {filter_base}) from (select * from rms_user {filter_base}) as a
LEFT JOIN (select id, user_id, drug_id from rms_user_medicament WHERE drug_id='{drug_id}')
as b on a.user_id=b.user_id as b on a.user_id=b.user_id
LEFT JOIN rms_medicament_variety as c on a.drug_id=c.variety_id
GROUP BY a.user_id
""" """
try: try:
count_number = len(self.execute(sql_all).fetchall()) count_number = len(self.execute(sql_all).fetchall())
@ -64,15 +63,19 @@ class BllUserMedicament(Repository):
""" """
return self.execute(sql_all).fetchall() return self.execute(sql_all).fetchall()
def del_user_ban_drug(self, user_id, drug_list): def del_user_ban_drug(self, user_id, drug_id):
try: try:
data_list = self.findList(and_( self.delete(and_(
EntityUserMedicament.user_id==user_id, EntityUserMedicament.user_id == user_id,
EntityUserMedicament.drug_id.in_(eval(drug_list)) EntityUserMedicament.drug_id == drug_id
)).all() ))
for i in data_list: # data_list = self.findList(and_(
self.session.delete(i) # EntityUserMedicament.user_id==user_id,
self.session.commit() # EntityUserMedicament.drug_id.in_(eval(drug_list))
# )).all()
# for i in data_list:
# self.session.delete(i)
# self.session.commit()
return True return True
except: except:
return False return False

Loading…
Cancel
Save