- Add go.mod (module tanabata/backend, Go 1.21) with uuid dependency - Implement internal/domain: File, Tag, TagRule, Category, Pool, PoolFile, User, Session, Permission, ObjectType, AuditEntry + all pagination types - Add domain error sentinels (ErrNotFound, ErrForbidden, etc.) - Add context helpers WithUser/UserFromContext for JWT propagation - Fix migration: remove redundant DEFAULT on exif jsonb column Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
55 lines
1.2 KiB
Go
55 lines
1.2 KiB
Go
package domain
|
|
|
|
import (
|
|
"encoding/json"
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
// MIMEType holds MIME whitelist data.
|
|
type MIMEType struct {
|
|
ID int16
|
|
Name string
|
|
Extension string
|
|
}
|
|
|
|
// File represents a managed file record.
|
|
type File struct {
|
|
ID uuid.UUID
|
|
OriginalName *string
|
|
MIMEType string // denormalized from core.mime_types
|
|
MIMEExtension string // denormalized from core.mime_types
|
|
ContentDatetime time.Time
|
|
Notes *string
|
|
Metadata json.RawMessage
|
|
EXIF json.RawMessage
|
|
PHash *int64
|
|
CreatorID int16
|
|
CreatorName string // denormalized from core.users
|
|
IsPublic bool
|
|
IsDeleted bool
|
|
CreatedAt time.Time // extracted from UUID v7
|
|
Tags []Tag // loaded with the file
|
|
}
|
|
|
|
// FileListParams holds all parameters for listing/filtering files.
|
|
type FileListParams struct {
|
|
Filter string
|
|
Sort string
|
|
Order string
|
|
Cursor string
|
|
Anchor *uuid.UUID
|
|
Direction string // "forward" or "backward"
|
|
Limit int
|
|
Trash bool
|
|
Search string
|
|
}
|
|
|
|
// FilePage is the result of a cursor-based file listing.
|
|
type FilePage struct {
|
|
Items []File
|
|
NextCursor *string
|
|
PrevCursor *string
|
|
}
|