所有数据库表,提供相应的provider、桥接等方法

This commit is contained in:
Happi (哈比)
2026-03-10 12:09:45 +08:00
parent 084b7bbd23
commit 8130bf63fa
79 changed files with 3465 additions and 2730 deletions

View File

@@ -1,5 +1,5 @@
/// Domain
class Retry {
class ApiRetry {
final int? id;
final int? uid;
final String apiType;
@@ -13,7 +13,7 @@ class Retry {
final int? createTime;
final int? addIndex;
const Retry({
const ApiRetry({
this.id,
this.uid,
this.apiType = '',
@@ -28,7 +28,7 @@ class Retry {
this.addIndex,
});
Retry copyWith({
ApiRetry copyWith({
int? id,
int? uid,
String? apiType,
@@ -42,7 +42,7 @@ class Retry {
int? createTime,
int? addIndex,
}) {
return Retry(
return ApiRetry(
id: id ?? this.id,
uid: uid ?? this.uid,
apiType: apiType ?? this.apiType,

View File

@@ -1,112 +1,31 @@
/// 发现小程序 Domain 实体
class DiscoverMiniApp {
final String id;
final String? name;
final String? openuid;
final String? devId;
final String? icon;
final String? iconGaussian;
final String? downloadUrl;
final String? description;
final int? version;
final int? typ;
final int? flag;
final int? reviewStatus;
final int? favoriteAt;
final int? isActive;
final int? createdAt;
final int? updatedAt;
final int? deletedAt;
final double? score;
final String? channels;
final String? devName;
final String? pictureGaussian;
final String? picture;
final int? commentNum;
final String? lastLoginAt;
final String? screen;
import 'package:im_app/domain/entities/mini_app.dart';
class DiscoverMiniApp extends MiniApp {
const DiscoverMiniApp({
required this.id,
this.name,
this.openuid,
this.devId,
this.icon,
this.iconGaussian,
this.downloadUrl,
this.description,
this.version,
this.typ,
this.flag,
this.reviewStatus,
this.favoriteAt,
this.isActive,
this.createdAt,
this.updatedAt,
this.deletedAt,
this.score,
this.channels,
this.devName,
this.pictureGaussian,
this.picture,
this.commentNum,
this.lastLoginAt,
this.screen,
required super.id,
super.name,
super.openuid,
super.devId,
super.icon,
super.iconGaussian,
super.downloadUrl,
super.description,
super.version,
super.typ,
super.flag,
super.reviewStatus,
super.favoriteAt,
super.isActive,
super.createdAt,
super.updatedAt,
super.deletedAt,
super.score,
super.channels,
super.devName,
super.pictureGaussian,
super.picture,
super.commentNum,
super.lastLoginAt,
super.screen,
});
DiscoverMiniApp copyWith({
String? id,
String? name,
String? openuid,
String? devId,
String? icon,
String? iconGaussian,
String? downloadUrl,
String? description,
int? version,
int? typ,
int? flag,
int? reviewStatus,
int? favoriteAt,
int? isActive,
int? createdAt,
int? updatedAt,
int? deletedAt,
double? score,
String? channels,
String? devName,
String? pictureGaussian,
String? picture,
int? commentNum,
String? lastLoginAt,
String? screen,
}) {
return DiscoverMiniApp(
id: id ?? this.id,
name: name ?? this.name,
openuid: openuid ?? this.openuid,
devId: devId ?? this.devId,
icon: icon ?? this.icon,
iconGaussian: iconGaussian ?? this.iconGaussian,
downloadUrl: downloadUrl ?? this.downloadUrl,
description: description ?? this.description,
version: version ?? this.version,
typ: typ ?? this.typ,
flag: flag ?? this.flag,
reviewStatus: reviewStatus ?? this.reviewStatus,
favoriteAt: favoriteAt ?? this.favoriteAt,
isActive: isActive ?? this.isActive,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
deletedAt: deletedAt ?? this.deletedAt,
score: score ?? this.score,
channels: channels ?? this.channels,
devName: devName ?? this.devName,
pictureGaussian: pictureGaussian ?? this.pictureGaussian,
picture: picture ?? this.picture,
commentNum: commentNum ?? this.commentNum,
lastLoginAt: lastLoginAt ?? this.lastLoginAt,
screen: screen ?? this.screen,
);
}
}

View File

@@ -1,112 +1,31 @@
/// 探索小程序 Domain 实体
class ExploreMiniApp {
final String id;
final String? name;
final String? openuid;
final String? devId;
final String? icon;
final String? iconGaussian;
final String? downloadUrl;
final String? description;
final int? version;
final int? typ;
final int? flag;
final int? reviewStatus;
final int? favoriteAt;
final int? isActive;
final int? createdAt;
final int? updatedAt;
final int? deletedAt;
final double? score;
final String? channels;
final String? devName;
final String? pictureGaussian;
final String? picture;
final int? commentNum;
final int? lastLoginAt;
final String? screen;
import 'package:im_app/domain/entities/mini_app.dart';
class ExploreMiniApp extends MiniApp {
const ExploreMiniApp({
required this.id,
this.name,
this.openuid,
this.devId,
this.icon,
this.iconGaussian,
this.downloadUrl,
this.description,
this.version,
this.typ,
this.flag,
this.reviewStatus,
this.favoriteAt,
this.isActive,
this.createdAt,
this.updatedAt,
this.deletedAt,
this.score,
this.channels,
this.devName,
this.pictureGaussian,
this.picture,
this.commentNum,
this.lastLoginAt,
this.screen,
required super.id,
super.name,
super.openuid,
super.devId,
super.icon,
super.iconGaussian,
super.downloadUrl,
super.description,
super.version,
super.typ,
super.flag,
super.reviewStatus,
super.favoriteAt,
super.isActive,
super.createdAt,
super.updatedAt,
super.deletedAt,
super.score,
super.channels,
super.devName,
super.pictureGaussian,
super.picture,
super.commentNum,
super.lastLoginAt,
super.screen,
});
ExploreMiniApp copyWith({
String? id,
String? name,
String? openuid,
String? devId,
String? icon,
String? iconGaussian,
String? downloadUrl,
String? description,
int? version,
int? typ,
int? flag,
int? reviewStatus,
int? favoriteAt,
int? isActive,
int? createdAt,
int? updatedAt,
int? deletedAt,
double? score,
String? channels,
String? devName,
String? pictureGaussian,
String? picture,
int? commentNum,
int? lastLoginAt,
String? screen,
}) {
return ExploreMiniApp(
id: id ?? this.id,
name: name ?? this.name,
openuid: openuid ?? this.openuid,
devId: devId ?? this.devId,
icon: icon ?? this.icon,
iconGaussian: iconGaussian ?? this.iconGaussian,
downloadUrl: downloadUrl ?? this.downloadUrl,
description: description ?? this.description,
version: version ?? this.version,
typ: typ ?? this.typ,
flag: flag ?? this.flag,
reviewStatus: reviewStatus ?? this.reviewStatus,
favoriteAt: favoriteAt ?? this.favoriteAt,
isActive: isActive ?? this.isActive,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
deletedAt: deletedAt ?? this.deletedAt,
score: score ?? this.score,
channels: channels ?? this.channels,
devName: devName ?? this.devName,
pictureGaussian: pictureGaussian ?? this.pictureGaussian,
picture: picture ?? this.picture,
commentNum: commentNum ?? this.commentNum,
lastLoginAt: lastLoginAt ?? this.lastLoginAt,
screen: screen ?? this.screen,
);
}
}

View File

@@ -1,5 +1,5 @@
/// Domain
class Favourite {
class Favorite {
final int id;
final String parentId;
final String data;
@@ -16,7 +16,7 @@ class Favourite {
final int isUploaded;
final String urls;
const Favourite({
const Favorite({
required this.id,
this.parentId = '',
this.data = '',
@@ -34,7 +34,7 @@ class Favourite {
this.urls = '[]',
});
Favourite copyWith({
Favorite copyWith({
int? id,
String? parentId,
String? data,
@@ -51,7 +51,7 @@ class Favourite {
int? isUploaded,
String? urls,
}) {
return Favourite(
return Favorite(
id: id ?? this.id,
parentId: parentId ?? this.parentId,
data: data ?? this.data,

View File

@@ -1,5 +1,5 @@
/// Domain
class FavouriteDetail {
class FavoriteDetail {
final int? id;
final String relatedId;
final String content;
@@ -9,7 +9,7 @@ class FavouriteDetail {
final int? chatId;
final int? sendTime;
const FavouriteDetail({
const FavoriteDetail({
this.id,
this.relatedId = '',
this.content = '',
@@ -20,7 +20,7 @@ class FavouriteDetail {
this.sendTime,
});
FavouriteDetail copyWith({
FavoriteDetail copyWith({
int? id,
String? relatedId,
String? content,
@@ -30,7 +30,7 @@ class FavouriteDetail {
int? chatId,
int? sendTime,
}) {
return FavouriteDetail(
return FavoriteDetail(
id: id ?? this.id,
relatedId: relatedId ?? this.relatedId,
content: content ?? this.content,

View File

@@ -1,112 +1,32 @@
import 'package:im_app/domain/entities/mini_app.dart';
/// 收藏小程序 Domain 实体
class FavoriteMiniApp {
final String id;
final String? name;
final String? openuid;
final String? devId;
final String? icon;
final String? iconGaussian;
final String? downloadUrl;
final String? description;
final int? version;
final int? typ;
final int? flag;
final int? reviewStatus;
final int? favoriteAt;
final int? isActive;
final int? createdAt;
final int? updatedAt;
final int? deletedAt;
final double? score;
final String? channels;
final String? devName;
final String? pictureGaussian;
final String? picture;
final int? commentNum;
final int? lastLoginAt;
final String? screen;
class FavoriteMiniApp extends MiniApp {
const FavoriteMiniApp({
required this.id,
this.name,
this.openuid,
this.devId,
this.icon,
this.iconGaussian,
this.downloadUrl,
this.description,
this.version,
this.typ,
this.flag,
this.reviewStatus,
this.favoriteAt,
this.isActive,
this.createdAt,
this.updatedAt,
this.deletedAt,
this.score,
this.channels,
this.devName,
this.pictureGaussian,
this.picture,
this.commentNum,
this.lastLoginAt,
this.screen,
required super.id,
super.name,
super.openuid,
super.devId,
super.icon,
super.iconGaussian,
super.downloadUrl,
super.description,
super.version,
super.typ,
super.flag,
super.reviewStatus,
super.favoriteAt,
super.isActive,
super.createdAt,
super.updatedAt,
super.deletedAt,
super.score,
super.channels,
super.devName,
super.pictureGaussian,
super.picture,
super.commentNum,
super.lastLoginAt,
super.screen,
});
FavoriteMiniApp copyWith({
String? id,
String? name,
String? openuid,
String? devId,
String? icon,
String? iconGaussian,
String? downloadUrl,
String? description,
int? version,
int? typ,
int? flag,
int? reviewStatus,
int? favoriteAt,
int? isActive,
int? createdAt,
int? updatedAt,
int? deletedAt,
double? score,
String? channels,
String? devName,
String? pictureGaussian,
String? picture,
int? commentNum,
int? lastLoginAt,
String? screen,
}) {
return FavoriteMiniApp(
id: id ?? this.id,
name: name ?? this.name,
openuid: openuid ?? this.openuid,
devId: devId ?? this.devId,
icon: icon ?? this.icon,
iconGaussian: iconGaussian ?? this.iconGaussian,
downloadUrl: downloadUrl ?? this.downloadUrl,
description: description ?? this.description,
version: version ?? this.version,
typ: typ ?? this.typ,
flag: flag ?? this.flag,
reviewStatus: reviewStatus ?? this.reviewStatus,
favoriteAt: favoriteAt ?? this.favoriteAt,
isActive: isActive ?? this.isActive,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
deletedAt: deletedAt ?? this.deletedAt,
score: score ?? this.score,
channels: channels ?? this.channels,
devName: devName ?? this.devName,
pictureGaussian: pictureGaussian ?? this.pictureGaussian,
picture: picture ?? this.picture,
commentNum: commentNum ?? this.commentNum,
lastLoginAt: lastLoginAt ?? this.lastLoginAt,
screen: screen ?? this.screen,
);
}
}

View File

@@ -0,0 +1,114 @@
/// 小程序 Domain 实体
///
/// discover / explore / favorite / recent 四张表共用同一个实体
class MiniApp {
final String id;
final String? name;
final String? openuid;
final String? devId;
final String? icon;
final String? iconGaussian;
final String? downloadUrl;
final String? description;
final int? version;
final int? typ;
final int? flag;
final int? reviewStatus;
final int? favoriteAt;
final int? isActive;
final int? createdAt;
final int? updatedAt;
final int? deletedAt;
final double? score;
final String? channels;
final String? devName;
final String? pictureGaussian;
final String? picture;
final int? commentNum;
final String? lastLoginAt;
final String? screen;
const MiniApp({
required this.id,
this.name,
this.openuid,
this.devId,
this.icon,
this.iconGaussian,
this.downloadUrl,
this.description,
this.version,
this.typ,
this.flag,
this.reviewStatus,
this.favoriteAt,
this.isActive,
this.createdAt,
this.updatedAt,
this.deletedAt,
this.score,
this.channels,
this.devName,
this.pictureGaussian,
this.picture,
this.commentNum,
this.lastLoginAt,
this.screen,
});
MiniApp copyWith({
String? id,
String? name,
String? openuid,
String? devId,
String? icon,
String? iconGaussian,
String? downloadUrl,
String? description,
int? version,
int? typ,
int? flag,
int? reviewStatus,
int? favoriteAt,
int? isActive,
int? createdAt,
int? updatedAt,
int? deletedAt,
double? score,
String? channels,
String? devName,
String? pictureGaussian,
String? picture,
int? commentNum,
String? lastLoginAt,
String? screen,
}) {
return MiniApp(
id: id ?? this.id,
name: name ?? this.name,
openuid: openuid ?? this.openuid,
devId: devId ?? this.devId,
icon: icon ?? this.icon,
iconGaussian: iconGaussian ?? this.iconGaussian,
downloadUrl: downloadUrl ?? this.downloadUrl,
description: description ?? this.description,
version: version ?? this.version,
typ: typ ?? this.typ,
flag: flag ?? this.flag,
reviewStatus: reviewStatus ?? this.reviewStatus,
favoriteAt: favoriteAt ?? this.favoriteAt,
isActive: isActive ?? this.isActive,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
deletedAt: deletedAt ?? this.deletedAt,
score: score ?? this.score,
channels: channels ?? this.channels,
devName: devName ?? this.devName,
pictureGaussian: pictureGaussian ?? this.pictureGaussian,
picture: picture ?? this.picture,
commentNum: commentNum ?? this.commentNum,
lastLoginAt: lastLoginAt ?? this.lastLoginAt,
screen: screen ?? this.screen,
);
}
}

View File

@@ -1,112 +1,32 @@
import 'package:im_app/domain/entities/mini_app.dart';
/// 最近小程序 Domain 实体
class RecentMiniApp {
final String id;
final String? name;
final String? openuid;
final String? devId;
final String? icon;
final String? iconGaussian;
final String? downloadUrl;
final String? description;
final int? version;
final int? typ;
final int? flag;
final int? reviewStatus;
final int? favoriteAt;
final int? isActive;
final int? createdAt;
final int? updatedAt;
final int? deletedAt;
final double? score;
final String? channels;
final String? devName;
final String? pictureGaussian;
final String? picture;
final int? commentNum;
final int? lastLoginAt;
final String? screen;
class RecentMiniApp extends MiniApp {
const RecentMiniApp({
required this.id,
this.name,
this.openuid,
this.devId,
this.icon,
this.iconGaussian,
this.downloadUrl,
this.description,
this.version,
this.typ,
this.flag,
this.reviewStatus,
this.favoriteAt,
this.isActive,
this.createdAt,
this.updatedAt,
this.deletedAt,
this.score,
this.channels,
this.devName,
this.pictureGaussian,
this.picture,
this.commentNum,
this.lastLoginAt,
this.screen,
required super.id,
super.name,
super.openuid,
super.devId,
super.icon,
super.iconGaussian,
super.downloadUrl,
super.description,
super.version,
super.typ,
super.flag,
super.reviewStatus,
super.favoriteAt,
super.isActive,
super.createdAt,
super.updatedAt,
super.deletedAt,
super.score,
super.channels,
super.devName,
super.pictureGaussian,
super.picture,
super.commentNum,
super.lastLoginAt,
super.screen,
});
RecentMiniApp copyWith({
String? id,
String? name,
String? openuid,
String? devId,
String? icon,
String? iconGaussian,
String? downloadUrl,
String? description,
int? version,
int? typ,
int? flag,
int? reviewStatus,
int? favoriteAt,
int? isActive,
int? createdAt,
int? updatedAt,
int? deletedAt,
double? score,
String? channels,
String? devName,
String? pictureGaussian,
String? picture,
int? commentNum,
int? lastLoginAt,
String? screen,
}) {
return RecentMiniApp(
id: id ?? this.id,
name: name ?? this.name,
openuid: openuid ?? this.openuid,
devId: devId ?? this.devId,
icon: icon ?? this.icon,
iconGaussian: iconGaussian ?? this.iconGaussian,
downloadUrl: downloadUrl ?? this.downloadUrl,
description: description ?? this.description,
version: version ?? this.version,
typ: typ ?? this.typ,
flag: flag ?? this.flag,
reviewStatus: reviewStatus ?? this.reviewStatus,
favoriteAt: favoriteAt ?? this.favoriteAt,
isActive: isActive ?? this.isActive,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt,
deletedAt: deletedAt ?? this.deletedAt,
score: score ?? this.score,
channels: channels ?? this.channels,
devName: devName ?? this.devName,
pictureGaussian: pictureGaussian ?? this.pictureGaussian,
picture: picture ?? this.picture,
commentNum: commentNum ?? this.commentNum,
lastLoginAt: lastLoginAt ?? this.lastLoginAt,
screen: screen ?? this.screen,
);
}
}

View File

@@ -0,0 +1,48 @@
import 'package:im_app/domain/entities/api_retry.dart';
/// API 重试仓储接口
abstract class ApiRetryRepository {
// ── 监听 ─────────────────────────────────────────────────────────────────
Stream<List<ApiRetry>> watchAll();
Stream<List<ApiRetry>> watchPending();
// ── 读取 ─────────────────────────────────────────────────────────────────
Future<List<ApiRetry>> getAll();
Future<ApiRetry?> getById(int id);
/// 读取未同步的重试任务
Future<List<ApiRetry>> getPending();
/// 读取未过期的重试任务
Future<List<ApiRetry>> getActive();
// ── 写入 ─────────────────────────────────────────────────────────────────
/// 插入重试任务autoIncrement id无需提供
Future<void> insert(ApiRetry apiRetry);
Future<void> insertOrReplace(ApiRetry apiRetry);
Future<void> update(ApiRetry apiRetry);
/// 标记为已同步
Future<void> markSynced(int id);
/// 标记为已过期
Future<void> markExpired(int id);
// ── 删除 ─────────────────────────────────────────────────────────────────
Future<void> delete(int id);
Future<void> deleteByUid(int uid);
/// 清除已同步的重试任务
Future<void> deleteSynced();
Future<void> clear();
}

View File

@@ -0,0 +1,51 @@
import 'package:im_app/domain/entities/chat_category.dart';
/// 聊天分类仓储接口
///
/// ## 职责
/// - StorageSdkApi ↔ Domain ChatCategory 映射
/// - CRUD 操作(通过 StorageSdkApi不直接接触 DB
/// - 所有公开接口只接受 Domain 实体Companion 转换完全内聚在 Impl
///
/// ## 数据流
/// ```
/// 写入Domain ChatCategory → _toCompanion() → StorageSdkApi → DB
/// 读取DB row (DriftChatCategory) → _toEntity() → Domain ChatCategory
/// 监听DB 变化 → stream → Domain ChatCategory → UI
/// ```
abstract class ChatCategoryRepository {
// ── 监听 ─────────────────────────────────────────────────────────────────
/// 监听所有聊天分类DB 变化自动反映
Stream<List<ChatCategory>> watchAllChatCategories();
/// 监听指定聊天分类
Stream<ChatCategory?> watchChatCategory(int id);
// ── 读取 ─────────────────────────────────────────────────────────────────
/// 读取所有聊天分类
Future<List<ChatCategory>> getChatCategories();
/// 读取指定聊天分类,不存在返回 null
Future<ChatCategory?> getChatCategory(int id);
// ── 写入 ─────────────────────────────────────────────────────────────────
/// 插入或替换聊天分类
Future<void> insertOrReplaceChatCategory(ChatCategory chatCategory);
/// 批量插入或替换聊天分类
Future<void> insertOrReplaceChatCategories(List<ChatCategory> chatCategories);
/// 更新聊天分类
Future<void> updateChatCategory(ChatCategory chatCategory);
// ── 删除 ─────────────────────────────────────────────────────────────────
/// 删除指定聊天分类
Future<void> deleteChatCategory(int id);
/// 清空所有聊天分类
Future<void> clearChatCategories();
}

View File

@@ -0,0 +1,60 @@
import 'package:im_app/domain/entities/chat.dart';
/// 聊天仓储接口
///
/// ## 职责
/// - StorageSdkApi ↔ Domain Chat 映射
/// - CRUD 操作(通过 StorageSdkApi不直接接触 DB
/// - 所有公开接口只接受 Domain 实体Companion 转换完全内聚在 Impl
///
/// ## 数据流
/// ```
/// 写入Domain Chat → _toCompanion() → StorageSdkApi → DB
/// 读取DB row (DriftChat) → _toEntity() → Domain Chat
/// 监听DB 变化 → stream → Domain Chat → UI
/// ```
abstract class ChatRepository {
// ── 监听 ─────────────────────────────────────────────────────────────────
/// 监听所有聊天DB 变化自动反映
Stream<List<Chat>> watchAllChats();
/// 监听指定聊天
Stream<Chat?> watchChat(int id);
// ── 读取 ─────────────────────────────────────────────────────────────────
/// 读取所有聊天
Future<List<Chat>> getChats();
/// 读取指定聊天,不存在返回 null
Future<Chat?> getChat(int id);
/// 分页读取聊天
Future<List<Chat>> getChatsPage({required int offset, required int limit});
/// 统计聊天总数
Future<int> countChats();
// ── 写入 ─────────────────────────────────────────────────────────────────
/// 插入或替换聊天
Future<void> insertOrReplaceChat(Chat chat);
/// 批量插入或替换聊天
Future<void> insertOrReplaceChats(List<Chat> chats);
/// 更新聊天
Future<void> updateChat(Chat chat);
/// 批量更新聊天
Future<void> updateChatsBatch(List<Chat> chats);
// ── 删除 ─────────────────────────────────────────────────────────────────
/// 删除指定聊天
Future<void> deleteChat(int id);
/// 清空所有聊天
Future<void> clearChats();
}

View File

@@ -0,0 +1,60 @@
import 'package:im_app/domain/entities/favorite_detail.dart';
/// 收藏详情仓储接口
///
/// ## 职责
/// - StorageSdkApi ↔ Domain FavoriteDetail 映射
/// - CRUD 操作(通过 StorageSdkApi不直接接触 DB
/// - 所有公开接口只接受 Domain 实体Companion 转换完全内聚在 Impl
///
/// ## 数据流
/// ```
/// 写入Domain FavoriteDetail → _toCompanion() → StorageSdkApi → DB
/// 读取DB row (DriftFavoriteDetail) → _toEntity() → Domain FavoriteDetail
/// 监听DB 变化 → stream → Domain FavoriteDetail → UI
/// ```
abstract class FavoriteDetailRepository {
// ── 监听 ─────────────────────────────────────────────────────────────────
/// 监听所有收藏详情DB 变化自动反映
Stream<List<FavoriteDetail>> watchAll();
/// 监听指定 relatedId 的收藏详情
Stream<List<FavoriteDetail>> watchByRelatedId(String relatedId);
// ── 读取 ─────────────────────────────────────────────────────────────────
/// 读取所有收藏详情
Future<List<FavoriteDetail>> getAll();
/// 读取指定 id不存在返回 null
Future<FavoriteDetail?> getById(int id);
/// 读取指定 relatedId 的所有收藏详情
Future<List<FavoriteDetail>> getByRelatedId(String relatedId);
// ── 写入 ─────────────────────────────────────────────────────────────────
/// 插入收藏详情autoIncrement id无需提供
Future<void> insert(FavoriteDetail favoriteDetail);
/// 批量插入收藏详情
Future<void> insertAll(List<FavoriteDetail> favoriteDetails);
/// 插入或替换收藏详情
Future<void> insertOrReplace(FavoriteDetail favoriteDetail);
/// 更新收藏详情
Future<void> update(FavoriteDetail favoriteDetail);
// ── 删除 ─────────────────────────────────────────────────────────────────
/// 删除指定 id
Future<void> delete(int id);
/// 删除指定 relatedId 的所有收藏详情
Future<void> deleteByRelatedId(String relatedId);
/// 清空所有收藏详情
Future<void> clear();
}

View File

@@ -0,0 +1,63 @@
import 'package:im_app/domain/entities/favorite.dart';
/// 收藏仓储接口
///
/// ## 职责
/// - StorageSdkApi ↔ Domain Favorite 映射
/// - CRUD 操作(通过 StorageSdkApi不直接接触 DB
/// - 所有公开接口只接受 Domain 实体Companion 转换完全内聚在 Impl
///
/// ## 数据流
/// ```
/// 写入Domain Favorite → _toCompanion() → StorageSdkApi → DB
/// 读取DB row (DriftFavorite) → _toEntity() → Domain Favorite
/// 监听DB 变化 → stream → Domain Favorite → UI
/// ```
abstract class FavoriteRepository {
// ── 监听 ─────────────────────────────────────────────────────────────────
/// 监听所有收藏DB 变化自动反映
Stream<List<Favorite>> watchAll();
/// 监听指定收藏
Stream<Favorite?> watchById(int id);
/// 监听指定 parentId 的收藏
Stream<List<Favorite>> watchByParentId(String parentId);
// ── 读取 ─────────────────────────────────────────────────────────────────
/// 读取所有收藏
Future<List<Favorite>> getAll();
/// 读取指定收藏,不存在返回 null
Future<Favorite?> getById(int id);
/// 读取指定 parentId 的所有收藏
Future<List<Favorite>> getByParentId(String parentId);
/// 读取未上传的收藏
Future<List<Favorite>> getUnuploaded();
// ── 写入 ─────────────────────────────────────────────────────────────────
/// 插入或替换收藏
Future<void> insertOrReplace(Favorite favorite);
/// 批量插入或替换收藏
Future<void> insertOrReplaceAll(List<Favorite> favorites);
/// 更新收藏
Future<void> update(Favorite favorite);
// ── 删除 ─────────────────────────────────────────────────────────────────
/// 删除指定收藏
Future<void> delete(int id);
/// 删除指定 parentId 的所有收藏
Future<void> deleteByParentId(String parentId);
/// 清空所有收藏
Future<void> clear();
}

View File

@@ -0,0 +1,57 @@
import 'package:im_app/domain/entities/group.dart';
/// 群组仓储接口
///
/// ## 职责
/// - StorageSdkApi ↔ Domain Group 映射
/// - CRUD 操作(通过 StorageSdkApi不直接接触 DB
/// - 所有公开接口只接受 Domain 实体Companion 转换完全内聚在 Impl
///
/// ## 数据流
/// ```
/// 写入Domain Group → _toCompanion() → StorageSdkApi → DB
/// 读取DB row (DriftGroup) → _toEntity() → Domain Group
/// 监听DB 变化 → stream → Domain Group → UI
/// ```
abstract class GroupRepository {
// ── 监听 ─────────────────────────────────────────────────────────────────
/// 监听所有群组DB 变化自动反映
Stream<List<Group>> watchAll();
/// 监听指定群组
Stream<Group?> watchById(int id);
// ── 读取 ─────────────────────────────────────────────────────────────────
/// 读取所有群组
Future<List<Group>> getAll();
/// 读取指定群组,不存在返回 null
Future<Group?> getById(int id);
/// 读取指定 workspaceId 的所有群组
Future<List<Group>> getByWorkspace(int workspaceId);
// ── 写入 ─────────────────────────────────────────────────────────────────
/// 插入或替换群组
Future<void> insertOrReplace(Group group);
/// 批量插入或替换群组
Future<void> insertOrReplaceAll(List<Group> groups);
/// 更新群组
Future<void> update(Group group);
/// 批量更新群组
Future<void> updateBatch(List<Group> groups);
// ── 删除 ─────────────────────────────────────────────────────────────────
/// 删除指定群组
Future<void> delete(int id);
/// 清空所有群组
Future<void> clear();
}

View File

@@ -0,0 +1,67 @@
import 'package:im_app/domain/entities/message.dart';
/// 消息仓储接口
///
/// ## 职责
/// - StorageSdkApi ↔ Domain Message 映射
/// - CRUD 操作(通过 StorageSdkApi不直接接触 DB
/// - 所有公开接口只接受 Domain 实体Companion 转换完全内聚在 Impl
///
/// ## 数据流
/// ```
/// 写入Domain Message → _toCompanion() → StorageSdkApi → DB
/// 读取DB row (DriftMessage) → _toEntity() → Domain Message
/// 监听DB 变化 → stream → Domain Message → UI
/// ```
abstract class MessageRepository {
// ── 监听 ─────────────────────────────────────────────────────────────────
/// 监听指定 chatId 的所有消息,按 chatIdx 升序
Stream<List<Message>> watchByChatId(int chatId);
/// 监听指定消息
Stream<Message?> watchById(int id);
// ── 读取 ─────────────────────────────────────────────────────────────────
/// 读取指定 chatId 的所有消息,按 chatIdx 升序
Future<List<Message>> getByChatId(int chatId);
/// 分页读取指定 chatId 的消息
Future<List<Message>> getByChatIdPage({
required int chatId,
required int offset,
required int limit,
});
/// 读取指定消息,不存在返回 null
Future<Message?> getById(int id);
/// 读取指定 messageId不存在返回 null
Future<Message?> getByMessageId(int messageId);
/// 统计指定 chatId 的消息数量
Future<int> countByChatId(int chatId);
// ── 写入 ─────────────────────────────────────────────────────────────────
/// 插入或替换消息
Future<void> insertOrReplace(Message message);
/// 批量插入或替换消息
Future<void> insertOrReplaceAll(List<Message> messages);
/// 更新消息
Future<void> update(Message message);
// ── 删除 ─────────────────────────────────────────────────────────────────
/// 删除指定消息
Future<void> delete(int id);
/// 删除指定 chatId 的所有消息
Future<void> deleteByChatId(int chatId);
/// 清空所有消息
Future<void> clear();
}

View File

@@ -0,0 +1,47 @@
import 'package:im_app/domain/entities/mini_app.dart';
/// 小程序仓储接口discover / explore / favorite / recent 共用)
///
/// ## 职责
/// - StorageSdkApi ↔ Domain MiniApp 映射
/// - CRUD 操作(通过 StorageSdkApi不直接接触 DB
/// - 所有公开接口只接受 Domain 实体Companion 转换完全内聚在 Impl
abstract class MiniAppRepository {
// ── 监听 ─────────────────────────────────────────────────────────────────
/// 监听所有小程序DB 变化自动反映
Stream<List<MiniApp>> watchAll();
/// 监听指定小程序
Stream<MiniApp?> watch(String id);
// ── 读取 ─────────────────────────────────────────────────────────────────
/// 读取所有小程序
Future<List<MiniApp>> getAll();
/// 读取指定小程序,不存在返回 null
Future<MiniApp?> get(String id);
/// 检查是否存在
Future<bool> isExist(String id);
// ── 写入 ─────────────────────────────────────────────────────────────────
/// 插入或替换小程序
Future<void> insertOrReplace(MiniApp miniApp);
/// 批量插入或替换小程序
Future<void> insertOrReplaceAll(List<MiniApp> miniApps);
/// 更新小程序
Future<void> update(MiniApp miniApp);
// ── 删除 ─────────────────────────────────────────────────────────────────
/// 删除指定小程序
Future<void> delete(String id);
/// 清空所有小程序
Future<void> clear();
}

View File

@@ -0,0 +1,36 @@
import 'package:im_app/domain/entities/pending_friend_request_history.dart';
/// 待处理好友请求历史仓储接口
abstract class PendingFriendRequestHistoryRepository {
// ── 监听 ─────────────────────────────────────────────────────────────────
Stream<List<PendingFriendRequestHistory>> watchAll();
Stream<PendingFriendRequestHistory?> watchById(int id);
Stream<List<PendingFriendRequestHistory>> watchByUid(int uid);
// ── 读取 ─────────────────────────────────────────────────────────────────
Future<List<PendingFriendRequestHistory>> getAll();
Future<PendingFriendRequestHistory?> getById(int id);
Future<List<PendingFriendRequestHistory>> getByUid(int uid);
// ── 写入 ─────────────────────────────────────────────────────────────────
Future<void> insertOrReplace(PendingFriendRequestHistory history);
Future<void> insertOrReplaceAll(List<PendingFriendRequestHistory> histories);
Future<void> update(PendingFriendRequestHistory history);
// ── 删除 ─────────────────────────────────────────────────────────────────
Future<void> delete(int id);
Future<void> deleteByUid(int uid);
Future<void> clear();
}

View File

@@ -0,0 +1,38 @@
import 'package:im_app/domain/entities/sound.dart';
/// 音效仓储接口
abstract class SoundRepository {
// ── 监听 ─────────────────────────────────────────────────────────────────
Stream<List<Sound>> watchAll();
Stream<Sound?> watchById(int id);
Stream<List<Sound>> watchByType(int typ);
// ── 读取 ─────────────────────────────────────────────────────────────────
Future<List<Sound>> getAll();
Future<Sound?> getById(int id);
Future<List<Sound>> getByType(int typ);
Future<List<Sound>> getByChannelGroup(int channelGroupId);
Future<List<Sound>> getDefaults();
// ── 写入 ─────────────────────────────────────────────────────────────────
Future<void> insertOrReplace(Sound sound);
Future<void> insertOrReplaceAll(List<Sound> sounds);
Future<void> update(Sound sound);
// ── 删除 ─────────────────────────────────────────────────────────────────
Future<void> delete(int id);
Future<void> clear();
}

View File

@@ -0,0 +1,43 @@
import 'package:im_app/domain/entities/tag.dart';
/// 标签仓储接口
abstract class TagRepository {
// ── 监听 ─────────────────────────────────────────────────────────────────
Stream<List<Tag>> watchAll();
Stream<Tag?> watchById(int id);
Stream<List<Tag>> watchByUid(int uid);
Stream<List<Tag>> watchByType(int type);
// ── 读取 ─────────────────────────────────────────────────────────────────
Future<List<Tag>> getAll();
Future<Tag?> getById(int id);
Future<List<Tag>> getByUid(int uid);
Future<List<Tag>> getByType(int type);
// ── 写入 ─────────────────────────────────────────────────────────────────
/// 插入标签autoIncrement id无需提供
Future<void> insert(Tag tag);
Future<void> insertOrReplace(Tag tag);
Future<void> insertOrReplaceAll(List<Tag> tags);
Future<void> update(Tag tag);
// ── 删除 ─────────────────────────────────────────────────────────────────
Future<void> delete(int id);
Future<void> deleteByUid(int uid);
Future<void> clear();
}

View File

@@ -0,0 +1,34 @@
import 'package:im_app/domain/entities/user_request_history.dart';
/// 用户请求历史仓储接口
abstract class UserRequestHistoryRepository {
// ── 监听 ─────────────────────────────────────────────────────────────────
Stream<List<UserRequestHistory>> watchAll();
Stream<UserRequestHistory?> watchById(int id);
Stream<List<UserRequestHistory>> watchByStatus(int status);
// ── 读取 ─────────────────────────────────────────────────────────────────
Future<List<UserRequestHistory>> getAll();
Future<UserRequestHistory?> getById(int id);
Future<List<UserRequestHistory>> getByStatus(int status);
// ── 写入 ─────────────────────────────────────────────────────────────────
Future<void> insertOrReplace(UserRequestHistory history);
Future<void> insertOrReplaceAll(List<UserRequestHistory> histories);
Future<void> update(UserRequestHistory history);
// ── 删除 ─────────────────────────────────────────────────────────────────
Future<void> delete(int id);
Future<void> clear();
}

View File

@@ -0,0 +1,32 @@
import 'package:im_app/domain/entities/workspace.dart';
/// 工作空间仓储接口
abstract class WorkspaceRepository {
// ── 监听 ─────────────────────────────────────────────────────────────────
Stream<List<Workspace>> watchAll();
Stream<Workspace?> watchById(int id);
// ── 读取 ─────────────────────────────────────────────────────────────────
Future<List<Workspace>> getAll();
Future<Workspace?> getById(int id);
Future<List<Workspace>> getByOwner(int ownerId);
// ── 写入 ─────────────────────────────────────────────────────────────────
Future<void> insertOrReplace(Workspace workspace);
Future<void> insertOrReplaceAll(List<Workspace> workspaces);
Future<void> update(Workspace workspace);
// ── 删除 ─────────────────────────────────────────────────────────────────
Future<void> delete(int id);
Future<void> clear();
}