feat : new segment logic

This commit is contained in:
2025-07-21 09:32:29 +03:30
parent e3a808383e
commit d300133adf
4 changed files with 23 additions and 21 deletions

View File

@@ -13,6 +13,7 @@ abstract class SegmentationModel with _$SegmentationModel {
DateTime? date,
int? weight,
String? result,
String? guildKey,
}) = _SegmentationModel;
factory SegmentationModel.fromJson(Map<String, dynamic> json) =>

View File

@@ -16,7 +16,7 @@ T _$identity<T>(T value) => value;
/// @nodoc
mixin _$SegmentationModel {
String? get key; String? get productKey; Buyer? get buyer; DateTime? get date; int? get weight; String? get result;
String? get key; String? get productKey; Buyer? get buyer; DateTime? get date; int? get weight; String? get result; String? get guildKey;
/// Create a copy of SegmentationModel
/// with the given fields replaced by the non-null parameter values.
@JsonKey(includeFromJson: false, includeToJson: false)
@@ -29,16 +29,16 @@ $SegmentationModelCopyWith<SegmentationModel> get copyWith => _$SegmentationMode
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.result, result) || other.result == result));
return identical(this, other) || (other.runtimeType == runtimeType&&other is SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.result, result) || other.result == result)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,key,productKey,buyer,date,weight,result);
int get hashCode => Object.hash(runtimeType,key,productKey,buyer,date,weight,result,guildKey);
@override
String toString() {
return 'SegmentationModel(key: $key, productKey: $productKey, buyer: $buyer, date: $date, weight: $weight, result: $result)';
return 'SegmentationModel(key: $key, productKey: $productKey, buyer: $buyer, date: $date, weight: $weight, result: $result, guildKey: $guildKey)';
}
@@ -49,7 +49,7 @@ abstract mixin class $SegmentationModelCopyWith<$Res> {
factory $SegmentationModelCopyWith(SegmentationModel value, $Res Function(SegmentationModel) _then) = _$SegmentationModelCopyWithImpl;
@useResult
$Res call({
String? key, String? productKey, Buyer? buyer, DateTime? date, int? weight, String? result
String? key, String? productKey, Buyer? buyer, DateTime? date, int? weight, String? result, String? guildKey
});
@@ -66,7 +66,7 @@ class _$SegmentationModelCopyWithImpl<$Res>
/// Create a copy of SegmentationModel
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? key = freezed,Object? productKey = freezed,Object? buyer = freezed,Object? date = freezed,Object? weight = freezed,Object? result = freezed,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? key = freezed,Object? productKey = freezed,Object? buyer = freezed,Object? date = freezed,Object? weight = freezed,Object? result = freezed,Object? guildKey = freezed,}) {
return _then(_self.copyWith(
key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable
as String?,productKey: freezed == productKey ? _self.productKey : productKey // ignore: cast_nullable_to_non_nullable
@@ -74,6 +74,7 @@ as String?,buyer: freezed == buyer ? _self.buyer : buyer // ignore: cast_nullabl
as Buyer?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable
as DateTime?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable
as int?,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable
as String?,guildKey: freezed == guildKey ? _self.guildKey : guildKey // ignore: cast_nullable_to_non_nullable
as String?,
));
}
@@ -97,7 +98,7 @@ $BuyerCopyWith<$Res>? get buyer {
@JsonSerializable()
class _SegmentationModel implements SegmentationModel {
const _SegmentationModel({this.key, this.productKey, this.buyer, this.date, this.weight, this.result});
const _SegmentationModel({this.key, this.productKey, this.buyer, this.date, this.weight, this.result, this.guildKey});
factory _SegmentationModel.fromJson(Map<String, dynamic> json) => _$SegmentationModelFromJson(json);
@override final String? key;
@@ -106,6 +107,7 @@ class _SegmentationModel implements SegmentationModel {
@override final DateTime? date;
@override final int? weight;
@override final String? result;
@override final String? guildKey;
/// Create a copy of SegmentationModel
/// with the given fields replaced by the non-null parameter values.
@@ -120,16 +122,16 @@ Map<String, dynamic> toJson() {
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.result, result) || other.result == result));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _SegmentationModel&&(identical(other.key, key) || other.key == key)&&(identical(other.productKey, productKey) || other.productKey == productKey)&&(identical(other.buyer, buyer) || other.buyer == buyer)&&(identical(other.date, date) || other.date == date)&&(identical(other.weight, weight) || other.weight == weight)&&(identical(other.result, result) || other.result == result)&&(identical(other.guildKey, guildKey) || other.guildKey == guildKey));
}
@JsonKey(includeFromJson: false, includeToJson: false)
@override
int get hashCode => Object.hash(runtimeType,key,productKey,buyer,date,weight,result);
int get hashCode => Object.hash(runtimeType,key,productKey,buyer,date,weight,result,guildKey);
@override
String toString() {
return 'SegmentationModel(key: $key, productKey: $productKey, buyer: $buyer, date: $date, weight: $weight, result: $result)';
return 'SegmentationModel(key: $key, productKey: $productKey, buyer: $buyer, date: $date, weight: $weight, result: $result, guildKey: $guildKey)';
}
@@ -140,7 +142,7 @@ abstract mixin class _$SegmentationModelCopyWith<$Res> implements $SegmentationM
factory _$SegmentationModelCopyWith(_SegmentationModel value, $Res Function(_SegmentationModel) _then) = __$SegmentationModelCopyWithImpl;
@override @useResult
$Res call({
String? key, String? productKey, Buyer? buyer, DateTime? date, int? weight, String? result
String? key, String? productKey, Buyer? buyer, DateTime? date, int? weight, String? result, String? guildKey
});
@@ -157,7 +159,7 @@ class __$SegmentationModelCopyWithImpl<$Res>
/// Create a copy of SegmentationModel
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? key = freezed,Object? productKey = freezed,Object? buyer = freezed,Object? date = freezed,Object? weight = freezed,Object? result = freezed,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? key = freezed,Object? productKey = freezed,Object? buyer = freezed,Object? date = freezed,Object? weight = freezed,Object? result = freezed,Object? guildKey = freezed,}) {
return _then(_SegmentationModel(
key: freezed == key ? _self.key : key // ignore: cast_nullable_to_non_nullable
as String?,productKey: freezed == productKey ? _self.productKey : productKey // ignore: cast_nullable_to_non_nullable
@@ -165,6 +167,7 @@ as String?,buyer: freezed == buyer ? _self.buyer : buyer // ignore: cast_nullabl
as Buyer?,date: freezed == date ? _self.date : date // ignore: cast_nullable_to_non_nullable
as DateTime?,weight: freezed == weight ? _self.weight : weight // ignore: cast_nullable_to_non_nullable
as int?,result: freezed == result ? _self.result : result // ignore: cast_nullable_to_non_nullable
as String?,guildKey: freezed == guildKey ? _self.guildKey : guildKey // ignore: cast_nullable_to_non_nullable
as String?,
));
}

View File

@@ -18,6 +18,7 @@ _SegmentationModel _$SegmentationModelFromJson(Map<String, dynamic> json) =>
: DateTime.parse(json['date'] as String),
weight: (json['weight'] as num?)?.toInt(),
result: json['result'] as String?,
guildKey: json['guild_key'] as String?,
);
Map<String, dynamic> _$SegmentationModelToJson(_SegmentationModel instance) =>
@@ -28,6 +29,7 @@ Map<String, dynamic> _$SegmentationModelToJson(_SegmentationModel instance) =>
'date': instance.date?.toIso8601String(),
'weight': instance.weight,
'result': instance.result,
'guild_key': instance.guildKey,
};
_Buyer _$BuyerFromJson(Map<String, dynamic> json) => _Buyer(

View File

@@ -174,10 +174,11 @@ class SegmentationLogic extends GetxController {
var res = true;
SegmentationModel segmentationModel = SegmentationModel(
productKey: selectedProduct.value?.key,
weight: int.tryParse(weightController.text.clearComma) ?? 0,
);
iLog(segmentationModel.toString());
if (saleType.value == 2) {
segmentationModel.copyWith(guildKey: selectedGuildModel.value?.key);
}
safeCall(
call: () async => await rootLogic.chickenRepository.createSegmentation(
token: rootLogic.tokenService.accessToken.value!,
@@ -193,16 +194,11 @@ class SegmentationLogic extends GetxController {
return res;
}
Future<void> getGuilds() async {
safeCall(
call: () async =>
await rootLogic.chickenRepository.getGuilds(
call: () async => await rootLogic.chickenRepository.getGuilds(
token: rootLogic.tokenService.accessToken.value!,
queryParameters: buildQueryParams(
queryParams: {'all': true},
role: 'Steward',
),
queryParameters: buildQueryParams(queryParams: {'all': true}, role: 'Steward'),
),
onSuccess: (result) {
if (result != null) {