feat:新增菜谱详细信息模块
This commit is contained in:
@@ -4,43 +4,43 @@ part 'recipe.g.dart';
|
||||
|
||||
/// 食材信息
|
||||
@JsonSerializable()
|
||||
class Material {
|
||||
class RecipeMaterial {
|
||||
String type;
|
||||
String name;
|
||||
String amount;
|
||||
|
||||
Material({required this.type, required this.name, required this.amount});
|
||||
RecipeMaterial({required this.type, required this.name, required this.amount});
|
||||
|
||||
factory Material.fromJson(Map<String, dynamic> json) =>
|
||||
_$MaterialFromJson(json);
|
||||
factory RecipeMaterial.fromJson(Map<String, dynamic> json) =>
|
||||
_$RecipeMaterialFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$MaterialToJson(this);
|
||||
Map<String, dynamic> toJson() => _$RecipeMaterialToJson(this);
|
||||
}
|
||||
|
||||
/// 步骤信息
|
||||
@JsonSerializable()
|
||||
class Step {
|
||||
class RecipeStep {
|
||||
int sort;
|
||||
String content;
|
||||
String imageUrl;
|
||||
|
||||
Step({required this.sort, required this.content, required this.imageUrl});
|
||||
RecipeStep({required this.sort, required this.content, required this.imageUrl});
|
||||
|
||||
factory Step.fromJson(Map<String, dynamic> json) => _$StepFromJson(json);
|
||||
factory RecipeStep.fromJson(Map<String, dynamic> json) => _$RecipeStepFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$StepToJson(this);
|
||||
Map<String, dynamic> toJson() => _$RecipeStepToJson(this);
|
||||
}
|
||||
|
||||
/// 评论信息
|
||||
@JsonSerializable()
|
||||
class Comment {
|
||||
class RecipeComment {
|
||||
int id;
|
||||
String username;
|
||||
String avatar;
|
||||
String content;
|
||||
String date;
|
||||
|
||||
Comment({
|
||||
RecipeComment({
|
||||
required this.id,
|
||||
required this.username,
|
||||
required this.avatar,
|
||||
@@ -48,10 +48,10 @@ class Comment {
|
||||
required this.date,
|
||||
});
|
||||
|
||||
factory Comment.fromJson(Map<String, dynamic> json) =>
|
||||
_$CommentFromJson(json);
|
||||
factory RecipeComment.fromJson(Map<String, dynamic> json) =>
|
||||
_$RecipeCommentFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$CommentToJson(this);
|
||||
Map<String, dynamic> toJson() => _$RecipeCommentToJson(this);
|
||||
}
|
||||
|
||||
/// 成果信息
|
||||
@@ -94,44 +94,44 @@ class RecipeQuery {
|
||||
/// 菜谱信息
|
||||
@JsonSerializable()
|
||||
class Recipe {
|
||||
int? id;
|
||||
int id;
|
||||
String name;
|
||||
String category;
|
||||
double recommendRate;
|
||||
String? remark;
|
||||
String remark;
|
||||
bool isShare;
|
||||
int? userId;
|
||||
String? username;
|
||||
String? avatar;
|
||||
List<Material>? materialList;
|
||||
List<Step>? stepList;
|
||||
int userId;
|
||||
String username;
|
||||
String avatar;
|
||||
List<RecipeMaterial> materialList;
|
||||
List<RecipeStep> stepList;
|
||||
List<Record> recordList;
|
||||
List<int>? likeList;
|
||||
int? likeCount;
|
||||
List<int>? favouriteList;
|
||||
int? favouriteCount;
|
||||
List<Comment>? commentList;
|
||||
int? commentCount;
|
||||
List<int> likeList;
|
||||
int likeCount;
|
||||
List<int> favouriteList;
|
||||
int favouriteCount;
|
||||
List<RecipeComment> commentList;
|
||||
int commentCount;
|
||||
|
||||
Recipe({
|
||||
this.id,
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.category,
|
||||
required this.recommendRate,
|
||||
this.remark,
|
||||
required this.remark,
|
||||
required this.isShare,
|
||||
this.userId,
|
||||
this.username,
|
||||
this.avatar,
|
||||
this.materialList,
|
||||
this.stepList,
|
||||
required this.userId,
|
||||
required this.username,
|
||||
required this.avatar,
|
||||
required this.materialList,
|
||||
required this.stepList,
|
||||
required this.recordList,
|
||||
this.likeList,
|
||||
this.likeCount,
|
||||
this.favouriteList,
|
||||
this.favouriteCount,
|
||||
this.commentList,
|
||||
this.commentCount,
|
||||
required this.likeList,
|
||||
required this.likeCount,
|
||||
required this.favouriteList,
|
||||
required this.favouriteCount,
|
||||
required this.commentList,
|
||||
required this.commentCount,
|
||||
});
|
||||
|
||||
factory Recipe.fromJson(Map<String, dynamic> json) => _$RecipeFromJson(json);
|
||||
@@ -139,4 +139,80 @@ class Recipe {
|
||||
Map<String, dynamic> toJson() => _$RecipeToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class RecipeSummary {
|
||||
int id;
|
||||
String name;
|
||||
String category;
|
||||
double recommendRate;
|
||||
bool isShare;
|
||||
List<Record> recordList;
|
||||
int likeCount;
|
||||
int favouriteCount;
|
||||
int commentCount;
|
||||
int userId;
|
||||
String username;
|
||||
String avatar;
|
||||
|
||||
RecipeSummary({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.category,
|
||||
required this.recommendRate,
|
||||
required this.isShare,
|
||||
required this.userId,
|
||||
required this.username,
|
||||
required this.avatar,
|
||||
required this.recordList,
|
||||
required this.likeCount,
|
||||
required this.favouriteCount,
|
||||
required this.commentCount,
|
||||
});
|
||||
|
||||
factory RecipeSummary.fromJson(Map<String, dynamic> json) => _$RecipeSummaryFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$RecipeSummaryToJson(this);
|
||||
}
|
||||
|
||||
@JsonSerializable()
|
||||
class RecipeDetail {
|
||||
int id;
|
||||
String name;
|
||||
String category;
|
||||
double recommendRate;
|
||||
String remark;
|
||||
bool isShare;
|
||||
int userId;
|
||||
String username;
|
||||
String avatar;
|
||||
List<RecipeMaterial> materialList;
|
||||
List<RecipeStep> stepList;
|
||||
List<Record> recordList;
|
||||
List<int> likeList;
|
||||
List<int> favouriteList;
|
||||
List<RecipeComment> commentList;
|
||||
|
||||
RecipeDetail({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.category,
|
||||
required this.recommendRate,
|
||||
required this.remark,
|
||||
required this.isShare,
|
||||
required this.userId,
|
||||
required this.username,
|
||||
required this.avatar,
|
||||
required this.materialList,
|
||||
required this.stepList,
|
||||
required this.recordList,
|
||||
required this.likeList,
|
||||
required this.favouriteList,
|
||||
required this.commentList,
|
||||
});
|
||||
|
||||
factory RecipeDetail.fromJson(Map<String, dynamic> json) => _$RecipeDetailFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$RecipeDetailToJson(this);
|
||||
}
|
||||
|
||||
enum ViewType { recipe, calendar, timeline }
|
||||
|
||||
Reference in New Issue
Block a user