refactor(apps): 重构数据层目录结构并新增启动预热编排器
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
enum InboxMessageType { friendRequest, calendar, system, group }
|
||||
|
||||
enum InboxMessageStatus { pending, accepted, rejected, dismissed }
|
||||
|
||||
class InboxMessage {
|
||||
final String id;
|
||||
final String recipientId;
|
||||
final String? senderId;
|
||||
final InboxMessageType messageType;
|
||||
final String? scheduleItemId;
|
||||
final String? friendshipId;
|
||||
final Map<String, dynamic>? content;
|
||||
final bool isRead;
|
||||
final InboxMessageStatus status;
|
||||
final DateTime createdAt;
|
||||
|
||||
const InboxMessage({
|
||||
required this.id,
|
||||
required this.recipientId,
|
||||
required this.senderId,
|
||||
required this.messageType,
|
||||
required this.scheduleItemId,
|
||||
required this.friendshipId,
|
||||
required this.content,
|
||||
required this.isRead,
|
||||
required this.status,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
factory InboxMessage.fromJson(Map<String, dynamic> json) {
|
||||
return InboxMessage(
|
||||
id: json['id'] as String,
|
||||
recipientId: json['recipient_id'] as String,
|
||||
senderId: json['sender_id'] as String?,
|
||||
messageType: _messageTypeFromApi(json['message_type'] as String),
|
||||
scheduleItemId: json['schedule_item_id'] as String?,
|
||||
friendshipId: json['friendship_id'] as String?,
|
||||
content: json['content'] as Map<String, dynamic>?,
|
||||
isRead: json['is_read'] as bool,
|
||||
status: _messageStatusFromApi(json['status'] as String),
|
||||
createdAt: DateTime.parse(json['created_at'] as String),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
InboxMessageType _messageTypeFromApi(String raw) {
|
||||
switch (raw) {
|
||||
case 'friend_request':
|
||||
return InboxMessageType.friendRequest;
|
||||
case 'calendar':
|
||||
return InboxMessageType.calendar;
|
||||
case 'system':
|
||||
return InboxMessageType.system;
|
||||
case 'group':
|
||||
return InboxMessageType.group;
|
||||
default:
|
||||
throw StateError('Unsupported inbox message type: $raw');
|
||||
}
|
||||
}
|
||||
|
||||
InboxMessageStatus _messageStatusFromApi(String raw) {
|
||||
switch (raw) {
|
||||
case 'pending':
|
||||
return InboxMessageStatus.pending;
|
||||
case 'accepted':
|
||||
return InboxMessageStatus.accepted;
|
||||
case 'rejected':
|
||||
return InboxMessageStatus.rejected;
|
||||
case 'dismissed':
|
||||
return InboxMessageStatus.dismissed;
|
||||
default:
|
||||
throw StateError('Unsupported inbox message status: $raw');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user