From d6b913a76308fc87046a49098413f12cd64daea5 Mon Sep 17 00:00:00 2001 From: Robin Dittmar Date: Fri, 14 Aug 2026 16:56:17 +0200 Subject: [PATCH] feat: ListService now supports user management and creating/updating list items --- internal/domain/list.go | 44 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/internal/domain/list.go b/internal/domain/list.go index 904f070..99acd38 100644 --- a/internal/domain/list.go +++ b/internal/domain/list.go @@ -49,3 +49,47 @@ func (s *ListService) Create(ctx context.Context, name string, userIDs []string) return s.repo.CreateList(ctx, name, userIDs) } + +func (s *ListService) AddUserToList(ctx context.Context, listID string, userID string) error { + if listID == "" { + return errors.New("list id must not be empty") + } + if userID == "" { + return errors.New("user id must not be empty") + } + + return s.repo.AddUserToList(ctx, listID, userID) +} + +func (s *ListService) RemoveUserFromList(ctx context.Context, listID string, userID string) error { + if listID == "" { + return errors.New("list id must not be empty") + } + if userID == "" { + return errors.New("user id must not be empty") + } + + return s.repo.RemoveUserFromList(ctx, listID, userID) +} + +func (s *ListService) CreateListItem(ctx context.Context, listID string, title string) (*ListItem, error) { + if listID == "" { + return nil, errors.New("list id must not be empty") + } + if title == "" { + return nil, errors.New("list item title must not be empty") + } + + return s.repo.CreateListItem(ctx, listID, title) +} + +func (s *ListService) UpdateListItem(ctx context.Context, listItemID, title string, isCompleted bool) error { + if listItemID == "" { + return errors.New("list item id must not be empty") + } + if title == "" { + return errors.New("list item title must not be empty") + } + + return s.repo.UpdateListItem(ctx, listItemID, title, isCompleted) +}