chat_item.dart 880 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. import 'package:json_annotation/json_annotation.dart';
  2. part 'chat_item.g.dart';
  3. @JsonSerializable()
  4. class ChatItem {
  5. @JsonKey(name: "id", fromJson: _intToString, toJson: _stringToInt)
  6. final String id;
  7. @JsonKey(name: "chatId")
  8. final String conversationId;
  9. @JsonKey(name: "role")
  10. final String role;
  11. @JsonKey(name: "content")
  12. String content;
  13. @JsonKey(name: "createTime")
  14. final String createTime;
  15. @JsonKey(name: "talkId")
  16. String? talkId;
  17. @JsonKey(name: "title")
  18. String? talkTitle;
  19. ChatItem({
  20. required this.id,
  21. required this.conversationId,
  22. required this.role,
  23. required this.content,
  24. required this.createTime,
  25. });
  26. factory ChatItem.fromJson(Map<String, dynamic> json) => _$ChatItemFromJson(json);
  27. static String _intToString(int value) => value.toString();
  28. static int _stringToInt(String value) => int.parse(value);
  29. }