From 650f7fefe94b78d18d2614994da510ca37ad0b99 Mon Sep 17 00:00:00 2001 From: Conner Date: Thu, 24 Oct 2024 22:35:05 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20#8/PaginationDto,=20JobPostingWorkerDto?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 기본 페이지네이션 모델인 PaginationDto 추가 2. 지원자 모델 JobPostingWorkerDto 추가 3. PaginationDto 로 지원자 목록 모델 추가 --- lib/core/network/dto/dto.dart | 1 + .../dto/pagination/pagination_dto.dart | 30 ++ .../pagination/pagination_dto.freezed.dart | 266 +++++++++++++++++ .../dto/pagination/pagination_dto.g.dart | 31 ++ lib/core/network/network.dart | 1 + .../dto/worker/job_posting_worker_dto.dart | 20 ++ .../job_posting_worker_dto.freezed.dart | 271 ++++++++++++++++++ .../dto/worker/job_posting_worker_dto.g.dart | 32 +++ .../dto/worker/job_posting_workers_dto.dart | 6 + .../data/data_sources/dto/worker/worker.dart | 2 + .../data_sources/dto/simple_user_dto.dart | 5 + .../dto/simple_user_dto.freezed.dart | 23 +- .../data_sources/dto/simple_user_dto.g.dart | 23 ++ 13 files changed, 710 insertions(+), 1 deletion(-) create mode 100644 lib/core/network/dto/dto.dart create mode 100644 lib/core/network/dto/pagination/pagination_dto.dart create mode 100644 lib/core/network/dto/pagination/pagination_dto.freezed.dart create mode 100644 lib/core/network/dto/pagination/pagination_dto.g.dart create mode 100644 lib/feature/job_posting/data/data_sources/dto/worker/job_posting_worker_dto.dart create mode 100644 lib/feature/job_posting/data/data_sources/dto/worker/job_posting_worker_dto.freezed.dart create mode 100644 lib/feature/job_posting/data/data_sources/dto/worker/job_posting_worker_dto.g.dart create mode 100644 lib/feature/job_posting/data/data_sources/dto/worker/job_posting_workers_dto.dart create mode 100644 lib/feature/job_posting/data/data_sources/dto/worker/worker.dart create mode 100644 lib/feature/user/data/data_sources/dto/simple_user_dto.g.dart diff --git a/lib/core/network/dto/dto.dart b/lib/core/network/dto/dto.dart new file mode 100644 index 0000000..3637e1d --- /dev/null +++ b/lib/core/network/dto/dto.dart @@ -0,0 +1 @@ +export 'pagination/pagination_dto.dart'; diff --git a/lib/core/network/dto/pagination/pagination_dto.dart b/lib/core/network/dto/pagination/pagination_dto.dart new file mode 100644 index 0000000..b1a0e4f --- /dev/null +++ b/lib/core/network/dto/pagination/pagination_dto.dart @@ -0,0 +1,30 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'pagination_dto.freezed.dart'; + +part 'pagination_dto.g.dart'; + +@Freezed(genericArgumentFactories: true) +class PaginationDto with _$PaginationDto { + factory PaginationDto({ + required List content, + required int totalPages, + required int totalElements, + required int size, + required int number, + }) = _PaginationDto; + + factory PaginationDto.fromJson( + Map json, Function itemFromJson) { + var content = json['content'].cast>(); + return PaginationDto( + content: List.from( + content.map((itemJson) => itemFromJson(itemJson)), + ), + totalPages: json['totalPages'] as int, + totalElements: json['totalElements'] as int, + number: json['number'] as int, + size: json['size'] as int, + ); + } +} diff --git a/lib/core/network/dto/pagination/pagination_dto.freezed.dart b/lib/core/network/dto/pagination/pagination_dto.freezed.dart new file mode 100644 index 0000000..e0c3701 --- /dev/null +++ b/lib/core/network/dto/pagination/pagination_dto.freezed.dart @@ -0,0 +1,266 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'pagination_dto.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +PaginationDto _$PaginationDtoFromJson( + Map json, T Function(Object?) fromJsonT) { + return _PaginationDto.fromJson(json, fromJsonT); +} + +/// @nodoc +mixin _$PaginationDto { + List get content => throw _privateConstructorUsedError; + int get totalPages => throw _privateConstructorUsedError; + int get totalElements => throw _privateConstructorUsedError; + int get size => throw _privateConstructorUsedError; + int get number => throw _privateConstructorUsedError; + + /// Serializes this PaginationDto to a JSON map. + Map toJson(Object? Function(T) toJsonT) => + throw _privateConstructorUsedError; + + /// Create a copy of PaginationDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $PaginationDtoCopyWith> get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $PaginationDtoCopyWith { + factory $PaginationDtoCopyWith( + PaginationDto value, $Res Function(PaginationDto) then) = + _$PaginationDtoCopyWithImpl>; + @useResult + $Res call( + {List content, + int totalPages, + int totalElements, + int size, + int number}); +} + +/// @nodoc +class _$PaginationDtoCopyWithImpl> + implements $PaginationDtoCopyWith { + _$PaginationDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of PaginationDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? content = null, + Object? totalPages = null, + Object? totalElements = null, + Object? size = null, + Object? number = null, + }) { + return _then(_value.copyWith( + content: null == content + ? _value.content + : content // ignore: cast_nullable_to_non_nullable + as List, + totalPages: null == totalPages + ? _value.totalPages + : totalPages // ignore: cast_nullable_to_non_nullable + as int, + totalElements: null == totalElements + ? _value.totalElements + : totalElements // ignore: cast_nullable_to_non_nullable + as int, + size: null == size + ? _value.size + : size // ignore: cast_nullable_to_non_nullable + as int, + number: null == number + ? _value.number + : number // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$PaginationDtoImplCopyWith + implements $PaginationDtoCopyWith { + factory _$$PaginationDtoImplCopyWith(_$PaginationDtoImpl value, + $Res Function(_$PaginationDtoImpl) then) = + __$$PaginationDtoImplCopyWithImpl; + @override + @useResult + $Res call( + {List content, + int totalPages, + int totalElements, + int size, + int number}); +} + +/// @nodoc +class __$$PaginationDtoImplCopyWithImpl + extends _$PaginationDtoCopyWithImpl> + implements _$$PaginationDtoImplCopyWith { + __$$PaginationDtoImplCopyWithImpl(_$PaginationDtoImpl _value, + $Res Function(_$PaginationDtoImpl) _then) + : super(_value, _then); + + /// Create a copy of PaginationDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? content = null, + Object? totalPages = null, + Object? totalElements = null, + Object? size = null, + Object? number = null, + }) { + return _then(_$PaginationDtoImpl( + content: null == content + ? _value._content + : content // ignore: cast_nullable_to_non_nullable + as List, + totalPages: null == totalPages + ? _value.totalPages + : totalPages // ignore: cast_nullable_to_non_nullable + as int, + totalElements: null == totalElements + ? _value.totalElements + : totalElements // ignore: cast_nullable_to_non_nullable + as int, + size: null == size + ? _value.size + : size // ignore: cast_nullable_to_non_nullable + as int, + number: null == number + ? _value.number + : number // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable(genericArgumentFactories: true) +class _$PaginationDtoImpl implements _PaginationDto { + _$PaginationDtoImpl( + {required final List content, + required this.totalPages, + required this.totalElements, + required this.size, + required this.number}) + : _content = content; + + factory _$PaginationDtoImpl.fromJson( + Map json, T Function(Object?) fromJsonT) => + _$$PaginationDtoImplFromJson(json, fromJsonT); + + final List _content; + @override + List get content { + if (_content is EqualUnmodifiableListView) return _content; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_content); + } + + @override + final int totalPages; + @override + final int totalElements; + @override + final int size; + @override + final int number; + + @override + String toString() { + return 'PaginationDto<$T>(content: $content, totalPages: $totalPages, totalElements: $totalElements, size: $size, number: $number)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$PaginationDtoImpl && + const DeepCollectionEquality().equals(other._content, _content) && + (identical(other.totalPages, totalPages) || + other.totalPages == totalPages) && + (identical(other.totalElements, totalElements) || + other.totalElements == totalElements) && + (identical(other.size, size) || other.size == size) && + (identical(other.number, number) || other.number == number)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, + const DeepCollectionEquality().hash(_content), + totalPages, + totalElements, + size, + number); + + /// Create a copy of PaginationDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$PaginationDtoImplCopyWith> get copyWith => + __$$PaginationDtoImplCopyWithImpl>( + this, _$identity); + + @override + Map toJson(Object? Function(T) toJsonT) { + return _$$PaginationDtoImplToJson(this, toJsonT); + } +} + +abstract class _PaginationDto implements PaginationDto { + factory _PaginationDto( + {required final List content, + required final int totalPages, + required final int totalElements, + required final int size, + required final int number}) = _$PaginationDtoImpl; + + factory _PaginationDto.fromJson( + Map json, T Function(Object?) fromJsonT) = + _$PaginationDtoImpl.fromJson; + + @override + List get content; + @override + int get totalPages; + @override + int get totalElements; + @override + int get size; + @override + int get number; + + /// Create a copy of PaginationDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$PaginationDtoImplCopyWith> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/core/network/dto/pagination/pagination_dto.g.dart b/lib/core/network/dto/pagination/pagination_dto.g.dart new file mode 100644 index 0000000..a22163b --- /dev/null +++ b/lib/core/network/dto/pagination/pagination_dto.g.dart @@ -0,0 +1,31 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'pagination_dto.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$PaginationDtoImpl _$$PaginationDtoImplFromJson( + Map json, + T Function(Object? json) fromJsonT, +) => + _$PaginationDtoImpl( + content: (json['content'] as List).map(fromJsonT).toList(), + totalPages: (json['totalPages'] as num).toInt(), + totalElements: (json['totalElements'] as num).toInt(), + size: (json['size'] as num).toInt(), + number: (json['number'] as num).toInt(), + ); + +Map _$$PaginationDtoImplToJson( + _$PaginationDtoImpl instance, + Object? Function(T value) toJsonT, +) => + { + 'content': instance.content.map(toJsonT).toList(), + 'totalPages': instance.totalPages, + 'totalElements': instance.totalElements, + 'size': instance.size, + 'number': instance.number, + }; diff --git a/lib/core/network/network.dart b/lib/core/network/network.dart index 948ca0c..4f63c58 100644 --- a/lib/core/network/network.dart +++ b/lib/core/network/network.dart @@ -1,3 +1,4 @@ export 'api.dart'; export 'mock_api.dart'; export 'api_response.dart'; +export 'dto/dto.dart'; diff --git a/lib/feature/job_posting/data/data_sources/dto/worker/job_posting_worker_dto.dart b/lib/feature/job_posting/data/data_sources/dto/worker/job_posting_worker_dto.dart new file mode 100644 index 0000000..aa381dc --- /dev/null +++ b/lib/feature/job_posting/data/data_sources/dto/worker/job_posting_worker_dto.dart @@ -0,0 +1,20 @@ +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:withu_app/feature/user/user.dart'; + +part 'job_posting_worker_dto.freezed.dart'; + +part 'job_posting_worker_dto.g.dart'; + +@freezed +class JobPostingWorkerDto with _$JobPostingWorkerDto { + factory JobPostingWorkerDto({ + required String id, + required SimpleUserDto userInfo, + required bool workStatus, // 출근 여부 + DateTime? workStartTime, // 근무 시작 시간 + DateTime? workEndTime, // 근무 종료 시간 + }) = _JobPostingWorkerDto; + + factory JobPostingWorkerDto.fromJson(Map json) => + _$JobPostingWorkerDtoFromJson(json); +} diff --git a/lib/feature/job_posting/data/data_sources/dto/worker/job_posting_worker_dto.freezed.dart b/lib/feature/job_posting/data/data_sources/dto/worker/job_posting_worker_dto.freezed.dart new file mode 100644 index 0000000..5a37f06 --- /dev/null +++ b/lib/feature/job_posting/data/data_sources/dto/worker/job_posting_worker_dto.freezed.dart @@ -0,0 +1,271 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'job_posting_worker_dto.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +JobPostingWorkerDto _$JobPostingWorkerDtoFromJson(Map json) { + return _JobPostingWorkerDto.fromJson(json); +} + +/// @nodoc +mixin _$JobPostingWorkerDto { + String get id => throw _privateConstructorUsedError; + SimpleUserDto get userInfo => throw _privateConstructorUsedError; + bool get workStatus => throw _privateConstructorUsedError; // 출근 여부 + DateTime? get workStartTime => throw _privateConstructorUsedError; // 근무 시작 시간 + DateTime? get workEndTime => throw _privateConstructorUsedError; + + /// Serializes this JobPostingWorkerDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + + /// Create a copy of JobPostingWorkerDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + $JobPostingWorkerDtoCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $JobPostingWorkerDtoCopyWith<$Res> { + factory $JobPostingWorkerDtoCopyWith( + JobPostingWorkerDto value, $Res Function(JobPostingWorkerDto) then) = + _$JobPostingWorkerDtoCopyWithImpl<$Res, JobPostingWorkerDto>; + @useResult + $Res call( + {String id, + SimpleUserDto userInfo, + bool workStatus, + DateTime? workStartTime, + DateTime? workEndTime}); + + $SimpleUserDtoCopyWith<$Res> get userInfo; +} + +/// @nodoc +class _$JobPostingWorkerDtoCopyWithImpl<$Res, $Val extends JobPostingWorkerDto> + implements $JobPostingWorkerDtoCopyWith<$Res> { + _$JobPostingWorkerDtoCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + /// Create a copy of JobPostingWorkerDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? userInfo = null, + Object? workStatus = null, + Object? workStartTime = freezed, + Object? workEndTime = freezed, + }) { + return _then(_value.copyWith( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + userInfo: null == userInfo + ? _value.userInfo + : userInfo // ignore: cast_nullable_to_non_nullable + as SimpleUserDto, + workStatus: null == workStatus + ? _value.workStatus + : workStatus // ignore: cast_nullable_to_non_nullable + as bool, + workStartTime: freezed == workStartTime + ? _value.workStartTime + : workStartTime // ignore: cast_nullable_to_non_nullable + as DateTime?, + workEndTime: freezed == workEndTime + ? _value.workEndTime + : workEndTime // ignore: cast_nullable_to_non_nullable + as DateTime?, + ) as $Val); + } + + /// Create a copy of JobPostingWorkerDto + /// with the given fields replaced by the non-null parameter values. + @override + @pragma('vm:prefer-inline') + $SimpleUserDtoCopyWith<$Res> get userInfo { + return $SimpleUserDtoCopyWith<$Res>(_value.userInfo, (value) { + return _then(_value.copyWith(userInfo: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$JobPostingWorkerDtoImplCopyWith<$Res> + implements $JobPostingWorkerDtoCopyWith<$Res> { + factory _$$JobPostingWorkerDtoImplCopyWith(_$JobPostingWorkerDtoImpl value, + $Res Function(_$JobPostingWorkerDtoImpl) then) = + __$$JobPostingWorkerDtoImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String id, + SimpleUserDto userInfo, + bool workStatus, + DateTime? workStartTime, + DateTime? workEndTime}); + + @override + $SimpleUserDtoCopyWith<$Res> get userInfo; +} + +/// @nodoc +class __$$JobPostingWorkerDtoImplCopyWithImpl<$Res> + extends _$JobPostingWorkerDtoCopyWithImpl<$Res, _$JobPostingWorkerDtoImpl> + implements _$$JobPostingWorkerDtoImplCopyWith<$Res> { + __$$JobPostingWorkerDtoImplCopyWithImpl(_$JobPostingWorkerDtoImpl _value, + $Res Function(_$JobPostingWorkerDtoImpl) _then) + : super(_value, _then); + + /// Create a copy of JobPostingWorkerDto + /// with the given fields replaced by the non-null parameter values. + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? id = null, + Object? userInfo = null, + Object? workStatus = null, + Object? workStartTime = freezed, + Object? workEndTime = freezed, + }) { + return _then(_$JobPostingWorkerDtoImpl( + id: null == id + ? _value.id + : id // ignore: cast_nullable_to_non_nullable + as String, + userInfo: null == userInfo + ? _value.userInfo + : userInfo // ignore: cast_nullable_to_non_nullable + as SimpleUserDto, + workStatus: null == workStatus + ? _value.workStatus + : workStatus // ignore: cast_nullable_to_non_nullable + as bool, + workStartTime: freezed == workStartTime + ? _value.workStartTime + : workStartTime // ignore: cast_nullable_to_non_nullable + as DateTime?, + workEndTime: freezed == workEndTime + ? _value.workEndTime + : workEndTime // ignore: cast_nullable_to_non_nullable + as DateTime?, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$JobPostingWorkerDtoImpl implements _JobPostingWorkerDto { + _$JobPostingWorkerDtoImpl( + {required this.id, + required this.userInfo, + required this.workStatus, + this.workStartTime, + this.workEndTime}); + + factory _$JobPostingWorkerDtoImpl.fromJson(Map json) => + _$$JobPostingWorkerDtoImplFromJson(json); + + @override + final String id; + @override + final SimpleUserDto userInfo; + @override + final bool workStatus; +// 출근 여부 + @override + final DateTime? workStartTime; +// 근무 시작 시간 + @override + final DateTime? workEndTime; + + @override + String toString() { + return 'JobPostingWorkerDto(id: $id, userInfo: $userInfo, workStatus: $workStatus, workStartTime: $workStartTime, workEndTime: $workEndTime)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$JobPostingWorkerDtoImpl && + (identical(other.id, id) || other.id == id) && + (identical(other.userInfo, userInfo) || + other.userInfo == userInfo) && + (identical(other.workStatus, workStatus) || + other.workStatus == workStatus) && + (identical(other.workStartTime, workStartTime) || + other.workStartTime == workStartTime) && + (identical(other.workEndTime, workEndTime) || + other.workEndTime == workEndTime)); + } + + @JsonKey(includeFromJson: false, includeToJson: false) + @override + int get hashCode => Object.hash( + runtimeType, id, userInfo, workStatus, workStartTime, workEndTime); + + /// Create a copy of JobPostingWorkerDto + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) + @override + @pragma('vm:prefer-inline') + _$$JobPostingWorkerDtoImplCopyWith<_$JobPostingWorkerDtoImpl> get copyWith => + __$$JobPostingWorkerDtoImplCopyWithImpl<_$JobPostingWorkerDtoImpl>( + this, _$identity); + + @override + Map toJson() { + return _$$JobPostingWorkerDtoImplToJson( + this, + ); + } +} + +abstract class _JobPostingWorkerDto implements JobPostingWorkerDto { + factory _JobPostingWorkerDto( + {required final String id, + required final SimpleUserDto userInfo, + required final bool workStatus, + final DateTime? workStartTime, + final DateTime? workEndTime}) = _$JobPostingWorkerDtoImpl; + + factory _JobPostingWorkerDto.fromJson(Map json) = + _$JobPostingWorkerDtoImpl.fromJson; + + @override + String get id; + @override + SimpleUserDto get userInfo; + @override + bool get workStatus; // 출근 여부 + @override + DateTime? get workStartTime; // 근무 시작 시간 + @override + DateTime? get workEndTime; + + /// Create a copy of JobPostingWorkerDto + /// with the given fields replaced by the non-null parameter values. + @override + @JsonKey(includeFromJson: false, includeToJson: false) + _$$JobPostingWorkerDtoImplCopyWith<_$JobPostingWorkerDtoImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/feature/job_posting/data/data_sources/dto/worker/job_posting_worker_dto.g.dart b/lib/feature/job_posting/data/data_sources/dto/worker/job_posting_worker_dto.g.dart new file mode 100644 index 0000000..8847c52 --- /dev/null +++ b/lib/feature/job_posting/data/data_sources/dto/worker/job_posting_worker_dto.g.dart @@ -0,0 +1,32 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'job_posting_worker_dto.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$JobPostingWorkerDtoImpl _$$JobPostingWorkerDtoImplFromJson( + Map json) => + _$JobPostingWorkerDtoImpl( + id: json['id'] as String, + userInfo: + SimpleUserDto.fromJson(json['userInfo'] as Map), + workStatus: json['workStatus'] as bool, + workStartTime: json['workStartTime'] == null + ? null + : DateTime.parse(json['workStartTime'] as String), + workEndTime: json['workEndTime'] == null + ? null + : DateTime.parse(json['workEndTime'] as String), + ); + +Map _$$JobPostingWorkerDtoImplToJson( + _$JobPostingWorkerDtoImpl instance) => + { + 'id': instance.id, + 'userInfo': instance.userInfo, + 'workStatus': instance.workStatus, + 'workStartTime': instance.workStartTime?.toIso8601String(), + 'workEndTime': instance.workEndTime?.toIso8601String(), + }; diff --git a/lib/feature/job_posting/data/data_sources/dto/worker/job_posting_workers_dto.dart b/lib/feature/job_posting/data/data_sources/dto/worker/job_posting_workers_dto.dart new file mode 100644 index 0000000..9eec5cc --- /dev/null +++ b/lib/feature/job_posting/data/data_sources/dto/worker/job_posting_workers_dto.dart @@ -0,0 +1,6 @@ +import 'package:withu_app/core/core.dart'; + +import 'job_posting_worker_dto.dart'; + +/// 공고 목록 모델 +typedef JobPostingWorkersDto = PaginationDto; diff --git a/lib/feature/job_posting/data/data_sources/dto/worker/worker.dart b/lib/feature/job_posting/data/data_sources/dto/worker/worker.dart new file mode 100644 index 0000000..1939a48 --- /dev/null +++ b/lib/feature/job_posting/data/data_sources/dto/worker/worker.dart @@ -0,0 +1,2 @@ +export 'job_posting_workers_dto.dart'; +export 'job_posting_worker_dto.dart'; diff --git a/lib/feature/user/data/data_sources/dto/simple_user_dto.dart b/lib/feature/user/data/data_sources/dto/simple_user_dto.dart index 41761b7..2ca6ef1 100644 --- a/lib/feature/user/data/data_sources/dto/simple_user_dto.dart +++ b/lib/feature/user/data/data_sources/dto/simple_user_dto.dart @@ -2,6 +2,8 @@ import 'package:freezed_annotation/freezed_annotation.dart'; part 'simple_user_dto.freezed.dart'; +part 'simple_user_dto.g.dart'; + @freezed class SimpleUserDto with _$SimpleUserDto { factory SimpleUserDto({ @@ -10,4 +12,7 @@ class SimpleUserDto with _$SimpleUserDto { required int age, // 나이 required String profile, // 프로필 이미지 }) = _SimpleUserDto; + + factory SimpleUserDto.fromJson(Map json) => + _$SimpleUserDtoFromJson(json); } diff --git a/lib/feature/user/data/data_sources/dto/simple_user_dto.freezed.dart b/lib/feature/user/data/data_sources/dto/simple_user_dto.freezed.dart index 708c4ad..3604aec 100644 --- a/lib/feature/user/data/data_sources/dto/simple_user_dto.freezed.dart +++ b/lib/feature/user/data/data_sources/dto/simple_user_dto.freezed.dart @@ -14,6 +14,10 @@ T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); +SimpleUserDto _$SimpleUserDtoFromJson(Map json) { + return _SimpleUserDto.fromJson(json); +} + /// @nodoc mixin _$SimpleUserDto { String get id => throw _privateConstructorUsedError; // id @@ -21,6 +25,9 @@ mixin _$SimpleUserDto { int get age => throw _privateConstructorUsedError; // 나이 String get profile => throw _privateConstructorUsedError; + /// Serializes this SimpleUserDto to a JSON map. + Map toJson() => throw _privateConstructorUsedError; + /// Create a copy of SimpleUserDto /// with the given fields replaced by the non-null parameter values. @JsonKey(includeFromJson: false, includeToJson: false) @@ -129,7 +136,7 @@ class __$$SimpleUserDtoImplCopyWithImpl<$Res> } /// @nodoc - +@JsonSerializable() class _$SimpleUserDtoImpl implements _SimpleUserDto { _$SimpleUserDtoImpl( {required this.id, @@ -137,6 +144,9 @@ class _$SimpleUserDtoImpl implements _SimpleUserDto { required this.age, required this.profile}); + factory _$SimpleUserDtoImpl.fromJson(Map json) => + _$$SimpleUserDtoImplFromJson(json); + @override final String id; // id @@ -165,6 +175,7 @@ class _$SimpleUserDtoImpl implements _SimpleUserDto { (identical(other.profile, profile) || other.profile == profile)); } + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, id, name, age, profile); @@ -175,6 +186,13 @@ class _$SimpleUserDtoImpl implements _SimpleUserDto { @pragma('vm:prefer-inline') _$$SimpleUserDtoImplCopyWith<_$SimpleUserDtoImpl> get copyWith => __$$SimpleUserDtoImplCopyWithImpl<_$SimpleUserDtoImpl>(this, _$identity); + + @override + Map toJson() { + return _$$SimpleUserDtoImplToJson( + this, + ); + } } abstract class _SimpleUserDto implements SimpleUserDto { @@ -184,6 +202,9 @@ abstract class _SimpleUserDto implements SimpleUserDto { required final int age, required final String profile}) = _$SimpleUserDtoImpl; + factory _SimpleUserDto.fromJson(Map json) = + _$SimpleUserDtoImpl.fromJson; + @override String get id; // id @override diff --git a/lib/feature/user/data/data_sources/dto/simple_user_dto.g.dart b/lib/feature/user/data/data_sources/dto/simple_user_dto.g.dart new file mode 100644 index 0000000..b210c1e --- /dev/null +++ b/lib/feature/user/data/data_sources/dto/simple_user_dto.g.dart @@ -0,0 +1,23 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'simple_user_dto.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$SimpleUserDtoImpl _$$SimpleUserDtoImplFromJson(Map json) => + _$SimpleUserDtoImpl( + id: json['id'] as String, + name: json['name'] as String, + age: (json['age'] as num).toInt(), + profile: json['profile'] as String, + ); + +Map _$$SimpleUserDtoImplToJson(_$SimpleUserDtoImpl instance) => + { + 'id': instance.id, + 'name': instance.name, + 'age': instance.age, + 'profile': instance.profile, + };