flutter架 构项目基础

This commit is contained in:
崔宝新
2026-09-04 15:22:20 +08:00
parent 70967229d0
commit 0c5aee59c0
265 changed files with 35484 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
import 'package:new_learn/core/api/my_point/model.dart';
import 'package:new_learn/core/network/dio_client.dart';
/// ============================================================
/// 【my_point 模块接口】积分接口 —— 对标 Vue3 端 api/userPoint/index.ts
///
/// getRecordPage —— 积分记录分页(页码分页)
/// GET /api/v1/UserPointsRecord/GetUserPointRecordPagedList
/// 参数:pageIndex / pageSize
///
/// 说明:排行榜相关接口(getUserCount / getUserRankPagedList)归属班级模块,
/// 统一收在 core/api/class/api.dart。
/// ============================================================
class UserPointApi {
UserPointApi._();
static final UserPointApi instance = UserPointApi._();
/// 积分记录分页(页码分页:pageIndex / pageSize)
Future<UserPointRecordPage> getRecordPage({
int pageIndex = 1,
int pageSize = 10,
}) async {
final data = await DioClient.instance.get(
'/api/v1/UserPointsRecord/GetUserPointRecordPagedList',
query: {'pageIndex': pageIndex, 'pageSize': pageSize},
);
return UserPointRecordPage.fromJson(data as Map<String, dynamic>);
}
}
+62
View File
@@ -0,0 +1,62 @@
/// ============================================================
/// 【my_point 模块模型】积分实体 —— 对标 Vue3 端 api/userPoint/type.ts
///
/// UserPointRecord(积分变动记录)/ UserPointRecordPage(分页响应)
///
/// 序列化:手动 fromJson(兼容 {code, message, data: {...}} 响应壳),
/// 等价原 point_model_original_version.dart 的自包含实现,不依赖 build_runner。
/// ============================================================
library;
/// 单条积分变动记录
class UserPointRecord {
const UserPointRecord({
this.points = 0,
this.pointMessage = '',
this.type = 0,
this.bizTime = '',
});
final int points; // 积分变动值(正=加分,负=扣分)
final String pointMessage; // 变动说明
final int type; // 类型
final String bizTime; // 变动时间字符串
factory UserPointRecord.fromJson(Map<String, dynamic> json) {
return UserPointRecord(
points: (json['points'] as num?)?.toInt() ?? 0,
pointMessage: json['pointMessage'] as String? ?? '',
type: (json['type'] as num?)?.toInt() ?? 0,
bizTime: json['bizTime'] as String? ?? '',
);
}
}
/// 积分记录分页响应
class UserPointRecordPage {
const UserPointRecordPage({
this.data = const [],
this.total = 0,
this.pageIndex = 1,
this.pageSize = 10,
});
final List<UserPointRecord> data; // 当前页记录
final int total; // 总记录数
final int pageIndex;
final int pageSize;
/// 兼容业务响应壳 {code, message, data: {...}}:data 存在就取 data
factory UserPointRecordPage.fromJson(Map<String, dynamic> json) {
final payload = (json['data'] as Map<String, dynamic>?) ?? json;
return UserPointRecordPage(
data: (payload['data'] as List<dynamic>? ?? const [])
.whereType<Map<String, dynamic>>()
.map(UserPointRecord.fromJson)
.toList(),
total: (payload['total'] as num?)?.toInt() ?? 0,
pageIndex: (payload['pageIndex'] as num?)?.toInt() ?? 1,
pageSize: (payload['pageSize'] as num?)?.toInt() ?? 10,
);
}
}