Переписал DTO
This commit is contained in:
parent
6e60f76f2f
commit
5a97a3bb7f
28
lib/data/dto/page_dto.dart
Normal file
28
lib/data/dto/page_dto.dart
Normal file
@ -0,0 +1,28 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
@JsonSerializable(createToJson: false)
|
||||
class PageDto {
|
||||
final List<UserDto> 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<String, dynamic> json) =>
|
||||
_$PageDtoFromJson(json);
|
||||
}
|
32
lib/data/dto/user_dto.dart
Normal file
32
lib/data/dto/user_dto.dart
Normal file
@ -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<String, dynamic> json) =>
|
||||
_$UserDtoFromJson(json);
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
part 'user_dto.g.dart';
|
||||
|
||||
@JsonSerializable(createToJson: false)
|
||||
class UsersDto {
|
||||
final List<UserDto>? 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<String, dynamic> 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<String, dynamic> json) =>
|
||||
_$UserDtoFromJson(json);
|
||||
}
|
||||
|
||||
@JsonSerializable(createToJson: false)
|
||||
class LocationDto {
|
||||
final double? lat;
|
||||
final double? lon;
|
||||
|
||||
const LocationDto({this.lat, this.lon});
|
||||
|
||||
factory LocationDto.fromJson(Map<String, dynamic> 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<String, dynamic> json) =>
|
||||
_$UserDataDtoFromJson(json);
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'user_dto.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
UsersDto _$UsersDtoFromJson(Map<String, dynamic> json) => UsersDto(
|
||||
items: (json['items'] as List<dynamic>?)
|
||||
?.map((e) => UserDto.fromJson(e as Map<String, dynamic>))
|
||||
.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<String, dynamic> json) => UserDto(
|
||||
model: json['model'] == null
|
||||
? null
|
||||
: UserDataDto.fromJson(json['model'] as Map<String, dynamic>),
|
||||
age: (json['age'] as num?)?.toInt(),
|
||||
distance: (json['distance'] as num?)?.toDouble(),
|
||||
);
|
||||
|
||||
LocationDto _$LocationDtoFromJson(Map<String, dynamic> json) => LocationDto(
|
||||
lat: (json['lat'] as num?)?.toDouble(),
|
||||
lon: (json['lon'] as num?)?.toDouble(),
|
||||
);
|
||||
|
||||
UserDataDto _$UserDataDtoFromJson(Map<String, dynamic> 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<String, dynamic>),
|
||||
);
|
Loading…
Reference in New Issue
Block a user