-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add management grade manager subject template list api (#2498)
- Loading branch information
Showing
12 changed files
with
197 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
""" | ||
TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-权限中心(BlueKing-IAM) available. | ||
Copyright (C) 2017-2021 THL A29 Limited, a Tencent company. All rights reserved. | ||
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at http://opensource.org/licenses/MIT | ||
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
specific language governing permissions and limitations under the License. | ||
""" | ||
|
||
from django.shortcuts import get_object_or_404 | ||
from drf_yasg.utils import swagger_auto_schema | ||
from rest_framework import status | ||
from rest_framework.response import Response | ||
from rest_framework.viewsets import GenericViewSet | ||
|
||
from backend.api.authentication import ESBAuthentication | ||
from backend.api.management.constants import ManagementAPIEnum, VerifyApiParamLocationEnum | ||
from backend.api.management.v2.permissions import ManagementAPIPermission | ||
from backend.api.management.v2.serializers import ManagementSubjectTemplateSLZ | ||
from backend.apps.role.models import Role | ||
from backend.apps.subject_template.filters import SubjectTemplateFilter | ||
from backend.biz.role import RoleListQuery | ||
from backend.common.filters import NoCheckModelFilterBackend | ||
from backend.service.constants import RoleType | ||
|
||
|
||
class ManagementGradeManagerSubjectTemplateViewSet(GenericViewSet): | ||
"""分级管理员下人员模版""" | ||
|
||
authentication_classes = [ESBAuthentication] | ||
permission_classes = [ManagementAPIPermission] | ||
|
||
management_api_permission = { | ||
"list": (VerifyApiParamLocationEnum.ROLE_IN_PATH.value, ManagementAPIEnum.V2_SUBJECT_TEMPLATE_LIST.value), | ||
} | ||
|
||
lookup_field = "id" | ||
queryset = Role.objects.filter(type__in=[RoleType.GRADE_MANAGER.value, RoleType.SUBSET_MANAGER.value]).order_by( | ||
"-updated_time" | ||
) | ||
filterset_class = SubjectTemplateFilter | ||
filter_backends = [NoCheckModelFilterBackend] | ||
|
||
@swagger_auto_schema( | ||
operation_description="人员模版列表", | ||
responses={status.HTTP_200_OK: ManagementSubjectTemplateSLZ(label="人员模版", many=True)}, | ||
tags=["management.role.subject_template"], | ||
) | ||
def list(self, request, *args, **kwargs): | ||
role = get_object_or_404(self.queryset, id=kwargs["id"]) | ||
|
||
queryset = RoleListQuery(role).query_subject_template() | ||
queryset = self.filter_queryset(queryset) | ||
|
||
page = self.paginate_queryset(queryset) | ||
if page is not None: | ||
serializer = ManagementSubjectTemplateSLZ(page, many=True) | ||
return self.get_paginated_response(serializer.data) | ||
|
||
serializer = ManagementSubjectTemplateSLZ(queryset, many=True) | ||
return Response(serializer.data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
saas/resources/apigateway/docs/zh/v2_management_grade_manager_list_subject_templates.md.j2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
### 查询分级管理员下人员模版列表 | ||
|
||
#### Parameters | ||
| 字段 | 类型 | 位置 | 必须 | 描述 | | ||
|---|---|---|---|---| | ||
| name | string | query | 否 | 人员模版名称筛选 | | ||
| id | int | query | 否 | 人员模版id筛选 | | ||
| description | string | query | 否 | 人员模版描述筛选 | | ||
| page_size | int | query | 是 | 分页大小, 最大500 | | ||
| page | int | query | 是 | 分页 | | ||
|
||
#### Request | ||
```json | ||
GET /api/v2/open/management/systems/demo/grade_managers/1/subject_templates/?page_size=100&page=1 | ||
``` | ||
|
||
#### Response | ||
|
||
> Status: 200 OK | ||
|
||
| 字段 | 类型 | 描述 | | ||
|---|---|---| | ||
| id| int | 人员模版ID | | ||
| name| string | 人员模版名称 | | ||
| description| string | 人员模版描述 | | ||
| readonly| bool| 是否是只读人员模版| | ||
| source_group_id| int| 来源用户组ID | | ||
|
||
```json | ||
{ | ||
"code": 0, | ||
"message": "ok", | ||
"data": { | ||
"count": 1, | ||
"results": [ | ||
{ | ||
"id": 1, | ||
"name": "人员模版", | ||
"description": "人员模版", | ||
"readonly": false, | ||
"source_group_id": 0 | ||
} | ||
] | ||
} | ||
} | ||
``` | ||
|
||
{% include '_api_v2_status_code.md.j2' %} |