From 7128d4f2d68296c8f327319cb7048f1b4c296d67 Mon Sep 17 00:00:00 2001 From: mso7nueh Date: Fri, 16 Aug 2024 17:37:25 +0300 Subject: [PATCH] merge --- lib/features/recipes/models/image.g.dart | 15 -- .../recipes/models/recipe_model.g.dart | 16 +- .../recipes/services/recipe_service.g.dart | 147 +++++++++++------- 3 files changed, 99 insertions(+), 79 deletions(-) delete mode 100644 lib/features/recipes/models/image.g.dart diff --git a/lib/features/recipes/models/image.g.dart b/lib/features/recipes/models/image.g.dart deleted file mode 100644 index 3e44a28c..00000000 --- a/lib/features/recipes/models/image.g.dart +++ /dev/null @@ -1,15 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'image.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$ImageImpl _$$ImageImplFromJson(Map json) => _$ImageImpl( - path: json['path'] as String, - ); - -Map _$$ImageImplToJson(_$ImageImpl instance) => { - 'path': instance.path, - }; diff --git a/lib/features/recipes/models/recipe_model.g.dart b/lib/features/recipes/models/recipe_model.g.dart index ac7c7c2d..d5ab9c96 100644 --- a/lib/features/recipes/models/recipe_model.g.dart +++ b/lib/features/recipes/models/recipe_model.g.dart @@ -6,9 +6,16 @@ part of 'recipe_model.dart'; // JsonSerializableGenerator // ************************************************************************** -_$RecipeModelImpl _$$RecipeModelImplFromJson(Map json) => _$RecipeModelImpl( - ingredients: (json['ingredients'] as List?)?.map((e) => e == null ? null : Ingredient.fromJson(e as Map)).toList(), - steps: (json['steps'] as List?)?.map((e) => e == null ? null : Step.fromJson(e as Map)).toList(), +_$RecipeModelImpl _$$RecipeModelImplFromJson(Map json) => + _$RecipeModelImpl( + ingredients: (json['ingredients'] as List?) + ?.map((e) => + e == null ? null : Ingredient.fromJson(e as Map)) + .toList(), + steps: (json['steps'] as List?) + ?.map((e) => + e == null ? null : Step.fromJson(e as Map)) + .toList(), type: json['type'] as String?, state: json['state'] as String?, title: json['title'] as String?, @@ -18,7 +25,8 @@ _$RecipeModelImpl _$$RecipeModelImplFromJson(Map json) => _$Rec cooking_time: (json['cooking_time'] as num?)?.toInt(), ); -Map _$$RecipeModelImplToJson(_$RecipeModelImpl instance) => { +Map _$$RecipeModelImplToJson(_$RecipeModelImpl instance) => + { 'ingredients': instance.ingredients, 'steps': instance.steps, 'type': instance.type, diff --git a/lib/features/recipes/services/recipe_service.g.dart b/lib/features/recipes/services/recipe_service.g.dart index de85e17d..c28edc26 100644 --- a/lib/features/recipes/services/recipe_service.g.dart +++ b/lib/features/recipes/services/recipe_service.g.dart @@ -12,36 +12,45 @@ class _RecipeService implements RecipeService { _RecipeService( this._dio, { this.baseUrl, + this.errorLogger, }); final Dio _dio; String? baseUrl; + final ParseErrorLogger? errorLogger; + @override Future getRecipe(String id) async { final _extra = {}; final queryParameters = {}; final _headers = {}; const Map? _data = null; - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/recipes/show/${id}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = RecipeModel.fromJson(_result.data!); + .compose( + _dio.options, + '/api/recipes/show/${id}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late RecipeModel _value; + try { + _value = RecipeModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -51,28 +60,34 @@ class _RecipeService implements RecipeService { final queryParameters = {r'name': name}; final _headers = {}; const Map? _data = null; - final _result = await _dio.fetch>( - _setStreamType>>(Options( + final _options = _setStreamType>>(Options( method: 'GET', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/diary/product_nutritional_values/filter', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - var _value = _result.data!.map((k, dynamic v) => MapEntry( - k, - (v as List) - .map((i) => Product.fromJson(i as Map)) - .toList())); + .compose( + _dio.options, + '/api/diary/product_nutritional_values/filter', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late Map> _value; + try { + _value = _result.data!.map((k, dynamic v) => MapEntry( + k, + (v as List) + .map((i) => Product.fromJson(i as Map)) + .toList())); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -82,24 +97,30 @@ class _RecipeService implements RecipeService { final queryParameters = {}; final _headers = {}; final _data = FormData.fromMap(recipe); - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/recipes/create', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = RecipeModel.fromJson(_result.data!); + .compose( + _dio.options, + '/api/recipes/create', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late RecipeModel _value; + try { + _value = RecipeModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; } @@ -112,24 +133,30 @@ class _RecipeService implements RecipeService { final queryParameters = {}; final _headers = {}; final _data = FormData.fromMap(recipe); - final _result = await _dio - .fetch>(_setStreamType(Options( + final _options = _setStreamType(Options( method: 'POST', headers: _headers, extra: _extra, ) - .compose( - _dio.options, - '/api/recipes/update/{id}', - queryParameters: queryParameters, - data: _data, - ) - .copyWith( - baseUrl: _combineBaseUrls( - _dio.options.baseUrl, - baseUrl, - )))); - final _value = RecipeModel.fromJson(_result.data!); + .compose( + _dio.options, + '/api/recipes/update/{id}', + queryParameters: queryParameters, + data: _data, + ) + .copyWith( + baseUrl: _combineBaseUrls( + _dio.options.baseUrl, + baseUrl, + ))); + final _result = await _dio.fetch>(_options); + late RecipeModel _value; + try { + _value = RecipeModel.fromJson(_result.data!); + } on Object catch (e, s) { + errorLogger?.logError(e, s, _options); + rethrow; + } return _value; }