fix: add batch get access mode api

This commit is contained in:
GareArc
2025-04-11 15:24:32 -04:00
parent cb13b53ccd
commit 5f87bdbe3a
7 changed files with 86 additions and 68 deletions

View File

@ -66,9 +66,14 @@ class AppListApi(Resource):
return {"data": [], "total": 0, "page": 1, "limit": 20, "has_more": False}
if FeatureService.get_system_features().webapp_auth.enabled:
app_ids = [str(app.id) for app in app_pagination.items]
res = EnterpriseService.WebAppAuth.batch_get_app_access_mode_by_id(app_ids=app_ids)
if len(res) != len(app_ids):
raise BadRequest("Invalid app id in webapp auth")
for app in app_pagination.items:
app_setting = EnterpriseService.get_app_access_mode_by_id(app_id=str(app.id))
app.access_mode = app_setting.access_mode
if str(app.id) in res:
app.access_mode = res[str(app.id)].access_mode
return marshal(app_pagination, app_pagination_fields), 200
@ -115,7 +120,7 @@ class AppApi(Resource):
app_model = app_service.get_app(app_model)
if FeatureService.get_system_features().webapp_auth.enabled:
app_setting = EnterpriseService.get_app_access_mode_by_id(app_id=str(app_model.id))
app_setting = EnterpriseService.WebAppAuth.get_app_access_mode_by_id(app_id=str(app_model.id))
app_model.access_mode = app_setting.access_mode
return app_model