completed go backend
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
E "github.com/IBM/fp-go/either"
|
||||
)
|
||||
|
||||
// curried delegiert eine Methode mit Kontext und gibt eine Funktion zurück.
|
||||
// curried is a helper function to simplify currying by taking a context and returning a function.
|
||||
func curried[T any, R any](ctx context.Context, fn func(context.Context, T) E.Either[error, R]) func(T) E.Either[error, R] {
|
||||
return func(input T) E.Either[error, R] {
|
||||
return fn(ctx, input)
|
||||
|
||||
@@ -20,28 +20,28 @@ func NewProjectRepository(dataSource data.ProjectDataSource) repository.ProjectR
|
||||
}
|
||||
|
||||
// Create delegates the creation of a project to the data source.
|
||||
func (r *ProjectRepositoryImpl) Create(ctx context.Context, project entities.ProjectCreate) E.Either[error, entities.Project] {
|
||||
return r.dataSource.Create(ctx, project)
|
||||
func (r *ProjectRepositoryImpl) Create(ctx context.Context) func(project entities.ProjectCreate) E.Either[error, entities.Project] {
|
||||
return curried(ctx, r.dataSource.Create)
|
||||
}
|
||||
|
||||
// FindByID delegates fetching a project by ID to the data source.
|
||||
func (r *ProjectRepositoryImpl) FindByID(ctx context.Context, id string) E.Either[error, entities.Project] {
|
||||
return r.dataSource.FindByID(ctx, id)
|
||||
func (r *ProjectRepositoryImpl) FindByID(ctx context.Context) func(id string) E.Either[error, entities.Project] {
|
||||
return curried(ctx, r.dataSource.FindByID)
|
||||
}
|
||||
|
||||
// FindByUserID delegates fetching all projects for a user to the data source.
|
||||
func (r *ProjectRepositoryImpl) FindByUserID(ctx context.Context, userID string) E.Either[error, []entities.Project] {
|
||||
return r.dataSource.FindByUserID(ctx, userID)
|
||||
// FindByUserID delegates fetching projects by user ID to the data source.
|
||||
func (r *ProjectRepositoryImpl) FindByUserID(ctx context.Context) func(userID string) E.Either[error, []entities.Project] {
|
||||
return curried(ctx, r.dataSource.FindByUserID)
|
||||
}
|
||||
|
||||
// Update delegates updating a project to the data source.
|
||||
func (r *ProjectRepositoryImpl) Update(ctx context.Context, project entities.ProjectUpdate) E.Either[error, entities.Project] {
|
||||
return r.dataSource.Update(ctx, project)
|
||||
func (r *ProjectRepositoryImpl) Update(ctx context.Context) func(project entities.ProjectUpdate) E.Either[error, entities.Project] {
|
||||
return curried(ctx, r.dataSource.Update)
|
||||
}
|
||||
|
||||
// Delete delegates deleting a project to the data source.
|
||||
func (r *ProjectRepositoryImpl) Delete(ctx context.Context, id string) E.Either[error, entities.Project] {
|
||||
return r.dataSource.Delete(ctx, id)
|
||||
func (r *ProjectRepositoryImpl) Delete(ctx context.Context) func(id string) E.Either[error, entities.Project] {
|
||||
return curried(ctx, r.dataSource.Delete)
|
||||
}
|
||||
|
||||
// FindAll delegates fetching all projects to the data source.
|
||||
|
||||
@@ -13,33 +13,35 @@ import (
|
||||
type ProjectTaskRepositoryImpl struct {
|
||||
dataSource data.ProjectTaskDataSource
|
||||
}
|
||||
|
||||
// NewProjectTaskRepository creates a new instance of ProjectTaskRepositoryImpl.
|
||||
func NewProjectTaskRepository(dataSource data.ProjectTaskDataSource) repository.ProjectTaskRepository {
|
||||
return &ProjectTaskRepositoryImpl{dataSource: dataSource}
|
||||
}
|
||||
// FindByProjectID implements repository.ProjectTaskRepository.
|
||||
func (r *ProjectTaskRepositoryImpl) FindByProjectID(ctx context.Context, projectID string) E.Either[error, []entities.ProjectTask] {
|
||||
return r.dataSource.FindByProjectID(ctx, projectID)
|
||||
}
|
||||
|
||||
// Create delegates the creation of a project task to the data source.
|
||||
func (r *ProjectTaskRepositoryImpl) Create(ctx context.Context, task entities.ProjectTaskCreate) E.Either[error, entities.ProjectTask] {
|
||||
return r.dataSource.Create(ctx, task)
|
||||
func (r *ProjectTaskRepositoryImpl) Create(ctx context.Context) func(task entities.ProjectTaskCreate) E.Either[error, entities.ProjectTask] {
|
||||
return curried(ctx, r.dataSource.Create)
|
||||
}
|
||||
|
||||
// FindByID delegates fetching a project task by ID to the data source.
|
||||
func (r *ProjectTaskRepositoryImpl) FindByID(ctx context.Context, id string) E.Either[error, entities.ProjectTask] {
|
||||
return r.dataSource.FindByID(ctx, id)
|
||||
func (r *ProjectTaskRepositoryImpl) FindByID(ctx context.Context) func(id string) E.Either[error, entities.ProjectTask] {
|
||||
return curried(ctx, r.dataSource.FindByID)
|
||||
}
|
||||
|
||||
// FindByProjectID delegates fetching project tasks by project ID to the data source.
|
||||
func (r *ProjectTaskRepositoryImpl) FindByProjectID(ctx context.Context) func(projectID string) E.Either[error, []entities.ProjectTask] {
|
||||
return curried(ctx, r.dataSource.FindByProjectID)
|
||||
}
|
||||
|
||||
// Update delegates updating a project task to the data source.
|
||||
func (r *ProjectTaskRepositoryImpl) Update(ctx context.Context, task entities.ProjectTaskUpdate) E.Either[error, entities.ProjectTask] {
|
||||
return r.dataSource.Update(ctx, task)
|
||||
func (r *ProjectTaskRepositoryImpl) Update(ctx context.Context) func(task entities.ProjectTaskUpdate) E.Either[error, entities.ProjectTask] {
|
||||
return curried(ctx, r.dataSource.Update)
|
||||
}
|
||||
|
||||
// Delete delegates deleting a project task to the data source.
|
||||
func (r *ProjectTaskRepositoryImpl) Delete(ctx context.Context, id string) E.Either[error, entities.ProjectTask] {
|
||||
return r.dataSource.Delete(ctx, id)
|
||||
func (r *ProjectTaskRepositoryImpl) Delete(ctx context.Context) func(id string) E.Either[error, entities.ProjectTask] {
|
||||
return curried(ctx, r.dataSource.Delete)
|
||||
}
|
||||
|
||||
// FindAll delegates fetching all project tasks to the data source.
|
||||
|
||||
@@ -19,37 +19,37 @@ func NewTimeEntryRepository(dataSource data.TimeEntryDataSource) repository.Time
|
||||
return &TimeEntryRepositoryImpl{dataSource: dataSource}
|
||||
}
|
||||
|
||||
// FindByProjectID implements repository.TimeEntryRepository.
|
||||
func (r *TimeEntryRepositoryImpl) FindByProjectID(ctx context.Context, projectID string) E.Either[error, []entities.TimeEntry] {
|
||||
return r.dataSource.FindByProjectID(ctx, projectID)
|
||||
// Create delegates the creation of a TimeEntry to the data source.
|
||||
func (r *TimeEntryRepositoryImpl) Create(ctx context.Context) func(entry entities.TimeEntryCreate) E.Either[error, entities.TimeEntry] {
|
||||
return curried(ctx, r.dataSource.Create)
|
||||
}
|
||||
|
||||
// FindByUserID implements repository.TimeEntryRepository.
|
||||
func (r *TimeEntryRepositoryImpl) FindByUserID(ctx context.Context, userID string) E.Either[error, []entities.TimeEntry] {
|
||||
return r.dataSource.FindByUserID(ctx, userID)
|
||||
// FindByID delegates fetching a TimeEntry by ID to the data source.
|
||||
func (r *TimeEntryRepositoryImpl) FindByID(ctx context.Context) func(id string) E.Either[error, entities.TimeEntry] {
|
||||
return curried(ctx, r.dataSource.FindByID)
|
||||
}
|
||||
|
||||
// Create delegates the creation of a time entry to the data source.
|
||||
func (r *TimeEntryRepositoryImpl) Create(ctx context.Context, entry entities.TimeEntryCreate) E.Either[error, entities.TimeEntry] {
|
||||
return r.dataSource.Create(ctx, entry)
|
||||
// FindByUserID delegates fetching TimeEntries by UserID to the data source.
|
||||
func (r *TimeEntryRepositoryImpl) FindByUserID(ctx context.Context) func(userID string) E.Either[error, []entities.TimeEntry] {
|
||||
return curried(ctx, r.dataSource.FindByUserID)
|
||||
}
|
||||
|
||||
// FindByID delegates fetching a time entry by ID to the data source.
|
||||
func (r *TimeEntryRepositoryImpl) FindByID(ctx context.Context, id string) E.Either[error, entities.TimeEntry] {
|
||||
return r.dataSource.FindByID(ctx, id)
|
||||
// FindByProjectID delegates fetching TimeEntries by ProjectID to the data source.
|
||||
func (r *TimeEntryRepositoryImpl) FindByProjectID(ctx context.Context) func(projectID string) E.Either[error, []entities.TimeEntry] {
|
||||
return curried(ctx, r.dataSource.FindByProjectID)
|
||||
}
|
||||
|
||||
// Update delegates updating a time entry to the data source.
|
||||
func (r *TimeEntryRepositoryImpl) Update(ctx context.Context, entry entities.TimeEntryUpdate) E.Either[error, entities.TimeEntry] {
|
||||
return r.dataSource.Update(ctx, entry)
|
||||
// Update delegates updating a TimeEntry to the data source.
|
||||
func (r *TimeEntryRepositoryImpl) Update(ctx context.Context) func(entry entities.TimeEntryUpdate) E.Either[error, entities.TimeEntry] {
|
||||
return curried(ctx, r.dataSource.Update)
|
||||
}
|
||||
|
||||
// Delete delegates deleting a time entry to the data source.
|
||||
func (r *TimeEntryRepositoryImpl) Delete(ctx context.Context, id string) E.Either[error, entities.TimeEntry] {
|
||||
return r.dataSource.Delete(ctx, id)
|
||||
// Delete delegates deleting a TimeEntry to the data source.
|
||||
func (r *TimeEntryRepositoryImpl) Delete(ctx context.Context) func(id string) E.Either[error, entities.TimeEntry] {
|
||||
return curried(ctx, r.dataSource.Delete)
|
||||
}
|
||||
|
||||
// FindAll delegates fetching all time entries to the data source.
|
||||
// FindAll delegates fetching all TimeEntries to the data source.
|
||||
func (r *TimeEntryRepositoryImpl) FindAll(ctx context.Context) E.Either[error, []entities.TimeEntry] {
|
||||
return r.dataSource.FindAll(ctx)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package repository
|
||||
import (
|
||||
"actatempus_backend/internal/domain/data"
|
||||
"actatempus_backend/internal/domain/entities"
|
||||
"actatempus_backend/internal/domain/repository"
|
||||
"context"
|
||||
|
||||
E "github.com/IBM/fp-go/either"
|
||||
@@ -13,32 +14,37 @@ type UserRepositoryImpl struct {
|
||||
dataSource data.UserDataSource
|
||||
}
|
||||
|
||||
// Create delegiert die Erstellung eines Benutzers an die Datenquelle.
|
||||
// NewUserRepository creates a new instance of UserRepositoryImpl.
|
||||
func NewUserRepository(dataSource data.UserDataSource) repository.UserRepository {
|
||||
return &UserRepositoryImpl{dataSource: dataSource}
|
||||
}
|
||||
|
||||
// Create delegates the creation of a user to the data source.
|
||||
func (r *UserRepositoryImpl) Create(ctx context.Context) func(user entities.UserCreate) E.Either[error, entities.User] {
|
||||
return curried(ctx, r.dataSource.Create)
|
||||
}
|
||||
|
||||
// FindByID delegiert das Abrufen eines Benutzers nach ID an die Datenquelle.
|
||||
// FindByID delegates fetching a user by ID to the data source.
|
||||
func (r *UserRepositoryImpl) FindByID(ctx context.Context) func(id string) E.Either[error, entities.User] {
|
||||
return curried(ctx, r.dataSource.FindByID)
|
||||
}
|
||||
|
||||
// FindByEmail delegiert das Abrufen eines Benutzers nach E-Mail an die Datenquelle.
|
||||
// FindByEmail delegates fetching a user by email to the data source.
|
||||
func (r *UserRepositoryImpl) FindByEmail(ctx context.Context) func(email string) E.Either[error, entities.User] {
|
||||
return curried(ctx, r.dataSource.FindByEmail)
|
||||
}
|
||||
|
||||
// Update delegiert das Aktualisieren eines Benutzers an die Datenquelle.
|
||||
// Update delegates updating a user to the data source.
|
||||
func (r *UserRepositoryImpl) Update(ctx context.Context) func(user entities.UserUpdate) E.Either[error, entities.User] {
|
||||
return curried(ctx, r.dataSource.Update)
|
||||
}
|
||||
|
||||
// Delete delegiert das Löschen eines Benutzers an die Datenquelle.
|
||||
// Delete delegates deleting a user to the data source.
|
||||
func (r *UserRepositoryImpl) Delete(ctx context.Context) func(id string) E.Either[error, entities.User] {
|
||||
return curried(ctx, r.dataSource.Delete)
|
||||
}
|
||||
|
||||
// FindAll delegiert das Abrufen aller Benutzer an die Datenquelle.
|
||||
// FindAll delegates fetching all users to the data source.
|
||||
func (r *UserRepositoryImpl) FindAll(ctx context.Context) E.Either[error, []entities.User] {
|
||||
return r.dataSource.FindAll(ctx)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user