class UserEntity {
  String userId;
  String mobile;
  String name;
  String avatarUrl;
  String token;
  int userLevel;
  String userLevelName;
  MaintenanceCompany maintenanceCompany;
  Role role;
  List<AppMenus> appMenus;
  int expertFlag;
  int expertLevel;

  UserEntity(
      {this.userId,
      this.mobile,
      this.name,
      this.avatarUrl,
      this.token,
      this.userLevel,
      this.userLevelName,
      this.maintenanceCompany,
      this.role,
      this.expertFlag,
      this.expertLevel,
      this.appMenus});

  UserEntity.fromJsonMap(Map<String, dynamic> json) {
    userId = json['userId'];
    expertFlag = json['expertFlag'];
    expertLevel = json['expertLevel'];
    mobile = json['mobile'];
    name = json['name'];
    avatarUrl = json['avatarUrl'];
    token = json['token'];
    userLevel = json['userLevel'];
    userLevelName = json['userLevelName'];
    maintenanceCompany = json['maintenanceCompany'] != null
        ? new MaintenanceCompany.fromJsonMap(json['maintenanceCompany'])
        : null;
    role = json['role'] != null ? new Role.fromJsonMap(json['role']) : null;
    if (json['appMenus'] != null) {
      appMenus = new List<AppMenus>();
      json['appMenus'].forEach((v) {
        appMenus.add(new AppMenus.fromJsonMap(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['userId'] = this.userId;
    data['mobile'] = this.mobile;
    data['name'] = this.name;
    data['expertFlag'] = this.expertFlag;
    data['expertLevel'] = this.expertLevel;

    data['avatarUrl'] = this.avatarUrl;
    data['token'] = this.token;
    data['userLevel'] = this.userLevel;
    data['userLevelName'] = this.userLevelName;
    if (this.maintenanceCompany != null) {
      data['maintenanceCompany'] = this.maintenanceCompany.toJson();
    }
    if (this.role != null) {
      data['role'] = this.role.toJson();
    }
    if (this.appMenus != null) {
      data['appMenus'] = this.appMenus.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class MaintenanceCompany {
  String id;
  String name;
  String address;

  MaintenanceCompany({this.id, this.name, this.address});

  MaintenanceCompany.fromJsonMap(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    address = json['address'];
  }

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

class Role {
  String id;
  String name;
  String code;
  String description;

  Role({this.id, this.name, this.code, this.description});

  Role.fromJsonMap(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    code = json['code'];
    description = json['description'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['name'] = this.name;
    data['code'] = this.code;
    data['description'] = this.description;
    return data;
  }
}

class AppMenus {
  int id;
  String name;
  String router;
  int status;

  AppMenus({this.id, this.name, this.router, this.status});

  AppMenus.fromJsonMap(Map<String, dynamic> json) {
    id = json['id'];
    name = json['name'];
    router = json['router'];
    status = json['status'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['name'] = this.name;
    data['router'] = this.router;
    data['status'] = this.status;
    return data;
  }
}
