comments_model.dart 7.2 KB
import 'dart:convert';

import 'package:common_utils/common_utils.dart';

class CommentsModel {
  int? ret;
  List<CommentsSunModel>? data;
  String? msg;

  CommentsModel({this.ret, this.data, this.msg});

  CommentsModel.fromJson(Map<String, dynamic> json) {
    ret = json['ret'];
    if (json['data'] != null) {
      data = <CommentsSunModel>[];
      json['data'].forEach((v) {
        data!.add(new CommentsSunModel.fromJson(v));
      });
    }
    msg = json['msg'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['ret'] = this.ret;
    if (this.data != null) {
      data['data'] = this.data!.map((v) => v.toJson()).toList();
    }
    data['msg'] = this.msg;
    return data;
  }
}

class CommentsSunModel {
  String? id;
  String? pid;
  String? sid;
  String? rid;
  String? author;
  String? authorImage;
  String? grade;
  String? status;
  String? evalLabel;
  String? text;
  String? createTime;
  List<CommentsImageModel>? enclosure;
  String? isnoshow;
  Reply? reply;

  String? ddate;
  String? ddateSolt;
  String? tableinfo;

  String get createTimeStr {
    DateTime dateTime = DateTime.fromMillisecondsSinceEpoch(
        int.parse(createTime.toString()) * 1000);
    return DateUtil.formatDate(dateTime, format: DateFormats.y_mo_d);
  }

  CommentsSunModel(
      {this.id,
      this.pid,
      this.sid,
      this.rid,
      this.author,
      this.authorImage,
      this.grade,
      this.status,
      this.evalLabel,
      this.text,
      this.createTime,
      this.enclosure,
      this.isnoshow,
      this.reply,
      this.ddate,
      this.ddateSolt,
      this.tableinfo});

  CommentsSunModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    pid = json['pid'];
    sid = json['sid'];
    rid = json['rid'];
    author = json['author'];
    authorImage = json['author_image'];
    grade = json['grade'];
    status = json['status'];
    evalLabel = json['eval_label'];
    text = json['text'];
    createTime = json['create_time'];
    enclosure = <CommentsImageModel>[];
    if (json['enclosure'] != null) {
      if (jsonDecode(json['enclosure']) is List) {
        List temp = jsonDecode(json['enclosure']);
        temp.forEach((element) {
          enclosure!.add(CommentsImageModel.fromJson(element));
        });
      }
    }

    isnoshow = json['isnoshow'];
    reply = json['reply'] != null ? new Reply.fromJson(json['reply']) : null;

    ddate = json['ddate'];
    ddateSolt = json['ddate_solt'];
    tableinfo = json['tableinfo'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['pid'] = this.pid;
    data['sid'] = this.sid;
    data['rid'] = this.rid;
    data['author'] = this.author;
    data['author_image'] = this.authorImage;
    data['grade'] = this.grade;
    data['status'] = this.status;
    data['eval_label'] = this.evalLabel;
    data['text'] = this.text;
    data['create_time'] = this.createTime;
    data['enclosure'] = this.enclosure;
    data['isnoshow'] = this.isnoshow;
    if (this.reply != null) {
      data['reply'] = this.reply!.toJson();
    }
    if (this.enclosure != null) {
      data['enclosure'] = jsonEncode(this.enclosure);
    }

    data['ddate'] = this.ddate;
    data['ddate_solt'] = this.ddateSolt;
    data['tableinfo'] = this.tableinfo;
    return data;
  }
}

class Reply {
  String? id;
  String? pid;
  String? sid;
  String? rid;
  String? author;
  String? authorImage;
  String? grade;
  String? status;
  String? evalLabel;
  String? text;
  String? createTime;
  String? enclosure;
  dynamic isnoshow;

  Reply(
      {this.id,
      this.pid,
      this.sid,
      this.rid,
      this.author,
      this.authorImage,
      this.grade,
      this.status,
      this.evalLabel,
      this.text,
      this.createTime,
      this.enclosure,
      this.isnoshow});

  Reply.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    pid = json['pid'];
    sid = json['sid'];
    rid = json['rid'];
    author = json['author'];
    authorImage = json['author_image'];
    grade = json['grade'];
    status = json['status'];
    evalLabel = json['eval_label'];
    text = json['text'];
    createTime = json['create_time'];
    enclosure = json['enclosure'];
    isnoshow = json['isnoshow'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['pid'] = this.pid;
    data['sid'] = this.sid;
    data['rid'] = this.rid;
    data['author'] = this.author;
    data['author_image'] = this.authorImage;
    data['grade'] = this.grade;
    data['status'] = this.status;
    data['eval_label'] = this.evalLabel;
    data['text'] = this.text;
    data['create_time'] = this.createTime;
    data['enclosure'] = this.enclosure;
    data['isnoshow'] = this.isnoshow;
    return data;
  }
}

class CommentsImageModel {
  String? key;
  String? bucket;
  String? mimeType;
  String? fsize;
  dynamic exif;
  ImageInfo? imageInfo;
  ImageAve? imageAve;
  String? url;
  String? avinfo;

  String? filePath;

  CommentsImageModel({
    this.key,
    this.bucket,
    this.mimeType,
    this.fsize,
    this.exif,
    this.imageInfo,
    this.imageAve,
    this.url,
    this.avinfo,
  });

  CommentsImageModel.fromJson(Map<String, dynamic> json) {
    key = json['key'];
    bucket = json['bucket'];
    mimeType = json['mimeType'];
    fsize = json['fsize'];
    exif = json['exif'];
    imageInfo = json['imageInfo'] != null
        ? new ImageInfo.fromJson(json['imageInfo'])
        : null;
    imageAve = json['imageAve'] != null
        ? new ImageAve.fromJson(json['imageAve'])
        : null;
    url = json['url'];
    avinfo = json['avinfo'] == null ? null : jsonEncode(json['avinfo']);
    print(avinfo);
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['key'] = this.key;
    data['bucket'] = this.bucket;
    data['mimeType'] = this.mimeType;
    data['fsize'] = this.fsize;
    data['exif'] = this.exif;
    if (this.imageInfo != null) {
      data['imageInfo'] = this.imageInfo!.toJson();
    }
    if (this.imageAve != null) {
      data['imageAve'] = this.imageAve!.toJson();
    }
    data['url'] = this.url;

    data['avinfo'] = this.avinfo;
    return data;
  }
}

class ImageInfo {
  String? colorModel;
  String? format;
  int? height;
  int? size;
  int? width;

  ImageInfo({this.colorModel, this.format, this.height, this.size, this.width});

  ImageInfo.fromJson(Map<String, dynamic> json) {
    colorModel = json['colorModel'];
    format = json['format'];
    height = json['height'];
    size = json['size'];
    width = json['width'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['colorModel'] = this.colorModel;
    data['format'] = this.format;
    data['height'] = this.height;
    data['size'] = this.size;
    data['width'] = this.width;
    return data;
  }
}

class ImageAve {
  String? rGB;

  ImageAve({this.rGB});

  ImageAve.fromJson(Map<String, dynamic> json) {
    rGB = json['RGB'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['RGB'] = this.rGB;
    return data;
  }
}