diff --git a/apps/power/views.py b/apps/power/views.py index c325df0..fb795f3 100644 --- a/apps/power/views.py +++ b/apps/power/views.py @@ -45,10 +45,10 @@ def get_power_list(): # 获取模块列表 @power_router.route("/get_module_list", methods=["GET", "POST"]) -@token_auth.login_required +# @token_auth.login_required def get_module_list(): data_list = BllModule().get_module_list() - return jsonify(Utils.true_return(data=Utils.msyql_table_model(data_list))) + return jsonify(Utils.true_return(data=data_list)) # 添加角色 @power_router.route("/add_update_role", methods=["GET", "POST"]) @@ -57,8 +57,8 @@ def add_role(): role_id = request.values.get("role_id") role_code = request.values.get("role_code") role_name = request.values.get("role_name") - sys_module_list = request.values.get("sys_module_list") - client_module_list = request.values.get("client_module_list") + sys_module_list = request.values.getlist("sys_module") + client_module_list = request.values.getlist("client_module") description = request.values.get("description") # 获取角色代码或者角色名的角色信息 obj = BllRole().findEntity( @@ -127,6 +127,8 @@ def add_role(): @token_auth.login_required def remove_role(): role_id = request.values.get("role_id") - BllRole().delete(EntityRole.role_id==role_id) - BllModuleRelation().delete(EntityModuleRelation.object_id==role_id) - return jsonify(Utils.true_return(msg="删除成功")) + if role_id: + BllRole().delete(EntityRole.role_id==role_id) + BllModuleRelation().delete(EntityModuleRelation.object_id==role_id) + return jsonify(Utils.true_return(msg="删除成功")) + return jsonify(Utils.false_return(msg="请选择角色")) \ No newline at end of file diff --git a/apps/user/views.py b/apps/user/views.py index db49906..6cc7bbc 100644 --- a/apps/user/views.py +++ b/apps/user/views.py @@ -121,5 +121,7 @@ def update_user_info(): @token_auth.login_required def del_user(): user_id = request.values.get("user_id") - BllUser().delete(EntityUser.user_id==user_id) - return jsonify(Utils.true_return(msg="删除成功")) + if user_id: + BllUser().delete(EntityUser.user_id==user_id) + return jsonify(Utils.true_return(msg="删除成功")) + return jsonify(Utils.false_return("未选择用户")) diff --git a/db_logic/module.py b/db_logic/module.py index 50c3a4c..6765d58 100644 --- a/db_logic/module.py +++ b/db_logic/module.py @@ -19,7 +19,19 @@ class BllModule(Repository): sql_all = """ select module_id, module_type, module_name, sort_index, description from rms_module where is_enabled=1 """ - return self.execute(sql_all).fetchall() + data = { + "sys_list":[], + "client_list":[] + } + sql_data = Utils.msyql_table_model(self.execute(sql_all).fetchall()) + for i in sql_data: + if i['module_type'] == "2": + data["sys_list"].append(i) + if i["module_type"] == "1": + data["client_list"].append(i) + data["sys_list"].sort(key=lambda x: x['sort_index']) + data["client_list"].sort(key=lambda x: x['sort_index']) + return data # return self.findList().all() def inster_info_list(self): @@ -44,11 +56,11 @@ class BllModule(Repository): obj_list.append(obj) self.insert_many(obj_list) -# if __name__ == '__main__': - # from Common.Utils import Utils - # aaa = BllModule().get_module_list() +if __name__ == '__main__': + from Common.Utils import Utils + aaa = BllModule().get_module_list() # print([i for i in aaa]) - # aaa_list = Utils.to_dict(aaa, 1) - # for i in aaa_list: - # print(i) - # print(aaa) + aaa_list = Utils.to_dict(aaa, 1) + for i in aaa_list: + print(i) + print(aaa)