import 'package:equatable/equatable.dart';

class UserInfoBO extends Equatable {
  final int userId;
  final String userName;
  final String nickName;
  final String phonenumber;
  final String email;
  final String sex;
  final String avatarUrl;
  final String deptName;
  final String tenantId;

  const UserInfoBO({
    required this.userId,
    required this.userName,
    required this.nickName,
    required this.phonenumber,
    required this.email,
    required this.sex,
    required this.avatarUrl,
    required this.deptName,
    required this.tenantId,
  });

  factory UserInfoBO.fromJson(Map<String, dynamic> json) {
    return UserInfoBO(
      userId: int.tryParse(json['userId']?.toString() ?? '') ?? 0,
      userName: json['userName'] as String? ?? '',
      nickName: json['nickName'] as String? ?? '',
      phonenumber: json['phonenumber'] as String? ?? '',
      email: json['email'] as String? ?? '',
      sex: json['sex'] as String? ?? '',
      avatarUrl: json['avatarUrl'] as String? ?? '',
      deptName: json['deptName'] as String? ?? '',
      tenantId: json['tenantId'] as String? ?? '',
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'userId': userId,
      'userName': userName,
      'nickName': nickName,
      'phonenumber': phonenumber,
      'email': email,
      'sex': sex,
      'avatarUrl': avatarUrl,
      'deptName': deptName,
      'tenantId': tenantId,
    };
  }

  @override
  List<Object?> get props => [
        userId,
        userName,
        nickName,
        phonenumber,
        email,
        sex,
        avatarUrl,
        deptName,
        tenantId,
      ];
}
