refactor(apps): 重构数据层目录结构并新增启动预热编排器
This commit is contained in:
+1
-1
@@ -1,4 +1,4 @@
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
import '../models/automation_job_model.dart';
|
||||
|
||||
class AutomationJobsApi {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
|
||||
class AppVersionResponse {
|
||||
final bool hasUpdate;
|
||||
+20
-1
@@ -1,6 +1,6 @@
|
||||
import '../../../../data/cache/cache_policy.dart';
|
||||
import '../../../../data/cache/cached_repository.dart';
|
||||
import '../../../../data/models/user_profile.dart';
|
||||
import '../../../contacts/data/models/user_profile.dart';
|
||||
|
||||
class UserProfileCacheRepository extends CachedRepository<UserProfile> {
|
||||
static const String cacheKey = 'settings:user_profile';
|
||||
@@ -22,6 +22,8 @@ class UserProfileCacheRepository extends CachedRepository<UserProfile> {
|
||||
hardTtl: Duration(minutes: 30),
|
||||
minRefreshInterval: Duration(minutes: 1),
|
||||
),
|
||||
encodeValue: _encodeUserProfile,
|
||||
decodeValue: _decodeUserProfile,
|
||||
);
|
||||
|
||||
UserProfile? get cachedUser => _cachedUser;
|
||||
@@ -64,4 +66,21 @@ class UserProfileCacheRepository extends CachedRepository<UserProfile> {
|
||||
}
|
||||
return remote;
|
||||
}
|
||||
|
||||
static Object? _encodeUserProfile(UserProfile user) {
|
||||
return <String, Object?>{
|
||||
'id': user.id,
|
||||
'username': user.username,
|
||||
'phone': user.phone,
|
||||
'avatar_url': user.avatarUrl,
|
||||
'bio': user.bio,
|
||||
};
|
||||
}
|
||||
|
||||
static UserProfile _decodeUserProfile(Object? raw) {
|
||||
if (raw is! Map) {
|
||||
throw const FormatException('Invalid cached user profile payload');
|
||||
}
|
||||
return UserProfile.fromJson(Map<String, dynamic>.from(raw));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import 'package:social_app/core/network/i_api_client.dart';
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
import '../models/memory_models.dart';
|
||||
|
||||
class MemoryService {
|
||||
|
||||
@@ -2,8 +2,8 @@ import 'dart:io';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../../../../core/network/i_api_client.dart';
|
||||
import '../../../../data/models/user_profile.dart';
|
||||
import '../../../../data/network/i_api_client.dart';
|
||||
import '../../../contacts/data/models/user_profile.dart';
|
||||
|
||||
class UserProfileService {
|
||||
static const _prefix = '/api/v1/users';
|
||||
|
||||
Reference in New Issue
Block a user