class MessageModel {
  final String id;
  final String title;
  final String content;
  final String msgType;
  final String? bizType;
  final String? bizId;
  final bool isRead;
  final DateTime createTime;

  const MessageModel({
    required this.id,
    required this.title,
    this.content = '',
    this.msgType = 'system',
    this.bizType,
    this.bizId,
    this.isRead = false,
    required this.createTime,
  });

  factory MessageModel.fromJson(Map<String, dynamic> json) => MessageModel(
    id: json['id'] as String,
    title: json['title'] as String,
    content: json['content'] as String? ?? '',
    msgType: json['msgType'] as String? ?? 'system',
    bizType: json['bizType'] as String?,
    bizId: json['bizId'] as String?,
    isRead: json['isRead'] as bool? ?? false,
    createTime: DateTime.parse(json['createTime'] as String),
  );

  static final mockMessages = [
    MessageModel(id: '1', title: '张三的报销申请待审批', content: '报销金额 ¥2,380.00', msgType: 'approval_notice', bizType: 'expense', bizId: 'exp-001', isRead: false, createTime: DateTime(2024, 5, 22, 9, 30)),
    MessageModel(id: '2', title: '李四的加班申请待审批', content: '加班时长 4小时', msgType: 'approval_notice', bizType: 'overtime', bizId: 'ot-001', isRead: false, createTime: DateTime(2024, 5, 21, 14, 0)),
    MessageModel(id: '3', title: '报销单审批已通过', content: 'BX-20240428-002 已通过', msgType: 'approval_result', bizType: 'expense', bizId: 'exp-002', isRead: true, createTime: DateTime(2024, 5, 20, 10, 0)),
    MessageModel(id: '4', title: '关于启用新版报销流程的通知', content: '', msgType: 'announcement', bizType: 'announcement', bizId: 'an-002', isRead: false, createTime: DateTime(2024, 5, 19, 14, 0)),
  ];
}
