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