import 'package:sk_base_mobile/models/role.model.dart';

class UserInfoModel {
  int? id;
  String? createdAt;
  String? updatedAt;
  String? username;
  String? nickname;
  String? avatar;
  String? qq;
  String? email;
  String? phone;
  String? remark;
  int? status;
  List<RoleModel>? roles;

  UserInfoModel(
      {this.id,
      this.createdAt,
      this.updatedAt,
      this.username,
      this.nickname,
      this.avatar,
      this.qq,
      this.email,
      this.phone,
      this.remark,
      this.status,
      this.roles});

  UserInfoModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    createdAt = json['createdAt'];
    updatedAt = json['updatedAt'];
    username = json['username'];
    nickname = json['nickname'];
    avatar = json['avatar'];
    qq = json['qq'];
    email = json['email'];
    phone = json['phone'];
    remark = json['remark'];
    status = json['status'];
    if (json['roles'] != null) {
      roles = <RoleModel>[];
      json['roles'].forEach((v) {
        roles!.add(RoleModel.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['id'] = id;
    data['createdAt'] = createdAt;
    data['updatedAt'] = updatedAt;
    data['username'] = username;
    data['nickname'] = nickname;
    data['avatar'] = avatar;
    data['qq'] = qq;
    data['email'] = email;
    data['phone'] = phone;
    data['remark'] = remark;
    data['status'] = status;
    if (roles != null) {
      data['roles'] = roles!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}
