diff --git a/mg/handlers/apps_v4_handler.py b/mg/handlers/apps_v4_handler.py index d78f5bb..2a4bc56 100644 --- a/mg/handlers/apps_v4_handler.py +++ b/mg/handlers/apps_v4_handler.py @@ -14,7 +14,7 @@ from libs.base_handler import BaseHandler from models.authority import RoleApps -from services.app_service import get_apps_list_for_main, get_apps_list_for_api, opt_obj, get_apps_list_for_role +from services.app_service import get_apps_list_for_main, get_apps_list_for_api, opt_obj, get_apps_list_for_role, get_apps_list_for_frontend class RoleAPPHandler(BaseHandler, ABC): @@ -100,11 +100,17 @@ def get(self, *args, **kwargs): self.write(res) +class FrontendAppListHandler(BaseHandler, ABC): + def get(self, *args, **kwargs): + res = get_apps_list_for_frontend(**self.params) + self.write(res) + + apps_urls = [ (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/apps/list/", AppListHandler, {"handle_name": "PAAS-基础功能-查看应用-待删除", "method": ["GET"]}), # TODO 待删除 + (r"/v4/na/apps/list/", FrontendAppListHandler) # 免认证查看应用列表 ] if __name__ == "__main__": diff --git a/mg/handlers/business_v4_handler.py b/mg/handlers/business_v4_handler.py index 4ba3a9d..8fb86e8 100644 --- a/mg/handlers/business_v4_handler.py +++ b/mg/handlers/business_v4_handler.py @@ -144,8 +144,8 @@ 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/na/biz/list/", BizListNaHandler, {"handle_name": "PAAS-基础功能-免认证查看业务列表", "method": ["GET"]}), - (r"/v4/na/biz/change/", BizChangeNaHandler, {"handle_name": "PAAS-基础功能-免认证切换业务", "method": ["GET"]}) + (r"/v4/na/biz/list/", BizListNaHandler), # 免认证查看业务列表 + (r"/v4/na/biz/change/", BizChangeNaHandler) # 免认证切换业务 ] if __name__ == "__main__": pass diff --git a/mg/handlers/roles_v4_handler.py b/mg/handlers/roles_v4_handler.py index bc85593..c22de48 100644 --- a/mg/handlers/roles_v4_handler.py +++ b/mg/handlers/roles_v4_handler.py @@ -163,12 +163,12 @@ async def post(self, *args, **kwargs): roles_v4_urls = [ (r"/v4/role/list/", RoleListHandler, {"handle_name": "PAAS-基础功能-查看常规角色列表", "method": ["GET"]}), (r"/v4/role/base_list/", RoleBaseListHandler, {"handle_name": "PAAS-基础功能-查看所有基础角色", "method": ["GET"]}), - (r"/v3/accounts/role/", RoleHandler, {"handle_name": "角色列表-待销毁", "method": ["ALL"]}), + # (r"/v3/accounts/role/", RoleHandler, {"handle_name": "角色列表-待销毁", "method": ["ALL"]}), (r"/v4/role/", RoleHandler, {"handle_name": "权限中心-角色管理V4", "method": ["ALL"]}), (r"/v4/role/sync/", RoleSyncHandler, {"handle_name": "权限中心-角色权限同步", "method": ["ALL"]}), (r"/v4/role_user/", RoleUserHandler, {"handle_name": "权限中心-角色用户管理", "method": ["ALL"]}), # TODO 暂时保留 - (r"/v3/accounts/all_role_user/", RoleUserAllHandler, {"handle_name": "查询所有用户角色-待废弃", "method": ["GET"]}), + # (r"/v3/accounts/all_role_user/", RoleUserAllHandler, {"handle_name": "查询所有用户角色-待废弃", "method": ["GET"]}), (r"/v4/all_role_user/", RoleUserAllHandler, {"handle_name": "权限中心-查询所有用户角色V4", "method": ["GET"]}) ] diff --git a/mg/handlers/sys_index_handler.py b/mg/handlers/sys_index_handler.py index 163091a..1aa4d12 100644 --- a/mg/handlers/sys_index_handler.py +++ b/mg/handlers/sys_index_handler.py @@ -96,12 +96,12 @@ def get(self, *args, **kwargs): index_step_urls = [ - (r"/v4/ops-step-service/", IndexStepHandler, {"handle_name": "PAAS-基础功能-首页步骤管理", "method": ["ALL"]}), - (r"/v4/ops-service-categories/", ServiceCategoriesHandler, {"handle_name": "PAAS-基础功能-首页服务列表", "method": ["ALL"]}), - (r"/v4/ops-index-service/", IndexServiceHandler, {"handle_name": "PAAS-基础功能-首页服务管理", "method": ["ALL"]}), - (r"/v4/na/index-step/", IndexStep, {"handle_name": "PAAS-基础功能-首页步骤", "method": ["GET"]}), # 免认证 - (r"/v4/na/index-service-categories/", ServiceCategories, {"handle_name": "PAAS-基础功能-首页服务定制表", "method": ["GET"]}), - (r"/v4/na/index-service/", IndexService, {"handle_name": "PAAS-基础功能-首页服务", "method": ["GET"]}) # 免认证 + (r"/v4/ops-step-service/", IndexStepHandler, {"handle_name": "PAAS管理-首页-步骤管理", "method": ["ALL"]}), + (r"/v4/ops-service-categories/", ServiceCategoriesHandler, {"handle_name": "PAAS管理-首页-服务列表", "method": ["ALL"]}), + (r"/v4/ops-index-service/", IndexServiceHandler, {"handle_name": "PAAS管理-首页-服务管理", "method": ["ALL"]}), + (r"/v4/na/index-step/", IndexStep), # 免认证 首页步骤" + (r"/v4/na/index-service-categories/", ServiceCategories), # 免认证 首页服务定制表 + (r"/v4/na/index-service/", IndexService) # 免认证 首页服务 ] if __name__ == "__main__": diff --git a/mg/handlers/sys_mg_v4_handler.py b/mg/handlers/sys_mg_v4_handler.py index 9ae2e12..2a552d2 100644 --- a/mg/handlers/sys_mg_v4_handler.py +++ b/mg/handlers/sys_mg_v4_handler.py @@ -252,8 +252,8 @@ def post(self, *args, **kwargs): sys_mg_v4_urls = [ - (r"/v4/app/opt_log/", LogV4Handler, {"handle_name": "PAAS管理-操作日志V4"}), - (r"/v4/na/conf/", OpenConfHandler), # PAAS管理-开放配置v4 + (r"/v4/app/opt_log/", LogV4Handler, {"handle_name": "PAAS管理-操作日志V4", "method": ["GET"]}), + (r"/v4/na/conf/", OpenConfHandler), # PAAS-基础功能-开放配置 (r'/v4/sysconfig/settings/', AppSettingsHandler, {"handle_name": "PAAS管理-系统设置", "method": ["ALL"]}), (r'/v4/sysconfig/check/', CheckSettingsHandler, {"handle_name": "PAAS管理-系统设置检查", "method": ["ALL"]}), (r'/v4/authority/register/', AuthorityRegister, {"handle_name": "PAAS管理-权限注册", "method": ["ALL"]}), diff --git a/mg/handlers/users_v4_handler.py b/mg/handlers/users_v4_handler.py index 34ec17e..db5fc52 100644 --- a/mg/handlers/users_v4_handler.py +++ b/mg/handlers/users_v4_handler.py @@ -186,7 +186,6 @@ def get(self): (r"/v4/user/send_addr/", UserAddrHandler, {"handle_name": "PAAS-基础功能-查看用户联系方式", "method": ["GET"]}), (r"/v4/reset_mfa/", ResetMFAHandler, {"handle_name": "PAAS管理-重置二次认证", "method": ["ALL"]}), (r"/v4/reset_pw/", ResetPasswordHandler, {"handle_name": "PAAS管理-重置密码", "method": ["ALL"]}), - (r"/v3/accounts/user/", UserHandler, {"handle_name": "权限中心-用户管理-待废弃", "method": ["ALL"]}), (r"/v4/user/", UserHandler, {"handle_name": "权限中心-用户管理V4", "method": ["ALL"]}), ] diff --git a/services/app_service.py b/services/app_service.py index 82dc0e3..03caed6 100644 --- a/services/app_service.py +++ b/services/app_service.py @@ -13,7 +13,7 @@ from websdk2.sqlalchemy_pagination import paginate # from websdk2.model_utils import CommonOptView, queryset_to_list -from libs.feature_model_utils import CommonOptView, queryset_to_list +from libs.feature_model_utils import CommonOptView, queryset_to_list, model_to_dict from models.authority import RoleApps from models.paas_model import AppsModel @@ -56,3 +56,24 @@ def get_apps_list_for_role(role_id: int) -> list: RoleApps.role_id == role_id, RoleApps.status == '0', AppsModel.status == '0').all() return queryset_to_list(app_info) + + +def get_apps_list_for_frontend(**params) -> dict: + with DBContext('r') as session: + apps = session.query(AppsModel).all() + filtered_apps = [] + for app in apps: + __dict = model_to_dict(app) + frontend_code = __dict.get('frontend_code') + if frontend_code == 'no': + continue + __dict["app_code"] = frontend_code if frontend_code else __dict.get('app_code') # TODO 前端变更后删除 + __dict["frontend_code"] = frontend_code if frontend_code else __dict.get('app_code') + + filtered_apps.append(__dict) + return { + 'code': 0, + 'msg': '获取成功', + 'data': filtered_apps, + 'count': len(filtered_apps) # 统计符合条件的应用数量 + }