同步dbretry接口
This commit is contained in:
21
apps/im_app/lib/domain/enums/retry_status.dart
Normal file
21
apps/im_app/lib/domain/enums/retry_status.dart
Normal file
@@ -0,0 +1,21 @@
|
||||
/// 重试同步状态
|
||||
///
|
||||
/// 对应 api_retry 表中 synced 字段的值
|
||||
enum RetryStatus {
|
||||
notYet(0),
|
||||
success(1),
|
||||
failed(-1),
|
||||
cancel(2),
|
||||
replace(3);
|
||||
|
||||
const RetryStatus(this.value);
|
||||
|
||||
final int value;
|
||||
|
||||
static RetryStatus fromValue(int value) {
|
||||
return RetryStatus.values.firstWhere(
|
||||
(e) => e.value == value,
|
||||
orElse: () => RetryStatus.notYet,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -14,12 +14,22 @@ abstract class ApiRetryRepository {
|
||||
|
||||
Future<ApiRetry?> getById(int id);
|
||||
|
||||
/// 读取指定 uid 的第一条重试任务
|
||||
Future<ApiRetry?> getByUid(int uid);
|
||||
|
||||
/// 读取未同步的重试任务
|
||||
Future<List<ApiRetry>> getPending();
|
||||
|
||||
/// 读取未过期的重试任务
|
||||
Future<List<ApiRetry>> getActive();
|
||||
|
||||
/// 读取指定 endPoint 且未同步的重试任务,按 createTime 升序
|
||||
Future<List<ApiRetry>> getByEndPointPending(String endPoint);
|
||||
|
||||
/// 读取指定同步状态的所有重试任务,按 createTime 升序
|
||||
/// synced: 0 未同步 / 1 已同步 / -1 失败
|
||||
Future<List<ApiRetry>> getBySynced(int synced);
|
||||
|
||||
// ── 写入 ─────────────────────────────────────────────────────────────────
|
||||
|
||||
/// 插入重试任务(autoIncrement id,无需提供)
|
||||
@@ -41,6 +51,9 @@ abstract class ApiRetryRepository {
|
||||
|
||||
Future<void> deleteByUid(int uid);
|
||||
|
||||
/// 删除已完成的重试任务(synced = success / failed / cancel / replace)
|
||||
Future<void> deleteFinished();
|
||||
|
||||
/// 清除已同步的重试任务
|
||||
Future<void> deleteSynced();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user