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"""