66 @date:2025/6/23 10:42
77 @desc:
88"""
9+ from django .utils .translation import gettext_lazy as _
910from drf_spectacular .utils import extend_schema
1011from rest_framework .request import Request
1112from rest_framework .views import APIView
12- from django .utils .translation import gettext_lazy as _
1313
14+ from chat .api .chat_api import HistoricalConversationAPI , PageHistoricalConversationAPI
1415from chat .api .vote_api import VoteAPI
15- from chat .serializers .chat_record import VoteSerializer
16+ from chat .serializers .chat_record import VoteSerializer , ChatRecordSerializer
1617from common import result
1718from common .auth import TokenAuth
1819
@@ -35,3 +36,42 @@ def put(self, request: Request, chat_id: str, chat_record_id: str):
3536 data = {'chat_id' : chat_id ,
3637 'chat_record_id' : chat_record_id
3738 }).vote (request .data ))
39+
40+
41+ class HistoricalConversationView (APIView ):
42+ authentication_classes = [TokenAuth ]
43+
44+ @extend_schema (
45+ methods = ['GET' ],
46+ description = _ ("Get historical conversation" ),
47+ summary = _ ("Get historical conversation" ),
48+ operation_id = _ ("Get historical conversation" ), # type: ignore
49+ parameters = HistoricalConversationAPI .get_parameters (),
50+ responses = HistoricalConversationAPI .get_response (),
51+ tags = [_ ('Chat' )] # type: ignore
52+ )
53+ def get (self , request : Request ):
54+ return result .success (ChatRecordSerializer (
55+ data = {
56+ 'application_id' : request .auth .application_id ,
57+ 'chat_user_id' : request .auth .chat_user_id ,
58+ }).list ())
59+
60+ class PageView (APIView ):
61+ authentication_classes = [TokenAuth ]
62+
63+ @extend_schema (
64+ methods = ['GET' ],
65+ description = _ ("Get historical conversation by page" ),
66+ summary = _ ("Get historical conversation by page" ),
67+ operation_id = _ ("Get historical conversation by page" ), # type: ignore
68+ parameters = PageHistoricalConversationAPI .get_parameters (),
69+ responses = PageHistoricalConversationAPI .get_response (),
70+ tags = [_ ('Chat' )] # type: ignore
71+ )
72+ def get (self , request : Request , current_page : int , page_size : int ):
73+ return result .success (ChatRecordSerializer (
74+ data = {
75+ 'application_id' : request .auth .application_id ,
76+ 'chat_user_id' : request .auth .chat_user_id ,
77+ }).page (current_page , page_size ))
0 commit comments