lens @ 752ee7db471f3d5368f30a5841d5286465a8d5ab

  1package repository
  2
  3import (
  4	"context"
  5	"strings"
  6	"time"
  7)
  8
  9type (
 10	Media struct {
 11		ID       uint
 12		Name     string
 13		Path     string
 14		PathHash string
 15		MIMEType string
 16	}
 17
 18	MediaEXIF struct {
 19		Width           *float64
 20		Height          *float64
 21		Description     *string
 22		Camera          *string
 23		Maker           *string
 24		Lens            *string
 25		DateShot        *time.Time
 26		Exposure        *float64
 27		Aperture        *float64
 28		Iso             *int64
 29		FocalLength     *float64
 30		Flash           *int64
 31		Orientation     *int64
 32		ExposureProgram *int64
 33		GPSLatitude     *float64
 34		GPSLongitude    *float64
 35	}
 36
 37	Album struct {
 38		ID   uint
 39		Name string
 40		Path string
 41	}
 42
 43	MediaThumbnail struct {
 44		Path string
 45	}
 46
 47	Pagination struct {
 48		Page    int
 49		Size    int
 50		AlbumID *uint
 51		Path    string
 52	}
 53
 54	CreateMedia struct {
 55		Name     string
 56		Path     string
 57		PathHash string
 58		MIMEType string
 59	}
 60
 61	CreateAlbum struct {
 62		ParentID *uint
 63		Name     string
 64		Path     string
 65	}
 66
 67	CreateAlbumFile struct {
 68		MediaID uint
 69		AlbumID uint
 70	}
 71
 72	MediaRepository interface {
 73		Create(context.Context, *CreateMedia) error
 74		Exists(context.Context, string) (bool, error)
 75		List(context.Context, *Pagination) ([]*Media, error)
 76		Get(context.Context, string) (*Media, error)
 77		GetPath(context.Context, string) (string, error)
 78		GetThumbnailPath(context.Context, string) (string, error)
 79
 80		ListEmptyEXIF(context.Context, *Pagination) ([]*Media, error)
 81		GetEXIF(context.Context, uint) (*MediaEXIF, error)
 82		CreateEXIF(context.Context, uint, *MediaEXIF) error
 83
 84		ListEmptyThumbnail(context.Context, *Pagination) ([]*Media, error)
 85		GetThumbnail(context.Context, uint) (*MediaThumbnail, error)
 86		CreateThumbnail(context.Context, uint, *MediaThumbnail) error
 87
 88		ListEmptyAlbums(context.Context, *Pagination) ([]*Media, error)
 89		ListAlbums(context.Context, uint) ([]*Album, error)
 90		ExistsAlbumByAbsolutePath(context.Context, string) (bool, error)
 91		GetAlbumByAbsolutePath(context.Context, string) (*Album, error)
 92		GetAlbum(context.Context, uint) (*Album, error)
 93		CreateAlbum(context.Context, *CreateAlbum) (*Album, error)
 94		CreateAlbumFile(context.Context, *CreateAlbumFile) error
 95	}
 96)
 97
 98func (m *Media) IsVideo() bool {
 99	return strings.HasPrefix(m.MIMEType, "video")
100}