feat(app): ListMarket 支持可管理公司安装分布(InstalledCompanies),市场接口对管理员附带管理范围内已装公司名
This commit is contained in:
1 parent
d6c72b5ef9
commit
c122f80261
3 files changed
+40
-5
No files matched your search
@@ -5,7 +5,7 @@
|
||||
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>GERP 管理系统</title>
|
||||
<script type="module" crossorigin src="/assets/index-B8Srzqt1.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index-DwrTmOE5.js"></script>
|
||||
<link rel="modulepreload" crossorigin href="/assets/rolldown-runtime-hePW80VL.js">
|
||||
<link rel="modulepreload" crossorigin href="/assets/element-plus-DtMR4CIi.js">
|
||||
<link rel="modulepreload" crossorigin href="/assets/utils-C0vl14oO.js">
|
||||
@@ -14,7 +14,7 @@
|
||||
<link rel="modulepreload" crossorigin href="/assets/formkit-DL7Nej8X.js">
|
||||
<link rel="modulepreload" crossorigin href="/assets/vue-vendor-DmO0PmrK.js">
|
||||
<link rel="modulepreload" crossorigin href="/assets/serverScope-C6yhSV7-.js">
|
||||
<link rel="stylesheet" crossorigin href="/assets/style-C9mOjRHK.css">
|
||||
<link rel="stylesheet" crossorigin href="/assets/style-BKPzjs47.css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
@@ -54,8 +54,14 @@ def _ToBytes(value):
|
||||
return value
|
||||
|
||||
|
||||
def _AppFlat(app, tenant_installed=None, user_record=None, company_installed=None):
|
||||
"""App 实例 → 市场/我的应用视图 dict"""
|
||||
def _AppFlat(app, tenant_installed=None, user_record=None, company_installed=None,
|
||||
installed_companies=None):
|
||||
"""App 实例 → 市场/我的应用视图 dict
|
||||
|
||||
Args:
|
||||
installed_companies: 管理员视角——可管理范围内已装该应用的公司名列表
|
||||
(非管理员/未传时为空列表,前端仅在管理员视图渲染)
|
||||
"""
|
||||
return {
|
||||
'AppUUID': UUIDObj(app.AppUUID).str,
|
||||
'AppCode': app.AppCode,
|
||||
@@ -75,6 +81,8 @@ def _AppFlat(app, tenant_installed=None, user_record=None, company_installed=Non
|
||||
'TenantAuth': tenant_installed.AuthStatus if tenant_installed else 0,
|
||||
# 公司维度安装(指定公司安装时 TenantInstalled=0、CompanyInstalled=1)
|
||||
'CompanyInstalled': 1 if company_installed and company_installed.InstallStatus == 1 else 0,
|
||||
# 管理员视角:可管理范围内已装该应用的公司名(前端卡片标记"管理"依据)
|
||||
'InstalledCompanies': list(installed_companies or []),
|
||||
'UserEnabled': 1 if user_record and user_record.UseStatus == 1 else 0,
|
||||
'ApplyStatus': user_record.ApplyStatus if user_record else 0,
|
||||
}
|
||||
@@ -100,13 +108,16 @@ class AppManager:
|
||||
return App.objects.filter(AppUUID=_ToBytes(AppUUID)).first()
|
||||
|
||||
@staticmethod
|
||||
def ListMarket(TenantUUID=None, UserUUID=None, CompanyUUID=None):
|
||||
def ListMarket(TenantUUID=None, UserUUID=None, CompanyUUID=None, ManageableCompanies=None):
|
||||
"""应用市场列表——每个应用附带租户/公司安装状态与个人启用/申请状态
|
||||
|
||||
Args:
|
||||
TenantUUID: 当前租户 UUID(bytes/str/UUIDObj),用于标注"企业功能已安装"
|
||||
UserUUID: 当前用户 UUID,用于标注"个人已启用/申请中"
|
||||
CompanyUUID: 当前公司 UUID(可选),用于标注"指定公司已安装"
|
||||
ManageableCompanies: 管理员可管理公司 UUID 列表(可选);
|
||||
传入时附加 InstalledCompanies=可管理范围内已装该应用的公司名,
|
||||
供前端对"非本公司的安装"也显示"管理"与卡片标记。
|
||||
|
||||
Returns:
|
||||
list[dict]
|
||||
@@ -127,6 +138,23 @@ class AppManager:
|
||||
if user_bytes:
|
||||
for ua in UserApp.objects.filter(UserUUID=user_bytes):
|
||||
user_map[UUIDObj(ua.AppUUID).str] = ua
|
||||
# 管理员视角:可管理范围内已装各应用的公司名(app str -> [公司名])
|
||||
installed_companies_map = {}
|
||||
manageable_bytes = [_ToBytes(c) for c in (ManageableCompanies or []) if _ToBytes(c)]
|
||||
if manageable_bytes:
|
||||
from gvsdsdk.models import Company as SdkCompany
|
||||
company_name_map = {
|
||||
_ToBytes(c.CompanyUUID): c.CompanyName
|
||||
for c in SdkCompany.objects.filter(CompanyUUID__in=manageable_bytes)
|
||||
}
|
||||
app_bytes_list = [_ToBytes(a.AppUUID) for a in apps]
|
||||
for ca in CompanyApp.objects.filter(
|
||||
AppUUID__in=app_bytes_list,
|
||||
CompanyUUID__in=manageable_bytes,
|
||||
InstallStatus=1):
|
||||
name = company_name_map.get(_ToBytes(ca.CompanyUUID))
|
||||
if name:
|
||||
installed_companies_map.setdefault(UUIDObj(ca.AppUUID).str, []).append(name)
|
||||
result = []
|
||||
for app in apps:
|
||||
key = UUIDObj(app.AppUUID).str
|
||||
@@ -135,6 +163,7 @@ class AppManager:
|
||||
tenant_installed=tenant_map.get(key),
|
||||
user_record=user_map.get(key),
|
||||
company_installed=company_map.get(key),
|
||||
installed_companies=installed_companies_map.get(key),
|
||||
))
|
||||
return result
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import logging
|
||||
from rest_framework.permissions import IsAuthenticated
|
||||
from rest_framework.response import Response
|
||||
|
||||
from gvsdsdk.auth.admin_service import IsAdmin
|
||||
from gvsdsdk.auth.permissions import IsAdminUser
|
||||
from gvsdsdk.model_utils import UUIDObj
|
||||
|
||||
@@ -109,10 +110,15 @@ class AppMarketView(ELTAuthenticatedAPIView):
|
||||
permission_classes = [IsAuthenticated]
|
||||
|
||||
def get(self, request):
|
||||
# 管理员视角:传入可管理公司列表,附加 InstalledCompanies(管理范围内已装公司名)
|
||||
manageable = None
|
||||
if IsAdmin(request=request):
|
||||
manageable, _scope = AppManager.GetManageableCompanies(request)
|
||||
data = AppManager.ListMarket(
|
||||
TenantUUID=_GetTenantBytes(request),
|
||||
UserUUID=_GetUserBytes(request),
|
||||
CompanyUUID=_GetCompanyBytes(request),
|
||||
ManageableCompanies=manageable,
|
||||
)
|
||||
return Response({'code': 0, 'data': {'list': data, 'total': len(data)}})
|
||||
|
||||
|
||||
Reference in new issue
Block a user