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

JobListDetailEntity $JobListDetailEntityFromJson(Map<String, dynamic> json) {
  final JobListDetailEntity jobListDetailEntity = JobListDetailEntity();
  final int? jobId = jsonConvert.convert<int>(json['job_id']);
  if (jobId != null) {
    jobListDetailEntity.jobId = jobId;
  }
  final String? jobTitle = jsonConvert.convert<String>(json['job_title']);
  if (jobTitle != null) {
    jobListDetailEntity.jobTitle = jobTitle;
  }
  final int? needNum = jsonConvert.convert<int>(json['need_num']);
  if (needNum != null) {
    jobListDetailEntity.needNum = needNum;
  }
  final String? departmentId = jsonConvert.convert<String>(json['department_id']);
  if (departmentId != null) {
    jobListDetailEntity.departmentId = departmentId;
  }
  final String? startTime = jsonConvert.convert<String>(json['start_time']);
  if (startTime != null) {
    jobListDetailEntity.startTime = startTime;
  }
  final String? endTime = jsonConvert.convert<String>(json['end_time']);
  if (endTime != null) {
    jobListDetailEntity.endTime = endTime;
  }
  final List<JobListDetailDepartmentList>? departmentList = (json['department_list'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<JobListDetailDepartmentList>(e) as JobListDetailDepartmentList).toList();
  if (departmentList != null) {
    jobListDetailEntity.departmentList = departmentList;
  }
  return jobListDetailEntity;
}

Map<String, dynamic> $JobListDetailEntityToJson(JobListDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['job_id'] = entity.jobId;
  data['job_title'] = entity.jobTitle;
  data['need_num'] = entity.needNum;
  data['department_id'] = entity.departmentId;
  data['start_time'] = entity.startTime;
  data['end_time'] = entity.endTime;
  data['department_list'] = entity.departmentList?.map((v) => v.toJson()).toList();
  return data;
}

extension JobListDetailEntityExtension on JobListDetailEntity {
  JobListDetailEntity copyWith({
    int? jobId,
    String? jobTitle,
    int? needNum,
    String? departmentId,
    String? startTime,
    String? endTime,
    List<JobListDetailDepartmentList>? departmentList,
  }) {
    return JobListDetailEntity()
      ..jobId = jobId ?? this.jobId
      ..jobTitle = jobTitle ?? this.jobTitle
      ..needNum = needNum ?? this.needNum
      ..departmentId = departmentId ?? this.departmentId
      ..startTime = startTime ?? this.startTime
      ..endTime = endTime ?? this.endTime
      ..departmentList = departmentList ?? this.departmentList;
  }
}

JobListDetailDepartmentList $JobListDetailDepartmentListFromJson(Map<String, dynamic> json) {
  final JobListDetailDepartmentList jobListDetailDepartmentList = JobListDetailDepartmentList();
  final int? value = jsonConvert.convert<int>(json['value']);
  if (value != null) {
    jobListDetailDepartmentList.value = value;
  }
  final String? txt = jsonConvert.convert<String>(json['txt']);
  if (txt != null) {
    jobListDetailDepartmentList.txt = txt;
  }
  final String? selected = jsonConvert.convert<String>(json['selected']);
  if (selected != null) {
    jobListDetailDepartmentList.selected = selected;
  }
  return jobListDetailDepartmentList;
}

Map<String, dynamic> $JobListDetailDepartmentListToJson(JobListDetailDepartmentList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['value'] = entity.value;
  data['txt'] = entity.txt;
  data['selected'] = entity.selected;
  return data;
}

extension JobListDetailDepartmentListExtension on JobListDetailDepartmentList {
  JobListDetailDepartmentList copyWith({
    int? value,
    String? txt,
    String? selected,
  }) {
    return JobListDetailDepartmentList()
      ..value = value ?? this.value
      ..txt = txt ?? this.txt
      ..selected = selected ?? this.selected;
  }
}