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

LabourRequestListEntity $LabourRequestListEntityFromJson(Map<String, dynamic> json) {
  final LabourRequestListEntity labourRequestListEntity = LabourRequestListEntity();
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    labourRequestListEntity.total = total;
  }
  final List<LabourRequestListRows>? rows = (json['rows'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<LabourRequestListRows>(e) as LabourRequestListRows).toList();
  if (rows != null) {
    labourRequestListEntity.rows = rows;
  }
  return labourRequestListEntity;
}

Map<String, dynamic> $LabourRequestListEntityToJson(LabourRequestListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['total'] = entity.total;
  data['rows'] = entity.rows?.map((v) => v.toJson()).toList();
  return data;
}

extension LabourRequestListEntityExtension on LabourRequestListEntity {
  LabourRequestListEntity copyWith({
    int? total,
    List<LabourRequestListRows>? rows,
  }) {
    return LabourRequestListEntity()
      ..total = total ?? this.total
      ..rows = rows ?? this.rows;
  }
}

LabourRequestListRows $LabourRequestListRowsFromJson(Map<String, dynamic> json) {
  final LabourRequestListRows labourRequestListRows = LabourRequestListRows();
  final int? requestId = jsonConvert.convert<int>(json['request_id']);
  if (requestId != null) {
    labourRequestListRows.requestId = requestId;
  }
  final String? jobTitle = jsonConvert.convert<String>(json['job_title']);
  if (jobTitle != null) {
    labourRequestListRows.jobTitle = jobTitle;
  }
  final String? departmentName = jsonConvert.convert<String>(json['department_name']);
  if (departmentName != null) {
    labourRequestListRows.departmentName = departmentName;
  }
  final String? jobTime = jsonConvert.convert<String>(json['job_time']);
  if (jobTime != null) {
    labourRequestListRows.jobTime = jobTime;
  }
  final int? needNum = jsonConvert.convert<int>(json['need_num']);
  if (needNum != null) {
    labourRequestListRows.needNum = needNum;
  }
  final int? coStatus = jsonConvert.convert<int>(json['co_status']);
  if (coStatus != null) {
    labourRequestListRows.coStatus = coStatus;
  }
  final String? coStatusShow = jsonConvert.convert<String>(json['co_status_show']);
  if (coStatusShow != null) {
    labourRequestListRows.coStatusShow = coStatusShow;
  }
  final bool? publishStatus = jsonConvert.convert<bool>(json['publish_status']);
  if (publishStatus != null) {
    labourRequestListRows.publishStatus = publishStatus;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    labourRequestListRows.createdAt = createdAt;
  }
  final List<String>? actionList = (json['action_list'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (actionList != null) {
    labourRequestListRows.actionList = actionList;
  }
  return labourRequestListRows;
}

Map<String, dynamic> $LabourRequestListRowsToJson(LabourRequestListRows entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['request_id'] = entity.requestId;
  data['job_title'] = entity.jobTitle;
  data['department_name'] = entity.departmentName;
  data['job_time'] = entity.jobTime;
  data['need_num'] = entity.needNum;
  data['co_status'] = entity.coStatus;
  data['co_status_show'] = entity.coStatusShow;
  data['publish_status'] = entity.publishStatus;
  data['created_at'] = entity.createdAt;
  data['action_list'] = entity.actionList;
  return data;
}

extension LabourRequestListRowsExtension on LabourRequestListRows {
  LabourRequestListRows copyWith({
    int? requestId,
    String? jobTitle,
    String? departmentName,
    String? jobTime,
    int? needNum,
    int? coStatus,
    String? coStatusShow,
    bool? publishStatus,
    String? createdAt,
    List<String>? actionList,
  }) {
    return LabourRequestListRows()
      ..requestId = requestId ?? this.requestId
      ..jobTitle = jobTitle ?? this.jobTitle
      ..departmentName = departmentName ?? this.departmentName
      ..jobTime = jobTime ?? this.jobTime
      ..needNum = needNum ?? this.needNum
      ..coStatus = coStatus ?? this.coStatus
      ..coStatusShow = coStatusShow ?? this.coStatusShow
      ..publishStatus = publishStatus ?? this.publishStatus
      ..createdAt = createdAt ?? this.createdAt
      ..actionList = actionList ?? this.actionList;
  }
}