13
13
14
14
from application .serializers .chat_message_serializers import ChatMessageSerializer
15
15
from application .serializers .chat_serializers import ChatSerializers , ChatRecordSerializer
16
- from application .swagger_api .chat_api import ChatApi , VoteApi , ChatRecordApi , ImproveApi , ChatRecordImproveApi
16
+ from application .swagger_api .chat_api import ChatApi , VoteApi , ChatRecordApi , ImproveApi , ChatRecordImproveApi , \
17
+ ChatClientHistoryApi
17
18
from common .auth import TokenAuth , has_permissions
18
19
from common .constants .authentication_type import AuthenticationType
19
20
from common .constants .permission_constants import Permission , Group , Operate , \
@@ -137,6 +138,28 @@ def delete(self, request: Request, application_id: str, chat_id: str):
137
138
data = {'application_id' : application_id , 'user_id' : request .user .id ,
138
139
'chat_id' : chat_id }).delete ())
139
140
141
+ class ClientChatHistoryPage (APIView ):
142
+ authentication_classes = [TokenAuth ]
143
+
144
+ @action (methods = ['GET' ], detail = False )
145
+ @swagger_auto_schema (operation_summary = "分页获取客户端对话列表" ,
146
+ operation_id = "分页获取客户端对话列表" ,
147
+ manual_parameters = result .get_page_request_params (
148
+ ChatClientHistoryApi .get_request_params_api ()),
149
+ responses = result .get_page_api_response (ChatApi .get_response_body_api ()),
150
+ tags = ["应用/对话日志" ]
151
+ )
152
+ @has_permissions (
153
+ ViewPermission ([RoleConstants .APPLICATION_ACCESS_TOKEN ],
154
+ [lambda r , keywords : Permission (group = Group .APPLICATION , operate = Operate .USE ,
155
+ dynamic_tag = keywords .get ('application_id' ))])
156
+ )
157
+ def get (self , request : Request , application_id : str , current_page : int , page_size : int ):
158
+ return result .success (ChatSerializers .ClientChatHistory (
159
+ data = {'client_id' : request .auth .client_id , 'application_id' : application_id }).page (
160
+ current_page = current_page ,
161
+ page_size = page_size ))
162
+
140
163
class Page (APIView ):
141
164
authentication_classes = [TokenAuth ]
142
165
@@ -198,7 +221,7 @@ def get(self, request: Request, application_id: str, chat_id: str, chat_record_i
198
221
def get (self , request : Request , application_id : str , chat_id : str ):
199
222
return result .success (ChatRecordSerializer .Query (
200
223
data = {'application_id' : application_id ,
201
- 'chat_id' : chat_id }).list ())
224
+ 'chat_id' : chat_id , 'order_asc' : request . query_params . get ( 'order_asc' ) }).list ())
202
225
203
226
class Page (APIView ):
204
227
authentication_classes = [TokenAuth ]
@@ -219,7 +242,8 @@ class Page(APIView):
219
242
def get (self , request : Request , application_id : str , chat_id : str , current_page : int , page_size : int ):
220
243
return result .success (ChatRecordSerializer .Query (
221
244
data = {'application_id' : application_id ,
222
- 'chat_id' : chat_id }).page (current_page , page_size ))
245
+ 'chat_id' : chat_id , 'order_asc' : request .query_params .get ('order_asc' )}).page (current_page ,
246
+ page_size ))
223
247
224
248
class Vote (APIView ):
225
249
authentication_classes = [TokenAuth ]
0 commit comments