implemented other repos, services, objects ...
This commit is contained in:
@@ -1,6 +1,13 @@
|
||||
import 'package:backend_dart/domain/data/project_data_source.dart';
|
||||
import 'package:backend_dart/domain/data/project_task_data_source.dart';
|
||||
import 'package:backend_dart/domain/data/time_entry_data_source.dart';
|
||||
import 'package:backend_dart/domain/data/user_data_source.dart';
|
||||
|
||||
abstract class IDatabase {
|
||||
UserDataSource get users;
|
||||
TimeEntryDataSource get timeEntries;
|
||||
ProjectTaskDataSource get tasks;
|
||||
ProjectDataSource get projects;
|
||||
|
||||
Future<void> close();
|
||||
}
|
||||
|
||||
@@ -7,30 +7,33 @@ abstract class ProjectDataSource {
|
||||
/// Creates a new project in the data source.
|
||||
///
|
||||
/// Throws an error if the creation fails.
|
||||
TaskEither<IError, Project> createProject(ProjectCreate project);
|
||||
TaskEither<IError, Project> create(ProjectCreate project);
|
||||
|
||||
/// Retrieves a project by its unique ID.
|
||||
///
|
||||
/// Returns `null` if no project is found.
|
||||
TaskEither<IError, Project> findProjectById(String id);
|
||||
TaskEither<IError, Project> findById(String id);
|
||||
|
||||
/// Retrieves all projects associated with a specific user.
|
||||
///
|
||||
/// Returns an empty list if no projects are found.
|
||||
TaskEither<IError,List<Project>> findProjectsByUserId(String userId);
|
||||
TaskEither<IError, List<Project>> findByUserId(String userId);
|
||||
|
||||
/// Updates an existing project in the data source.
|
||||
///
|
||||
/// Throws an error if the update fails.
|
||||
TaskEither<IError, Project> updateProject(ProjectUpdate project);
|
||||
TaskEither<IError, Project> update(ProjectUpdate project);
|
||||
|
||||
/// Deletes a project by its unique ID.
|
||||
///
|
||||
/// Throws an error if the deletion fails.
|
||||
TaskEither<IError, Project> deleteProject(String id);
|
||||
TaskEither<IError, Project> delete(String id);
|
||||
|
||||
/// Retrieves all projects in the data source.
|
||||
///
|
||||
/// Returns an empty list if no projects exist.
|
||||
TaskEither<IError, List<Project>> findAllProjects();
|
||||
TaskEither<IError, List<Project>> findAll();
|
||||
|
||||
/// Generates a new unique ID for a task.
|
||||
TaskEither<IError, String> generateId();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import 'package:backend_dart/domain/entities/project_task.dart';
|
||||
import 'package:backend_dart/domain/interface/error.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
/// Interface for managing task data interactions.
|
||||
abstract class ProjectTaskDataSource {
|
||||
/// Creates a new task in the data source.
|
||||
///
|
||||
/// Throws an error if the creation fails.
|
||||
TaskEither<IError, ProjectTask> create(ProjectTaskCreate task);
|
||||
|
||||
/// Retrieves a task by its unique ID.
|
||||
///
|
||||
/// Returns `null` if no task is found.
|
||||
TaskEither<IError, ProjectTask> findById(String id);
|
||||
|
||||
/// Retrieves all tasks for a specific project.
|
||||
///
|
||||
/// Returns an empty list if no tasks are found.
|
||||
TaskEither<IError, List<ProjectTask>> findByProjectId(String projectId);
|
||||
|
||||
/// Updates an existing task in the data source.
|
||||
///
|
||||
/// Throws an error if the update fails.
|
||||
TaskEither<IError, ProjectTask> update(ProjectTaskUpdate task);
|
||||
|
||||
/// Deletes a task by its unique ID.
|
||||
///
|
||||
/// Throws an error if the deletion fails.
|
||||
TaskEither<IError, ProjectTask> delete(String id);
|
||||
|
||||
/// Retrieves all tasks in the data source.
|
||||
///
|
||||
/// Returns an empty list if no tasks exist.
|
||||
TaskEither<IError, List<ProjectTask>> findAll();
|
||||
|
||||
/// Generates a new unique ID for a task.
|
||||
TaskEither<IError, String> generateId();
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import 'package:backend_dart/domain/entities/time_entry.dart';
|
||||
import 'package:backend_dart/domain/interface/error.dart';
|
||||
import 'package:fpdart/fpdart.dart';
|
||||
|
||||
/// Interface for managing time entry data interactions.
|
||||
abstract class TimeEntryDataSource {
|
||||
/// Creates a new time entry in the data source.
|
||||
///
|
||||
/// Throws an error if the creation fails.
|
||||
TaskEither<IError, TimeEntry> create(TimeEntryCreate timeEntry);
|
||||
|
||||
/// Retrieves a time entry by its unique ID.
|
||||
///
|
||||
/// Returns `null` if no time entry is found.
|
||||
TaskEither<IError, TimeEntry> findById(String id);
|
||||
|
||||
/// Retrieves all time entries for a specific user.
|
||||
///
|
||||
/// Returns an empty list if no time entries are found.
|
||||
TaskEither<IError, List<TimeEntry>> findByUserId(String userId);
|
||||
|
||||
/// Retrieves all time entries for a specific project.
|
||||
///
|
||||
/// Returns an empty list if no time entries are found.
|
||||
TaskEither<IError, List<TimeEntry>> findByProjectId(String projectId);
|
||||
|
||||
/// Updates an existing time entry in the data source.
|
||||
///
|
||||
/// Throws an error if the update fails.
|
||||
TaskEither<IError, TimeEntry> update(TimeEntryUpdate timeEntry);
|
||||
|
||||
/// Deletes a time entry by its unique ID.
|
||||
///
|
||||
/// Throws an error if the deletion fails.
|
||||
TaskEither<IError, TimeEntry> delete(String id);
|
||||
|
||||
/// Retrieves all time entries in the data source.
|
||||
///
|
||||
/// Returns an empty list if no time entries exist.
|
||||
TaskEither<IError, List<TimeEntry>> findAll();
|
||||
|
||||
/// Generates a new unique ID for a time entry.
|
||||
TaskEither<IError, String> generateId();
|
||||
}
|
||||
Reference in New Issue
Block a user