refactor: remove unused local and remote data sources, models, and tests for chicken and poultry features to streamline codebase

This commit is contained in:
2025-12-08 16:10:34 +03:30
parent 890be0ded6
commit 455a5a5571
230 changed files with 2812 additions and 3471 deletions

View File

@@ -0,0 +1,8 @@
import 'package:rasadyar_chicken/features/common/data/model/local/widely_used_local_model.dart';
abstract class ChickenLocalDataSource {
Future<void> openBox();
Future<void> initWidleyUsed();
WidelyUsedLocalModel? getAllWidely();
}

View File

@@ -0,0 +1,54 @@
import 'package:rasadyar_chicken/features/common/data/model/local/widely_used_local_model.dart';
import 'package:rasadyar_chicken/features/steward/presentation/routes/routes.dart';
import 'package:rasadyar_core/core.dart';
import 'chicken_local.dart';
class ChickenLocalDataSourceImp implements ChickenLocalDataSource {
HiveLocalStorage local = diCore.get<HiveLocalStorage>();
final String boxName = 'Chicken_Widley_Box';
@override
Future<void> openBox() async {
await local.openBox<WidelyUsedLocalModel>(boxName);
}
@override
Future<void> initWidleyUsed() async {
/* List<WidelyUsedLocalItem> tmpList = [
WidelyUsedLocalItem(
index: 0,
pathId: 0,
title: 'خرید داخل استان',
color: AppColor.greenLightActive.toARGB32(),
iconColor: AppColor.greenNormal.toARGB32(),
iconPath: Assets.vec.cubeSearchSvg.path,
path: StewardRoutes.buysInProvinceSteward,
),
WidelyUsedLocalItem(
index: 1,
pathId: 1,
title: 'فروش داخل استان',
color: AppColor.blueLightActive.toARGB32(),
iconColor: AppColor.blueNormal.toARGB32(),
iconPath: Assets.vec.cubeSvg.path,
path: StewardRoutes.salesInProvinceSteward,
),
WidelyUsedLocalItem(
index: 2,
title: 'قطعه‌بندی',
color: AppColor.blueLightActive.toARGB32(),
iconColor: AppColor.blueNormal.toARGB32(),
iconPath: Assets.vec.cubeRotateSvg.path,
path: StewardRoutes.buysInProvinceSteward,
),
]; */
}
@override
WidelyUsedLocalModel? getAllWidely() {
var res = local.readBox<WidelyUsedLocalModel>(boxName: boxName);
return res?.isNotEmpty == true ? res!.first : null;
}
}

View File

@@ -0,0 +1,16 @@
import 'package:rasadyar_chicken/features/common/data/model/response/user_info/user_info_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/user_profile_model/user_profile_model.dart';
abstract class AuthRemoteDataSource {
Future<UserProfileModel?> login({required Map<String, dynamic> authRequest});
Future<void> logout();
Future<bool> hasAuthenticated();
Future<UserInfoModel?> getUserInfo(String phoneNumber);
Future<void> stewardAppLogin({required String token, Map<String, dynamic>? queryParameters});
}

View File

@@ -0,0 +1,67 @@
import 'package:rasadyar_chicken/features/common/data/model/response/user_info/user_info_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/user_profile_model/user_profile_model.dart';
import 'package:rasadyar_core/core.dart';
import 'auth_remote.dart';
class AuthRemoteDataSourceImp extends AuthRemoteDataSource {
final DioRemote _httpClient;
final String _BASE_URL = 'auth/api/v1/';
AuthRemoteDataSourceImp(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<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.rasadyar.com/api/send_otp/',
data: {"mobile": phoneNumber, "state": ""},
fromJson: UserInfoModel.fromJson,
headers: {'Content-Type': 'application/json'},
);
return res.data;
}
@override
Future<void> stewardAppLogin({
required String token,
Map<String, dynamic>? queryParameters,
}) async {
await _httpClient.post(
'/steward-app-login/',
data: queryParameters,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer $token',
},
);
}
}

View File

@@ -1,3 +0,0 @@
abstract class ChickenRemoteDataSource {
Future<void> getChickens();
}

View File

@@ -0,0 +1,75 @@
import 'package:rasadyar_chicken/features/common/data/model/request/change_password/change_password_request_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/bar_information/bar_information.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/broadcast_price/broadcast_price.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/guild/guild_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/guild_profile/guild_profile.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/inventory/inventory_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/iran_province_city/iran_province_city_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/kill_house_distribution_info/kill_house_distribution_info.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/roles_products/roles_products.dart';
import 'package:rasadyar_chicken/features/steward/data/model/response/segmentation_model/segmentation_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/user_profile/user_profile.dart';
import 'package:rasadyar_core/core.dart';
abstract class CommonRemoteDatasource {
Future<List<InventoryModel>?> getInventory({
required String token,
CancelToken? cancelToken,
});
Future<KillHouseDistributionInfo?> getKillHouseDistributionInfo({
required String token,
});
Future<BarInformation?> getGeneralBarInformation({
required String token,
Map<String, dynamic>? queryParameters,
});
Future<List<ProductModel>?> getRolesProducts({required String token});
Future<List<GuildModel>?> getGuilds({
required String token,
Map<String, dynamic>? queryParameters,
});
Future<GuildProfile?> getProfile({required String token});
Future<List<IranProvinceCityModel>?> getProvince({CancelToken? cancelToken});
Future<List<IranProvinceCityModel>?> getCity({required String provinceName});
Future<UserProfile?> getUserProfile({required String token});
Future<void> updateUserProfile({
required String token,
required UserProfile userProfile,
});
Future<void> updatePassword({
required String token,
required ChangePasswordRequestModel model,
});
Future<PaginationModel<SegmentationModel>?> getSegmentation({
required String token,
Map<String, dynamic>? queryParameters,
});
Future<void> createSegmentation({
required String token,
required SegmentationModel model,
});
Future<void> editSegmentation({
required String token,
required SegmentationModel model,
});
Future<SegmentationModel?> deleteSegmentation({
required String token,
required String key,
});
Future<BroadcastPrice?> getBroadcastPrice({required String token});
}

View File

@@ -0,0 +1,238 @@
import 'package:rasadyar_chicken/features/common/data/model/request/change_password/change_password_request_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/bar_information/bar_information.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/broadcast_price/broadcast_price.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/guild/guild_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/guild_profile/guild_profile.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/inventory/inventory_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/iran_province_city/iran_province_city_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/kill_house_distribution_info/kill_house_distribution_info.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/roles_products/roles_products.dart';
import 'package:rasadyar_chicken/features/steward/data/model/response/segmentation_model/segmentation_model.dart';
import 'package:rasadyar_chicken/features/common/data/model/response/user_profile/user_profile.dart';
import 'package:rasadyar_core/core.dart';
import 'common_remote.dart';
class CommonRemoteDatasourceImp implements CommonRemoteDatasource {
final DioRemote _httpClient;
CommonRemoteDatasourceImp(this._httpClient);
@override
Future<List<InventoryModel>?> getInventory({
required String token,
CancelToken? cancelToken,
}) async {
var res = await _httpClient.get(
'/roles-products/?role=Steward',
headers: {'Authorization': 'Bearer $token'},
fromJsonList: (json) => (json)
.map((item) => InventoryModel.fromJson(item as Map<String, dynamic>))
.toList(),
);
return res.data;
}
@override
Future<KillHouseDistributionInfo?> getKillHouseDistributionInfo({
required String token,
}) async {
var res = await _httpClient.get(
'/kill-house-distribution-info/?role=Steward',
headers: {'Authorization': 'Bearer $token'},
fromJson: KillHouseDistributionInfo.fromJson,
);
return res.data;
}
@override
Future<BarInformation?> getGeneralBarInformation({
required String token,
Map<String, dynamic>? queryParameters,
}) async {
var res = await _httpClient.get(
'/bars_for_kill_house_dashboard/',
queryParameters: queryParameters,
headers: {'Authorization': 'Bearer $token'},
fromJson: BarInformation.fromJson,
);
return res.data;
}
@override
Future<List<ProductModel>?> getRolesProducts({required String token}) async {
var res = await _httpClient.get(
'/roles-products/?role=Steward',
headers: {'Authorization': 'Bearer $token'},
fromJsonList: (json) => json
.map((item) => ProductModel.fromJson(item as Map<String, dynamic>))
.toList(),
);
return res.data;
}
@override
Future<List<GuildModel>?> getGuilds({
required String token,
Map<String, dynamic>? queryParameters,
}) async {
var res = await _httpClient.get(
'/guilds/',
queryParameters: queryParameters,
headers: {'Authorization': 'Bearer $token'},
fromJsonList: (json) => json
.map((item) => GuildModel.fromJson(item as Map<String, dynamic>))
.toList(),
);
return res.data;
}
@override
Future<GuildProfile?> getProfile({required String token}) async {
var res = await _httpClient.get(
'/guilds/0/?profile',
headers: {'Authorization': 'Bearer $token'},
fromJson: GuildProfile.fromJson,
);
return res.data;
}
@override
Future<List<IranProvinceCityModel>?> getCity({
required String provinceName,
}) async {
var res = await _httpClient.get(
'/iran_city/',
queryParameters: {'name': provinceName},
fromJsonList: (json) => json
.map(
(item) =>
IranProvinceCityModel.fromJson(item as Map<String, dynamic>),
)
.toList(),
);
return res.data;
}
@override
Future<List<IranProvinceCityModel>?> getProvince({
CancelToken? cancelToken,
}) async {
var res = await _httpClient.get(
'/iran_province/',
fromJsonList: (json) => json
.map(
(item) =>
IranProvinceCityModel.fromJson(item as Map<String, dynamic>),
)
.toList(),
);
return res.data;
}
@override
Future<UserProfile?> getUserProfile({required String token}) async {
var res = await _httpClient.get(
'/system_user_profile/?self-profile',
headers: {'Authorization': 'Bearer $token'},
fromJson: (json) => UserProfile.fromJson(json),
);
return res.data;
}
@override
Future<void> updateUserProfile({
required String token,
required UserProfile userProfile,
}) async {
await _httpClient.put(
'/system_user_profile/0/',
headers: {'Authorization': 'Bearer $token'},
data: userProfile.toJson()..removeWhere((key, value) => value == null),
);
}
@override
Future<void> updatePassword({
required String token,
required ChangePasswordRequestModel model,
}) async {
await _httpClient.post(
'/api/change_password/',
headers: {'Authorization': 'Bearer $token'},
data: model.toJson()..removeWhere((key, value) => value == null),
);
}
@override
Future<PaginationModel<SegmentationModel>?> getSegmentation({
required String token,
Map<String, dynamic>? queryParameters,
}) async {
var res = await _httpClient.get(
'/app-segmentation/',
queryParameters: queryParameters,
headers: {'Authorization': 'Bearer $token'},
fromJson: (json) => PaginationModel<SegmentationModel>.fromJson(
json,
(json) => SegmentationModel.fromJson(json as Map<String, dynamic>),
),
);
return res.data;
}
@override
Future<void> createSegmentation({
required String token,
required SegmentationModel model,
}) async {
await _httpClient.post(
'/app-segmentation/',
data: model.toJson()..removeWhere((key, value) => value == null),
headers: {'Authorization': 'Bearer $token'},
);
}
@override
Future<void> editSegmentation({
required String token,
required SegmentationModel model,
}) async {
await _httpClient.put(
'/app-segmentation/0/',
data: model.toJson()..removeWhere((key, value) => value == null),
headers: {'Authorization': 'Bearer $token'},
);
}
@override
Future<SegmentationModel?> deleteSegmentation({
required String token,
required String key,
}) async {
var res = await _httpClient.delete<SegmentationModel?>(
'/app-segmentation/0/',
queryParameters: {'key': key},
headers: {'Authorization': 'Bearer $token'},
fromJson: (json) => SegmentationModel.fromJson(json),
);
return res.data;
}
@override
Future<BroadcastPrice?> getBroadcastPrice({required String token}) async {
var res = await _httpClient.get(
'/broadcast-price/',
headers: {'Authorization': 'Bearer $token'},
fromJson: (json) => BroadcastPrice.fromJson(json),
);
return res.data;
}
}