import 'package:json_annotation/json_annotation.dart'; part 'recipe.g.dart'; /// 食材信息 @JsonSerializable() class Material { String type; String name; String amount; Material({required this.type, required this.name, required this.amount}); factory Material.fromJson(Map json) => _$MaterialFromJson(json); Map toJson() => _$MaterialToJson(this); } /// 步骤信息 @JsonSerializable() class Step { int sort; String content; String imageUrl; Step({required this.sort, required this.content, required this.imageUrl}); factory Step.fromJson(Map json) => _$StepFromJson(json); Map toJson() => _$StepToJson(this); } /// 评论信息 @JsonSerializable() class Comment { int id; String username; String avatar; String content; String date; Comment({ required this.id, required this.username, required this.avatar, required this.content, required this.date, }); factory Comment.fromJson(Map json) => _$CommentFromJson(json); Map toJson() => _$CommentToJson(this); } /// 成果信息 @JsonSerializable() class Record { int? id; String name; String category; int person; String date; String imageUrl; Record({ this.id, required this.name, required this.category, required this.person, required this.date, required this.imageUrl, }); factory Record.fromJson(Map json) => _$RecordFromJson(json); Map toJson() => _$RecordToJson(this); } @JsonSerializable() class RecipeQuery { String category; RecipeQuery({ required this.category }); factory RecipeQuery.fromJson(Map json) => _$RecipeQueryFromJson(json); Map toJson() => _$RecipeQueryToJson(this); } /// 菜谱信息 @JsonSerializable() class Recipe { int? id; String name; String category; double recommendRate; String? remark; bool isShare; int? userId; String? username; String? avatar; List? materialList; List? stepList; List recordList; List? likeList; int? likeCount; List? favouriteList; int? favouriteCount; List? commentList; int? commentCount; Recipe({ this.id, required this.name, required this.category, required this.recommendRate, this.remark, required this.isShare, this.userId, this.username, this.avatar, this.materialList, this.stepList, required this.recordList, this.likeList, this.likeCount, this.favouriteList, this.favouriteCount, this.commentList, this.commentCount, }); factory Recipe.fromJson(Map json) => _$RecipeFromJson(json); Map toJson() => _$RecipeToJson(this); } enum ViewType { recipe, calendar, timeline }