lens @ 1ae70dbd9124675d4a510954619b01edd5f1f6c3

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