lens @ 6e84441dab0a2b89869e33d7e89d14189d9b67c0

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