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 }
|
||||
|
||||
@@ -6,45 +6,50 @@ part of 'recipe.dart';
|
||||
// JsonSerializableGenerator
|
||||
// **************************************************************************
|
||||
|
||||
Material _$MaterialFromJson(Map<String, dynamic> json) => Material(
|
||||
type: json['type'] as String,
|
||||
name: json['name'] as String,
|
||||
amount: json['amount'] as String,
|
||||
);
|
||||
RecipeMaterial _$RecipeMaterialFromJson(Map<String, dynamic> json) =>
|
||||
RecipeMaterial(
|
||||
type: json['type'] as String,
|
||||
name: json['name'] as String,
|
||||
amount: json['amount'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$MaterialToJson(Material instance) => <String, dynamic>{
|
||||
'type': instance.type,
|
||||
'name': instance.name,
|
||||
'amount': instance.amount,
|
||||
};
|
||||
Map<String, dynamic> _$RecipeMaterialToJson(RecipeMaterial instance) =>
|
||||
<String, dynamic>{
|
||||
'type': instance.type,
|
||||
'name': instance.name,
|
||||
'amount': instance.amount,
|
||||
};
|
||||
|
||||
Step _$StepFromJson(Map<String, dynamic> json) => Step(
|
||||
RecipeStep _$RecipeStepFromJson(Map<String, dynamic> json) => RecipeStep(
|
||||
sort: (json['sort'] as num).toInt(),
|
||||
content: json['content'] as String,
|
||||
imageUrl: json['imageUrl'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$StepToJson(Step instance) => <String, dynamic>{
|
||||
'sort': instance.sort,
|
||||
'content': instance.content,
|
||||
'imageUrl': instance.imageUrl,
|
||||
};
|
||||
Map<String, dynamic> _$RecipeStepToJson(RecipeStep instance) =>
|
||||
<String, dynamic>{
|
||||
'sort': instance.sort,
|
||||
'content': instance.content,
|
||||
'imageUrl': instance.imageUrl,
|
||||
};
|
||||
|
||||
Comment _$CommentFromJson(Map<String, dynamic> json) => Comment(
|
||||
id: (json['id'] as num).toInt(),
|
||||
username: json['username'] as String,
|
||||
avatar: json['avatar'] as String,
|
||||
content: json['content'] as String,
|
||||
date: json['date'] as String,
|
||||
);
|
||||
RecipeComment _$RecipeCommentFromJson(Map<String, dynamic> json) =>
|
||||
RecipeComment(
|
||||
id: (json['id'] as num).toInt(),
|
||||
username: json['username'] as String,
|
||||
avatar: json['avatar'] as String,
|
||||
content: json['content'] as String,
|
||||
date: json['date'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CommentToJson(Comment instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'username': instance.username,
|
||||
'avatar': instance.avatar,
|
||||
'content': instance.content,
|
||||
'date': instance.date,
|
||||
};
|
||||
Map<String, dynamic> _$RecipeCommentToJson(RecipeComment instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'username': instance.username,
|
||||
'avatar': instance.avatar,
|
||||
'content': instance.content,
|
||||
'date': instance.date,
|
||||
};
|
||||
|
||||
Record _$RecordFromJson(Map<String, dynamic> json) => Record(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
@@ -71,42 +76,42 @@ Map<String, dynamic> _$RecipeQueryToJson(RecipeQuery instance) =>
|
||||
<String, dynamic>{'category': instance.category};
|
||||
|
||||
Recipe _$RecipeFromJson(Map<String, dynamic> json) => Recipe(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
id: (json['id'] as num).toInt(),
|
||||
name: json['name'] as String,
|
||||
category: json['category'] as String,
|
||||
recommendRate: (json['recommendRate'] as num).toDouble(),
|
||||
remark: json['remark'] as String?,
|
||||
remark: json['remark'] as String,
|
||||
isShare: json['isShare'] as bool,
|
||||
userId: (json['userId'] as num?)?.toInt(),
|
||||
username: json['username'] as String?,
|
||||
avatar: json['avatar'] as String?,
|
||||
userId: (json['userId'] as num).toInt(),
|
||||
username: json['username'] as String,
|
||||
avatar: json['avatar'] as String,
|
||||
materialList:
|
||||
(json['materialList'] as List<dynamic>?)
|
||||
?.map((e) => Material.fromJson(e as Map<String, dynamic>))
|
||||
(json['materialList'] as List<dynamic>)
|
||||
.map((e) => RecipeMaterial.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
stepList:
|
||||
(json['stepList'] as List<dynamic>?)
|
||||
?.map((e) => Step.fromJson(e as Map<String, dynamic>))
|
||||
(json['stepList'] as List<dynamic>)
|
||||
.map((e) => RecipeStep.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
recordList:
|
||||
(json['recordList'] as List<dynamic>)
|
||||
.map((e) => Record.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
likeList:
|
||||
(json['likeList'] as List<dynamic>?)
|
||||
?.map((e) => (e as num).toInt())
|
||||
(json['likeList'] as List<dynamic>)
|
||||
.map((e) => (e as num).toInt())
|
||||
.toList(),
|
||||
likeCount: (json['likeCount'] as num?)?.toInt(),
|
||||
likeCount: (json['likeCount'] as num).toInt(),
|
||||
favouriteList:
|
||||
(json['favouriteList'] as List<dynamic>?)
|
||||
?.map((e) => (e as num).toInt())
|
||||
(json['favouriteList'] as List<dynamic>)
|
||||
.map((e) => (e as num).toInt())
|
||||
.toList(),
|
||||
favouriteCount: (json['favouriteCount'] as num?)?.toInt(),
|
||||
favouriteCount: (json['favouriteCount'] as num).toInt(),
|
||||
commentList:
|
||||
(json['commentList'] as List<dynamic>?)
|
||||
?.map((e) => Comment.fromJson(e as Map<String, dynamic>))
|
||||
(json['commentList'] as List<dynamic>)
|
||||
.map((e) => RecipeComment.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
commentCount: (json['commentCount'] as num?)?.toInt(),
|
||||
commentCount: (json['commentCount'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$RecipeToJson(Recipe instance) => <String, dynamic>{
|
||||
@@ -129,3 +134,93 @@ Map<String, dynamic> _$RecipeToJson(Recipe instance) => <String, dynamic>{
|
||||
'commentList': instance.commentList,
|
||||
'commentCount': instance.commentCount,
|
||||
};
|
||||
|
||||
RecipeSummary _$RecipeSummaryFromJson(Map<String, dynamic> json) =>
|
||||
RecipeSummary(
|
||||
id: (json['id'] as num).toInt(),
|
||||
name: json['name'] as String,
|
||||
category: json['category'] as String,
|
||||
recommendRate: (json['recommendRate'] as num).toDouble(),
|
||||
isShare: json['isShare'] as bool,
|
||||
userId: (json['userId'] as num).toInt(),
|
||||
username: json['username'] as String,
|
||||
avatar: json['avatar'] as String,
|
||||
recordList:
|
||||
(json['recordList'] as List<dynamic>)
|
||||
.map((e) => Record.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
likeCount: (json['likeCount'] as num).toInt(),
|
||||
favouriteCount: (json['favouriteCount'] as num).toInt(),
|
||||
commentCount: (json['commentCount'] as num).toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$RecipeSummaryToJson(RecipeSummary instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'category': instance.category,
|
||||
'recommendRate': instance.recommendRate,
|
||||
'isShare': instance.isShare,
|
||||
'recordList': instance.recordList,
|
||||
'likeCount': instance.likeCount,
|
||||
'favouriteCount': instance.favouriteCount,
|
||||
'commentCount': instance.commentCount,
|
||||
'userId': instance.userId,
|
||||
'username': instance.username,
|
||||
'avatar': instance.avatar,
|
||||
};
|
||||
|
||||
RecipeDetail _$RecipeDetailFromJson(Map<String, dynamic> json) => RecipeDetail(
|
||||
id: (json['id'] as num).toInt(),
|
||||
name: json['name'] as String,
|
||||
category: json['category'] as String,
|
||||
recommendRate: (json['recommendRate'] as num).toDouble(),
|
||||
remark: json['remark'] as String,
|
||||
isShare: json['isShare'] as bool,
|
||||
userId: (json['userId'] as num).toInt(),
|
||||
username: json['username'] as String,
|
||||
avatar: json['avatar'] as String,
|
||||
materialList:
|
||||
(json['materialList'] as List<dynamic>)
|
||||
.map((e) => RecipeMaterial.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
stepList:
|
||||
(json['stepList'] as List<dynamic>)
|
||||
.map((e) => RecipeStep.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
recordList:
|
||||
(json['recordList'] as List<dynamic>)
|
||||
.map((e) => Record.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
likeList:
|
||||
(json['likeList'] as List<dynamic>)
|
||||
.map((e) => (e as num).toInt())
|
||||
.toList(),
|
||||
favouriteList:
|
||||
(json['favouriteList'] as List<dynamic>)
|
||||
.map((e) => (e as num).toInt())
|
||||
.toList(),
|
||||
commentList:
|
||||
(json['commentList'] as List<dynamic>)
|
||||
.map((e) => RecipeComment.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$RecipeDetailToJson(RecipeDetail instance) =>
|
||||
<String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'category': instance.category,
|
||||
'recommendRate': instance.recommendRate,
|
||||
'remark': instance.remark,
|
||||
'isShare': instance.isShare,
|
||||
'userId': instance.userId,
|
||||
'username': instance.username,
|
||||
'avatar': instance.avatar,
|
||||
'materialList': instance.materialList,
|
||||
'stepList': instance.stepList,
|
||||
'recordList': instance.recordList,
|
||||
'likeList': instance.likeList,
|
||||
'favouriteList': instance.favouriteList,
|
||||
'commentList': instance.commentList,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user