feat : live stock batch
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
import 'package:rasadyar_livestock/data/model/response/address/address.dart';
|
||||
import 'package:rasadyar_livestock/data/model/response/live_tmp/livestock_model.dart';
|
||||
|
||||
abstract class LivestockRemoteDataSource {
|
||||
Future<LocationDetails> getLocationDetailsByLatLng({required double latitude, required double longitude});
|
||||
Future<LocationDetails> getLocationDetailsByLatLng({
|
||||
required double latitude,
|
||||
required double longitude,
|
||||
});
|
||||
|
||||
Future<bool> createTaggingLiveStock({required LivestockData data});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:rasadyar_core/core.dart';
|
||||
import 'package:rasadyar_livestock/data/data_source/remote/livestock/livestock_remote.dart';
|
||||
import 'package:rasadyar_livestock/data/model/response/address/address.dart';
|
||||
import 'package:rasadyar_livestock/data/model/response/live_tmp/livestock_model.dart';
|
||||
|
||||
class LivestockRemoteDataSourceImp implements LivestockRemoteDataSource {
|
||||
@override
|
||||
@@ -26,4 +27,29 @@ class LivestockRemoteDataSourceImp implements LivestockRemoteDataSource {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> createTaggingLiveStock({required LivestockData data}) async {
|
||||
try {
|
||||
Dio dio = Dio();
|
||||
dio.interceptors.add(PrettyDioLogger(
|
||||
requestBody: true,
|
||||
responseBody: true,
|
||||
requestHeader: true,
|
||||
responseHeader: true,
|
||||
error: true,
|
||||
compact: true,
|
||||
));
|
||||
dio.options.baseUrl = 'https://everestacademy.ir/live/';
|
||||
final response = await dio.post('api.php', data: data.toJson());
|
||||
if (response.statusCode == 200) {
|
||||
final data = response.data;
|
||||
return true;
|
||||
} else {
|
||||
throw Exception('Failed to load address');
|
||||
}
|
||||
} catch (e) {
|
||||
rethrow;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,14 +10,14 @@ _LoginRequestModel _$LoginRequestModelFromJson(Map<String, dynamic> json) =>
|
||||
_LoginRequestModel(
|
||||
username: json['username'] as String?,
|
||||
password: json['password'] as String?,
|
||||
captchaCode: json['captchaCode'] as String?,
|
||||
captchaKey: json['captchaKey'] as String?,
|
||||
captchaCode: json['captcha_code'] as String?,
|
||||
captchaKey: json['captcha_key'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LoginRequestModelToJson(_LoginRequestModel instance) =>
|
||||
<String, dynamic>{
|
||||
'username': instance.username,
|
||||
'password': instance.password,
|
||||
'captchaCode': instance.captchaCode,
|
||||
'captchaKey': instance.captchaKey,
|
||||
'captcha_code': instance.captchaCode,
|
||||
'captcha_key': instance.captchaKey,
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ _Address _$AddressFromJson(Map<String, dynamic> json) => _Address(
|
||||
district: json['district'] as String?,
|
||||
county: json['county'] as String?,
|
||||
province: json['province'] as String?,
|
||||
ISO3166_2_lvl4: json['ISO3166_2_lvl4'] as String?,
|
||||
ISO3166_2_lvl4: json['i_s_o3166_2_lvl4'] as String?,
|
||||
postcode: json['postcode'] as String?,
|
||||
country: json['country'] as String?,
|
||||
country_code: json['country_code'] as String?,
|
||||
@@ -32,7 +32,7 @@ Map<String, dynamic> _$AddressToJson(_Address instance) => <String, dynamic>{
|
||||
'district': instance.district,
|
||||
'county': instance.county,
|
||||
'province': instance.province,
|
||||
'ISO3166_2_lvl4': instance.ISO3166_2_lvl4,
|
||||
'i_s_o3166_2_lvl4': instance.ISO3166_2_lvl4,
|
||||
'postcode': instance.postcode,
|
||||
'country': instance.country,
|
||||
'country_code': instance.country_code,
|
||||
|
||||
@@ -10,12 +10,12 @@ _AuthResponseModel _$AuthResponseModelFromJson(Map<String, dynamic> json) =>
|
||||
_AuthResponseModel(
|
||||
refresh: json['refresh'] as String?,
|
||||
access: json['access'] as String?,
|
||||
otpStatus: json['otpStatus'] as bool?,
|
||||
otpStatus: json['otp_status'] as bool?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$AuthResponseModelToJson(_AuthResponseModel instance) =>
|
||||
<String, dynamic>{
|
||||
'refresh': instance.refresh,
|
||||
'access': instance.access,
|
||||
'otpStatus': instance.otpStatus,
|
||||
'otp_status': instance.otpStatus,
|
||||
};
|
||||
|
||||
@@ -9,17 +9,17 @@ part of 'captcha_response_model.dart';
|
||||
_CaptchaResponseModel _$CaptchaResponseModelFromJson(
|
||||
Map<String, dynamic> json,
|
||||
) => _CaptchaResponseModel(
|
||||
captchaKey: json['captchaKey'] as String?,
|
||||
captchaImage: json['captchaImage'] as String?,
|
||||
imageType: json['imageType'] as String?,
|
||||
imageDecode: json['imageDecode'] as String?,
|
||||
captchaKey: json['captcha_key'] as String?,
|
||||
captchaImage: json['captcha_image'] as String?,
|
||||
imageType: json['image_type'] as String?,
|
||||
imageDecode: json['image_decode'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CaptchaResponseModelToJson(
|
||||
_CaptchaResponseModel instance,
|
||||
) => <String, dynamic>{
|
||||
'captchaKey': instance.captchaKey,
|
||||
'captchaImage': instance.captchaImage,
|
||||
'imageType': instance.imageType,
|
||||
'imageDecode': instance.imageDecode,
|
||||
'captcha_key': instance.captchaKey,
|
||||
'captcha_image': instance.captchaImage,
|
||||
'image_type': instance.imageType,
|
||||
'image_decode': instance.imageDecode,
|
||||
};
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'livestock_model.freezed.dart';
|
||||
part 'livestock_model.g.dart';
|
||||
|
||||
@freezed
|
||||
abstract class LivestockData with _$LivestockData {
|
||||
const factory LivestockData({Rancher? rancher, Herd? herd, List<Livestock>? livestock}) =
|
||||
_LivestockData;
|
||||
|
||||
factory LivestockData.fromJson(Map<String, dynamic> json) => _$LivestockDataFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class Rancher with _$Rancher {
|
||||
const factory Rancher({String? name, String? phone, String? image}) = _Rancher;
|
||||
|
||||
factory Rancher.fromJson(Map<String, dynamic> json) => _$RancherFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class Herd with _$Herd {
|
||||
const factory Herd({Location? location, String? address, String? image}) = _Herd;
|
||||
|
||||
factory Herd.fromJson(Map<String, dynamic> json) => _$HerdFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class Location with _$Location {
|
||||
const factory Location({double? lat, double? lng}) = _Location;
|
||||
|
||||
factory Location.fromJson(Map<String, dynamic> json) => _$LocationFromJson(json);
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class Livestock with _$Livestock {
|
||||
const factory Livestock({
|
||||
String? species,
|
||||
String? breed,
|
||||
String? dateOfBirth,
|
||||
String? sex,
|
||||
String? motherTag,
|
||||
String? fatherTag,
|
||||
String? tagNumber,
|
||||
String? tagType,
|
||||
String? image,
|
||||
}) = _Livestock;
|
||||
|
||||
factory Livestock.fromJson(Map<String, dynamic> json) => _$LivestockFromJson(json);
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,88 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
part of 'livestock_model.dart';
|
||||
|
||||
// **************************************************************************
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
_LivestockData _$LivestockDataFromJson(Map<String, dynamic> json) =>
|
||||
_LivestockData(
|
||||
rancher: json['rancher'] == null
|
||||
? null
|
||||
: Rancher.fromJson(json['rancher'] as Map<String, dynamic>),
|
||||
herd: json['herd'] == null
|
||||
? null
|
||||
: Herd.fromJson(json['herd'] as Map<String, dynamic>),
|
||||
livestock: (json['livestock'] as List<dynamic>?)
|
||||
?.map((e) => Livestock.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LivestockDataToJson(_LivestockData instance) =>
|
||||
<String, dynamic>{
|
||||
'rancher': instance.rancher,
|
||||
'herd': instance.herd,
|
||||
'livestock': instance.livestock,
|
||||
};
|
||||
|
||||
_Rancher _$RancherFromJson(Map<String, dynamic> json) => _Rancher(
|
||||
name: json['name'] as String?,
|
||||
phone: json['phone'] as String?,
|
||||
image: json['image'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$RancherToJson(_Rancher instance) => <String, dynamic>{
|
||||
'name': instance.name,
|
||||
'phone': instance.phone,
|
||||
'image': instance.image,
|
||||
};
|
||||
|
||||
_Herd _$HerdFromJson(Map<String, dynamic> json) => _Herd(
|
||||
location: json['location'] == null
|
||||
? null
|
||||
: Location.fromJson(json['location'] as Map<String, dynamic>),
|
||||
address: json['address'] as String?,
|
||||
image: json['image'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$HerdToJson(_Herd instance) => <String, dynamic>{
|
||||
'location': instance.location,
|
||||
'address': instance.address,
|
||||
'image': instance.image,
|
||||
};
|
||||
|
||||
_Location _$LocationFromJson(Map<String, dynamic> json) => _Location(
|
||||
lat: (json['lat'] as num?)?.toDouble(),
|
||||
lng: (json['lng'] as num?)?.toDouble(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LocationToJson(_Location instance) => <String, dynamic>{
|
||||
'lat': instance.lat,
|
||||
'lng': instance.lng,
|
||||
};
|
||||
|
||||
_Livestock _$LivestockFromJson(Map<String, dynamic> json) => _Livestock(
|
||||
species: json['species'] as String?,
|
||||
breed: json['breed'] as String?,
|
||||
dateOfBirth: json['date_of_birth'] as String?,
|
||||
sex: json['sex'] as String?,
|
||||
motherTag: json['mother_tag'] as String?,
|
||||
fatherTag: json['father_tag'] as String?,
|
||||
tagNumber: json['tag_number'] as String?,
|
||||
tagType: json['tag_type'] as String?,
|
||||
image: json['image'] as String?,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$LivestockToJson(_Livestock instance) =>
|
||||
<String, dynamic>{
|
||||
'species': instance.species,
|
||||
'breed': instance.breed,
|
||||
'date_of_birth': instance.dateOfBirth,
|
||||
'sex': instance.sex,
|
||||
'mother_tag': instance.motherTag,
|
||||
'father_tag': instance.fatherTag,
|
||||
'tag_number': instance.tagNumber,
|
||||
'tag_type': instance.tagType,
|
||||
'image': instance.image,
|
||||
};
|
||||
@@ -26,12 +26,12 @@ _User _$UserFromJson(Map<String, dynamic> json) => _User(
|
||||
id: (json['id'] as num).toInt(),
|
||||
username: json['username'] as String,
|
||||
password: json['password'] as String,
|
||||
firstName: json['firstName'] as String,
|
||||
lastName: json['lastName'] as String,
|
||||
isActive: json['isActive'] as bool,
|
||||
firstName: json['first_name'] as String,
|
||||
lastName: json['last_name'] as String,
|
||||
isActive: json['is_active'] as bool,
|
||||
mobile: json['mobile'] as String,
|
||||
phone: json['phone'] as String,
|
||||
nationalCode: json['nationalCode'] as String,
|
||||
nationalCode: json['national_code'] as String,
|
||||
birthdate: DateTime.parse(json['birthdate'] as String),
|
||||
nationality: json['nationality'] as String,
|
||||
ownership: json['ownership'] as String,
|
||||
@@ -39,21 +39,21 @@ _User _$UserFromJson(Map<String, dynamic> json) => _User(
|
||||
photo: json['photo'] as String,
|
||||
province: (json['province'] as num).toInt(),
|
||||
city: (json['city'] as num).toInt(),
|
||||
otpStatus: json['otpStatus'] as bool,
|
||||
cityName: json['cityName'] as String,
|
||||
provinceName: json['provinceName'] as String,
|
||||
otpStatus: json['otp_status'] as bool,
|
||||
cityName: json['city_name'] as String,
|
||||
provinceName: json['province_name'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UserToJson(_User instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'username': instance.username,
|
||||
'password': instance.password,
|
||||
'firstName': instance.firstName,
|
||||
'lastName': instance.lastName,
|
||||
'isActive': instance.isActive,
|
||||
'first_name': instance.firstName,
|
||||
'last_name': instance.lastName,
|
||||
'is_active': instance.isActive,
|
||||
'mobile': instance.mobile,
|
||||
'phone': instance.phone,
|
||||
'nationalCode': instance.nationalCode,
|
||||
'national_code': instance.nationalCode,
|
||||
'birthdate': instance.birthdate.toIso8601String(),
|
||||
'nationality': instance.nationality,
|
||||
'ownership': instance.ownership,
|
||||
@@ -61,14 +61,14 @@ Map<String, dynamic> _$UserToJson(_User instance) => <String, dynamic>{
|
||||
'photo': instance.photo,
|
||||
'province': instance.province,
|
||||
'city': instance.city,
|
||||
'otpStatus': instance.otpStatus,
|
||||
'cityName': instance.cityName,
|
||||
'provinceName': instance.provinceName,
|
||||
'otp_status': instance.otpStatus,
|
||||
'city_name': instance.cityName,
|
||||
'province_name': instance.provinceName,
|
||||
};
|
||||
|
||||
_Role _$RoleFromJson(Map<String, dynamic> json) => _Role(
|
||||
id: (json['id'] as num).toInt(),
|
||||
roleName: json['roleName'] as String,
|
||||
roleName: json['role_name'] as String,
|
||||
description: json['description'] as String,
|
||||
type: RoleType.fromJson(json['type'] as Map<String, dynamic>),
|
||||
permissions: json['permissions'] as List<dynamic>,
|
||||
@@ -76,7 +76,7 @@ _Role _$RoleFromJson(Map<String, dynamic> json) => _Role(
|
||||
|
||||
Map<String, dynamic> _$RoleToJson(_Role instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'roleName': instance.roleName,
|
||||
'role_name': instance.roleName,
|
||||
'description': instance.description,
|
||||
'type': instance.type,
|
||||
'permissions': instance.permissions,
|
||||
@@ -91,14 +91,14 @@ Map<String, dynamic> _$RoleTypeToJson(_RoleType instance) => <String, dynamic>{
|
||||
};
|
||||
|
||||
_Permission _$PermissionFromJson(Map<String, dynamic> json) => _Permission(
|
||||
pageName: json['pageName'] as String,
|
||||
pageAccess: (json['pageAccess'] as List<dynamic>)
|
||||
pageName: json['page_name'] as String,
|
||||
pageAccess: (json['page_access'] as List<dynamic>)
|
||||
.map((e) => e as String)
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$PermissionToJson(_Permission instance) =>
|
||||
<String, dynamic>{
|
||||
'pageName': instance.pageName,
|
||||
'pageAccess': instance.pageAccess,
|
||||
'page_name': instance.pageName,
|
||||
'page_access': instance.pageAccess,
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:rasadyar_livestock/data/model/response/address/address.dart';
|
||||
import 'package:rasadyar_livestock/data/model/response/auth/auth_response_model.dart';
|
||||
import 'package:rasadyar_livestock/data/model/response/captcha/captcha_response_model.dart';
|
||||
import 'package:rasadyar_livestock/data/model/response/live_tmp/livestock_model.dart';
|
||||
|
||||
abstract class LivestockRepository {
|
||||
Future<LocationDetails?> getLocationDetails({
|
||||
@@ -8,4 +9,6 @@ abstract class LivestockRepository {
|
||||
required double longitude,
|
||||
});
|
||||
|
||||
Future<bool> createTaggingLiveStock({required LivestockData data});
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import 'package:rasadyar_livestock/data/data_source/remote/livestock/livestock_remote.dart';
|
||||
import 'package:rasadyar_livestock/data/model/response/address/address.dart';
|
||||
import 'package:rasadyar_livestock/data/model/response/live_tmp/livestock_model.dart';
|
||||
|
||||
import 'livestock_repository.dart';
|
||||
|
||||
@@ -9,10 +10,18 @@ class LivestockRepositoryImp implements LivestockRepository {
|
||||
LivestockRepositoryImp({required this.livestockRemote});
|
||||
|
||||
@override
|
||||
Future<LocationDetails?> getLocationDetails({required double latitude, required double longitude}) async {
|
||||
Future<LocationDetails?> getLocationDetails({
|
||||
required double latitude,
|
||||
required double longitude,
|
||||
}) async {
|
||||
return await livestockRemote.getLocationDetailsByLatLng(
|
||||
latitude: latitude,
|
||||
longitude: longitude,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<bool> createTaggingLiveStock({required LivestockData data}) async {
|
||||
return await livestockRemote.createTaggingLiveStock(data: data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user