aaa
This commit is contained in:
@@ -0,0 +1,58 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Product stage entity - pure domain model
|
||||
/// Represents a product at a specific production stage with quantities
|
||||
class ProductStageEntity extends Equatable {
|
||||
final int productId;
|
||||
final int? productStageId;
|
||||
final int? actionTypeId;
|
||||
final int passedQuantity;
|
||||
final int issuedQuantity;
|
||||
final double issuedQuantityWeight;
|
||||
final double passedQuantityWeight;
|
||||
final String? stageName;
|
||||
final String createdDate;
|
||||
|
||||
const ProductStageEntity({
|
||||
required this.productId,
|
||||
required this.productStageId,
|
||||
required this.actionTypeId,
|
||||
required this.passedQuantity,
|
||||
required this.issuedQuantity,
|
||||
required this.issuedQuantityWeight,
|
||||
required this.passedQuantityWeight,
|
||||
required this.stageName,
|
||||
required this.createdDate,
|
||||
});
|
||||
|
||||
/// Get display name for the stage
|
||||
/// Returns "No Stage" if stageName is null
|
||||
String get displayName => stageName ?? 'No Stage';
|
||||
|
||||
/// Check if this is a valid stage (has a stage name)
|
||||
bool get hasStage => stageName != null && stageName!.isNotEmpty;
|
||||
|
||||
/// Check if this stage has any passed quantity
|
||||
bool get hasPassedQuantity => passedQuantity > 0;
|
||||
|
||||
/// Check if this stage has any issued quantity
|
||||
bool get hasIssuedQuantity => issuedQuantity > 0;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
productId,
|
||||
productStageId,
|
||||
actionTypeId,
|
||||
passedQuantity,
|
||||
issuedQuantity,
|
||||
issuedQuantityWeight,
|
||||
passedQuantityWeight,
|
||||
stageName,
|
||||
createdDate,
|
||||
];
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'ProductStageEntity(productId: $productId, stageName: $stageName, passedQuantity: $passedQuantity)';
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import '../../../../core/errors/failures.dart';
|
||||
import '../entities/product_entity.dart';
|
||||
import '../entities/product_stage_entity.dart';
|
||||
|
||||
/// Abstract repository interface for products
|
||||
/// Defines the contract for product data operations
|
||||
@@ -15,4 +16,15 @@ abstract class ProductsRepository {
|
||||
int warehouseId,
|
||||
String type,
|
||||
);
|
||||
|
||||
/// Get product stages for a product in a warehouse
|
||||
///
|
||||
/// [warehouseId] - The ID of the warehouse
|
||||
/// [productId] - The ID of the product
|
||||
///
|
||||
/// Returns Either<Failure, List<ProductStageEntity>>
|
||||
Future<Either<Failure, List<ProductStageEntity>>> getProductDetail(
|
||||
int warehouseId,
|
||||
int productId,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import '../../../../core/errors/failures.dart';
|
||||
import '../entities/product_stage_entity.dart';
|
||||
import '../repositories/products_repository.dart';
|
||||
|
||||
/// Use case for getting product stages
|
||||
/// Encapsulates the business logic for fetching product stage information
|
||||
class GetProductDetailUseCase {
|
||||
final ProductsRepository repository;
|
||||
|
||||
GetProductDetailUseCase(this.repository);
|
||||
|
||||
/// Execute the use case
|
||||
///
|
||||
/// [warehouseId] - The ID of the warehouse
|
||||
/// [productId] - The ID of the product
|
||||
///
|
||||
/// Returns Either<Failure, List<ProductStageEntity>>
|
||||
Future<Either<Failure, List<ProductStageEntity>>> call(
|
||||
int warehouseId,
|
||||
int productId,
|
||||
) async {
|
||||
return await repository.getProductDetail(warehouseId, productId);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user