123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337 |
- import 'package:sport/bean/share_info.dart';
- class MessageInstance {
- int fromId;
- int toId;
- String type;
- MessageData data;
- int read;
- bool selfSend;
- String createdAt;
- MessageUser toUser;
- MessageUser fromUser;
- String relate;
- MessageInstance(
- {this.fromId,
- this.toId,
- this.type,
- this.data,
- this.read,
- this.selfSend,
- this.createdAt,
- this.toUser,
- this.fromUser,
- this.relate});
- MessageInstance.fromJson(Map<String, dynamic> json) {
- fromId = json['from_id'];
- toId = json['to_id'];
- type = json['type'];
- data = json['data'] != null ? new MessageData.fromJson(json['data']) : null;
- read = json['read'];
- selfSend = json['self_send'];
- createdAt = json['created_at'];
- toUser = json['to_user'] != null
- ? new MessageUser.fromJson(json['to_user'])
- : null;
- fromUser = json['from_user'] != null
- ? new MessageUser.fromJson(json['from_user'])
- : null;
- relate = json['relate'];
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['from_id'] = this.fromId;
- data['to_id'] = this.toId;
- data['type'] = this.type;
- if (this.data != null) {
- data['data'] = this.data.toJson();
- }
- data['read'] = this.read;
- data['self_send'] = this.selfSend;
- data['created_at'] = this.createdAt;
- if (this.toUser != null) {
- data['to_user'] = this.toUser.toJson();
- }
- if (this.fromUser != null) {
- data['from_user'] = this.fromUser.toJson();
- }
- data['relate'] = this.relate;
- return data;
- }
- }
- class MessageData {
- String text;
- String url;
- String logo;
- MessagePostUser user;
- MessageForum forum;
- MessageSubject subject;
- Share share;
- MessageData({
- this.text,
- this.url,
- this.logo,
- this.user,
- this.forum,
- this.subject,
- this.share
- });
- MessageData.fromJson(Map<String, dynamic> json) {
- text = json['text'];
- url = json['url'];
- logo = json['logo'];
- user = json['user'] != null ? MessagePostUser.fromJson(json['user']) : null;
- forum = json['forum'] != null ? MessageForum.fromJson(json['forum']) : null;
- subject = json['subject'] != null
- ? MessageSubject.fromJson(json["subject"])
- : null;
- share = json['share'] != null ? Share.fromJson(json['share']):null;
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> map = new Map<String, dynamic>();
- map['text'] = this.text;
- map['url'] = this.url;
- map['logo'] = this.logo;
- map['user'] = this.user;
- map['forum'] = this.forum;
- map['subject'] = this.subject;
- map["share"] = this.share;
- return map;
- }
- }
- class MessageUser {
- int id;
- String name;
- String avatar;
- bool online;
- MessageUser({this.id, this.name, this.avatar, this.online});
- MessageUser.fromJson(Map<String, dynamic> json) {
- id = json['id'];
- name = json['name'];
- avatar = json['avatar'];
- online = json['online'];
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['id'] = this.id;
- data['name'] = this.name;
- data['avatar'] = this.avatar;
- data['online'] = this.online;
- return data;
- }
- }
- // 这里是轮询的消息结构...
- class Message {
- int curId;
- List<MessageInstance> messages;
- Message({this.curId, this.messages});
- Message.fromJson(Map<String, dynamic> json) {
- curId = json['cur_id'];
- messages = new List<MessageInstance>();
- if (json['messages'] != null) {
- json['messages'].forEach((v) {
- messages.add(new MessageInstance.fromJson(v));
- });
- }
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['id'] = this.curId;
- if (this.messages != null) {
- data['messages'] = this.messages.map((v) => v.toJson()).toList();
- }
- return data;
- }
- }
- class ChatMessage {
- MessageUser user;
- List<MessageInstance> messages;
- ChatMessage({this.user, this.messages});
- ChatMessage.fromJson(Map<String, dynamic> json) {
- user = json['user'];
- messages = new List<MessageInstance>();
- if (json['message'] != null) {
- json['message'].forEach((v) {
- messages.add(new MessageInstance.fromJson(v));
- });
- }
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['user'] = this.user;
- if (this.messages != null) {
- data['messages'] = this.messages.map((v) => v.toJson()).toList();
- }
- return data;
- }
- }
- // 聊天首页
- class ChatMessageInstance {
- int id;
- int fromId;
- int toId;
- String type;
- String relate;
- bool selfSend;
- int read;
- int unreadCount;
- String createdAt;
- MessageData data;
- MessageUser toUser;
- MessageUser fromUser;
- ChatMessageInstance({
- this.id,
- this.fromId,
- this.toId,
- this.type,
- this.relate,
- this.selfSend,
- this.read,
- this.unreadCount,
- this.createdAt,
- this.data,
- this.toUser,
- this.fromUser,
- });
- ChatMessageInstance.fromJson(Map<String, dynamic> json) {
- id = json['id'];
- fromId = json['from_id'];
- toId = json['to_id'];
- type = json['type'];
- relate = json['relate'];
- selfSend = json['self_send'];
- read = json['read'];
- unreadCount = json['unread_count'];
- createdAt = json['created_at'];
- data = json['data'];
- toUser = json['to_user'];
- fromUser = json['from_user'];
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['id'] = this.id;
- data['from_id'] = this.fromId;
- data['to_id'] = this.toId;
- data['type'] = this.type;
- data['relate'] = this.relate;
- data['self_send'] = this.selfSend;
- data['read'] = this.read;
- data['unread_count'] = this.unreadCount;
- data['created_at'] = this.createdAt;
- data['data'] = this.data;
- data['to_user'] = this.toUser;
- data['from_user'] = this.fromUser;
- return data;
- }
- }
- class ChatOnlineInfo {
- bool online;
- String relate;
- int userId;
- ChatOnlineInfo.fromJson(Map<String, dynamic> json) {
- online = json['online'];
- relate = json['relate'];
- userId = json['id'];
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['online'] = this.online;
- data['relate'] = this.relate;
- data['id'] = this.userId;
- return data;
- }
- }
- class MessageForum {
- String cover;
- String name;
- int id;
- MessageForum.fromJson(Map<String, dynamic> json) {
- cover = json['cover'];
- name = json['name'];
- id = json['id'];
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['cover'] = this.cover;
- data['name'] = this.name;
- data['id'] = this.id;
- return data;
- }
- }
- class MessageSubject {
- String title;
- String content;
- int id;
- List<String> images;
- String cover;
- MessageSubject.fromJson(Map<String, dynamic> json) {
- title = json['title'];
- content = json['content'];
- id = json['id'];
- images = new List<String>();
- cover = json['cover'];
- images = [];
- if (json['images'] != null && json['images'].length > 0) {
- json['images'].forEach((v) {
- images.add(v);
- });
- }
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['title'] = this.title;
- data['content'] = this.content;
- data['images'] = this.images;
- data['id'] = this.id;
- data['cover'] = this.cover;
- return data;
- }
- }
- class MessagePostUser {
- int id;
- String name;
- MessagePostUser({this.id, this.name});
- MessagePostUser.fromJson(Map<String, dynamic> json) {
- id = json['id'];
- name = json['name'];
- }
- Map<String, dynamic> toJson() {
- final Map<String, dynamic> data = new Map<String, dynamic>();
- data['name'] = this.name;
- data['id'] = this.id;
- return data;
- }
- }
|