Better implementation of Bookmarks, using its own table

This commit is contained in:
Deluan
2020-08-01 12:17:06 -04:00
parent 23d69d26e0
commit ed726c2126
17 changed files with 362 additions and 186 deletions
+28
View File
@@ -0,0 +1,28 @@
package model
import "time"
type Bookmarkable struct {
BookmarkPosition int64 `json:"bookmarkPosition"`
}
type BookmarkableRepository interface {
AddBookmark(id, comment string, position int64) error
DeleteBookmark(id string) error
GetBookmarks() (Bookmarks, error)
}
type Bookmark struct {
Item MediaFile `json:"item"`
Comment string `json:"comment"`
Position int64 `json:"position"`
ChangedBy string `json:"changed_by"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
type Bookmarks []Bookmark
// While I can't find a better way to make these fields optional in the models, I keep this list here
// to be used in other packages
var BookmarkFields = []string{"bookmarkPosition"}
+2
View File
@@ -7,6 +7,7 @@ import (
type MediaFile struct {
Annotations
Bookmarkable
ID string `json:"id" orm:"pk;column(id)"`
Path string `json:"path"`
@@ -63,6 +64,7 @@ type MediaFileRepository interface {
DeleteByPath(path string) (int64, error)
AnnotatedRepository
BookmarkableRepository
}
func (mf MediaFile) GetAnnotations() Annotations {
-14
View File
@@ -7,7 +7,6 @@ import (
type PlayQueue struct {
ID string `json:"id" orm:"column(id)"`
UserID string `json:"userId" orm:"column(user_id)"`
Comment string `json:"comment"`
Current string `json:"current"`
Position int64 `json:"position"`
ChangedBy string `json:"changedBy"`
@@ -21,17 +20,4 @@ type PlayQueues []PlayQueue
type PlayQueueRepository interface {
Store(queue *PlayQueue) error
Retrieve(userId string) (*PlayQueue, error)
AddBookmark(userId, id, comment string, position int64) error
GetBookmarks(userId string) (Bookmarks, error)
DeleteBookmark(userId, id string) error
}
type Bookmark struct {
Item MediaFile `json:"item"`
Comment string `json:"comment"`
Position int64 `json:"position"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
}
type Bookmarks []Bookmark