Added better archive functionalty (backend side atm)
Code refactoring
This commit is contained in:
51
server/archive/domain/archive.go
Normal file
51
server/archive/domain/archive.go
Normal file
@@ -0,0 +1,51 @@
|
||||
package domain
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
"github.com/marcopeocchi/yt-dlp-web-ui/v3/server/archive/data"
|
||||
)
|
||||
|
||||
type ArchiveEntry struct {
|
||||
Id string `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Path string `json:"path"`
|
||||
Thumbnail string `json:"thumbnail"`
|
||||
Source string `json:"source"`
|
||||
Metadata string `json:"metadata"`
|
||||
CreatedAt time.Time `json:"created_at"`
|
||||
}
|
||||
|
||||
type PaginatedResponse[T any] struct {
|
||||
First int64 `json:"first"`
|
||||
Next int64 `json:"next"`
|
||||
Data T `json:"data"`
|
||||
}
|
||||
|
||||
type Repository interface {
|
||||
Archive(ctx context.Context, model *data.ArchiveEntry) error
|
||||
SoftDelete(ctx context.Context, id string) (*data.ArchiveEntry, error)
|
||||
HardDelete(ctx context.Context, id string) (*data.ArchiveEntry, error)
|
||||
List(ctx context.Context, startRowId int, limit int) (*[]data.ArchiveEntry, error)
|
||||
GetCursor(ctx context.Context, id string) (int64, error)
|
||||
}
|
||||
|
||||
type Service interface {
|
||||
Archive(ctx context.Context, entity *ArchiveEntry) error
|
||||
SoftDelete(ctx context.Context, id string) (*ArchiveEntry, error)
|
||||
HardDelete(ctx context.Context, id string) (*ArchiveEntry, error)
|
||||
List(ctx context.Context, startRowId int, limit int) (*PaginatedResponse[[]ArchiveEntry], error)
|
||||
GetCursor(ctx context.Context, id string) (int64, error)
|
||||
}
|
||||
|
||||
type RestHandler interface {
|
||||
List() http.HandlerFunc
|
||||
Archive() http.HandlerFunc
|
||||
SoftDelete() http.HandlerFunc
|
||||
HardDelete() http.HandlerFunc
|
||||
GetCursor() http.HandlerFunc
|
||||
ApplyRouter() func(chi.Router)
|
||||
}
|
||||
Reference in New Issue
Block a user