Skip to content

Commit

Permalink
feat: add subject template group list api
Browse files Browse the repository at this point in the history
  • Loading branch information
zhu327 committed Dec 12, 2023
1 parent a20efec commit bfadf87
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 2 deletions.
10 changes: 10 additions & 0 deletions saas/backend/apps/subject/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@
views.SubjectPolicySearchViewSet.as_view({"post": "search"}),
name="subject.policy_search",
),
path(
"subject_template_groups/",
views.SubjectTemplateGroupViewSet.as_view({"post": "list"}),
name="subject.subject_template_group",
),
path(
"departments/-/subject_template_groups/",
views.DepartmentSubjectTemplateGroupViewSet.as_view({"post": "list"}),
name="subject.department.subject_template_group",
),
]
),
)
Expand Down
39 changes: 37 additions & 2 deletions saas/backend/apps/subject/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@
from backend.apps.group.models import Group
from backend.apps.group.serializers import GroupSearchSLZ
from backend.apps.policy.serializers import PolicyDeleteSLZ, PolicyPartDeleteSLZ, PolicySLZ, PolicySystemSLZ
from backend.apps.user.serializers import GroupSLZ, UserPolicySearchSLZ
from backend.apps.user.views import SubjectGroupSearchMixin, UserPolicySearchViewSet
from backend.apps.user.serializers import GroupSLZ, SubjectTemplateGroupSLZ, UserPolicySearchSLZ
from backend.apps.user.views import (
SubjectGroupSearchMixin,
UserDepartmentSubjectTemplateGroupViewSet,
UserPolicySearchViewSet,
UserSubjectTemplateGroupViewSet,
)
from backend.audit.audit import audit_context_setter, view_audit_decorator
from backend.biz.group import GroupBiz
from backend.biz.policy import ConditionBean, PolicyOperationBiz, PolicyQueryBiz
Expand Down Expand Up @@ -391,3 +396,33 @@ def search(self, request, *args, **kwargs):
def get_subject(self, request, kwargs):
subject = Subject(type=kwargs["subject_type"], id=kwargs["subject_id"])
return subject


class SubjectTemplateGroupViewSet(UserSubjectTemplateGroupViewSet):
@swagger_auto_schema(
operation_description="我的权限-人员模版用户组列表",
request_body=GroupSearchSLZ(label="用户组搜索"),
responses={status.HTTP_200_OK: SubjectTemplateGroupSLZ(label="用户组", many=True)},
tags=["subject"],
)
def list(self, request, *args, **kwargs):
return super().list(request, *args, **kwargs)

def get_subject(self, request, kwargs):
subject = Subject(type=kwargs["subject_type"], id=kwargs["subject_id"])
return subject


class DepartmentSubjectTemplateGroupViewSet(UserDepartmentSubjectTemplateGroupViewSet):
@swagger_auto_schema(
operation_description="我的权限-部门人员模版用户组列表",
request_body=GroupSearchSLZ(label="用户组搜索"),
responses={status.HTTP_200_OK: SubjectTemplateGroupSLZ(label="用户组", many=True)},
tags=["subject"],
)
def list(self, request, *args, **kwargs):
return super().list(request, *args, **kwargs)

def get_subject(self, request, kwargs):
subject = Subject(type=kwargs["subject_type"], id=kwargs["subject_id"])
return subject

0 comments on commit bfadf87

Please sign in to comment.