feat:增加消息记录功能
This commit is contained in:
19
lib/apis/message_api.dart
Normal file
19
lib/apis/message_api.dart
Normal file
@@ -0,0 +1,19 @@
|
||||
import 'package:sweet_chat_app/models/chat_message.dart';
|
||||
import 'package:sweet_chat_app/models/chat_session.dart';
|
||||
import 'package:sweet_chat_app/services/dio_service.dart';
|
||||
|
||||
Future<List<ChatSession>> getChatSessionApi(int userId) async {
|
||||
final res = await dioService.get('/message/session/$userId');
|
||||
|
||||
if (res.data == null) return [];
|
||||
|
||||
return (res.data as List).map((e) => ChatSession.fromJson(e)).toList();
|
||||
}
|
||||
|
||||
Future<List<ChatMessage>> getChatMessageApi(int conversationId) async {
|
||||
final res = await dioService.get('/message/session/$conversationId/detail');
|
||||
|
||||
if (res.data == null) return [];
|
||||
|
||||
return (res.data as List).map((e) => ChatMessage.fromJson(e)).toList();
|
||||
}
|
||||
Reference in New Issue
Block a user