refactor(apps): 重构数据层目录结构并新增启动预热编排器
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
import '../models/automation_job_model.dart';
|
||||
|
||||
class AutomationJobsApi {
|
||||
final IApiClient _client;
|
||||
static const _prefix = '/api/v1/automation-jobs';
|
||||
|
||||
AutomationJobsApi(this._client);
|
||||
|
||||
Future<List<AutomationJobModel>> list() async {
|
||||
final response = await _client.get(_prefix);
|
||||
final parsed = AutomationJobListResponse.fromJson(response.data);
|
||||
return parsed.items;
|
||||
}
|
||||
|
||||
Future<AutomationJobModel> get(String id) async {
|
||||
final response = await _client.get('$_prefix/$id');
|
||||
return AutomationJobModel.fromJson(response.data);
|
||||
}
|
||||
|
||||
Future<AutomationJobModel> create(AutomationJobCreateRequest request) async {
|
||||
final response = await _client.post(_prefix, data: request.toJson());
|
||||
return AutomationJobModel.fromJson(response.data);
|
||||
}
|
||||
|
||||
Future<AutomationJobModel> update(
|
||||
String id,
|
||||
AutomationJobUpdateRequest request,
|
||||
) async {
|
||||
final data = request.toJson();
|
||||
final response = await _client.patch('$_prefix/$id', data: data);
|
||||
return AutomationJobModel.fromJson(response.data);
|
||||
}
|
||||
|
||||
Future<void> delete(String id) async {
|
||||
await _client.delete('$_prefix/$id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
import 'package:social_app/data/network/i_api_client.dart';
|
||||
|
||||
class AppVersionResponse {
|
||||
final bool hasUpdate;
|
||||
final String latestVersionName;
|
||||
final int latestVersionCode;
|
||||
final int minSupportedVersionCode;
|
||||
final String updateType;
|
||||
final String? downloadUrl;
|
||||
final String? releaseNotes;
|
||||
final String? fileName;
|
||||
final int? fileSize;
|
||||
final String? sha256;
|
||||
|
||||
AppVersionResponse({
|
||||
required this.hasUpdate,
|
||||
required this.latestVersionName,
|
||||
required this.latestVersionCode,
|
||||
required this.minSupportedVersionCode,
|
||||
required this.updateType,
|
||||
this.downloadUrl,
|
||||
this.releaseNotes,
|
||||
this.fileName,
|
||||
this.fileSize,
|
||||
this.sha256,
|
||||
});
|
||||
|
||||
factory AppVersionResponse.fromJson(Map<String, dynamic> json) {
|
||||
return AppVersionResponse(
|
||||
hasUpdate: json['has_update'] as bool,
|
||||
latestVersionName: json['latest_version_name'] as String,
|
||||
latestVersionCode: json['latest_version_code'] as int,
|
||||
minSupportedVersionCode: json['min_supported_version_code'] as int,
|
||||
updateType: json['update_type'] as String,
|
||||
downloadUrl: json['download_url'] as String?,
|
||||
releaseNotes: json['release_notes'] as String?,
|
||||
fileName: json['file_name'] as String?,
|
||||
fileSize: json['file_size'] as int?,
|
||||
sha256: json['sha256'] as String?,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class SettingsApi {
|
||||
final IApiClient _client;
|
||||
static const _prefix = '/api/v1/app';
|
||||
|
||||
SettingsApi(this._client);
|
||||
|
||||
Future<AppVersionResponse> checkUpdates({
|
||||
required int currentVersionCode,
|
||||
required String currentVersionName,
|
||||
String platform = 'android',
|
||||
String channel = 'release',
|
||||
}) async {
|
||||
final params = <String, String>{
|
||||
'platform': platform,
|
||||
'channel': channel,
|
||||
'current_version_code': currentVersionCode.toString(),
|
||||
'current_version_name': currentVersionName,
|
||||
};
|
||||
final queryString = Uri(queryParameters: params).query;
|
||||
final response = await _client.get('$_prefix/check-updates?$queryString');
|
||||
return AppVersionResponse.fromJson(response.data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user