Skip to content

Commit

Permalink
2024年12月13日 优化应用管理03
Browse files Browse the repository at this point in the history
  • Loading branch information
ss1917 committed Dec 13, 2024
1 parent f1719fb commit 748b487
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 17 deletions.
12 changes: 9 additions & 3 deletions mg/handlers/apps_v4_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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__":
Expand Down
4 changes: 2 additions & 2 deletions mg/handlers/business_v4_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions mg/handlers/roles_v4_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]})
]

Expand Down
12 changes: 6 additions & 6 deletions mg/handlers/sys_index_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__":
Expand Down
4 changes: 2 additions & 2 deletions mg/handlers/sys_mg_v4_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}),
Expand Down
1 change: 0 additions & 1 deletion mg/handlers/users_v4_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]}),
]

Expand Down
23 changes: 22 additions & 1 deletion services/app_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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) # 统计符合条件的应用数量
}

0 comments on commit 748b487

Please sign in to comment.