feat: ListService now supports user management and creating/updating list items
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user