From 596ff39a624abaae7b1396cb09693a88a6721a60 Mon Sep 17 00:00:00 2001 From: "apan_youxiang@163.com" Date: Mon, 15 Aug 2022 09:21:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7=E6=9D=83?= =?UTF-8?q?=E9=99=90=E8=BF=94=E5=9B=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/power/views.py | 2 +- db_logic/module_relation.py | 30 ++++++++++++++++++++++++++---- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/apps/power/views.py b/apps/power/views.py index 4b92922..a237cdd 100644 --- a/apps/power/views.py +++ b/apps/power/views.py @@ -85,7 +85,7 @@ def get_login_user_power_list(): # user_info = BllUser().findEntity(user_id) module_list = BllModuleRelation().get_login_user_module_list( user_id=user_info.user_id, role_id=user_info.role_id) - module_list = Utils.msyql_table_model(module_list) + # module_list = Utils.msyql_table_model(module_list) return jsonify(Utils.true_return(data=module_list)) # 获取角色标签列表 diff --git a/db_logic/module_relation.py b/db_logic/module_relation.py index e057635..3d1c849 100644 --- a/db_logic/module_relation.py +++ b/db_logic/module_relation.py @@ -18,20 +18,42 @@ class BllModuleRelation(Repository): def get_login_user_module_list(self, user_id, role_id): sql_all = f""" - select c.module_id, c.module_code, c.sort_index, c.module_name from( + select c.module_id, c.module_code, c.sort_index, c.module_name, c.module_type from( - SELECT a.module_id, b.module_code, b.sort_index, b.module_name + SELECT a.module_id, b.module_code, b.sort_index, b.module_name, b.module_type from rms_module_relation as a LEFT JOIN rms_module as b on a.module_id=b.module_id WHERE object_id='{user_id}' AND object_type=2 AND b.module_type!=1 UNION - SELECT a.module_id, b.module_code, b.sort_index, b.module_name + SELECT a.module_id, b.module_code, b.sort_index, b.module_name, b.module_type from rms_module_relation as a LEFT JOIN rms_module as b on a.module_id=b.module_id WHERE object_id='{role_id}' AND object_type=1 AND b.module_type!=1 ) c ORDER BY c.sort_index asc """ - return self.execute(sql_all).fetchall() + sql_data = self.execute(sql_all).fetchall() + data = Utils.msyql_table_model(sql_data) + data_dict = { + "client_manage": [], + "drug_manage": [], + "standard_manage": [], + "consumables_manage": [], + "instrument_manage": [] + } + for i in data: + if i["module_type"] == "1": + data_dict["client_manage"].append(i) + elif i["module_type"] == "2": + data_dict["drug_manage"].append(i) + elif i["module_type"] == "3": + data_dict["standard_manage"].append(i) + elif i["module_type"] == "4": + data_dict["consumables_manage"].append(i) + elif i["module_type"] == "5": + data_dict["instrument_manage"].append(i) + + return data_dict + # return self.execute(sql_all).fetchall() def get_user_module_list(self, user_info): sql_all = f"""