- backend: deleting an album moves its photos to the trash without losing files (photos.album_id nullable, FK ON DELETE SET NULL, migration 000006; dropped S3 prefix delete); restore accepts an album target (album_required when the album is gone); user-scoped tags (000007) with GET /tags, POST/DELETE /photos/:id/tags, tags included in photo responses; GET /trash/count - frontend: right-click context menus for photos (grid + viewer) and albums (rail + overview); single shared PhotoPanel reused in viewer and gallery selection (not a copy); viewer download/delete moved to the panel 'Действия'; transparent compact viewer top bar; trash entry as last rail item with per-album photo counts and trash count; album rename/delete dialogs - openspec: sync lightroom-workspace-ui artifacts (specs photos/ui-workspace, design #24-30, tasks 9.17-9.24)
141 lines
4.5 KiB
Go
141 lines
4.5 KiB
Go
package models
|
|
|
|
import "time"
|
|
|
|
type User struct {
|
|
ID string `json:"id"`
|
|
Email string `json:"email"`
|
|
PasswordHash string `json:"-"`
|
|
Name string `json:"name"`
|
|
AvatarURL string `json:"avatar_url,omitempty"`
|
|
Preferences map[string]any `json:"preferences,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type PublicUser struct {
|
|
ID string `json:"id"`
|
|
Email string `json:"email,omitempty"`
|
|
Name string `json:"name"`
|
|
AvatarURL string `json:"avatar_url,omitempty"`
|
|
}
|
|
|
|
func (u *User) Public() PublicUser {
|
|
if u == nil {
|
|
return PublicUser{}
|
|
}
|
|
return PublicUser{ID: u.ID, Email: u.Email, Name: u.Name, AvatarURL: u.AvatarURL}
|
|
}
|
|
|
|
type Album struct {
|
|
ID string `json:"id"`
|
|
OwnerID string `json:"owner_id"`
|
|
Title string `json:"title"`
|
|
Description string `json:"description"`
|
|
CoverPhotoID *string `json:"cover_photo_id,omitempty"`
|
|
CoverThumbKey string `json:"-"`
|
|
CoverThumbURL string `json:"cover_thumb_url,omitempty"`
|
|
PhotosCount int `json:"photos_count"`
|
|
MembersCount int `json:"members_count"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type AlbumMember struct {
|
|
AlbumID string `json:"album_id"`
|
|
UserID string `json:"user_id"`
|
|
Role string `json:"role"`
|
|
InvitedBy *string `json:"invited_by,omitempty"`
|
|
JoinedAt time.Time `json:"joined_at"`
|
|
User PublicUser `json:"user"`
|
|
}
|
|
|
|
type Invite struct {
|
|
ID string `json:"id"`
|
|
AlbumID string `json:"album_id"`
|
|
Token string `json:"token"`
|
|
Role string `json:"role"`
|
|
CreatedBy string `json:"created_by"`
|
|
ExpiresAt time.Time `json:"expires_at"`
|
|
MaxUses int `json:"max_uses"`
|
|
Uses int `json:"uses"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type Photo struct {
|
|
ID string `json:"id"`
|
|
AlbumID string `json:"album_id"`
|
|
UploaderID string `json:"uploader_id"`
|
|
StorageKey string `json:"-"`
|
|
ThumbKey string `json:"-"`
|
|
PreviewKey string `json:"-"`
|
|
OriginalFilename string `json:"original_filename"`
|
|
Size int64 `json:"size"`
|
|
Width int `json:"width"`
|
|
Height int `json:"height"`
|
|
MimeType string `json:"mime_type"`
|
|
TakenAt *time.Time `json:"taken_at,omitempty"`
|
|
Latitude *float64 `json:"latitude,omitempty"`
|
|
Longitude *float64 `json:"longitude,omitempty"`
|
|
Caption string `json:"caption"`
|
|
EXIF map[string]any `json:"exif,omitempty"`
|
|
Tags []Tag `json:"tags,omitempty"`
|
|
DeletedAt *time.Time `json:"deleted_at,omitempty"`
|
|
AlbumTitle string `json:"album_title,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
Uploader PublicUser `json:"uploader"`
|
|
LikesCount int `json:"likes_count"`
|
|
CommentsCount int `json:"comments_count"`
|
|
LikedByMe bool `json:"liked_by_me"`
|
|
ThumbURL string `json:"thumb_url,omitempty"`
|
|
PreviewURL string `json:"preview_url,omitempty"`
|
|
OriginalURL string `json:"original_url,omitempty"`
|
|
DownloadURL string `json:"download_url,omitempty"`
|
|
}
|
|
|
|
type Tag struct {
|
|
ID string `json:"id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
type Comment struct {
|
|
ID string `json:"id"`
|
|
PhotoID string `json:"photo_id"`
|
|
UserID string `json:"user_id"`
|
|
Text string `json:"text"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
User PublicUser `json:"user"`
|
|
}
|
|
|
|
type Notification struct {
|
|
ID string `json:"id"`
|
|
UserID string `json:"user_id"`
|
|
Type string `json:"type"`
|
|
PayloadJSON map[string]any `json:"payload"`
|
|
ReadAt *time.Time `json:"read_at,omitempty"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
}
|
|
|
|
type ShareLink struct {
|
|
ID string `json:"id"`
|
|
AlbumID string `json:"album_id"`
|
|
Token string `json:"token"`
|
|
CreatedBy string `json:"created_by"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
ExpiresAt time.Time `json:"expires_at"`
|
|
RevokedAt *time.Time `json:"revoked_at,omitempty"`
|
|
}
|
|
|
|
func (s *ShareLink) Active(now time.Time) bool {
|
|
return s.RevokedAt == nil && now.Before(s.ExpiresAt)
|
|
}
|
|
|
|
type RefreshToken struct {
|
|
ID string
|
|
UserID string
|
|
TokenHash string
|
|
ExpiresAt time.Time
|
|
RevokedAt *time.Time
|
|
CreatedAt time.Time
|
|
}
|