import 'package:drift/drift.dart';
import 'package:im_app/data/local/drift/app_database.dart';
import 'package:im_app/domain/entities/pending_friend_request_history.dart';

/// 待处理好友请求历史 DTO
class PendingFriendRequestHistoryDto {
  final int id;
  final int uid;
  final int requestTime;
  final String? remarks;
  final String? source;
  final int? rs;

  const PendingFriendRequestHistoryDto({
    required this.id,
    required this.uid,
    required this.requestTime,
    this.remarks,
    this.source,
    this.rs,
  });

  factory PendingFriendRequestHistoryDto.fromJson(Map<String, dynamic> json) =>
      PendingFriendRequestHistoryDto(
        id: json['id'] as int,
        uid: json['uid'] as int,
        requestTime: json['request_time'] as int,
        remarks: json['remarks'],
        source: json['source'],
        rs: json['rs'],
      );

  Map<String, dynamic> toJson() => {
        'id': id,
        'uid': uid,
        'request_time': requestTime,
        'remarks': remarks,
        'source': source,
        'rs': rs,
      };

  PendingFriendRequestHistory toEntity() => PendingFriendRequestHistory(
        id: id,
        uid: uid,
        requestTime: requestTime,
        remarks: remarks,
        source: source,
        rs: rs,
      );

  factory PendingFriendRequestHistoryDto.fromEntity(
          PendingFriendRequestHistory history) =>
      PendingFriendRequestHistoryDto(
        id: history.id,
        uid: history.uid,
        requestTime: history.requestTime,
        remarks: history.remarks,
        source: history.source,
        rs: history.rs,
      );

  PendingFriendRequestHistoriesCompanion toCompanion() =>
      PendingFriendRequestHistoriesCompanion(
        id: Value(id),
        uid: Value(uid),
        requestTime: Value(requestTime),
        remarks: Value(remarks),
        source: Value(source),
        rs: Value(rs),
      );
}