feat:增加消息记录功能

This commit is contained in:
2026-06-19 21:10:03 +08:00
parent bb1160ad18
commit 5d12377606
23 changed files with 458 additions and 170 deletions

19
lib/apis/message_api.dart Normal file
View 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();
}