feat:增加dio网络请求
This commit is contained in:
@@ -1,30 +1,140 @@
|
||||
class Recipe {
|
||||
final String name;
|
||||
final String category;
|
||||
final String date;
|
||||
final String imageUrl;
|
||||
final int likeCount;
|
||||
final int favoriteCount;
|
||||
final int commentCount;
|
||||
import 'package:json_annotation/json_annotation.dart';
|
||||
|
||||
Recipe(
|
||||
this.name,
|
||||
this.category,
|
||||
this.date,
|
||||
this.imageUrl,
|
||||
this.likeCount,
|
||||
this.favoriteCount,
|
||||
this.commentCount,
|
||||
);
|
||||
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<String, dynamic> json) =>
|
||||
_$MaterialFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$MaterialToJson(this);
|
||||
}
|
||||
|
||||
class Record {
|
||||
final String name;
|
||||
final String category;
|
||||
final String date;
|
||||
final String imageUrl;
|
||||
/// 步骤信息
|
||||
@JsonSerializable()
|
||||
class Step {
|
||||
int sort;
|
||||
String content;
|
||||
String imageUrl;
|
||||
|
||||
Record(this.name, this.category, this.date, this.imageUrl);
|
||||
Step({
|
||||
required this.sort,
|
||||
required this.content,
|
||||
required this.imageUrl,
|
||||
});
|
||||
|
||||
factory Step.fromJson(Map<String, dynamic> json) =>
|
||||
_$StepFromJson(json);
|
||||
|
||||
Map<String, dynamic> 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<String, dynamic> json) =>
|
||||
_$CommentFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$CommentToJson(this);
|
||||
}
|
||||
|
||||
/// 成果信息
|
||||
@JsonSerializable()
|
||||
class Record {
|
||||
int id;
|
||||
String name;
|
||||
String? category;
|
||||
int person;
|
||||
String date;
|
||||
String imageUrl;
|
||||
|
||||
Record({
|
||||
required this.id,
|
||||
required this.name,
|
||||
this.category,
|
||||
required this.person,
|
||||
required this.date,
|
||||
required this.imageUrl,
|
||||
});
|
||||
|
||||
factory Record.fromJson(Map<String, dynamic> json) =>
|
||||
_$RecordFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$RecordToJson(this);
|
||||
}
|
||||
|
||||
/// 菜谱信息
|
||||
@JsonSerializable()
|
||||
class Recipe {
|
||||
int? id;
|
||||
String name;
|
||||
String category;
|
||||
double recommendRate;
|
||||
String? remark;
|
||||
bool isShare;
|
||||
int? userId;
|
||||
String? username;
|
||||
String? avatar;
|
||||
List<Material> materialList;
|
||||
List<Step> stepList;
|
||||
List<Record> recordList;
|
||||
List<int>? likeList;
|
||||
int? likeCount;
|
||||
List<int>? favouriteList;
|
||||
int? favouriteCount;
|
||||
List<Comment>? 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,
|
||||
required this.materialList,
|
||||
required this.stepList,
|
||||
required this.recordList,
|
||||
this.likeList,
|
||||
this.likeCount,
|
||||
this.favouriteList,
|
||||
this.favouriteCount,
|
||||
this.commentList,
|
||||
this.commentCount,
|
||||
});
|
||||
|
||||
factory Recipe.fromJson(Map<String, dynamic> json) =>
|
||||
_$RecipeFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$RecipeToJson(this);
|
||||
}
|
||||
|
||||
enum ViewType { recipe, calendar, timeline }
|
||||
|
||||
125
lib/models/recipe.g.dart
Normal file
125
lib/models/recipe.g.dart
Normal file
@@ -0,0 +1,125 @@
|
||||
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||
|
||||
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,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$MaterialToJson(Material instance) => <String, dynamic>{
|
||||
'type': instance.type,
|
||||
'name': instance.name,
|
||||
'amount': instance.amount,
|
||||
};
|
||||
|
||||
Step _$StepFromJson(Map<String, dynamic> json) => Step(
|
||||
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,
|
||||
};
|
||||
|
||||
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,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$CommentToJson(Comment 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(),
|
||||
name: json['name'] as String,
|
||||
category: json['category'] as String?,
|
||||
person: (json['person'] as num).toInt(),
|
||||
date: json['date'] as String,
|
||||
imageUrl: json['imageUrl'] as String,
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$RecordToJson(Record instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'name': instance.name,
|
||||
'category': instance.category,
|
||||
'person': instance.person,
|
||||
'date': instance.date,
|
||||
'imageUrl': instance.imageUrl,
|
||||
};
|
||||
|
||||
Recipe _$RecipeFromJson(Map<String, dynamic> json) => Recipe(
|
||||
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) => Material.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
stepList:
|
||||
(json['stepList'] as List<dynamic>)
|
||||
.map((e) => Step.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(),
|
||||
likeCount: (json['likeCount'] as num?)?.toInt(),
|
||||
favouriteList:
|
||||
(json['favouriteList'] as List<dynamic>?)
|
||||
?.map((e) => (e as num).toInt())
|
||||
.toList(),
|
||||
favouriteCount: (json['favouriteCount'] as num?)?.toInt(),
|
||||
commentList:
|
||||
(json['commentList'] as List<dynamic>?)
|
||||
?.map((e) => Comment.fromJson(e as Map<String, dynamic>))
|
||||
.toList(),
|
||||
commentCount: (json['commentCount'] as num?)?.toInt(),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$RecipeToJson(Recipe 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,
|
||||
'likeCount': instance.likeCount,
|
||||
'favouriteList': instance.favouriteList,
|
||||
'favouriteCount': instance.favouriteCount,
|
||||
'commentList': instance.commentList,
|
||||
'commentCount': instance.commentCount,
|
||||
};
|
||||
@@ -4,29 +4,29 @@ part 'session.g.dart';
|
||||
|
||||
@JsonSerializable()
|
||||
class SaTokenInfo {
|
||||
String? tokenName;
|
||||
String? tokenValue;
|
||||
bool? isLogin;
|
||||
String tokenName;
|
||||
String tokenValue;
|
||||
bool isLogin;
|
||||
dynamic loginId;
|
||||
String? loginType;
|
||||
int? tokenTimeout;
|
||||
int? sessionTimeout;
|
||||
int? tokenSessionTimeout;
|
||||
int? tokenActiveTimeout;
|
||||
String? loginDeviceType;
|
||||
String loginType;
|
||||
int tokenTimeout;
|
||||
int sessionTimeout;
|
||||
int tokenSessionTimeout;
|
||||
int tokenActiveTimeout;
|
||||
String loginDeviceType;
|
||||
String? tag;
|
||||
|
||||
SaTokenInfo({
|
||||
this.tokenName,
|
||||
this.tokenValue,
|
||||
this.isLogin,
|
||||
this.loginId,
|
||||
this.loginType,
|
||||
this.tokenTimeout,
|
||||
this.sessionTimeout,
|
||||
this.tokenSessionTimeout,
|
||||
this.tokenActiveTimeout,
|
||||
this.loginDeviceType,
|
||||
required this.tokenName,
|
||||
required this.tokenValue,
|
||||
required this.isLogin,
|
||||
required this.loginId,
|
||||
required this.loginType,
|
||||
required this.tokenTimeout,
|
||||
required this.sessionTimeout,
|
||||
required this.tokenSessionTimeout,
|
||||
required this.tokenActiveTimeout,
|
||||
required this.loginDeviceType,
|
||||
this.tag,
|
||||
});
|
||||
|
||||
@@ -36,6 +36,7 @@ class SaTokenInfo {
|
||||
|
||||
@JsonSerializable()
|
||||
class User {
|
||||
int? id;
|
||||
String? username;
|
||||
int? gender;
|
||||
String? phoneNumber;
|
||||
@@ -47,7 +48,6 @@ class User {
|
||||
String? job;
|
||||
List<String>? tags;
|
||||
String? description;
|
||||
String? id;
|
||||
|
||||
User({
|
||||
this.id,
|
||||
@@ -70,10 +70,10 @@ class User {
|
||||
|
||||
@JsonSerializable()
|
||||
class Session {
|
||||
SaTokenInfo? saToken;
|
||||
User? userInfo;
|
||||
SaTokenInfo saToken;
|
||||
User userInfo;
|
||||
|
||||
Session({this.saToken, this.userInfo});
|
||||
Session({required this.saToken, required this.userInfo});
|
||||
|
||||
factory Session.fromJson(Map<String, dynamic> json) => _$SessionFromJson(json);
|
||||
Map<String, dynamic> toJson() => _$SessionToJson(this);
|
||||
|
||||
@@ -7,16 +7,16 @@ part of 'session.dart';
|
||||
// **************************************************************************
|
||||
|
||||
SaTokenInfo _$SaTokenInfoFromJson(Map<String, dynamic> json) => SaTokenInfo(
|
||||
tokenName: json['tokenName'] as String?,
|
||||
tokenValue: json['tokenValue'] as String?,
|
||||
isLogin: json['isLogin'] as bool?,
|
||||
tokenName: json['tokenName'] as String,
|
||||
tokenValue: json['tokenValue'] as String,
|
||||
isLogin: json['isLogin'] as bool,
|
||||
loginId: json['loginId'],
|
||||
loginType: json['loginType'] as String?,
|
||||
tokenTimeout: (json['tokenTimeout'] as num?)?.toInt(),
|
||||
sessionTimeout: (json['sessionTimeout'] as num?)?.toInt(),
|
||||
tokenSessionTimeout: (json['tokenSessionTimeout'] as num?)?.toInt(),
|
||||
tokenActiveTimeout: (json['tokenActiveTimeout'] as num?)?.toInt(),
|
||||
loginDeviceType: json['loginDeviceType'] as String?,
|
||||
loginType: json['loginType'] as String,
|
||||
tokenTimeout: (json['tokenTimeout'] as num).toInt(),
|
||||
sessionTimeout: (json['sessionTimeout'] as num).toInt(),
|
||||
tokenSessionTimeout: (json['tokenSessionTimeout'] as num).toInt(),
|
||||
tokenActiveTimeout: (json['tokenActiveTimeout'] as num).toInt(),
|
||||
loginDeviceType: json['loginDeviceType'] as String,
|
||||
tag: json['tag'] as String?,
|
||||
);
|
||||
|
||||
@@ -36,7 +36,7 @@ Map<String, dynamic> _$SaTokenInfoToJson(SaTokenInfo instance) =>
|
||||
};
|
||||
|
||||
User _$UserFromJson(Map<String, dynamic> json) => User(
|
||||
id: json['id'] as String?,
|
||||
id: (json['id'] as num?)?.toInt(),
|
||||
username: json['username'] as String?,
|
||||
gender: (json['gender'] as num?)?.toInt(),
|
||||
phoneNumber: json['phoneNumber'] as String?,
|
||||
@@ -54,6 +54,7 @@ User _$UserFromJson(Map<String, dynamic> json) => User(
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{
|
||||
'id': instance.id,
|
||||
'username': instance.username,
|
||||
'gender': instance.gender,
|
||||
'phoneNumber': instance.phoneNumber,
|
||||
@@ -65,18 +66,11 @@ Map<String, dynamic> _$UserToJson(User instance) => <String, dynamic>{
|
||||
'job': instance.job,
|
||||
'tags': instance.tags,
|
||||
'description': instance.description,
|
||||
'id': instance.id,
|
||||
};
|
||||
|
||||
Session _$SessionFromJson(Map<String, dynamic> json) => Session(
|
||||
saToken:
|
||||
json['saToken'] == null
|
||||
? null
|
||||
: SaTokenInfo.fromJson(json['saToken'] as Map<String, dynamic>),
|
||||
userInfo:
|
||||
json['userInfo'] == null
|
||||
? null
|
||||
: User.fromJson(json['userInfo'] as Map<String, dynamic>),
|
||||
saToken: SaTokenInfo.fromJson(json['saToken'] as Map<String, dynamic>),
|
||||
userInfo: User.fromJson(json['userInfo'] as Map<String, dynamic>),
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$SessionToJson(Session instance) => <String, dynamic>{
|
||||
|
||||
Reference in New Issue
Block a user