From f1719fbe44fb0ab4814236f230b342b0a682cf1a Mon Sep 17 00:00:00 2001 From: shenshuo <191715030@qq.com> Date: Fri, 13 Dec 2024 12:39:53 +0800 Subject: [PATCH] =?UTF-8?q?2024=E5=B9=B412=E6=9C=8813=E6=97=A5=20=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=BA=94=E7=94=A8=E7=AE=A1=E7=90=8602?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- libs/registration.py | 56 ++++++++++++++++++++---------- mg/handlers/apps_v4_handler.py | 3 +- mg/handlers/business_v4_handler.py | 2 +- mg/handlers/sys_mg_v4_handler.py | 28 +++++++-------- 4 files changed, 51 insertions(+), 38 deletions(-) diff --git a/libs/registration.py b/libs/registration.py index 90932b6..f522839 100644 --- a/libs/registration.py +++ b/libs/registration.py @@ -4,11 +4,13 @@ Version : 0.0.1 Contact : 191715030@qq.com Author : shenshuo -Date : 2021/11/1 17:07 -Desc : 注册各种信息到pass平台 +Date : 2024/12/13 17:07 +Desc : 注册各种信息到管理平台 """ import json +import logging + from websdk2.client import AcsClient from websdk2.configs import configs from settings import settings @@ -16,40 +18,39 @@ if configs.can_import: configs.import_dict(**settings) client = AcsClient() -# uri = "/api/mg/v3/accounts/authority/register/" uri = "/api/p/v4/authority/register/" menu_list = [ { "name": "MGauthority", - "details": "权限-权限管理" + "details": "管理后台-权限-权限管理" }, { "name": "MGuserlist", - "details": "权限-用户列表" + "details": "管理后台-权限-用户列表" }, { "name": "MGtokenlist", - "details": "权限-令牌列表" + "details": "管理后台-权限-令牌列表" }, { "name": "MGLinklist", - "details": "权限-免密链接" + "details": "管理后台-权限-免密链接" }, { "name": "MGapplist", - "details": "权限-应用列表" + "details": "管理后台-权限-应用列表" }, { "name": "MGbusiness", - "details": "权限-业务管理列表" + "details": "管理后台-权限-业务管理列表" }, { "name": "MGmenus", - "details": "权限-菜单列表" + "details": "管理后台-权限-菜单列表" }, { "name": "MGcomponents", - "details": "权限-前端组件" + "details": "管理后台-权限-前端组件" }, { "name": "MGfunctions", - "details": "权限-权限列表" + "details": "管理后台-权限-权限列表" }, { "name": "MGrole", - "details": "权限-角色管理" + "details": "管理后台-权限-角色管理" }, { "name": "systeMmanage", @@ -61,19 +62,19 @@ }, { "name": "systemEmail", - "details": "管理后台-邮件设置" + "details": "管理后台-配置-邮件设置" }, { "name": "systemLdap", - "details": "管理后台-LDAP设置" + "details": "管理后台-配置-LDAP设置" }, { "name": "systemBase", - "details": "管理后台-基础设置" + "details": "管理后台-配置-基础设置" }, { "name": "systemFeishu", - "details": "管理后台-飞书设置" + "details": "管理后台-配置-飞书设置" }, { "name": "systemAudit", @@ -83,6 +84,22 @@ "name": "systemAuditLog", "details": "管理后台-审计日志" }, + { + "name": "homepageManage", + "details": "管理后台-首页管理" + }, + { + "name": "MGopsService", + "details": "管理后台-首页管理-导航页步骤" + }, + { + "name": "MGopsGlobalCategory", + "details": "管理后台-首页管理-导航页项目分类" + }, + { + "name": "MGopsGlobalService", + "details": "管理后台-首页管理-导航页项目服务" + }, ] component_list = [ { @@ -242,7 +259,7 @@ def registration_to_paas(): body=json.dumps(body), description='自动注册') response = client.do_action(**registration_data) - print(json.loads(response)) + logging.info(json.loads(response)) return response @@ -250,6 +267,7 @@ class Registration: def __init__(self, **kwargs): pass - def start_server(self): + @staticmethod + def start_server(): registration_to_paas() raise Exception('初始化完成') diff --git a/mg/handlers/apps_v4_handler.py b/mg/handlers/apps_v4_handler.py index ed06d11..d78f5bb 100644 --- a/mg/handlers/apps_v4_handler.py +++ b/mg/handlers/apps_v4_handler.py @@ -104,8 +104,7 @@ def get(self, *args, **kwargs): (r"/v4/apps/", AppsV4Handler, {"handle_name": "PAAS管理-应用管理", "method": ["ALL"]}), (r"/v4/role_app/", RoleAPPHandler, {"handle_name": "权限中心-应用角色管理", "method": ["ALL"]}), (r"/v4/apps/list/", AppListHandler, {"handle_name": "PAAS-基础功能-查看应用列表", "method": ["GET"]}), - (r"/v4/na/apps/list/", AppListHandler, {"handle_name": "PAAS-基础功能-免认证查看应用列表", "method": ["GET"]}), - + (r"/v4/na/apps/list/", AppListHandler, {"handle_name": "PAAS-基础功能-免认证查看应用列表", "method": ["GET"]}) ] if __name__ == "__main__": diff --git a/mg/handlers/business_v4_handler.py b/mg/handlers/business_v4_handler.py index 019e33b..4ba3a9d 100644 --- a/mg/handlers/business_v4_handler.py +++ b/mg/handlers/business_v4_handler.py @@ -143,7 +143,7 @@ def get(self): biz_v4_mg_urls = [ (r"/v4/biz/", BusinessHandler, {"handle_name": "权限中心-业务管理", "method": ["ALL"]}), - (r"/v4/biz/list/", BusinessListHandler, {"handle_name": "PAAS基础功能-查看业务列表和切换", "method": ["GET"]}), + (r"/v4/biz/list/", BusinessListHandler, {"handle_name": "PAAS-基础功能-查看业务列表和切换", "method": ["GET"]}), (r"/v4/na/biz/list/", BizListNaHandler, {"handle_name": "PAAS-基础功能-免认证查看业务列表", "method": ["GET"]}), (r"/v4/na/biz/change/", BizChangeNaHandler, {"handle_name": "PAAS-基础功能-免认证切换业务", "method": ["GET"]}) ] diff --git a/mg/handlers/sys_mg_v4_handler.py b/mg/handlers/sys_mg_v4_handler.py index 9b71faa..9ae2e12 100644 --- a/mg/handlers/sys_mg_v4_handler.py +++ b/mg/handlers/sys_mg_v4_handler.py @@ -9,6 +9,7 @@ import base64 import json +import logging from abc import ABC from concurrent.futures import ThreadPoolExecutor @@ -106,14 +107,15 @@ def post(self, *args, **kwargs): try: self.register_func(func_list) except Exception as err: - print(err) - return self.write(dict(code=-2, msg='注册API权限失败')) + logging.error(f"注册API权限失败 {err}") + # return self.write(dict(code=-2, msg='注册API权限失败')) if menu_list and isinstance(menu_list, list): try: self.register_menu(menu_list) except Exception as err: - return self.write(dict(code=-3, msg='注册前端菜单失败')) + logging.error(f"注册前端菜单失败 {err}") + # return self.write(dict(code=-3, msg='注册前端菜单失败')) if component_list and isinstance(component_list, list): try: @@ -130,23 +132,19 @@ def post(self, *args, **kwargs): return self.write(dict(code=0, msg='注册结束')) def register_menu(self, data): - for d in data: - menu_name = d.get('name') - details = d.get('details', '')[0:250] - if not menu_name: continue + valid_data = filter(lambda d: d.get('name'), data) + for d in valid_data: with DBContext('w', None, True) as session: + menu_name = d['name'] + details = (d.get('details') or '')[:250] try: session.add(insert_or_update(Menus, f"menu_name='{menu_name}' and app_code='{self.app_code}'", - app_code=self.app_code, details=details, - menu_name=menu_name)) - except exc.IntegrityError as e: - print(e) + app_code=self.app_code, details=details, menu_name=menu_name)) except Exception as err: - print(err) - + logging.error(err) + session.commit() def register_component(self, data): for d in data: - status = d.get('status', '0') name = d.get('name') details = d.get('details', '')[0:250] if not name: continue @@ -155,8 +153,6 @@ def register_component(self, data): session.add(insert_or_update(Components, f"name='{name}' and app_code='{self.app_code}'", app_code=self.app_code, details=details, name=name)) - except exc.IntegrityError as e: - print(e) except Exception as err: print(err)