完善状态查找达人接口

This commit is contained in:
Zixiao Wang 2025-06-05 11:34:03 +08:00
parent 165ad823f5
commit cbe13c319b

View File

@ -27,6 +27,7 @@ from .models import Product, Negotiation, Message
from .serializers import NegotiationSerializer
from apps.daren_detail.models import CreatorProfile
from apps.brands.models import Product
from django.forms.models import model_to_dict
client = Client(host="http://localhost:11434")
class ContentAnalysisAPI(APIView):
@ -400,17 +401,21 @@ class NegotiationViewSet(viewsets.ModelViewSet):
# 获取所有相关的达人
creators = CreatorProfile.objects.filter(negotiation__in=negotiations).distinct()
if creators.exists():
# 序列化达人数据
creator_data = [{'name': creator.name, 'category': creator.category, 'followers': creator.followers} for
creator in creators]
# 返回所有字段信息
creator_data = [self._get_creator_full_info(creator) for creator in creators]
else:
creator_data = []
print("creator_data: ", creator_data)
return Response({
'code': 200,
'message': '成功找到符合条件的达人',
'data': creator_data
})
def _get_creator_full_info(self, creator):
# 返回creator的所有字段为字典
return model_to_dict(creator, exclude=['avatar'])
@action(detail=False, methods=['post'])
def offer_status(self, request):
"""获取谈判状态"""