import 'dart:convert';

/// loginType : "merchant"
/// shopName : "双屿pirse(测77)"
/// logo : "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/20240925/835c45e4729048e8921ba17d021029ec.jpg"
/// shopId : 11
/// mainId : 11
/// user : {"authorities":[{"authority":"tbProductGroup:del"},{"authority":"tbProductGroup:list"},{"authority":"roles:add"},{"authority":"roles:edit"},{"authority":"roles:del"},{"authority":"tbShopTable:list"},{"authority":"roles:list"}],"dataScopes":[18],"roles":["tbProductGroup:del","tbProductGroup:list","roles:add","roles:edit","roles:del","tbShopTable:list","roles:list"],"user":{"avatarName":null,"avatarPath":null,"createBy":"admin","createTime":"2024-05-27 14:10:09","dept":{"id":18,"name":"前厅"},"deptId":null,"email":null,"enabled":true,"gender":null,"id":40,"isAdmin":false,"jobs":[{"id":10,"name":"产品经理"}],"nickName":"双屿pirse(测77)","password":"$2a$10$j414tLJ/fdXXzXriW3y9A.QdP9Ak1.1hiGbvb1.zmQjPc5q.xoipy","phone":"13575788745","pwdResetTime":"2024-08-05 14:18:59","roles":[{"dataScope":"本级","id":2,"level":2,"name":"普通用户"}],"updateBy":"admin","updateTime":"2024-05-27 14:10:09","username":"13718478323"}}
/// token : "Bearer eyJhbGciOiJIUzUxMiJ9.eyJqdGkiOiI3ZWYzZmU2NWM0ZDU0ZjE5OWU5YmE4NTQ1NmUyZDZiZiIsInVzZXIiOiIxMzcxODQ3ODMyMyIsInNob3BJZCI6IjExIiwic3ViIjoiMTM3MTg0NzgzMjMifQ.9DY1f02WGTJ2e5w1MFJrUQ4KwEvl-QKWsSRALvpYYo6EsA3NercZAN56xL68e8K0eSsArk-9i1LFxb-PtBwmgw"

LoginResult loginResultFromJson(String str) =>
    LoginResult.fromJson(json.decode(str));

String loginResultToJson(LoginResult data) => json.encode(data.toJson());

class LoginResult {
  LoginResult({
    String? loginType,
    String? shopName,
    String? logo,
    num? shopId,
    num? mainId,
    User? user,
    String? token,
  }) {
    _loginType = loginType;
    _shopName = shopName;
    _logo = logo;
    _shopId = shopId;
    _mainId = mainId;
    _user = user;
    _token = token;
  }

  LoginResult.fromJson(dynamic json) {
    _loginType = json['loginType'];
    _shopName = json['shopName'];
    _logo = json['logo'];
    _shopId = json['shopId'];
    _mainId = json['mainId'];
    _user = json['user'] != null ? User.fromJson(json['user']) : null;
    _token = json['token'];
  }

  String? _loginType;
  String? _shopName;
  String? _logo;
  num? _shopId;
  num? _mainId;
  User? _user;
  String? _token;

  LoginResult copyWith({
    String? loginType,
    String? shopName,
    String? logo,
    num? shopId,
    num? mainId,
    User? user,
    String? token,
  }) =>
      LoginResult(
        loginType: loginType ?? _loginType,
        shopName: shopName ?? _shopName,
        logo: logo ?? _logo,
        shopId: shopId ?? _shopId,
        mainId: mainId ?? _mainId,
        user: user ?? _user,
        token: token ?? _token,
      );

  String? get loginType => _loginType;

  String? get shopName => _shopName;

  String? get logo => _logo;

  num? get shopId => _shopId;

  num? get mainId => _mainId;

  User? get user => _user;

  String? get token => _token;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['loginType'] = _loginType;
    map['shopName'] = _shopName;
    map['logo'] = _logo;
    map['shopId'] = _shopId;
    map['mainId'] = _mainId;
    if (_user != null) {
      map['user'] = _user?.toJson();
    }
    map['token'] = _token;
    return map;
  }
}

/// authorities : [{"authority":"tbProductGroup:del"},{"authority":"tbProductGroup:list"},{"authority":"roles:add"},{"authority":"roles:edit"},{"authority":"roles:del"},{"authority":"tbShopTable:list"},{"authority":"roles:list"}]
/// dataScopes : [18]
/// roles : ["tbProductGroup:del","tbProductGroup:list","roles:add","roles:edit","roles:del","tbShopTable:list","roles:list"]
/// user : {"avatarName":null,"avatarPath":null,"createBy":"admin","createTime":"2024-05-27 14:10:09","dept":{"id":18,"name":"前厅"},"deptId":null,"email":null,"enabled":true,"gender":null,"id":40,"isAdmin":false,"jobs":[{"id":10,"name":"产品经理"}],"nickName":"双屿pirse(测77)","password":"$2a$10$j414tLJ/fdXXzXriW3y9A.QdP9Ak1.1hiGbvb1.zmQjPc5q.xoipy","phone":"13575788745","pwdResetTime":"2024-08-05 14:18:59","roles":[{"dataScope":"本级","id":2,"level":2,"name":"普通用户"}],"updateBy":"admin","updateTime":"2024-05-27 14:10:09","username":"13718478323"}

User userFromJson(String str) => User.fromJson(json.decode(str));

String userToJson(User data) => json.encode(data.toJson());

class User {
  User({
    List<Authorities>? authorities,
    List<num>? dataScopes,
    List<String>? roles,
    UserInfo? userInfo,
  }) {
    _authorities = authorities;
    _dataScopes = dataScopes;
    _roles = roles;
    _userInfo = userInfo;
  }

  User.fromJson(dynamic json) {
    if (json['authorities'] != null) {
      _authorities = [];
      json['authorities'].forEach((v) {
        _authorities?.add(Authorities.fromJson(v));
      });
    }
    _dataScopes =
        json['dataScopes'] != null ? json['dataScopes'].cast<num>() : [];
    _roles = json['roles'] != null ? json['roles'].cast<String>() : [];
    _userInfo = json['user'] != null ? UserInfo.fromJson(json['user']) : null;
  }

  List<Authorities>? _authorities;
  List<num>? _dataScopes;
  List<String>? _roles;
  UserInfo? _userInfo;

  User copyWith({
    List<Authorities>? authorities,
    List<num>? dataScopes,
    List<String>? roles,
    UserInfo? userInfo,
  }) =>
      User(
        authorities: authorities ?? _authorities,
        dataScopes: dataScopes ?? _dataScopes,
        roles: roles ?? _roles,
        userInfo: userInfo ?? _userInfo,
      );

  List<Authorities>? get authorities => _authorities;

  List<num>? get dataScopes => _dataScopes;

  List<String>? get roles => _roles;

  UserInfo? get userInfo => _userInfo;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    if (_authorities != null) {
      map['authorities'] = _authorities?.map((v) => v.toJson()).toList();
    }
    map['dataScopes'] = _dataScopes;
    map['roles'] = _roles;
    if (_userInfo != null) {
      map['user'] = _userInfo?.toJson();
    }
    return map;
  }
}

/// avatarName : null
/// avatarPath : null
/// createBy : "admin"
/// createTime : "2024-05-27 14:10:09"
/// dept : {"id":18,"name":"前厅"}
/// deptId : null
/// email : null
/// enabled : true
/// gender : null
/// id : 40
/// isAdmin : false
/// jobs : [{"id":10,"name":"产品经理"}]
/// nickName : "双屿pirse(测77)"
/// password : "$2a$10$j414tLJ/fdXXzXriW3y9A.QdP9Ak1.1hiGbvb1.zmQjPc5q.xoipy"
/// phone : "13575788745"
/// pwdResetTime : "2024-08-05 14:18:59"
/// roles : [{"dataScope":"本级","id":2,"level":2,"name":"普通用户"}]
/// updateBy : "admin"
/// updateTime : "2024-05-27 14:10:09"
/// username : "13718478323"

User userInfoFromJson(String str) => User.fromJson(json.decode(str));

String userInfoToJson(User data) => json.encode(data.toJson());

class UserInfo {
  UserInfo({
    dynamic avatarName,
    dynamic avatarPath,
    String? createBy,
    String? createTime,
    Dept? dept,
    dynamic deptId,
    dynamic email,
    bool? enabled,
    dynamic gender,
    num? id,
    bool? isAdmin,
    List<Jobs>? jobs,
    String? nickName,
    String? password,
    String? phone,
    String? pwdResetTime,
    List<Roles>? roles,
    String? updateBy,
    String? updateTime,
    String? username,
  }) {
    _avatarName = avatarName;
    _avatarPath = avatarPath;
    _createBy = createBy;
    _createTime = createTime;
    _dept = dept;
    _deptId = deptId;
    _email = email;
    _enabled = enabled;
    _gender = gender;
    _id = id;
    _isAdmin = isAdmin;
    _jobs = jobs;
    _nickName = nickName;
    _password = password;
    _phone = phone;
    _pwdResetTime = pwdResetTime;
    _roles = roles;
    _updateBy = updateBy;
    _updateTime = updateTime;
    _username = username;
  }

  UserInfo.fromJson(dynamic json) {
    _avatarName = json['avatarName'];
    _avatarPath = json['avatarPath'];
    _createBy = json['createBy'];
    _createTime = json['createTime'];
    _dept = json['dept'] != null ? Dept.fromJson(json['dept']) : null;
    _deptId = json['deptId'];
    _email = json['email'];
    _enabled = json['enabled'];
    _gender = json['gender'];
    _id = json['id'];
    _isAdmin = json['isAdmin'];
    if (json['jobs'] != null) {
      _jobs = [];
      json['jobs'].forEach((v) {
        _jobs?.add(Jobs.fromJson(v));
      });
    }
    _nickName = json['nickName'];
    _password = json['password'];
    _phone = json['phone'];
    _pwdResetTime = json['pwdResetTime'];
    if (json['roles'] != null) {
      _roles = [];
      json['roles'].forEach((v) {
        _roles?.add(Roles.fromJson(v));
      });
    }
    _updateBy = json['updateBy'];
    _updateTime = json['updateTime'];
    _username = json['username'];
  }

  dynamic _avatarName;
  dynamic _avatarPath;
  String? _createBy;
  String? _createTime;
  Dept? _dept;
  dynamic _deptId;
  dynamic _email;
  bool? _enabled;
  dynamic _gender;
  num? _id;
  bool? _isAdmin;
  List<Jobs>? _jobs;
  String? _nickName;
  String? _password;
  String? _phone;
  String? _pwdResetTime;
  List<Roles>? _roles;
  String? _updateBy;
  String? _updateTime;
  String? _username;

  UserInfo copyWith({
    dynamic avatarName,
    dynamic avatarPath,
    String? createBy,
    String? createTime,
    Dept? dept,
    dynamic deptId,
    dynamic email,
    bool? enabled,
    dynamic gender,
    num? id,
    bool? isAdmin,
    List<Jobs>? jobs,
    String? nickName,
    String? password,
    String? phone,
    String? pwdResetTime,
    List<Roles>? roles,
    String? updateBy,
    String? updateTime,
    String? username,
  }) =>
      UserInfo(
        avatarName: avatarName ?? _avatarName,
        avatarPath: avatarPath ?? _avatarPath,
        createBy: createBy ?? _createBy,
        createTime: createTime ?? _createTime,
        dept: dept ?? _dept,
        deptId: deptId ?? _deptId,
        email: email ?? _email,
        enabled: enabled ?? _enabled,
        gender: gender ?? _gender,
        id: id ?? _id,
        isAdmin: isAdmin ?? _isAdmin,
        jobs: jobs ?? _jobs,
        nickName: nickName ?? _nickName,
        password: password ?? _password,
        phone: phone ?? _phone,
        pwdResetTime: pwdResetTime ?? _pwdResetTime,
        roles: roles ?? _roles,
        updateBy: updateBy ?? _updateBy,
        updateTime: updateTime ?? _updateTime,
        username: username ?? _username,
      );

  dynamic get avatarName => _avatarName;

  dynamic get avatarPath => _avatarPath;

  String? get createBy => _createBy;

  String? get createTime => _createTime;

  Dept? get dept => _dept;

  dynamic get deptId => _deptId;

  dynamic get email => _email;

  bool? get enabled => _enabled;

  dynamic get gender => _gender;

  num? get id => _id;

  bool? get isAdmin => _isAdmin;

  List<Jobs>? get jobs => _jobs;

  String? get nickName => _nickName;

  String? get password => _password;

  String? get phone => _phone;

  String? get pwdResetTime => _pwdResetTime;

  List<Roles>? get roles => _roles;

  String? get updateBy => _updateBy;

  String? get updateTime => _updateTime;

  String? get username => _username;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['avatarName'] = _avatarName;
    map['avatarPath'] = _avatarPath;
    map['createBy'] = _createBy;
    map['createTime'] = _createTime;
    if (_dept != null) {
      map['dept'] = _dept?.toJson();
    }
    map['deptId'] = _deptId;
    map['email'] = _email;
    map['enabled'] = _enabled;
    map['gender'] = _gender;
    map['id'] = _id;
    map['isAdmin'] = _isAdmin;
    if (_jobs != null) {
      map['jobs'] = _jobs?.map((v) => v.toJson()).toList();
    }
    map['nickName'] = _nickName;
    map['password'] = _password;
    map['phone'] = _phone;
    map['pwdResetTime'] = _pwdResetTime;
    if (_roles != null) {
      map['roles'] = _roles?.map((v) => v.toJson()).toList();
    }
    map['updateBy'] = _updateBy;
    map['updateTime'] = _updateTime;
    map['username'] = _username;
    return map;
  }
}

/// dataScope : "本级"
/// id : 2
/// level : 2
/// name : "普通用户"

Roles rolesFromJson(String str) => Roles.fromJson(json.decode(str));

String rolesToJson(Roles data) => json.encode(data.toJson());

class Roles {
  Roles({
    String? dataScope,
    num? id,
    num? level,
    String? name,
  }) {
    _dataScope = dataScope;
    _id = id;
    _level = level;
    _name = name;
  }

  Roles.fromJson(dynamic json) {
    _dataScope = json['dataScope'];
    _id = json['id'];
    _level = json['level'];
    _name = json['name'];
  }

  String? _dataScope;
  num? _id;
  num? _level;
  String? _name;

  Roles copyWith({
    String? dataScope,
    num? id,
    num? level,
    String? name,
  }) =>
      Roles(
        dataScope: dataScope ?? _dataScope,
        id: id ?? _id,
        level: level ?? _level,
        name: name ?? _name,
      );

  String? get dataScope => _dataScope;

  num? get id => _id;

  num? get level => _level;

  String? get name => _name;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['dataScope'] = _dataScope;
    map['id'] = _id;
    map['level'] = _level;
    map['name'] = _name;
    return map;
  }
}

/// id : 10
/// name : "产品经理"

Jobs jobsFromJson(String str) => Jobs.fromJson(json.decode(str));

String jobsToJson(Jobs data) => json.encode(data.toJson());

class Jobs {
  Jobs({
    num? id,
    String? name,
  }) {
    _id = id;
    _name = name;
  }

  Jobs.fromJson(dynamic json) {
    _id = json['id'];
    _name = json['name'];
  }

  num? _id;
  String? _name;

  Jobs copyWith({
    num? id,
    String? name,
  }) =>
      Jobs(
        id: id ?? _id,
        name: name ?? _name,
      );

  num? get id => _id;

  String? get name => _name;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = _id;
    map['name'] = _name;
    return map;
  }
}

/// id : 18
/// name : "前厅"

Dept deptFromJson(String str) => Dept.fromJson(json.decode(str));

String deptToJson(Dept data) => json.encode(data.toJson());

class Dept {
  Dept({
    num? id,
    String? name,
  }) {
    _id = id;
    _name = name;
  }

  Dept.fromJson(dynamic json) {
    _id = json['id'];
    _name = json['name'];
  }

  num? _id;
  String? _name;

  Dept copyWith({
    num? id,
    String? name,
  }) =>
      Dept(
        id: id ?? _id,
        name: name ?? _name,
      );

  num? get id => _id;

  String? get name => _name;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['id'] = _id;
    map['name'] = _name;
    return map;
  }
}

/// authority : "tbProductGroup:del"

Authorities authoritiesFromJson(String str) =>
    Authorities.fromJson(json.decode(str));

String authoritiesToJson(Authorities data) => json.encode(data.toJson());

class Authorities {
  Authorities({
    String? authority,
  }) {
    _authority = authority;
  }

  Authorities.fromJson(dynamic json) {
    _authority = json['authority'];
  }

  String? _authority;

  Authorities copyWith({
    String? authority,
  }) =>
      Authorities(
        authority: authority ?? _authority,
      );

  String? get authority => _authority;

  Map<String, dynamic> toJson() {
    final map = <String, dynamic>{};
    map['authority'] = _authority;
    return map;
  }
}
