diff --git a/lib/data/dto/page_dto.dart b/lib/data/dto/page_dto.dart new file mode 100644 index 0000000..250a153 --- /dev/null +++ b/lib/data/dto/page_dto.dart @@ -0,0 +1,28 @@ +import 'package:json_annotation/json_annotation.dart'; + +@JsonSerializable(createToJson: false) +class PageDto { + final List items; + final int itemsCount; + final int totalItemsCount; + final int pageNumber; + final int itemsByPage; + final int? prevPageNumber; + final int? nextPageNumber; + final int firstPageNumber; + final int lastPageNumber; + + const PageDto( + {this.items, + this.itemsCount, + this.totalItemsCount, + this.pageNumber, + this.itemsByPage, + this.prevPageNumber, + this.nextPageNumber, + this.firstPageNumber, + this.lastPageNumber}); + + factory PageDto.fromJson(Map json) => + _$PageDtoFromJson(json); +} diff --git a/lib/data/dto/user_dto.dart b/lib/data/dto/user_dto.dart new file mode 100644 index 0000000..1014a4b --- /dev/null +++ b/lib/data/dto/user_dto.dart @@ -0,0 +1,32 @@ +import 'package:json_annotation/json_annotation.dart'; + +@JsonSerializable(createToJson: false) +class UserDto { + final int? id; + final String? name; + final String? surname; + final String? description; + final String? image; + final String? gender; + final String? dateOfBirth; + final double? lat; + final double? lon; + final int? age; + final double? distance; + + const UserDto( + {this.id, + this.name, + this.surname, + this.description, + this.image, + this.gender, + this.dateOfBirth, + this.lat, + this.lon, + this.age, + this.distance}); + + factory UserDto.fromJson(Map json) => + _$UserDtoFromJson(json); +} diff --git a/lib/data/dtos/user_dto.dart b/lib/data/dtos/user_dto.dart deleted file mode 100644 index 755cad5..0000000 --- a/lib/data/dtos/user_dto.dart +++ /dev/null @@ -1,76 +0,0 @@ -import 'package:json_annotation/json_annotation.dart'; - -part 'user_dto.g.dart'; - -@JsonSerializable(createToJson: false) -class UsersDto { - final List? items; - final int? count; - final int? limit; - final int? countAll; - final int? pagesCount; - final int? pageNumber; - final bool? hasPrevPage; - final bool? hasNextPage; - - const UsersDto( - {this.items, - this.count, - this.limit, - this.countAll, - this.pagesCount, - this.pageNumber, - this.hasPrevPage, - this.hasNextPage}); - - factory UsersDto.fromJson(Map json) => - _$UsersDtoFromJson(json); -} - -@JsonSerializable(createToJson: false) -class UserDto { - final UserDataDto? model; - final int? age; - final double? distance; - - const UserDto({this.model, this.age, this.distance}); - - factory UserDto.fromJson(Map json) => - _$UserDtoFromJson(json); -} - -@JsonSerializable(createToJson: false) -class LocationDto { - final double? lat; - final double? lon; - - const LocationDto({this.lat, this.lon}); - - factory LocationDto.fromJson(Map json) => - _$LocationDtoFromJson(json); -} - -@JsonSerializable(createToJson: false) -class UserDataDto { - final int? id; - final String? name; - final String? surname; - final String? description; - final String? image; - final String? gender; - final String? dateOfBirth; - final LocationDto? location; - - const UserDataDto( - {this.id, - this.name, - this.surname, - this.description, - this.image, - this.gender, - this.dateOfBirth, - this.location}); - - factory UserDataDto.fromJson(Map json) => - _$UserDataDtoFromJson(json); -} diff --git a/lib/data/dtos/user_dto.g.dart b/lib/data/dtos/user_dto.g.dart deleted file mode 100644 index 0590f8a..0000000 --- a/lib/data/dtos/user_dto.g.dart +++ /dev/null @@ -1,46 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'user_dto.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -UsersDto _$UsersDtoFromJson(Map json) => UsersDto( - items: (json['items'] as List?) - ?.map((e) => UserDto.fromJson(e as Map)) - .toList(), - count: (json['count'] as num?)?.toInt(), - limit: (json['limit'] as num?)?.toInt(), - countAll: (json['countAll'] as num?)?.toInt(), - pagesCount: (json['pagesCount'] as num?)?.toInt(), - pageNumber: (json['pageNumber'] as num?)?.toInt(), - hasPrevPage: json['hasPrevPage'] as bool?, - hasNextPage: json['hasNextPage'] as bool?, - ); - -UserDto _$UserDtoFromJson(Map json) => UserDto( - model: json['model'] == null - ? null - : UserDataDto.fromJson(json['model'] as Map), - age: (json['age'] as num?)?.toInt(), - distance: (json['distance'] as num?)?.toDouble(), - ); - -LocationDto _$LocationDtoFromJson(Map json) => LocationDto( - lat: (json['lat'] as num?)?.toDouble(), - lon: (json['lon'] as num?)?.toDouble(), - ); - -UserDataDto _$UserDataDtoFromJson(Map json) => UserDataDto( - id: (json['id'] as num?)?.toInt(), - name: json['name'] as String?, - surname: json['surname'] as String?, - description: json['description'] as String?, - image: json['image'] as String?, - gender: json['gender'] as String?, - dateOfBirth: json['dateOfBirth'] as String?, - location: json['location'] == null - ? null - : LocationDto.fromJson(json['location'] as Map), - );