lens @ ff6b55491dec7ad1973dda37a35e2d9f47f75bcb

 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	MediaThumbnail struct {
38		Path string
39	}
40
41	Pagination struct {
42		Page int
43		Size int
44		Path string
45	}
46
47	CreateMedia struct {
48		Name     string
49		Path     string
50		PathHash string
51		MIMEType string
52	}
53
54	MediaRepository interface {
55		Create(context.Context, *CreateMedia) error
56		Exists(context.Context, string) (bool, error)
57		List(context.Context, *Pagination) ([]*Media, error)
58		Get(context.Context, string) (*Media, error)
59		GetPath(context.Context, string) (string, error)
60		GetThumbnailPath(context.Context, string) (string, error)
61
62		ListEmptyEXIF(context.Context, *Pagination) ([]*Media, error)
63		GetEXIF(context.Context, uint) (*MediaEXIF, error)
64		CreateEXIF(context.Context, uint, *MediaEXIF) error
65
66		ListEmptyThumbnail(context.Context, *Pagination) ([]*Media, error)
67		GetThumbnail(context.Context, uint) (*MediaThumbnail, error)
68		CreateThumbnail(context.Context, uint, *MediaThumbnail) error
69	}
70)
71
72func (m *Media) IsVideo() bool {
73	return strings.HasPrefix(m.MIMEType, "video")
74}