Skip to content
  • P
    Projects
  • G
    Groups
  • S
    Snippets
  • Help

杨树贤 / kefu_server

  • This project
    • Loading...
  • Sign in
Go to a project
  • Project
  • Repository
  • Issues 0
  • Merge Requests 0
  • Pipelines
  • Wiki
  • Snippets
  • Settings
  • Activity
  • Graph
  • Charts
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • Files
  • Commits
  • Branches
  • Tags
  • Contributors
  • Graph
  • Compare
  • Charts
Find file
BlameHistoryPermalink
Switch branch/tag
  • kefu_server
  • ui
  • kefu_workbench
  • lib
  • models
  • im_message_model.dart
  • chenxianqi's avatar
    增加kefu_workbench · a18da124
    chenxianqi committed 5 years ago
    a18da124
im_message_model.dart 1.93 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
import 'dart:convert';

class ImMessageModel {
  String bizType;
  String version;
  dynamic payload;
  int fromAccount;
  int toAccount;
  int timestamp;
  int read;
  int key;
  int transferAccount;
  bool isShowCancel = false;
  int uploadProgress;
  String avatar;
  String nickname;
  bool isShowDate = false;

  ImMessageModel(
      {this.bizType,
      this.key,
      this.isShowDate = false,
      this.uploadProgress,
      this.version,
      this.avatar,
      this.nickname,
      this.isShowCancel = false,
      this.payload,
      this.fromAccount,
      this.toAccount,
      this.timestamp,
      this.read,
      this.transferAccount});

  ImMessageModel.fromJson(Map<String, dynamic> json) {
    this.bizType = json['biz_type'];
    this.version = json['version'];
    this.isShowCancel = json['is_show_cancel'] ?? false;
    this.payload = json['payload'];
    this.key = json['key'];
    this.fromAccount = json['from_account'];
    this.toAccount = json['to_account'];
    this.timestamp = json['timestamp'];
    this.avatar = json['avatar'];
    this.read = json['read'];
    this.uploadProgress = json['upload_progress'] ?? 0;
    this.nickname = json['nickname'];
    this.transferAccount = json['transfer_account'];
  }

  String toBase64() {
    return base64Encode(utf8.encode(json.encode(toJson())));
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['biz_type'] = this.bizType;
    data['version'] = this.version;
    data['key'] = this.key;
    data['upload_progress'] = this.uploadProgress;
    data['is_show_cancel'] = this.isShowCancel;
    data['payload'] = this.payload;
    data['from_account'] = this.fromAccount;
    data['to_account'] = this.toAccount;
    data['timestamp'] = this.timestamp;
    data['avatar'] = this.avatar;
    data['read'] = this.read;
    data['nickname'] = this.nickname;
    data['transfer_account'] = this.transferAccount;
    return data;
  }
}