fix(blog posts, diets, plans, recipies): changed name of json field for descriptions of models

This commit is contained in:
Username1548
2025-03-28 20:36:09 +07:00
parent 7008276735
commit f9741adf1e
24 changed files with 134 additions and 208 deletions

View File

@@ -21,7 +21,7 @@ class RecipeCreateModel with _$RecipeCreateModel {
const factory RecipeCreateModel({
required String title,
required String state,
required String description,
@JsonKey(name: 'description_md') required String description,
required RecipeType type,
@JsonKey(name: 'video_url') String? videoUrl,
@JsonKey(name: 'cooking_time') String? cookingTime,

View File

@@ -23,6 +23,7 @@ RecipeCreateModel _$RecipeCreateModelFromJson(Map<String, dynamic> json) {
mixin _$RecipeCreateModel {
String get title => throw _privateConstructorUsedError;
String get state => throw _privateConstructorUsedError;
@JsonKey(name: 'description_md')
String get description => throw _privateConstructorUsedError;
RecipeType get type => throw _privateConstructorUsedError;
@JsonKey(name: 'video_url')
@@ -58,7 +59,7 @@ abstract class $RecipeCreateModelCopyWith<$Res> {
$Res call({
String title,
String state,
String description,
@JsonKey(name: 'description_md') String description,
RecipeType type,
@JsonKey(name: 'video_url') String? videoUrl,
@JsonKey(name: 'cooking_time') String? cookingTime,
@@ -179,7 +180,7 @@ abstract class _$$RecipeCreateModelImplCopyWith<$Res>
$Res call({
String title,
String state,
String description,
@JsonKey(name: 'description_md') String description,
RecipeType type,
@JsonKey(name: 'video_url') String? videoUrl,
@JsonKey(name: 'cooking_time') String? cookingTime,
@@ -292,7 +293,7 @@ class _$RecipeCreateModelImpl implements _RecipeCreateModel {
const _$RecipeCreateModelImpl({
required this.title,
required this.state,
required this.description,
@JsonKey(name: 'description_md') required this.description,
required this.type,
@JsonKey(name: 'video_url') this.videoUrl,
@JsonKey(name: 'cooking_time') this.cookingTime,
@@ -314,6 +315,7 @@ class _$RecipeCreateModelImpl implements _RecipeCreateModel {
@override
final String state;
@override
@JsonKey(name: 'description_md')
final String description;
@override
final RecipeType type;
@@ -427,7 +429,7 @@ abstract class _RecipeCreateModel implements RecipeCreateModel {
const factory _RecipeCreateModel({
required final String title,
required final String state,
required final String description,
@JsonKey(name: 'description_md') required final String description,
required final RecipeType type,
@JsonKey(name: 'video_url') final String? videoUrl,
@JsonKey(name: 'cooking_time') final String? cookingTime,
@@ -447,6 +449,7 @@ abstract class _RecipeCreateModel implements RecipeCreateModel {
@override
String get state;
@override
@JsonKey(name: 'description_md')
String get description;
@override
RecipeType get type;

View File

@@ -11,7 +11,7 @@ _$RecipeCreateModelImpl _$$RecipeCreateModelImplFromJson(
) => _$RecipeCreateModelImpl(
title: json['title'] as String,
state: json['state'] as String,
description: json['description'] as String,
description: json['description_md'] as String,
type: $enumDecode(_$RecipeTypeEnumMap, json['type']),
videoUrl: json['video_url'] as String?,
cookingTime: json['cooking_time'] as String?,
@@ -34,7 +34,7 @@ Map<String, dynamic> _$$RecipeCreateModelImplToJson(
) => <String, dynamic>{
'title': instance.title,
'state': instance.state,
'description': instance.description,
'description_md': instance.description,
'type': _$RecipeTypeEnumMap[instance.type]!,
'video_url': instance.videoUrl,
'cooking_time': instance.cookingTime,

View File

@@ -43,13 +43,13 @@ class RecipeRepository {
if (step != null) {
if ((step.image == null || (step.image?.isEmpty ?? true)) && step.description != null) {
stepsMap.add({
'description': step.description ?? "",
'description_md': step.description ?? "",
});
} else if (step.image != null && (step.image?.isNotEmpty ?? false)) {
final image = await ImageCompressUtility.compressFile(File(step.image ?? ''));
final multipartFile = await MultipartFile.fromFile(image.path);
stepsMap.add({
'description': step.description ?? "",
'description_md': step.description ?? "",
'image': multipartFile,
});
}
@@ -60,7 +60,7 @@ class RecipeRepository {
'state': 'active',
'title': recipe.title,
'tags': recipe.tags,
'description': recipe.description,
'description_md': recipe.description,
'video_url': recipe.video_url,
'ingredients': ingredientsMap,
'steps': stepsMap,