flutterFlutter

Flutter——数据模型封装与解析

2020-12-01  本文已影响0人  刘铁崧
  final List<Article> articleList = [];
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    CAYJHomeRequest.requestArticleList(0).then((value){
      setState(() {
        articleList.addAll(value);
      });
      print(articleList);
    });
  }
import 'package:cayj_cystudio/model/articlelist_model.dart';
import 'package:cayj_cystudio/service/config.dart';
import 'package:cayj_cystudio/service/http_request.dart';

class CAYJHomeRequest{
  static Future<List<Article>> requestArticleList(int offset) async {
    final articleURL = CYAPIConfig.HOME_ARTICLE_LIST + "?offset=$offset&limit=${CAYJHomeServiceConfig.ARTICLE_LIMIT}";
    final result = await CYHttpRequest.request(articleURL);//获取数据
    final dataList = result["data"]["articles"];
    // 数据解析
    List<Article> articleList = [];
    for(var article in dataList){
      articleList.add(Article.fromMap(article));
    }
    return articleList;
  }
}

CYHttpRequest参考https://www.jianshu.com/p/6398f9971a36

class Article{
  String title;
  String image;
  String details;
  int article_id;
  String launch_date;
  List<Comment> comments;
  List<User> followed_user;
  Article.fromMap(Map<String,dynamic>json){
    this.title = json["title"];
    this.image = json["image"];
    this.details = json["details"];
    this.article_id = json["article_id"];
    this.launch_date = json["launch_date"];
    this.comments = (json["comments"] as List<dynamic>).map((item){
      return Comment.fromMap(item);
    }).toList();

    this.followed_user = (json["followed_user"] as List<dynamic>).map((e){
      return User.fromMap(e);
    }).toList();
  }

  // 方便打印 cmd + n快捷键可以生成
  @override
  String toString() {
    return 'Article{title: $title, image: $image, details: $details, article_id: $article_id, launch_date: $launch_date, comments: $comments, followed_user: $followed_user}';
  }
}

class Comment {
  User user;
  String comment;
  Comment.fromMap(Map<String,dynamic>json){
    this.user = User.fromMap(json["user"]);
    this.comment = json["comment"];
  }
}

class User{
  String user_name;
  int user_id;
  int fans_count;
  int level;
  bool is_author;
  bool is_vip;

  User.fromMap(Map<String,dynamic>json){
    this.user_name = json["user_name"];
    this.user_id = json["user_id"];
    this.fans_count = json["fans_count"];
    this.level = json["level"];
    this.is_author = json["is_author"];
    this.is_vip = json["is_vip"];
  }
}
var data = {
        "code":"0",
        "message":"success",
        "data":{
            "message": {
                "total": 30,
                "start":0,
                "count":5,
            },
            "articles": [
                {
                    "title": "宠爱有家杭州分部正式成立",
                    "image": base_url + "product/product1.jpg",
                    "details": "宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立,宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立,宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立.",
                    "article_id": 1,
                    "launch_date": "2019-01-25",
                    "comments":[],
                    "followed_user":[
                        {
                            "user_name":"cy",
                            "user_id":1,
                            "fans_count":30,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"sky",
                            "user_id":2,
                            "fans_count":10,
                            "level":1,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user1",
                            "user_id":3,
                            "fans_count":1,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user2",
                            "user_id":4,
                            "fans_count":3,
                            "level":3,
                            "is_author":false,
                            "is_vip":false
                        },
                    ]
                }, 
                {
                    "title": "宠爱有家北京分部正式成立",
                    "image": base_url + "product/product2.jpg",
                    "details": "宠爱有家北京分部正式成立,宠爱有家北京分部正式成立宠爱有家北京分部正式成立宠爱有家北京分部正式成立宠爱有家北京分部正式成立,宠爱有家北京分部正式成立宠爱有家北京分部正式成立宠爱有家北京分部正式成立宠爱有家北京分部正式成立宠爱有家北京分部正式成立宠爱有家北京分部正式成立.",
                    "article_id": 2,
                    "launch_date": "2019-10-15",
                    "comments":[],
                    "followed_user":[
                        {
                            "user_name":"new_user1",
                            "user_id":3,
                            "fans_count":1,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user2",
                            "user_id":4,
                            "fans_count":3,
                            "level":3,
                            "is_author":false,
                            "is_vip":false
                        },
                    ]
                }, 
                {
                    "title": "宠爱有家苏州分部正式成立",
                    "image": base_url + "product/product3.jpg",
                    "details": "宠爱有家苏州分部正式成立;宠爱有家苏州分部正式成立宠爱有家苏州分部正式成立,宠爱有家苏州分部正式成立,宠爱有家苏州分部正式成立宠爱有家苏州分部正式成立.",
                    "article_id": 3,
                    "launch_date": "2018-03-25",
                    "comments":[
                        {
                            "user":{
                                "user_name":"cy",
                                "user_id":1,
                                "fans_count":30,
                                "level":3,
                                "is_author":true,
                                "is_vip":false
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },
                        {
                            "user":{
                                "user_name":"test",
                                "user_id":18,
                                "fans_count":20,
                                "level":10,
                                "is_author":true,
                                "is_vip":true
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },

                    ],
                    "followed_user":[
                        {
                            "user_name":"cy",
                            "user_id":1,
                            "fans_count":30,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user2",
                            "user_id":4,
                            "fans_count":3,
                            "level":3,
                            "is_author":false,
                            "is_vip":false
                        },
                    ]
                }, 
                {
                    "title": "宠爱有家程度分部正式成立",
                    "image": base_url + "product/product4.png",
                    "details": "宠爱有家程度分部正式成立,宠爱有家程度分部正式成立宠爱有家程度分部正式成立宠爱有家程度分部正式成立宠爱有家程度分部正式成立宠爱有家程度分部正式成立,宠爱有家程度分部正式成立.",
                    "article_id": 4,
                    "launch_date": "2019-01-25",
                    "comments":[
                        {
                            "user":{
                                "user_name":"cy",
                                "user_id":1,
                                "fans_count":30,
                                "level":3,
                                "is_author":true,
                                "is_vip":false
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },
                        {
                            "user":{
                                "user_name":"test",
                                "user_id":18,
                                "fans_count":20,
                                "level":10,
                                "is_author":true,
                                "is_vip":true
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },

                    ],
                    "followed_user":[],
                }, 
                {
                   "title": "宠爱有家天津分部正式成立",
                    "image": base_url + "product/product5.png",
                    "details": "宠爱有家天津分部正式成立,宠爱有家天津分部正式成立宠爱有家天津分部正式成立宠爱有家天津分部正式成立,宠爱有家天津分部正式成立.",
                    "article_id": 5,
                    "launch_date": "2020-01-05",
                    "comments":[
                        {
                            "user":{
                                "user_name":"cy",
                                "user_id":1,
                                "fans_count":30,
                                "level":3,
                                "is_author":true,
                                "is_vip":false
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        }
                    ],
                    "followed_user":[
                        {
                            "user_name":"cy",
                            "user_id":1,
                            "fans_count":30,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        }
                    ]
                }, 
                {
                    "title": "宠爱有家哈尔滨分部正式成立",
                    "image": base_url + "product/product2.jpg",
                    "details": "宠爱有家哈尔滨分部正式成立,宠爱有家哈尔滨分部正式成立,宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立.",
                    "article_id": 6,
                    "launch_date": "2015-11-25",
                    "comments":[],
                    "followed_user":[
                        {
                            "user_name":"new_user1",
                            "user_id":3,
                            "fans_count":1,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user2",
                            "user_id":4,
                            "fans_count":3,
                            "level":3,
                            "is_author":false,
                            "is_vip":false
                        },
                    ]
                }, 
                {
                    "title": "宠爱有家分部正式成立",
                    "image": base_url + "product/product1.jpg",
                    "details": "宠爱有家天津分部正式成立,宠爱有家天津分部正式成立宠爱有家天津分部正式成立宠爱有家天津分部正式成立,宠爱有家天津分部正式成立.",
                    "article_id": 7,
                    "launch_date": "2020-01-05",
                    "comments":[
                        {
                            "user":{
                                "user_name":"cy",
                                "user_id":1,
                                "fans_count":30,
                                "level":3,
                                "is_author":true,
                                "is_vip":false
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },
                        {
                            "user":{
                                "user_name":"test",
                                "user_id":18,
                                "fans_count":20,
                                "level":10,
                                "is_author":true,
                                "is_vip":true
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },

                    ],
                    "followed_user":[
                        {
                            "user_name":"cy",
                            "user_id":1,
                            "fans_count":30,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"sky",
                            "user_id":2,
                            "fans_count":10,
                            "level":1,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user1",
                            "user_id":3,
                            "fans_count":1,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user2",
                            "user_id":4,
                            "fans_count":3,
                            "level":3,
                            "is_author":false,
                            "is_vip":false
                        },
                    ]
                }, 
                {
                    "title": "宠爱有家天津分部正式成立",
                    "image": base_url + "product/product5.png",
                    "details": "宠爱有家天津分部正式成立,宠爱有家天津分部正式成立宠爱有家天津分部正式成立宠爱有家天津分部正式成立,宠爱有家天津分部正式成立.",
                    "article_id": 8,
                    "launch_date": "2020-01-05",
                    "comments":[
                        {
                            "user":{
                                "user_name":"test",
                                "user_id":18,
                                "fans_count":20,
                                "level":10,
                                "is_author":true,
                                "is_vip":true
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },

                    ],
                    "followed_user":[
                        {
                            "user_name":"cy",
                            "user_id":1,
                            "fans_count":30,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"sky",
                            "user_id":2,
                            "fans_count":10,
                            "level":1,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user1",
                            "user_id":3,
                            "fans_count":1,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user2",
                            "user_id":4,
                            "fans_count":3,
                            "level":3,
                            "is_author":false,
                            "is_vip":false
                        },
                    ]
                }, 
                {
                    "title": "宠爱有家哈尔滨分部正式成立",
                    "image": base_url + "product/product1.jpg",
                    "details": "宠爱有家哈尔滨分部正式成立,宠爱有家哈尔滨分部正式成立,宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立.",
                    "article_id": 9,
                    "launch_date": "2015-11-25",
                    "comments":[
                        {
                            "user":{
                                "user_name":"cy",
                                "user_id":1,
                                "fans_count":30,
                                "level":3,
                                "is_author":true,
                                "is_vip":false
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },
                        {
                            "user":{
                                "user_name":"test",
                                "user_id":18,
                                "fans_count":20,
                                "level":10,
                                "is_author":true,
                                "is_vip":true
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },

                    ],
                    "followed_user":[]
                }, 
                {
                    "title": "宠爱有家乌鲁木齐分部正式成立",
                    "image": base_url + "product/product2.jpg",
                    "details": "宠爱有家哈尔滨分部正式成立,宠爱有家哈尔滨分部正式成立,宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立.",
                    "article_id": 10,
                    "launch_date": "2011-11-25",
                    "comments":[],
                    "followed_user":[
                        {
                            "user_name":"cy",
                            "user_id":1,
                            "fans_count":30,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"sky",
                            "user_id":2,
                            "fans_count":10,
                            "level":1,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user1",
                            "user_id":3,
                            "fans_count":1,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user2",
                            "user_id":4,
                            "fans_count":3,
                            "level":3,
                            "is_author":false,
                            "is_vip":false
                        },
                    ]
                }, 
                {
                    "title": "宠爱有家哈尔滨分部正式成立",
                    "image": base_url + "product/product1.jpg",
                    "details": "宠爱有家哈尔滨分部正式成立,宠爱有家哈尔滨分部正式成立,宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立.",
                    "article_id": 11,
                    "launch_date": "2015-11-25",
                    "comments":[
                        {
                            "user":{
                                "user_name":"cy",
                                "user_id":1,
                                "fans_count":30,
                                "level":3,
                                "is_author":true,
                                "is_vip":false
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },
                        {
                            "user":{
                                "user_name":"test",
                                "user_id":18,
                                "fans_count":20,
                                "level":10,
                                "is_author":true,
                                "is_vip":true
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },

                    ],
                    "followed_user":[
                        {
                            "user_name":"cy",
                            "user_id":1,
                            "fans_count":30,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"sky",
                            "user_id":2,
                            "fans_count":10,
                            "level":1,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user1",
                            "user_id":3,
                            "fans_count":1,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user2",
                            "user_id":4,
                            "fans_count":3,
                            "level":3,
                            "is_author":false,
                            "is_vip":false
                        },
                    ]
                }, 
                {
                    "title": "宠爱有家哈尔滨分部正式成立",
                    "image": base_url + "product/product1.jpg",
                    "details": "宠爱有家哈尔滨分部正式成立,宠爱有家哈尔滨分部正式成立,宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立.",
                    "article_id": 12,
                    "launch_date": "2015-11-25",
                    "comments":[],
                    "followed_user":[
                        {
                            "user_name":"new_user2",
                            "user_id":4,
                            "fans_count":3,
                            "level":3,
                            "is_author":false,
                            "is_vip":false
                        },
                    ]
                }, 
                {
                    "title": "宠爱有家青岛分部正式成立",
                    "image": base_url + "product/product4.png",
                    "details": "宠爱有家青岛分部正式成立宠爱有家青岛分部正式成立,宠爱有家哈尔滨分部正式成立,宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立.",
                    "article_id": 13,
                    "launch_date": "2015-11-25",
                    "comments":[
                        {
                            "user":{
                                "user_name":"test",
                                "user_id":18,
                                "fans_count":20,
                                "level":10,
                                "is_author":true,
                                "is_vip":true
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },

                    ],
                    "followed_user":[
                        {
                            "user_name":"cy",
                            "user_id":1,
                            "fans_count":30,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"sky",
                            "user_id":2,
                            "fans_count":10,
                            "level":1,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user1",
                            "user_id":3,
                            "fans_count":1,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user2",
                            "user_id":4,
                            "fans_count":3,
                            "level":3,
                            "is_author":false,
                            "is_vip":false
                        },
                    ]
                }, 
                {
                    "title": "宠爱有家郑州分部正式成立",
                    "image": base_url + "product/product1.jpg",
                    "details": "宠爱有家郑州分部正式成立宠爱有家郑州分部正式成立,宠爱有家郑州分部正式成立,宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立宠爱有家哈尔滨分部正式成立.",
                    "article_id": 14,
                    "launch_date": "2015-11-25",
                    "comments":[],
                    "followed_user":[
                        {
                            "user_name":"cy",
                            "user_id":1,
                            "fans_count":30,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"sky",
                            "user_id":2,
                            "fans_count":10,
                            "level":1,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user1",
                            "user_id":3,
                            "fans_count":1,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user2",
                            "user_id":4,
                            "fans_count":3,
                            "level":3,
                            "is_author":false,
                            "is_vip":false
                        },
                    ]
                }, 
                {
                    "title": "宠爱有家杭州分部正式成立",
                    "image": base_url + "product/product1.jpg",
                    "details": "宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立,宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立,宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立.",
                    "article_id": 15,
                    "launch_date": "2019-01-25",
                    "comments":[
                        {
                            "user":{
                                "user_name":"cy",
                                "user_id":1,
                                "fans_count":30,
                                "level":3,
                                "is_author":true,
                                "is_vip":false
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },
                        {
                            "user":{
                                "user_name":"test",
                                "user_id":18,
                                "fans_count":20,
                                "level":10,
                                "is_author":true,
                                "is_vip":true
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },

                    ],
                    "followed_user":[]
                }, 
                {
                    "title": "宠爱有家桂林分部正式成立",
                    "image": base_url + "product/product1.jpg",
                    "details": "宠爱有家桂林分部正式成立宠爱有家桂林分部正式成立宠爱有家桂林分部正式成立,宠爱有家桂林分部正式成立,宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立.",
                    "article_id": 16,
                    "launch_date": "2017-11-25",
                    "comments":[
                        {
                            "user":{
                                "user_name":"cy",
                                "user_id":1,
                                "fans_count":30,
                                "level":3,
                                "is_author":true,
                                "is_vip":false
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        }
                    ],
                    "followed_user":[]
                }, 
                {
                    "title": "宠爱有家武汉分部正式成立",
                    "image": base_url + "product/product1.jpg",
                    "details": "宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立,宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立,宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立.",
                    "article_id": 17,
                    "launch_date": "2016-06-25",
                    "comments":[
                        {
                            "user":{
                                "user_name":"cy",
                                "user_id":1,
                                "fans_count":30,
                                "level":3,
                                "is_author":true,
                                "is_vip":false
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },
                        {
                            "user":{
                                "user_name":"test",
                                "user_id":18,
                                "fans_count":20,
                                "level":10,
                                "is_author":true,
                                "is_vip":true
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },

                    ],
                    "followed_user":[
                        {
                            "user_name":"new_user1",
                            "user_id":3,
                            "fans_count":1,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user2",
                            "user_id":4,
                            "fans_count":3,
                            "level":3,
                            "is_author":false,
                            "is_vip":false
                        },
                    ]
                }, 
                {
                    "title": "宠爱有家徐州分部正式成立",
                    "image": base_url + "product/product1.jpg",
                    "details": "宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立,宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立,宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立.",
                    "article_id": 18,
                    "launch_date": "2010-01-20",
                    "comments":[
                        {
                            "user":{
                                "user_name":"cy",
                                "user_id":1,
                                "fans_count":30,
                                "level":3,
                                "is_author":true,
                                "is_vip":false
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },
                        {
                            "user":{
                                "user_name":"test",
                                "user_id":18,
                                "fans_count":20,
                                "level":10,
                                "is_author":true,
                                "is_vip":true
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },

                    ],
                    "followed_user":[]
                }, 
                {
                    "title": "宠爱有家图们分部正式成立",
                    "image": base_url + "product/product1.jpg",
                    "details": "宠爱有家图们分部正式成立,宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立,宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立.",
                    "article_id": 19,
                    "launch_date": "2010-01-20",
                    "comments":[
                        {
                            "user":{
                                "user_name":"cy",
                                "user_id":1,
                                "fans_count":30,
                                "level":3,
                                "is_author":true,
                                "is_vip":false
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },
                        {
                            "user":{
                                "user_name":"test",
                                "user_id":18,
                                "fans_count":20,
                                "level":10,
                                "is_author":true,
                                "is_vip":true
                            },
                            "comment":"恭喜恭喜恭喜恭喜阿斯顿发送到发送到发斯蒂芬阿斯顿发生大发送到"
                        },

                    ],
                    "followed_user":[
                        {
                            "user_name":"cy",
                            "user_id":1,
                            "fans_count":30,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"sky",
                            "user_id":2,
                            "fans_count":10,
                            "level":1,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user1",
                            "user_id":3,
                            "fans_count":1,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user2",
                            "user_id":4,
                            "fans_count":3,
                            "level":3,
                            "is_author":false,
                            "is_vip":false
                        },
                    ]
                }, 
                {
                    "title": "宠爱有家上海分部正式成立",
                    "image": base_url + "product/product1.jpg",
                    "details": "宠爱有家上海分部正式成立,宠爱有家上海分部正式成立宠爱有家上海分部正式成立宠爱有家上海分部正式成立宠爱有家上海分部正式成立宠爱有家上海分部正式成立,宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立宠爱有家杭州分部正式成立.",
                    "article_id": 20,
                    "launch_date": "2020-01-20",
                    "comments":[],
                    "followed_user":[
                        {
                            "user_name":"cy",
                            "user_id":1,
                            "fans_count":30,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"sky",
                            "user_id":2,
                            "fans_count":10,
                            "level":1,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user1",
                            "user_id":3,
                            "fans_count":1,
                            "level":3,
                            "is_author":true,
                            "is_vip":false
                        },
                        {
                            "user_name":"new_user2",
                            "user_id":4,
                            "fans_count":3,
                            "level":3,
                            "is_author":false,
                            "is_vip":false
                        },
                    ]
                }, 
            ],
        }
    };

使用第三方工具进行模型封装

上一篇下一篇

猜你喜欢

热点阅读