111 lines
3.5 KiB
Go
111 lines
3.5 KiB
Go
package internal
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/tech/sendico/pkg/merrors"
|
|
"github.com/tech/sendico/pkg/mlogger"
|
|
"github.com/tech/sendico/pkg/model"
|
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
|
)
|
|
|
|
// TaskManager is a placeholder implementation that validates input and provides a consistent
|
|
// constructor until the full business logic is available.
|
|
type TaskManager struct {
|
|
logger mlogger.Logger
|
|
projectDB any
|
|
taskDB any
|
|
}
|
|
|
|
// NewTaskManager creates a new TaskManager instance.
|
|
func NewTaskManager(logger mlogger.Logger, projectDB, taskDB any) *TaskManager {
|
|
var namedLogger mlogger.Logger
|
|
if logger != nil {
|
|
namedLogger = logger.Named("task_manager")
|
|
}
|
|
return &TaskManager{
|
|
logger: namedLogger,
|
|
projectDB: projectDB,
|
|
taskDB: taskDB,
|
|
}
|
|
}
|
|
|
|
func (m *TaskManager) CreateTask(ctx context.Context, accountRef, organizationRef primitive.ObjectID, task *model.Task) error {
|
|
if ctx == nil {
|
|
return merrors.InvalidArgument("context is nil")
|
|
}
|
|
if accountRef.IsZero() {
|
|
return merrors.InvalidArgument("account reference is zero")
|
|
}
|
|
if organizationRef.IsZero() {
|
|
return merrors.InvalidArgument("organization reference is zero")
|
|
}
|
|
if task == nil {
|
|
return merrors.InvalidArgument("task is nil")
|
|
}
|
|
if task.ProjectRef.IsZero() {
|
|
return merrors.InvalidArgument("task.projectRef is zero")
|
|
}
|
|
if task.StatusRef.IsZero() {
|
|
return merrors.InvalidArgument("task.statusRef is zero")
|
|
}
|
|
return merrors.NotImplemented("task manager CreateTask requires data layer integration")
|
|
}
|
|
|
|
func (m *TaskManager) MoveTask(ctx context.Context, accountRef, organizationRef primitive.ObjectID, taskRef, targetProjectRef, targetStatusRef primitive.ObjectID) error {
|
|
if ctx == nil {
|
|
return merrors.InvalidArgument("context is nil")
|
|
}
|
|
if accountRef.IsZero() {
|
|
return merrors.InvalidArgument("account reference is zero")
|
|
}
|
|
if organizationRef.IsZero() {
|
|
return merrors.InvalidArgument("organization reference is zero")
|
|
}
|
|
if taskRef.IsZero() {
|
|
return merrors.InvalidArgument("task reference is zero")
|
|
}
|
|
if targetProjectRef.IsZero() {
|
|
return merrors.InvalidArgument("target project reference is zero")
|
|
}
|
|
if targetStatusRef.IsZero() {
|
|
return merrors.InvalidArgument("target status reference is zero")
|
|
}
|
|
return merrors.NotImplemented("task manager MoveTask requires data layer integration")
|
|
}
|
|
|
|
func (m *TaskManager) MoveTasks(ctx context.Context, accountRef, organizationRef, sourceProjectRef, targetProjectRef, targetStatusRef primitive.ObjectID) error {
|
|
if ctx == nil {
|
|
return merrors.InvalidArgument("context is nil")
|
|
}
|
|
if accountRef.IsZero() {
|
|
return merrors.InvalidArgument("account reference is zero")
|
|
}
|
|
if organizationRef.IsZero() {
|
|
return merrors.InvalidArgument("organization reference is zero")
|
|
}
|
|
if sourceProjectRef.IsZero() {
|
|
return merrors.InvalidArgument("source project reference is zero")
|
|
}
|
|
if targetProjectRef.IsZero() {
|
|
return merrors.InvalidArgument("target project reference is zero")
|
|
}
|
|
if targetStatusRef.IsZero() {
|
|
return merrors.InvalidArgument("target status reference is zero")
|
|
}
|
|
return merrors.NotImplemented("task manager MoveTasks requires data layer integration")
|
|
}
|
|
|
|
func (m *TaskManager) DeleteTask(ctx context.Context, accountRef, taskRef primitive.ObjectID) error {
|
|
if ctx == nil {
|
|
return merrors.InvalidArgument("context is nil")
|
|
}
|
|
if accountRef.IsZero() {
|
|
return merrors.InvalidArgument("account reference is zero")
|
|
}
|
|
if taskRef.IsZero() {
|
|
return merrors.InvalidArgument("task reference is zero")
|
|
}
|
|
return merrors.NotImplemented("task manager DeleteTask requires data layer integration")
|
|
}
|