2020-09-15 07:28:53 +00:00
|
|
|
package models
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/jmoiron/sqlx"
|
|
|
|
)
|
|
|
|
|
|
|
|
type GalleryReader interface {
|
|
|
|
// Find(id int) (*Gallery, error)
|
|
|
|
FindMany(ids []int) ([]*Gallery, error)
|
2020-09-20 08:36:02 +00:00
|
|
|
FindByChecksum(checksum string) (*Gallery, error)
|
|
|
|
FindByPath(path string) (*Gallery, error)
|
2020-09-15 07:28:53 +00:00
|
|
|
FindBySceneID(sceneID int) (*Gallery, error)
|
2020-10-12 23:12:46 +00:00
|
|
|
FindByImageID(imageID int) ([]*Gallery, error)
|
2020-09-15 07:28:53 +00:00
|
|
|
// ValidGalleriesForScenePath(scenePath string) ([]*Gallery, error)
|
|
|
|
// Count() (int, error)
|
|
|
|
All() ([]*Gallery, error)
|
|
|
|
// Query(galleryFilter *GalleryFilterType, findFilter *FindFilterType) ([]*Gallery, int)
|
|
|
|
}
|
|
|
|
|
|
|
|
type GalleryWriter interface {
|
2020-09-20 08:36:02 +00:00
|
|
|
Create(newGallery Gallery) (*Gallery, error)
|
|
|
|
Update(updatedGallery Gallery) (*Gallery, error)
|
2020-09-15 07:28:53 +00:00
|
|
|
// Destroy(id int) error
|
|
|
|
// ClearGalleryId(sceneID int) error
|
|
|
|
}
|
|
|
|
|
|
|
|
type GalleryReaderWriter interface {
|
|
|
|
GalleryReader
|
|
|
|
GalleryWriter
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewGalleryReaderWriter(tx *sqlx.Tx) GalleryReaderWriter {
|
|
|
|
return &galleryReaderWriter{
|
|
|
|
tx: tx,
|
|
|
|
qb: NewGalleryQueryBuilder(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
type galleryReaderWriter struct {
|
|
|
|
tx *sqlx.Tx
|
|
|
|
qb GalleryQueryBuilder
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *galleryReaderWriter) FindMany(ids []int) ([]*Gallery, error) {
|
|
|
|
return t.qb.FindMany(ids)
|
|
|
|
}
|
|
|
|
|
2020-09-20 08:36:02 +00:00
|
|
|
func (t *galleryReaderWriter) FindByChecksum(checksum string) (*Gallery, error) {
|
|
|
|
return t.qb.FindByChecksum(checksum, t.tx)
|
|
|
|
}
|
|
|
|
|
2020-09-15 07:28:53 +00:00
|
|
|
func (t *galleryReaderWriter) All() ([]*Gallery, error) {
|
|
|
|
return t.qb.All()
|
|
|
|
}
|
|
|
|
|
2020-09-20 08:36:02 +00:00
|
|
|
func (t *galleryReaderWriter) FindByPath(path string) (*Gallery, error) {
|
|
|
|
return t.qb.FindByPath(path)
|
|
|
|
}
|
|
|
|
|
2020-09-15 07:28:53 +00:00
|
|
|
func (t *galleryReaderWriter) FindBySceneID(sceneID int) (*Gallery, error) {
|
|
|
|
return t.qb.FindBySceneID(sceneID, t.tx)
|
|
|
|
}
|
2020-09-20 08:36:02 +00:00
|
|
|
|
2020-10-12 23:12:46 +00:00
|
|
|
func (t *galleryReaderWriter) FindByImageID(imageID int) ([]*Gallery, error) {
|
|
|
|
return t.qb.FindByImageID(imageID, t.tx)
|
|
|
|
}
|
|
|
|
|
2020-09-20 08:36:02 +00:00
|
|
|
func (t *galleryReaderWriter) Create(newGallery Gallery) (*Gallery, error) {
|
|
|
|
return t.qb.Create(newGallery, t.tx)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *galleryReaderWriter) Update(updatedGallery Gallery) (*Gallery, error) {
|
|
|
|
return t.qb.Update(updatedGallery, t.tx)
|
|
|
|
}
|