feat:增加菜谱后端接口

This commit is contained in:
2025-07-16 19:59:35 +08:00
parent c8f93f15a1
commit eec0e9f7d3
14 changed files with 327 additions and 205 deletions

View File

@@ -9,11 +9,7 @@ class Material {
String name;
String amount;
Material({
required this.type,
required this.name,
required this.amount,
});
Material({required this.type, required this.name, required this.amount});
factory Material.fromJson(Map<String, dynamic> json) =>
_$MaterialFromJson(json);
@@ -28,14 +24,9 @@ class Step {
String content;
String imageUrl;
Step({
required this.sort,
required this.content,
required this.imageUrl,
});
Step({required this.sort, required this.content, required this.imageUrl});
factory Step.fromJson(Map<String, dynamic> json) =>
_$StepFromJson(json);
factory Step.fromJson(Map<String, dynamic> json) => _$StepFromJson(json);
Map<String, dynamic> toJson() => _$StepToJson(this);
}
@@ -66,28 +57,40 @@ class Comment {
/// 成果信息
@JsonSerializable()
class Record {
int id;
int? id;
String name;
String? category;
String category;
int person;
String date;
String imageUrl;
Record({
required this.id,
this.id,
required this.name,
this.category,
required this.category,
required this.person,
required this.date,
required this.imageUrl,
});
factory Record.fromJson(Map<String, dynamic> json) =>
_$RecordFromJson(json);
factory Record.fromJson(Map<String, dynamic> json) => _$RecordFromJson(json);
Map<String, dynamic> toJson() => _$RecordToJson(this);
}
@JsonSerializable()
class RecipeQuery {
String category;
RecipeQuery({
required this.category
});
factory RecipeQuery.fromJson(Map<String, dynamic> json) => _$RecipeQueryFromJson(json);
Map<String, dynamic> toJson() => _$RecipeQueryToJson(this);
}
/// 菜谱信息
@JsonSerializable()
class Recipe {
@@ -100,8 +103,8 @@ class Recipe {
int? userId;
String? username;
String? avatar;
List<Material> materialList;
List<Step> stepList;
List<Material>? materialList;
List<Step>? stepList;
List<Record> recordList;
List<int>? likeList;
int? likeCount;
@@ -120,8 +123,8 @@ class Recipe {
this.userId,
this.username,
this.avatar,
required this.materialList,
required this.stepList,
this.materialList,
this.stepList,
required this.recordList,
this.likeList,
this.likeCount,
@@ -131,8 +134,7 @@ class Recipe {
this.commentCount,
});
factory Recipe.fromJson(Map<String, dynamic> json) =>
_$RecipeFromJson(json);
factory Recipe.fromJson(Map<String, dynamic> json) => _$RecipeFromJson(json);
Map<String, dynamic> toJson() => _$RecipeToJson(this);
}