runable
This commit is contained in:
33
lib/features/categories/domain/entities/category.dart
Normal file
33
lib/features/categories/domain/entities/category.dart
Normal file
@@ -0,0 +1,33 @@
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
/// Category domain entity
|
||||
class Category extends Equatable {
|
||||
final String id;
|
||||
final String name;
|
||||
final String? description;
|
||||
final String? iconPath;
|
||||
final String? color;
|
||||
final int productCount;
|
||||
final DateTime createdAt;
|
||||
|
||||
const Category({
|
||||
required this.id,
|
||||
required this.name,
|
||||
this.description,
|
||||
this.iconPath,
|
||||
this.color,
|
||||
required this.productCount,
|
||||
required this.createdAt,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
id,
|
||||
name,
|
||||
description,
|
||||
iconPath,
|
||||
color,
|
||||
productCount,
|
||||
createdAt,
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import '../../../../core/errors/failures.dart';
|
||||
import '../entities/category.dart';
|
||||
|
||||
/// Category repository interface
|
||||
abstract class CategoryRepository {
|
||||
/// Get all categories from cache
|
||||
Future<Either<Failure, List<Category>>> getAllCategories();
|
||||
|
||||
/// Get category by ID
|
||||
Future<Either<Failure, Category>> getCategoryById(String id);
|
||||
|
||||
/// Sync categories from remote
|
||||
Future<Either<Failure, List<Category>>> syncCategories();
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:dartz/dartz.dart';
|
||||
import '../../../../core/errors/failures.dart';
|
||||
import '../entities/category.dart';
|
||||
import '../repositories/category_repository.dart';
|
||||
|
||||
/// Use case to get all categories
|
||||
class GetAllCategories {
|
||||
final CategoryRepository repository;
|
||||
|
||||
GetAllCategories(this.repository);
|
||||
|
||||
Future<Either<Failure, List<Category>>> call() async {
|
||||
return await repository.getAllCategories();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user