import 'package:domain/generated/json/base/json_convert_content.dart';
import 'package:domain/entity/response/revise_log_s_g_entity.dart';

ReviseLogSGEntity $ReviseLogSGEntityFromJson(Map<String, dynamic> json) {
  final ReviseLogSGEntity reviseLogSGEntity = ReviseLogSGEntity();
  final List<ReviseLogSGRecords>? records = (json['records'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<ReviseLogSGRecords>(e) as ReviseLogSGRecords).toList();
  if (records != null) {
    reviseLogSGEntity.records = records;
  }
  return reviseLogSGEntity;
}

Map<String, dynamic> $ReviseLogSGEntityToJson(ReviseLogSGEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['records'] = entity.records.map((v) => v.toJson()).toList();
  return data;
}

extension ReviseLogSGEntityExtension on ReviseLogSGEntity {
  ReviseLogSGEntity copyWith({
    List<ReviseLogSGRecords>? records,
  }) {
    return ReviseLogSGEntity()
      ..records = records ?? this.records;
  }
}

ReviseLogSGRecords $ReviseLogSGRecordsFromJson(Map<String, dynamic> json) {
  final ReviseLogSGRecords reviseLogSGRecords = ReviseLogSGRecords();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    reviseLogSGRecords.id = id;
  }
  final String? operationName = jsonConvert.convert<String>(json['operation_name']);
  if (operationName != null) {
    reviseLogSGRecords.operationName = operationName;
  }
  final int? dataType = jsonConvert.convert<int>(json['data_type']);
  if (dataType != null) {
    reviseLogSGRecords.dataType = dataType;
  }
  final String? desc = jsonConvert.convert<String>(json['desc']);
  if (desc != null) {
    reviseLogSGRecords.desc = desc;
  }
  final ReviseLogSGRecordsContent? content = jsonConvert.convert<ReviseLogSGRecordsContent>(json['content']);
  if (content != null) {
    reviseLogSGRecords.content = content;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    reviseLogSGRecords.createdAt = createdAt;
  }
  final String? actClass = jsonConvert.convert<String>(json['act_class']);
  if (actClass != null) {
    reviseLogSGRecords.actClass = actClass;
  }
  final String? actText = jsonConvert.convert<String>(json['act_text']);
  if (actText != null) {
    reviseLogSGRecords.actText = actText;
  }
  return reviseLogSGRecords;
}

Map<String, dynamic> $ReviseLogSGRecordsToJson(ReviseLogSGRecords entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['operation_name'] = entity.operationName;
  data['data_type'] = entity.dataType;
  data['desc'] = entity.desc;
  data['content'] = entity.content?.toJson();
  data['created_at'] = entity.createdAt;
  data['act_class'] = entity.actClass;
  data['act_text'] = entity.actText;
  return data;
}

extension ReviseLogSGRecordsExtension on ReviseLogSGRecords {
  ReviseLogSGRecords copyWith({
    String? id,
    String? operationName,
    int? dataType,
    String? desc,
    ReviseLogSGRecordsContent? content,
    String? createdAt,
    String? actClass,
    String? actText,
  }) {
    return ReviseLogSGRecords()
      ..id = id ?? this.id
      ..operationName = operationName ?? this.operationName
      ..dataType = dataType ?? this.dataType
      ..desc = desc ?? this.desc
      ..content = content ?? this.content
      ..createdAt = createdAt ?? this.createdAt
      ..actClass = actClass ?? this.actClass
      ..actText = actText ?? this.actText;
  }
}

ReviseLogSGRecordsContent $ReviseLogSGRecordsContentFromJson(Map<String, dynamic> json) {
  final ReviseLogSGRecordsContent reviseLogSGRecordsContent = ReviseLogSGRecordsContent();
  final ReviseLogSGRecordsOption? reviseHours = jsonConvert.convert<ReviseLogSGRecordsOption>(json['revise_hours']);
  if (reviseHours != null) {
    reviseLogSGRecordsContent.reviseHours = reviseHours;
  }
  final ReviseLogSGRecordsOption? reviseMsg = jsonConvert.convert<ReviseLogSGRecordsOption>(json['revise_msg']);
  if (reviseMsg != null) {
    reviseLogSGRecordsContent.reviseMsg = reviseMsg;
  }
  final ReviseLogSGRecordsOption? status = jsonConvert.convert<ReviseLogSGRecordsOption>(json['status']);
  if (status != null) {
    reviseLogSGRecordsContent.status = status;
  }
  return reviseLogSGRecordsContent;
}

Map<String, dynamic> $ReviseLogSGRecordsContentToJson(ReviseLogSGRecordsContent entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['revise_hours'] = entity.reviseHours?.toJson();
  data['revise_msg'] = entity.reviseMsg?.toJson();
  data['status'] = entity.status?.toJson();
  return data;
}

extension ReviseLogSGRecordsContentExtension on ReviseLogSGRecordsContent {
  ReviseLogSGRecordsContent copyWith({
    ReviseLogSGRecordsOption? reviseHours,
    ReviseLogSGRecordsOption? reviseMsg,
    ReviseLogSGRecordsOption? status,
  }) {
    return ReviseLogSGRecordsContent()
      ..reviseHours = reviseHours ?? this.reviseHours
      ..reviseMsg = reviseMsg ?? this.reviseMsg
      ..status = status ?? this.status;
  }
}

ReviseLogSGRecordsOption $ReviseLogSGRecordsOptionFromJson(Map<String, dynamic> json) {
  final ReviseLogSGRecordsOption reviseLogSGRecordsOption = ReviseLogSGRecordsOption();
  final String? field = jsonConvert.convert<String>(json['field']);
  if (field != null) {
    reviseLogSGRecordsOption.field = field;
  }
  final String? value = jsonConvert.convert<String>(json['value']);
  if (value != null) {
    reviseLogSGRecordsOption.value = value;
  }
  return reviseLogSGRecordsOption;
}

Map<String, dynamic> $ReviseLogSGRecordsOptionToJson(ReviseLogSGRecordsOption entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['field'] = entity.field;
  data['value'] = entity.value;
  return data;
}

extension ReviseLogSGRecordsOptionExtension on ReviseLogSGRecordsOption {
  ReviseLogSGRecordsOption copyWith({
    String? field,
    String? value,
  }) {
    return ReviseLogSGRecordsOption()
      ..field = field ?? this.field
      ..value = value ?? this.value;
  }
}