lens @ f99f2bc94808d784c92ec4e58c660a8be3ed7fce

 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	}
40
41	MediaThumbnail struct {
42		Path string
43	}
44
45	Pagination struct {
46		Page int
47		Size int
48		Path string
49	}
50
51	CreateMedia struct {
52		Name     string
53		Path     string
54		PathHash string
55		MIMEType string
56	}
57
58	CreateAlbum struct {
59		ParentID *uint
60		Name     string
61		Path     string
62	}
63
64	CreateAlbumFile struct {
65		MediaID uint
66		AlbumID uint
67	}
68
69	MediaRepository interface {
70		Create(context.Context, *CreateMedia) error
71		Exists(context.Context, string) (bool, error)
72		List(context.Context, *Pagination) ([]*Media, error)
73		Get(context.Context, string) (*Media, error)
74		GetPath(context.Context, string) (string, error)
75		GetThumbnailPath(context.Context, string) (string, error)
76
77		ListEmptyEXIF(context.Context, *Pagination) ([]*Media, error)
78		GetEXIF(context.Context, uint) (*MediaEXIF, error)
79		CreateEXIF(context.Context, uint, *MediaEXIF) error
80
81		ListEmptyThumbnail(context.Context, *Pagination) ([]*Media, error)
82		GetThumbnail(context.Context, uint) (*MediaThumbnail, error)
83		CreateThumbnail(context.Context, uint, *MediaThumbnail) error
84
85		ListEmptyAlbums(context.Context, *Pagination) ([]*Media, error)
86		ExistsAlbumByAbsolutePath(context.Context, string) (bool, error)
87		GetAlbumByAbsolutePath(context.Context, string) (*Album, error)
88		CreateAlbum(context.Context, *CreateAlbum) (*Album, error)
89		CreateAlbumFile(context.Context, *CreateAlbumFile) error
90	}
91)
92
93func (m *Media) IsVideo() bool {
94	return strings.HasPrefix(m.MIMEType, "video")
95}