feat:增加菜谱后端接口
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -47,9 +47,9 @@ Map<String, dynamic> _$CommentToJson(Comment instance) => <String, dynamic>{
|
||||
};
|
||||
|
||||
Record _$RecordFromJson(Map<String, dynamic> json) => Record(
|
||||
id: (json['id'] as num).toInt(),
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
name: json['name'] as String,
|
||||
category: json['category'] as String?,
|
||||
category: json['category'] as String,
|
||||
person: (json['person'] as num).toInt(),
|
||||
date: json['date'] as String,
|
||||
imageUrl: json['imageUrl'] as String,
|
||||
@@ -64,6 +64,12 @@ Map<String, dynamic> _$RecordToJson(Record instance) => <String, dynamic>{
|
||||
'imageUrl': instance.imageUrl,
|
||||
};
|
||||
|
||||
RecipeQuery _$RecipeQueryFromJson(Map<String, dynamic> json) =>
|
||||
RecipeQuery(category: json['category'] as String);
|
||||
|
||||
Map<String, dynamic> _$RecipeQueryToJson(RecipeQuery instance) =>
|
||||
<String, dynamic>{'category': instance.category};
|
||||
|
||||
Recipe _$RecipeFromJson(Map<String, dynamic> json) => Recipe(
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
name: json['name'] as String,
|
||||
@@ -75,12 +81,12 @@ Recipe _$RecipeFromJson(Map<String, dynamic> json) => Recipe(
|
||||
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) => Material.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) => Step.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
recordList:
|
||||
(json['recordList'] as List<dynamic>)
|
||||
|
||||
Reference in New Issue
Block a user