Historical conversation batch delete
This commit is contained in:
parent
6ca6c5b6d3
commit
ad44d4d6b2
@ -132,6 +132,17 @@ class HistoricalConversationOperateSerializer(serializers.Serializer):
|
|||||||
chat_user_id=self.data.get('chat_user_id')).update(is_deleted=True)
|
chat_user_id=self.data.get('chat_user_id')).update(is_deleted=True)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
class Clear(serializers.Serializer):
|
||||||
|
application_id = serializers.UUIDField(required=True, label=_('Application ID'))
|
||||||
|
chat_user_id = serializers.UUIDField(required=True, label=_('Chat User ID'))
|
||||||
|
|
||||||
|
def batch_logic_delete(self, with_valid=True):
|
||||||
|
if with_valid:
|
||||||
|
self.is_valid(raise_exception=True)
|
||||||
|
QuerySet(Chat).filter(application_id=self.data.get('application_id'),
|
||||||
|
chat_user_id=self.data.get('chat_user_id')).update(is_deleted=True)
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
class HistoricalConversationRecordSerializer(serializers.Serializer):
|
class HistoricalConversationRecordSerializer(serializers.Serializer):
|
||||||
application_id = serializers.UUIDField(required=True, label=_('Application ID'))
|
application_id = serializers.UUIDField(required=True, label=_('Application ID'))
|
||||||
|
|||||||
@ -20,6 +20,7 @@ urlpatterns = [
|
|||||||
path('historical_conversation', views.HistoricalConversationView.as_view(), name='historical_conversation'),
|
path('historical_conversation', views.HistoricalConversationView.as_view(), name='historical_conversation'),
|
||||||
path('historical_conversation/<str:chat_id>/record/<str:chat_record_id>',views.ChatRecordView.as_view(),name='conversation_details'),
|
path('historical_conversation/<str:chat_id>/record/<str:chat_record_id>',views.ChatRecordView.as_view(),name='conversation_details'),
|
||||||
path('historical_conversation/<int:current_page>/<int:page_size>', views.HistoricalConversationView.PageView.as_view(), name='historical_conversation'),
|
path('historical_conversation/<int:current_page>/<int:page_size>', views.HistoricalConversationView.PageView.as_view(), name='historical_conversation'),
|
||||||
|
path('historical_conversation/clear',views.HistoricalConversationView.BatchDelete.as_view(), name='historical_conversation_clear'),
|
||||||
path('historical_conversation/<str:chat_id>',views.HistoricalConversationView.Operate.as_view(), name='historical_conversation_operate'),
|
path('historical_conversation/<str:chat_id>',views.HistoricalConversationView.Operate.as_view(), name='historical_conversation_operate'),
|
||||||
path('historical_conversation_record/<str:chat_id>', views.HistoricalConversationRecordView.as_view(), name='historical_conversation_record'),
|
path('historical_conversation_record/<str:chat_id>', views.HistoricalConversationRecordView.as_view(), name='historical_conversation_record'),
|
||||||
path('historical_conversation_record/<str:chat_id>/<int:current_page>/<int:page_size>', views.HistoricalConversationRecordView.PageView.as_view(), name='historical_conversation_record')
|
path('historical_conversation_record/<str:chat_id>/<int:current_page>/<int:page_size>', views.HistoricalConversationRecordView.PageView.as_view(), name='historical_conversation_record')
|
||||||
|
|||||||
@ -99,6 +99,24 @@ class HistoricalConversationView(APIView):
|
|||||||
'chat_id': chat_id,
|
'chat_id': chat_id,
|
||||||
}).logic_delete())
|
}).logic_delete())
|
||||||
|
|
||||||
|
class BatchDelete(APIView):
|
||||||
|
authentication_classes = [TokenAuth]
|
||||||
|
|
||||||
|
@extend_schema(
|
||||||
|
methods=['DELETE'],
|
||||||
|
description=_("Batch delete history conversation"),
|
||||||
|
summary=_("Batch delete history conversation"),
|
||||||
|
operation_id=_("Batch delete history conversation"), # type: ignore
|
||||||
|
parameters=HistoricalConversationOperateAPI.get_parameters(),
|
||||||
|
responses=HistoricalConversationOperateAPI.get_response(),
|
||||||
|
tags=[_('Chat')] # type: ignore
|
||||||
|
)
|
||||||
|
def delete(self, request: Request):
|
||||||
|
return result.success(HistoricalConversationOperateSerializer.Clear(data={
|
||||||
|
'application_id': request.auth.application_id,
|
||||||
|
'chat_user_id': request.auth.chat_user_id,
|
||||||
|
}).batch_logic_delete())
|
||||||
|
|
||||||
class PageView(APIView):
|
class PageView(APIView):
|
||||||
authentication_classes = [TokenAuth]
|
authentication_classes = [TokenAuth]
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user