feat:增加Minio工具类

This commit is contained in:
2025-11-18 20:03:25 +08:00
parent 9a8e1a7419
commit b6995d8dd1
15 changed files with 332 additions and 194 deletions

View File

@@ -9,7 +9,11 @@ class RecipeMaterial {
String name;
String amount;
RecipeMaterial({required this.type, required this.name, required this.amount});
RecipeMaterial({
required this.type,
required this.name,
required this.amount,
});
factory RecipeMaterial.fromJson(Map<String, dynamic> json) =>
_$RecipeMaterialFromJson(json);
@@ -24,9 +28,14 @@ class RecipeStep {
String content;
String imageUrl;
RecipeStep({required this.sort, required this.content, required this.imageUrl});
RecipeStep({
required this.sort,
required this.content,
required this.imageUrl,
});
factory RecipeStep.fromJson(Map<String, dynamic> json) => _$RecipeStepFromJson(json);
factory RecipeStep.fromJson(Map<String, dynamic> json) =>
_$RecipeStepFromJson(json);
Map<String, dynamic> toJson() => _$RecipeStepToJson(this);
}
@@ -56,7 +65,7 @@ class RecipeComment {
/// 成果信息
@JsonSerializable()
class Record {
class FoodRecord {
int? id;
String name;
String category;
@@ -64,7 +73,7 @@ class Record {
String date;
String imageUrl;
Record({
FoodRecord({
this.id,
required this.name,
required this.category,
@@ -73,20 +82,31 @@ class Record {
required this.imageUrl,
});
factory Record.fromJson(Map<String, dynamic> json) => _$RecordFromJson(json);
factory FoodRecord.fromJson(Map<String, dynamic> json) =>
_$RecordFromJson(json);
Map<String, dynamic> toJson() => _$RecordToJson(this);
static FoodRecord getEmpty() {
return FoodRecord(
id: 0,
name: '',
category: '',
person: 0,
date: '',
imageUrl: '',
);
}
}
@JsonSerializable()
class RecipeQuery {
String category;
RecipeQuery({
required this.category
});
RecipeQuery({required this.category});
factory RecipeQuery.fromJson(Map<String, dynamic> json) => _$RecipeQueryFromJson(json);
factory RecipeQuery.fromJson(Map<String, dynamic> json) =>
_$RecipeQueryFromJson(json);
Map<String, dynamic> toJson() => _$RecipeQueryToJson(this);
}
@@ -105,7 +125,7 @@ class Recipe {
String avatar;
List<RecipeMaterial> materialList;
List<RecipeStep> stepList;
List<Record> recordList;
List<FoodRecord> recordList;
List<int> likeList;
int likeCount;
List<int> favouriteList;
@@ -146,7 +166,7 @@ class RecipeSummary {
String category;
double recommendRate;
bool isShare;
List<Record> recordList;
List<FoodRecord> recordList;
int likeCount;
int favouriteCount;
int commentCount;
@@ -169,7 +189,8 @@ class RecipeSummary {
required this.commentCount,
});
factory RecipeSummary.fromJson(Map<String, dynamic> json) => _$RecipeSummaryFromJson(json);
factory RecipeSummary.fromJson(Map<String, dynamic> json) =>
_$RecipeSummaryFromJson(json);
Map<String, dynamic> toJson() => _$RecipeSummaryToJson(this);
}
@@ -187,7 +208,7 @@ class RecipeDetail {
String avatar;
List<RecipeMaterial> materialList;
List<RecipeStep> stepList;
List<Record> recordList;
List<FoodRecord> recordList;
List<int> likeList;
List<int> favouriteList;
List<RecipeComment> commentList;
@@ -210,7 +231,8 @@ class RecipeDetail {
required this.commentList,
});
factory RecipeDetail.fromJson(Map<String, dynamic> json) => _$RecipeDetailFromJson(json);
factory RecipeDetail.fromJson(Map<String, dynamic> json) =>
_$RecipeDetailFromJson(json);
Map<String, dynamic> toJson() => _$RecipeDetailToJson(this);
}

View File

@@ -51,7 +51,7 @@ Map<String, dynamic> _$RecipeCommentToJson(RecipeComment instance) =>
'date': instance.date,
};
Record _$RecordFromJson(Map<String, dynamic> json) => Record(
FoodRecord _$RecordFromJson(Map<String, dynamic> json) => FoodRecord(
id: (json['id'] as num?)?.toInt(),
name: json['name'] as String,
category: json['category'] as String,
@@ -60,7 +60,7 @@ Record _$RecordFromJson(Map<String, dynamic> json) => Record(
imageUrl: json['imageUrl'] as String,
);
Map<String, dynamic> _$RecordToJson(Record instance) => <String, dynamic>{
Map<String, dynamic> _$RecordToJson(FoodRecord instance) => <String, dynamic>{
'id': instance.id,
'name': instance.name,
'category': instance.category,
@@ -95,7 +95,7 @@ Recipe _$RecipeFromJson(Map<String, dynamic> json) => Recipe(
.toList(),
recordList:
(json['recordList'] as List<dynamic>)
.map((e) => Record.fromJson(e as Map<String, dynamic>))
.map((e) => FoodRecord.fromJson(e as Map<String, dynamic>))
.toList(),
likeList:
(json['likeList'] as List<dynamic>)
@@ -147,7 +147,7 @@ RecipeSummary _$RecipeSummaryFromJson(Map<String, dynamic> json) =>
avatar: json['avatar'] as String,
recordList:
(json['recordList'] as List<dynamic>)
.map((e) => Record.fromJson(e as Map<String, dynamic>))
.map((e) => FoodRecord.fromJson(e as Map<String, dynamic>))
.toList(),
likeCount: (json['likeCount'] as num).toInt(),
favouriteCount: (json['favouriteCount'] as num).toInt(),
@@ -190,7 +190,7 @@ RecipeDetail _$RecipeDetailFromJson(Map<String, dynamic> json) => RecipeDetail(
.toList(),
recordList:
(json['recordList'] as List<dynamic>)
.map((e) => Record.fromJson(e as Map<String, dynamic>))
.map((e) => FoodRecord.fromJson(e as Map<String, dynamic>))
.toList(),
likeList:
(json['likeList'] as List<dynamic>)