Fix ai
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:budget_app/models/user.dart';
|
||||
import 'package:budget_app/logic/user/user_cubit.dart';
|
||||
import 'package:budget_app/injection_container.dart' as di;
|
||||
import 'package:budget_app/data/repositories/interfaces/iglobal_settings_repository.dart';
|
||||
import 'package:budget_app/data/repositories/interfaces/iuser_repository.dart';
|
||||
import 'package:budget_app/injection_container.dart' as di;
|
||||
import 'package:budget_app/logic/user/user_cubit.dart';
|
||||
import 'package:budget_app/models/user.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
|
||||
part 'auth_event.dart';
|
||||
part 'auth_state.dart';
|
||||
@@ -18,10 +18,10 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
required UserCubit userCubit,
|
||||
required IGlobalSettingsRepository settingsRepository,
|
||||
required IUserRepository userRepository,
|
||||
}) : _userCubit = userCubit,
|
||||
_settingsRepository = settingsRepository,
|
||||
_userRepository = userRepository,
|
||||
super(AuthInitial()) {
|
||||
}) : _userCubit = userCubit,
|
||||
_settingsRepository = settingsRepository,
|
||||
_userRepository = userRepository,
|
||||
super(AuthInitial()) {
|
||||
on<AuthStarted>(_onAuthStarted);
|
||||
on<AuthLoggedIn>(_onAuthLoggedIn);
|
||||
on<AuthLoggedOut>(_onAuthLoggedOut);
|
||||
@@ -56,6 +56,7 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
// Инициализируем зависимости для вошедшего пользователя.
|
||||
await di.initUserSpecificDependencies(event.user.id);
|
||||
_userCubit.setUser(event.user);
|
||||
|
||||
await _settingsRepository.setCurrentUserId(event.user.id);
|
||||
emit(AuthAuthenticated(user: event.user));
|
||||
}
|
||||
@@ -69,7 +70,9 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
}
|
||||
|
||||
Future<void> _onAuthRegisterRequested(
|
||||
AuthRegisterRequested event, Emitter<AuthState> emit) async {
|
||||
AuthRegisterRequested event,
|
||||
Emitter<AuthState> emit,
|
||||
) async {
|
||||
emit(AuthLoading());
|
||||
try {
|
||||
// 1. Создаем пользователя
|
||||
@@ -91,5 +94,3 @@ class AuthBloc extends Bloc<AuthEvent, AuthState> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:budget_app/pages/home/home_page.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:flutter_localizations/flutter_localizations.dart'; // Добавляем импорт
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
|
||||
import '/l10n/app_localizations.dart';
|
||||
@@ -16,6 +17,7 @@ import 'theme/app_theme.dart';
|
||||
|
||||
void main() async {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
await dotenv.load(fileName: ".env");
|
||||
await di.initGlobalDependencies();
|
||||
runApp(const MyApp());
|
||||
}
|
||||
|
||||
+10
-8
@@ -1,5 +1,6 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:hive_ce/hive.dart';
|
||||
|
||||
import '../utils/id_generator.dart';
|
||||
|
||||
part 'ai_rule.g.dart';
|
||||
@@ -17,7 +18,7 @@ enum AiRuleType {
|
||||
}
|
||||
|
||||
/// Перечисление для статуса обработки правила
|
||||
@HiveType(typeId: 21)
|
||||
@HiveType(typeId: 24)
|
||||
enum ProcessingStatus {
|
||||
/// Создано
|
||||
@HiveField(0)
|
||||
@@ -37,7 +38,7 @@ enum ProcessingStatus {
|
||||
}
|
||||
|
||||
/// Модель правила ИИ для обработки SMS сообщений
|
||||
@HiveType(typeId: 22)
|
||||
@HiveType(typeId: 23)
|
||||
class AiRule extends Equatable {
|
||||
/// Уникальный идентификатор правила
|
||||
@HiveField(0)
|
||||
@@ -98,10 +99,9 @@ class AiRule extends Equatable {
|
||||
this.skipRegex,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
}) :
|
||||
id = id ?? IdGenerator.generateId(),
|
||||
createdAt = createdAt ?? DateTime.now(),
|
||||
updatedAt = updatedAt ?? DateTime.now();
|
||||
}) : id = id ?? IdGenerator.generateId(),
|
||||
createdAt = createdAt ?? DateTime.now(),
|
||||
updatedAt = updatedAt ?? DateTime.now();
|
||||
|
||||
/// Метод для преобразования объекта в Map
|
||||
Map<String, dynamic> toMap() {
|
||||
@@ -128,7 +128,9 @@ class AiRule extends Equatable {
|
||||
type: AiRuleType.values.firstWhere((e) => e.name == map['type']),
|
||||
isActive: map['isActive'],
|
||||
confidencePercentage: map['confidencePercentage'],
|
||||
processingStatus: ProcessingStatus.values.firstWhere((e) => e.name == map['processingStatus']),
|
||||
processingStatus: ProcessingStatus.values.firstWhere(
|
||||
(e) => e.name == map['processingStatus'],
|
||||
),
|
||||
merchantPattern: map['merchantPattern'],
|
||||
categoryId: map['categoryId'],
|
||||
skipRegex: map['skipRegex'],
|
||||
@@ -165,4 +167,4 @@ class AiRule extends Equatable {
|
||||
|
||||
@override
|
||||
List<Object?> get props => [id];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ part of 'ai_rule.dart';
|
||||
|
||||
class AiRuleAdapter extends TypeAdapter<AiRule> {
|
||||
@override
|
||||
final typeId = 22;
|
||||
final typeId = 23;
|
||||
|
||||
@override
|
||||
AiRule read(BinaryReader reader) {
|
||||
@@ -111,7 +111,7 @@ class AiRuleTypeAdapter extends TypeAdapter<AiRuleType> {
|
||||
|
||||
class ProcessingStatusAdapter extends TypeAdapter<ProcessingStatus> {
|
||||
@override
|
||||
final typeId = 21;
|
||||
final typeId = 24;
|
||||
|
||||
@override
|
||||
ProcessingStatus read(BinaryReader reader) {
|
||||
|
||||
@@ -3,7 +3,7 @@ import 'package:hive_ce/hive.dart';
|
||||
|
||||
part 'ai_settings.g.dart';
|
||||
|
||||
@HiveType(typeId: 9)
|
||||
@HiveType(typeId: 25)
|
||||
class AiSettings extends HiveObject {
|
||||
@HiveField(0)
|
||||
String? apiKey;
|
||||
|
||||
@@ -8,7 +8,7 @@ part of 'ai_settings.dart';
|
||||
|
||||
class AiSettingsAdapter extends TypeAdapter<AiSettings> {
|
||||
@override
|
||||
final typeId = 9;
|
||||
final typeId = 25;
|
||||
|
||||
@override
|
||||
AiSettings read(BinaryReader reader) {
|
||||
|
||||
@@ -29,6 +29,8 @@ class SmsService {
|
||||
if (messagesFromDevice.isNotEmpty) {
|
||||
await _userRepository.updateLastSmsSyncTime(currentUser.id, DateTime.now());
|
||||
}
|
||||
} else {
|
||||
throw Exception("Текущий пользователь не найден.");
|
||||
}
|
||||
}
|
||||
return _smsRepository.getAll();
|
||||
|
||||
+2
-3
@@ -83,9 +83,8 @@ flutter:
|
||||
uses-material-design: true
|
||||
|
||||
# To add assets to your application, add an assets section, like this:
|
||||
# assets:
|
||||
# - images/a_dot_burr.jpeg
|
||||
# - images/a_dot_ham.jpeg
|
||||
assets:
|
||||
- .env
|
||||
|
||||
# An image asset can refer to one or more resolution-specific "variants", see
|
||||
# https://flutter.dev/to/resolution-aware-images
|
||||
|
||||
Reference in New Issue
Block a user