feat: 返回数据增加belong_dept_name等

This commit is contained in:
caoqianming 2023-07-25 14:24:21 +08:00
parent 841815bbb6
commit a668ca0b2f
3 changed files with 5 additions and 3 deletions

View File

@ -84,6 +84,8 @@ class MpointStatSerializer(CustomModelSerializer):
class EnStatSerializer(CustomModelSerializer):
mgroup_name = serializers.CharField(source='mgroup.name', read_only=True)
team_name = serializers.CharField(source='team.name', read_only=True)
belong_dept_name = serializers.CharField(source='mgroup.belong_dept.name', read_only=True)
class Meta:
model = EnStat
fields = '__all__'

View File

@ -65,5 +65,5 @@ class EnStatViewSet(ListModelMixin, CustomGenericViewSet):
perms_map = {'get': '*'}
queryset = EnStat.objects.all()
serializer_class = EnStatSerializer
select_related_fields = ['mgroup']
select_related_fields = ['mgroup', 'team', 'mgroup__belong_dept']
filterset_class = EnStatFilter

View File

@ -66,6 +66,6 @@ class GoalViewSet(CustomModelViewSet):
"""
queryset = Goal.objects.all()
serializer_class = GoalSerializer
select_related_fields = ['mgroup', 'product', 'team', 'goal_cate']
filterset_fields = ['mgroup', 'product', 'team', 'goal_cate', 'year', 'goal_cate__code']
select_related_fields = ['mgroup', 'goal_cate']
filterset_fields = ['mgroup', 'goal_cate', 'year', 'goal_cate__code']
search_fields = ['name']