提交 b2ebbece authored 作者: yueweilu's avatar yueweilu

接口

上级 74e379ca
part of apis;
\ No newline at end of file
part of apis;
abstract class LibraryAPI {
/// 1、图书分类
///
static Future <List<CategoryModel>> categoryList() async {
final result = await HttpService.to.post(
'/v1/book/category/getCategoryListAll',
params: {},
);
if (result.data is! Map && result.data['list'] is! List) return [];
return List.generate(result.data['list'].length, (index){
return CategoryModel.fromJson(result.data['list'][index]);
});
}
/// 2、图书标签
///
static Future <List<LabelModel>> labelList() async {
final result = await HttpService.to.post(
'/v1/book/category/getLabelListAll',
params: {},
);
if (result.data is! Map && result.data['list'] is! List) return [];
return List.generate(result.data['list'].length, (index){
return LabelModel.fromJson(result.data['list'][index]);
});
}
/// 3、书籍列表
static Future <List<CourseModel>> bookList({
int page = 1,
int limit = 20,
}) async {
final result = await HttpService.to.post(
'/v1/book/category/getBookList',
params: {
'currentPage': page,
'pageSize': limit,
},
);
if (result.data is! Map && result.data['list'] is! List) return [];
return List.generate(result.data['list'].length, (index){
return CourseModel.fromJson(result.data['list'][index]);
});
}
}
\ No newline at end of file
......@@ -15,7 +15,9 @@ class CourseModel {
this.progress,
this.lastChapter,
this.createTime,
this.days
this.days,
this.readNum,
this.isCollection
});
CourseModel.fromJson(dynamic json) {
......@@ -27,6 +29,9 @@ class CourseModel {
lastChapter = json['lastChapter'];
createTime = json['create_time'];
days = json['days'];
readNum = json['read_num'];
isCollection = json['is_collection'];
}
num? bookId;
String? bookName;
......@@ -36,6 +41,10 @@ class CourseModel {
String? lastChapter;
String? createTime;
String? days;
String? introduction;
num? readNum;
num? isCollection;
int get type {
if (progress == '0.00%'){
......@@ -65,6 +74,9 @@ class CourseModel {
String? lastChapter,
String? createTime,
String? days,
num? readNum,
num? isCollection,
}) => CourseModel( bookId: bookId ?? this.bookId,
bookName: bookName ?? this.bookName,
authors: authors ?? this.authors,
......@@ -73,6 +85,8 @@ class CourseModel {
lastChapter: lastChapter ?? this.lastChapter,
createTime: createTime ?? this.createTime,
days: days ?? this.days,
readNum: readNum ?? this.readNum,
isCollection: isCollection ?? this.isCollection
);
Map<String, dynamic> toJson() {
......@@ -85,6 +99,8 @@ class CourseModel {
map['lastChapter'] = lastChapter;
map['create_time'] = createTime;
map['days'] = days;
map['read_num'] = readNum;
map['is_collection'] = isCollection;
return map;
}
......
......@@ -9,4 +9,5 @@ part 'course.dart';
part 'ad_model.dart';
part 'user_model.dart';
part 'msg.dart';
part 'study_history.dart';
\ No newline at end of file
part 'study_history.dart';
part 'library.dart';
\ No newline at end of file
part of models;
/// 1、图书分类模型
///
class CategoryModel {
CategoryModel({
this.categoryId,
this.name,
});
CategoryModel.fromJson(dynamic json) {
categoryId = json['category_id'];
name = json['name'];
}
num? categoryId;
String? name;
CategoryModel copyWith({ num? categoryId,
String? name,
}) => CategoryModel( categoryId: categoryId ?? this.categoryId,
name: name ?? this.name,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['category_id'] = categoryId;
map['name'] = name;
return map;
}
}
/// 2、图书标签模型
///
class LabelModel {
LabelModel({
this.labelId,
this.name,
});
LabelModel.fromJson(dynamic json) {
labelId = json['label_id'];
name = json['name'];
}
num? labelId;
String? name;
LabelModel copyWith({ num? labelId,
String? name,
}) => LabelModel( labelId: labelId ?? this.labelId,
name: name ?? this.name,
);
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['label_id'] = labelId;
map['name'] = name;
return map;
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论