Files
dttmr-api/internal/domain/list.go
T
2026-07-20 21:57:43 +02:00

39 lines
808 B
Go

package domain
import (
"context"
"errors"
"time"
)
type List struct {
ID string `json:"id"`
Name string `json:"name"`
CreatedAt time.Time `json:"created_at"`
ModifiedAt time.Time `json:"modified_at"`
}
type ListRepository interface {
CreateList(ctx context.Context, name string, userIDs []string) (*List, error)
}
type ListService struct {
repo ListRepository
}
func NewListService(r ListRepository) *ListService {
return &ListService{repo: r}
}
func (s *ListService) Create(ctx context.Context, name string, userIDs []string) (*List, error) {
if len(userIDs) == 0 {
return nil, errors.New("users must have at least one associated user")
}
if name == "" {
return nil, errors.New("list name must not be empty")
}
return s.repo.CreateList(ctx, name, userIDs)
}