feat : profile and map

This commit is contained in:
2025-07-28 15:57:30 +03:30
parent 6057976b46
commit d9724f681c
67 changed files with 2835 additions and 444 deletions

View File

@@ -0,0 +1,17 @@
import 'package:rasadyar_inspection/data/model/response/auth/auth_response_model.dart';
import 'package:rasadyar_inspection/data/model/response/captcha/captcha_response_model.dart';
abstract class AuthRepository {
Future<AuthResponseModel?> login({required Map<String, dynamic> authRequest});
Future<CaptchaResponseModel?> captcha();
Future<void> logout();
Future<bool> hasAuthenticated();
Future<AuthResponseModel?> loginWithRefreshToken({required Map<String, dynamic> authRequest});
}

View File

@@ -0,0 +1,37 @@
import 'package:rasadyar_inspection/data/data_source/remote/auth/auth_remote.dart';
import 'package:rasadyar_inspection/data/model/response/auth/auth_response_model.dart';
import 'package:rasadyar_inspection/data/model/response/captcha/captcha_response_model.dart';
import 'auth_repository.dart';
class AuthRepositoryImpl implements AuthRepository {
final AuthRemote authRemote;
AuthRepositoryImpl(this.authRemote);
@override
Future<AuthResponseModel?> login({required Map<String, dynamic> authRequest}) async =>
await authRemote.login(authRequest: authRequest);
@override
Future<CaptchaResponseModel?> captcha() async {
return await authRemote.captcha();
}
@override
Future<AuthResponseModel?> loginWithRefreshToken({
required Map<String, dynamic> authRequest,
}) async {
return await authRemote.loginWithRefreshToken(authRequest: authRequest);
}
@override
Future<void> logout() async {
await authRemote.logout();
}
@override
Future<bool> hasAuthenticated() async {
return await authRemote.hasAuthenticated();
}
}

View File

@@ -1,18 +0,0 @@
import 'package:rasadyar_core/data/model/response/auth/auth_response_model.dart';
import 'package:rasadyar_core/data/model/response/captcha/captcha_response_model.dart';
import 'package:rasadyar_core/data/model/response/user_info/user_info_model.dart';
import 'package:rasadyar_core/data/model/response/user_profile_model/user_profile_model.dart';
abstract class AuthRepository {
Future<UserProfileModel?> login({required Map<String, dynamic> authRequest});
Future<CaptchaResponseModel?> captcha();
Future<void> logout();
Future<bool> hasAuthenticated();
Future<AuthResponseModel?> loginWithRefreshToken({required Map<String, dynamic> authRequest});
Future<UserInfoModel?> getUserInfo(String phoneNumber);
}

View File

@@ -1,72 +0,0 @@
import 'package:rasadyar_core/core.dart';
import 'package:rasadyar_core/data/model/response/auth/auth_response_model.dart';
import 'package:rasadyar_core/data/model/response/captcha/captcha_response_model.dart';
import 'package:rasadyar_core/data/model/response/user_info/user_info_model.dart';
import 'package:rasadyar_core/data/model/response/user_profile_model/user_profile_model.dart';
import 'auth_repository.dart';
class AuthRepositoryImpl implements AuthRepository {
final DioRemote _httpClient;
final String _BASE_URL = 'auth/api/v1/';
AuthRepositoryImpl(this._httpClient);
@override
Future<UserProfileModel?> login({required Map<String, dynamic> authRequest}) async {
var res = await _httpClient.post<UserProfileModel?>(
'/api/login/',
data: authRequest,
fromJson: UserProfileModel.fromJson,
headers: {'Content-Type': 'application/json'},
);
return res.data;
}
@override
Future<CaptchaResponseModel?> captcha() async {
var res = await _httpClient.post<CaptchaResponseModel?>(
'captcha/',
fromJson: CaptchaResponseModel.fromJson,
);
return res.data;
}
@override
Future<AuthResponseModel?> loginWithRefreshToken({
required Map<String, dynamic> authRequest,
}) async {
var res = await _httpClient.post<AuthResponseModel>(
'$_BASE_URL/login/',
data: authRequest,
headers: {'Content-Type': 'application/json'},
);
return res.data;
}
@override
Future<void> logout() {
// TODO: implement logout
throw UnimplementedError();
}
@override
Future<bool> hasAuthenticated() async {
final response = await _httpClient.get<bool>(
'$_BASE_URL/login/',
headers: {'Content-Type': 'application/json'},
);
return response.data ?? false;
}
@override
Future<UserInfoModel?> getUserInfo(String phoneNumber) async {
var res = await _httpClient.post<UserInfoModel?>(
'https://userbackend.rasadyaar.ir/api/send_otp/',
data: {"mobile": phoneNumber, "state": ""},
fromJson: UserInfoModel.fromJson,
headers: {'Content-Type': 'application/json'},
);
return res.data;
}
}

View File

@@ -0,0 +1,24 @@
import 'package:rasadyar_inspection/data/model/response/poultry_location/poultry_location_model.dart';
abstract class InspectionRepository {
/// Fetches the inspection data for a given [inspectionId].
///
/// Returns a `Future` that resolves to a `Map<String, dynamic>` containing
/// the inspection data.
Future<Map<String, dynamic>> fetchInspectionData(String inspectionId);
/// Fetches the list of inspections for a given [userId].
///
/// Returns a `Future` that resolves to a `List<Map<String, dynamic>>`
/// containing the list of inspections.
Future<List<Map<String, dynamic>>> fetchInspections(String userId);
/// Fetches nearby poultry locations based on the provided coordinates and radius.
///
/// Returns a `Future` that resolves to a `List<PoultryLocationModel>?`.
Future<List<PoultryLocationModel>?> getNearbyLocation({
double? centerLat,
double? centerLng,
double? radius,
});
}

View File

@@ -0,0 +1,34 @@
import 'package:rasadyar_inspection/data/data_source/remote/inspection/inspection_remote.dart';
import 'package:rasadyar_inspection/data/model/response/poultry_location/poultry_location_model.dart';
import 'package:rasadyar_inspection/data/repositories/inspection/inspection_repository.dart';
class InspectionRepositoryImp implements InspectionRepository {
final InspectionRemoteDataSource remoteDataSource;
InspectionRepositoryImp({required this.remoteDataSource});
@override
Future<Map<String, dynamic>> fetchInspectionData(String inspectionId) {
// TODO: implement fetchInspectionData
throw UnimplementedError();
}
@override
Future<List<Map<String, dynamic>>> fetchInspections(String userId) {
// TODO: implement fetchInspections
throw UnimplementedError();
}
@override
Future<List<PoultryLocationModel>?> getNearbyLocation({
double? centerLat,
double? centerLng,
double? radius,
}) async {
return remoteDataSource.getNearbyLocation(
centerLat: centerLat,
centerLng: centerLng,
radius: radius,
);
}
}

View File

@@ -0,0 +1,19 @@
import 'package:rasadyar_inspection/data/model/response/user_profile/user_profile_model.dart';
abstract class UserRepository {
/// Fetches the user profile from the remote data source.
///
/// Returns a [Future] that resolves to a [UserProfileModel].
Future<UserProfileModel?> fetchUserProfile({required String token});
/// Updates the user profile in the remote data source.
///
/// Takes a [UserProfileModel] as an argument and returns a [Future] that resolves to a boolean indicating success or failure.
Future<bool> updateUserProfile(UserProfileModel userProfile);
/// Changes the password of the user in the remote data source.
///
/// Takes the old password, new password, and confirm password as arguments and returns a [Future] that resolves to a boolean indicating success or failure.
Future<bool> changePassword(String oldPassword, String newPassword, String confirmPassword);
}

View File

@@ -0,0 +1,28 @@
import 'package:rasadyar_inspection/data/data_source/remote/user/user_data_source_imp.dart';
import 'package:rasadyar_inspection/data/model/response/user_profile/user_profile_model.dart';
import 'user_repository.dart';
class UserRepositoryImp implements UserRepository {
final UserRemoteDataSourceImp _remoteDataSource;
UserRepositoryImp(this._remoteDataSource);
@override
Future<bool> changePassword(String oldPassword, String newPassword, String confirmPassword) {
// TODO: implement changePassword
throw UnimplementedError();
}
@override
Future<UserProfileModel?> fetchUserProfile({required String token}) async {
return await _remoteDataSource.getProfile(token: token);
}
@override
Future<bool> updateUserProfile(UserProfileModel userProfile) {
// TODO: implement updateUserProfile
throw UnimplementedError();
}
}