마스터 고객/제품/창고 테스트 및 UI 구현
This commit is contained in:
99
lib/features/masters/product/domain/entities/product.dart
Normal file
99
lib/features/masters/product/domain/entities/product.dart
Normal file
@@ -0,0 +1,99 @@
|
||||
class Product {
|
||||
Product({
|
||||
this.id,
|
||||
required this.productCode,
|
||||
required this.productName,
|
||||
this.vendor,
|
||||
this.uom,
|
||||
this.isActive = true,
|
||||
this.isDeleted = false,
|
||||
this.note,
|
||||
this.createdAt,
|
||||
this.updatedAt,
|
||||
});
|
||||
|
||||
final int? id;
|
||||
final String productCode;
|
||||
final String productName;
|
||||
final ProductVendor? vendor;
|
||||
final ProductUom? uom;
|
||||
final bool isActive;
|
||||
final bool isDeleted;
|
||||
final String? note;
|
||||
final DateTime? createdAt;
|
||||
final DateTime? updatedAt;
|
||||
|
||||
Product copyWith({
|
||||
int? id,
|
||||
String? productCode,
|
||||
String? productName,
|
||||
ProductVendor? vendor,
|
||||
ProductUom? uom,
|
||||
bool? isActive,
|
||||
bool? isDeleted,
|
||||
String? note,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt,
|
||||
}) {
|
||||
return Product(
|
||||
id: id ?? this.id,
|
||||
productCode: productCode ?? this.productCode,
|
||||
productName: productName ?? this.productName,
|
||||
vendor: vendor ?? this.vendor,
|
||||
uom: uom ?? this.uom,
|
||||
isActive: isActive ?? this.isActive,
|
||||
isDeleted: isDeleted ?? this.isDeleted,
|
||||
note: note ?? this.note,
|
||||
createdAt: createdAt ?? this.createdAt,
|
||||
updatedAt: updatedAt ?? this.updatedAt,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
class ProductVendor {
|
||||
ProductVendor({
|
||||
required this.id,
|
||||
required this.vendorCode,
|
||||
required this.vendorName,
|
||||
});
|
||||
|
||||
final int id;
|
||||
final String vendorCode;
|
||||
final String vendorName;
|
||||
}
|
||||
|
||||
class ProductUom {
|
||||
ProductUom({required this.id, required this.uomName});
|
||||
|
||||
final int id;
|
||||
final String uomName;
|
||||
}
|
||||
|
||||
class ProductInput {
|
||||
ProductInput({
|
||||
required this.productCode,
|
||||
required this.productName,
|
||||
required this.vendorId,
|
||||
required this.uomId,
|
||||
this.isActive = true,
|
||||
this.note,
|
||||
});
|
||||
|
||||
final String productCode;
|
||||
final String productName;
|
||||
final int vendorId;
|
||||
final int uomId;
|
||||
final bool isActive;
|
||||
final String? note;
|
||||
|
||||
Map<String, dynamic> toPayload() {
|
||||
return {
|
||||
'product_code': productCode,
|
||||
'product_name': productName,
|
||||
'vendor_id': vendorId,
|
||||
'uom_id': uomId,
|
||||
'is_active': isActive,
|
||||
'note': note,
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:superport_v2/core/common/models/paginated_result.dart';
|
||||
|
||||
import '../entities/product.dart';
|
||||
|
||||
abstract class ProductRepository {
|
||||
Future<PaginatedResult<Product>> list({
|
||||
int page = 1,
|
||||
int pageSize = 20,
|
||||
String? query,
|
||||
int? vendorId,
|
||||
int? uomId,
|
||||
bool? isActive,
|
||||
});
|
||||
|
||||
Future<Product> create(ProductInput input);
|
||||
|
||||
Future<Product> update(int id, ProductInput input);
|
||||
|
||||
Future<void> delete(int id);
|
||||
|
||||
Future<Product> restore(int id);
|
||||
}
|
||||
Reference in New Issue
Block a user