1package repository
2
3import (
4 "context"
5
6 "github.com/bnema/dumber/internal/domain/entity"
7)
8
9// FavoriteRepository defines operations for bookmark persistence.
10type FavoriteRepository interface {
11 // Save creates or updates a favorite.
12 Save(ctx context.Context, fav *entity.Favorite) error
13
14 // FindByID retrieves a favorite by its ID.
15 FindByID(ctx context.Context, id entity.FavoriteID) (*entity.Favorite, error)
16
17 // FindByURL retrieves a favorite by its URL.
18 FindByURL(ctx context.Context, url string) (*entity.Favorite, error)
19
20 // GetAll retrieves all favorites.
21 GetAll(ctx context.Context) ([]*entity.Favorite, error)
22
23 // GetByTag retrieves favorites with a specific tag.
24 GetByTag(ctx context.Context, tagID entity.TagID) ([]*entity.Favorite, error)
25
26 // GetByShortcut retrieves the favorite with the given shortcut key (1-9).
27 GetByShortcut(ctx context.Context, key int) (*entity.Favorite, error)
28
29 // UpdatePosition updates a favorite's position.
30 UpdatePosition(ctx context.Context, id entity.FavoriteID, position int) error
31
32 // SetShortcut assigns a keyboard shortcut (1-9) or nil to remove.
33 SetShortcut(ctx context.Context, id entity.FavoriteID, key *int) error
34
35 // Delete removes a favorite by ID.
36 Delete(ctx context.Context, id entity.FavoriteID) error
37}
38
39// TagRepository defines operations for tag persistence.
40type TagRepository interface {
41 // Save creates or updates a tag.
42 Save(ctx context.Context, tag *entity.Tag) error
43
44 // FindByID retrieves a tag by its ID.
45 FindByID(ctx context.Context, id entity.TagID) (*entity.Tag, error)
46
47 // FindByName retrieves a tag by its name.
48 FindByName(ctx context.Context, name string) (*entity.Tag, error)
49
50 // GetAll retrieves all tags.
51 GetAll(ctx context.Context) ([]*entity.Tag, error)
52
53 // AssignToFavorite associates a tag with a favorite.
54 AssignToFavorite(ctx context.Context, tagID entity.TagID, favID entity.FavoriteID) error
55
56 // RemoveFromFavorite removes a tag association from a favorite.
57 RemoveFromFavorite(ctx context.Context, tagID entity.TagID, favID entity.FavoriteID) error
58
59 // GetForFavorite retrieves all tags associated with a favorite.
60 GetForFavorite(ctx context.Context, favID entity.FavoriteID) ([]*entity.Tag, error)
61
62 // Delete removes a tag by ID.
63 Delete(ctx context.Context, id entity.TagID) error
64}