From 1ae70dbd9124675d4a510954619b01edd5f1f6c3 Mon Sep 17 00:00:00 2001 From: Gabriel Arakaki Giovanini Date: Thu, 29 Jun 2023 23:21:56 +0200 Subject: ref: Move away other repositories Finish moving all repositories to a repository package. This should reduce the amount of packages. --- pkg/database/repository/filesystem.go | 10 ++++++ pkg/database/repository/media.go | 64 +++++++++++++++++++++++++++++++++++ pkg/database/repository/settings.go | 15 ++++++++ 3 files changed, 89 insertions(+) create mode 100644 pkg/database/repository/filesystem.go create mode 100644 pkg/database/repository/media.go create mode 100644 pkg/database/repository/settings.go (limited to 'pkg/database/repository') diff --git a/pkg/database/repository/filesystem.go b/pkg/database/repository/filesystem.go new file mode 100644 index 0000000..f553b3f --- /dev/null +++ b/pkg/database/repository/filesystem.go @@ -0,0 +1,10 @@ +package repository + +import "io/fs" + +type ( + FileSystemRepository interface { + List(path string) ([]fs.FileInfo, error) + Stat(path string) (fs.FileInfo, error) + } +) diff --git a/pkg/database/repository/media.go b/pkg/database/repository/media.go new file mode 100644 index 0000000..2e94ff3 --- /dev/null +++ b/pkg/database/repository/media.go @@ -0,0 +1,64 @@ +package repository + +import ( + "context" + "strings" + "time" +) + +type ( + Media struct { + ID uint + Name string + Path string + PathHash string + MIMEType string + } + + MediaEXIF struct { + Width *float64 + Height *float64 + Description *string + Camera *string + Maker *string + Lens *string + DateShot *time.Time + Exposure *float64 + Aperture *float64 + Iso *int64 + FocalLength *float64 + Flash *int64 + Orientation *int64 + ExposureProgram *int64 + GPSLatitude *float64 + GPSLongitude *float64 + } + + Pagination struct { + Page int + Size int + } + + CreateMedia struct { + Name string + Path string + PathHash string + MIMEType string + } + + MediaRepository interface { + Create(context.Context, *CreateMedia) error + Exists(context.Context, string) (bool, error) + List(context.Context, *Pagination) ([]*Media, error) + Get(context.Context, string) (*Media, error) + GetPath(context.Context, string) (string, error) + + GetEmptyEXIF(context.Context, *Pagination) ([]*Media, error) + GetEXIF(context.Context, uint) (*MediaEXIF, error) + CreateEXIF(context.Context, uint, *MediaEXIF) error + } +) + +func (m *Media) IsVideo() bool { + return strings.HasPrefix(m.MIMEType, "video") +} diff --git a/pkg/database/repository/settings.go b/pkg/database/repository/settings.go new file mode 100644 index 0000000..6ed1eb6 --- /dev/null +++ b/pkg/database/repository/settings.go @@ -0,0 +1,15 @@ +package repository + +import "context" + +type ( + Settings struct { + ShowMode bool + ShowOwner bool + } + + SettingsRepository interface { + Save(context.Context, *Settings) error + Load(context.Context) (*Settings, error) + } +) -- cgit v1.2.3