/// 그룹(권한 집합) 엔티티
///
/// - SRP: 그룹의 속성 정보만 표현한다.
/// - presentation/data 레이어의 구현 세부사항을 포함하지 않는다.
class Group {
  Group({
    this.id,
    required this.groupName,
    this.description,
    this.isDefault = false,
    this.isActive = true,
    this.isDeleted = false,
    this.note,
    this.createdAt,
    this.updatedAt,
  });

  /// PK (null 이면 신규 생성)
  final int? id;

  /// 그룹명
  final String groupName;

  /// 그룹 설명(선택)
  final String? description;

  /// 기본 그룹 여부
  final bool isDefault;

  /// 사용 여부
  final bool isActive;

  /// 삭제 여부(소프트 삭제)
  final bool isDeleted;

  /// 비고 메모
  final String? note;

  /// 타임스탬프
  final DateTime? createdAt;
  final DateTime? updatedAt;

  Group copyWith({
    int? id,
    String? groupName,
    String? description,
    bool? isDefault,
    bool? isActive,
    bool? isDeleted,
    String? note,
    DateTime? createdAt,
    DateTime? updatedAt,
  }) {
    return Group(
      id: id ?? this.id,
      groupName: groupName ?? this.groupName,
      description: description ?? this.description,
      isDefault: isDefault ?? this.isDefault,
      isActive: isActive ?? this.isActive,
      isDeleted: isDeleted ?? this.isDeleted,
      note: note ?? this.note,
      createdAt: createdAt ?? this.createdAt,
      updatedAt: updatedAt ?? this.updatedAt,
    );
  }
}

/// 그룹 생성/수정 입력 모델
class GroupInput {
  GroupInput({
    required this.groupName,
    this.description,
    this.isDefault = false,
    this.isActive = true,
    this.note,
  });

  final String groupName;
  final String? description;
  final bool isDefault;
  final bool isActive;
  final String? note;

  Map<String, dynamic> toPayload() {
    return {
      'group_name': groupName,
      'description': description,
      'is_default': isDefault,
      'is_active': isActive,
      'note': note,
    };
  }
}
