fill
This commit is contained in:
154
lib/features/products/domain/entities/product_entity.dart
Normal file
154
lib/features/products/domain/entities/product_entity.dart
Normal file
@@ -0,0 +1,154 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Product entity - pure domain model
|
||||
/// Represents a product in the warehouse management system
|
||||
class ProductEntity extends Equatable {
|
||||
final int id;
|
||||
final String name;
|
||||
final String code;
|
||||
final String fullName;
|
||||
final String? description;
|
||||
final String? lotCode;
|
||||
final String? lotNumber;
|
||||
final String? logo;
|
||||
final String? barcode;
|
||||
|
||||
// Quantity fields
|
||||
final int quantity;
|
||||
final int totalQuantity;
|
||||
final int passedQuantity;
|
||||
final double? passedQuantityWeight;
|
||||
final int issuedQuantity;
|
||||
final double? issuedQuantityWeight;
|
||||
final int piecesInStock;
|
||||
final double weightInStock;
|
||||
|
||||
// Weight and pieces
|
||||
final double weight;
|
||||
final int pieces;
|
||||
final double conversionRate;
|
||||
final double? percent;
|
||||
|
||||
// Price and status
|
||||
final double? price;
|
||||
final bool isActive;
|
||||
final bool isConfirm;
|
||||
final int? productStatusId;
|
||||
final int productTypeId;
|
||||
|
||||
// Relations
|
||||
final int? orderId;
|
||||
final int? parentId;
|
||||
final int? receiverStageId;
|
||||
final dynamic order;
|
||||
|
||||
// Dates
|
||||
final String? startDate;
|
||||
final String? endDate;
|
||||
|
||||
// Lists
|
||||
final List<dynamic> productions;
|
||||
final List<dynamic> customerProducts;
|
||||
final List<dynamic> productStages;
|
||||
final dynamic childrenProducts;
|
||||
final dynamic productStageWareHouses;
|
||||
final dynamic productStageDetailWareHouses;
|
||||
final dynamic productExportExcelSheetDataModels;
|
||||
final dynamic materialLabels;
|
||||
final dynamic materials;
|
||||
final dynamic images;
|
||||
final dynamic attachmentFiles;
|
||||
|
||||
const ProductEntity({
|
||||
required this.id,
|
||||
required this.name,
|
||||
required this.code,
|
||||
required this.fullName,
|
||||
this.description,
|
||||
this.lotCode,
|
||||
this.lotNumber,
|
||||
this.logo,
|
||||
this.barcode,
|
||||
required this.quantity,
|
||||
required this.totalQuantity,
|
||||
required this.passedQuantity,
|
||||
this.passedQuantityWeight,
|
||||
required this.issuedQuantity,
|
||||
this.issuedQuantityWeight,
|
||||
required this.piecesInStock,
|
||||
required this.weightInStock,
|
||||
required this.weight,
|
||||
required this.pieces,
|
||||
required this.conversionRate,
|
||||
this.percent,
|
||||
this.price,
|
||||
required this.isActive,
|
||||
required this.isConfirm,
|
||||
this.productStatusId,
|
||||
required this.productTypeId,
|
||||
this.orderId,
|
||||
this.parentId,
|
||||
this.receiverStageId,
|
||||
this.order,
|
||||
this.startDate,
|
||||
this.endDate,
|
||||
this.productions = const [],
|
||||
this.customerProducts = const [],
|
||||
this.productStages = const [],
|
||||
this.childrenProducts,
|
||||
this.productStageWareHouses,
|
||||
this.productStageDetailWareHouses,
|
||||
this.productExportExcelSheetDataModels,
|
||||
this.materialLabels,
|
||||
this.materials,
|
||||
this.images,
|
||||
this.attachmentFiles,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
name,
|
||||
code,
|
||||
fullName,
|
||||
description,
|
||||
lotCode,
|
||||
lotNumber,
|
||||
logo,
|
||||
barcode,
|
||||
quantity,
|
||||
totalQuantity,
|
||||
passedQuantity,
|
||||
passedQuantityWeight,
|
||||
issuedQuantity,
|
||||
issuedQuantityWeight,
|
||||
piecesInStock,
|
||||
weightInStock,
|
||||
weight,
|
||||
pieces,
|
||||
conversionRate,
|
||||
percent,
|
||||
price,
|
||||
isActive,
|
||||
isConfirm,
|
||||
productStatusId,
|
||||
productTypeId,
|
||||
orderId,
|
||||
parentId,
|
||||
receiverStageId,
|
||||
order,
|
||||
startDate,
|
||||
endDate,
|
||||
productions,
|
||||
customerProducts,
|
||||
productStages,
|
||||
childrenProducts,
|
||||
productStageWareHouses,
|
||||
productStageDetailWareHouses,
|
||||
productExportExcelSheetDataModels,
|
||||
materialLabels,
|
||||
materials,
|
||||
images,
|
||||
attachmentFiles,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import '../../../../core/errors/failures.dart';
|
||||
import '../entities/product_entity.dart';
|
||||
|
||||
/// Abstract repository interface for products
|
||||
/// Defines the contract for product data operations
|
||||
abstract class ProductsRepository {
|
||||
/// Get products for a specific warehouse and operation type
|
||||
///
|
||||
/// [warehouseId] - The ID of the warehouse
|
||||
/// [type] - The operation type ('import' or 'export')
|
||||
///
|
||||
/// Returns Either<Failure, List<ProductEntity>>
|
||||
Future<Either<Failure, List<ProductEntity>>> getProducts(
|
||||
int warehouseId,
|
||||
String type,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import '../../../../core/errors/failures.dart';
|
||||
import '../entities/product_entity.dart';
|
||||
import '../repositories/products_repository.dart';
|
||||
|
||||
/// Use case for getting products
|
||||
/// Encapsulates the business logic for fetching products
|
||||
class GetProductsUseCase {
|
||||
final ProductsRepository repository;
|
||||
|
||||
GetProductsUseCase(this.repository);
|
||||
|
||||
/// Execute the use case
|
||||
///
|
||||
/// [warehouseId] - The ID of the warehouse to get products from
|
||||
/// [type] - The operation type ('import' or 'export')
|
||||
///
|
||||
/// Returns Either<Failure, List<ProductEntity>>
|
||||
Future<Either<Failure, List<ProductEntity>>> call(
|
||||
int warehouseId,
|
||||
String type,
|
||||
) async {
|
||||
return await repository.getProducts(warehouseId, type);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user