01c36eb32e
- 删除 mock_api_client、mock_calendar_service、mock_history_service - 新增 fixed_length_code_input、link_button、message_composer 共享组件 - 优化登录/注册/密码重置页面使用新组件 - 简化 injection.dart 移除 mock 分支 - 更新 env.dart 配置(BACKEND_URL 替换 API_URL) - 后端 agentscope 工具和测试更新 - 重构 AGENTS.md 文档结构 - 新增 deploy/ 目录和 protocol 文档
51 lines
1.3 KiB
Dart
51 lines
1.3 KiB
Dart
import 'package:social_app/core/api/i_api_client.dart';
|
|
|
|
import '../calendar_api.dart';
|
|
import '../models/schedule_item_model.dart';
|
|
|
|
class CalendarService {
|
|
final IApiClient _apiClient;
|
|
CalendarApi? _calendarApi;
|
|
|
|
CalendarService({required IApiClient apiClient}) : _apiClient = apiClient;
|
|
|
|
CalendarApi get _api {
|
|
final api = _calendarApi;
|
|
if (api != null) {
|
|
return api;
|
|
}
|
|
final created = CalendarApi(_apiClient);
|
|
_calendarApi = created;
|
|
return created;
|
|
}
|
|
|
|
Future<List<ScheduleItemModel>> getEventsForDay(DateTime date) async {
|
|
final start = DateTime(date.year, date.month, date.day);
|
|
final end = DateTime(date.year, date.month, date.day, 23, 59, 59);
|
|
return getEventsForRange(start, end);
|
|
}
|
|
|
|
Future<List<ScheduleItemModel>> getEventsForRange(
|
|
DateTime start,
|
|
DateTime end,
|
|
) async {
|
|
return _api.listByRange(startAt: start, endAt: end);
|
|
}
|
|
|
|
Future<ScheduleItemModel?> getEventById(String id) async {
|
|
return _api.getById(id);
|
|
}
|
|
|
|
Future<ScheduleItemModel> addEvent(ScheduleItemModel event) async {
|
|
return _api.create(event);
|
|
}
|
|
|
|
Future<ScheduleItemModel> updateEvent(ScheduleItemModel event) async {
|
|
return _api.update(event);
|
|
}
|
|
|
|
Future<void> deleteEvent(String id) async {
|
|
await _api.delete(id);
|
|
}
|
|
}
|