mirror of
https://github.com/stashapp/stash.git
synced 2025-12-17 20:34:37 +03:00
* Remove ID from PerformerPartial * Separate studio model from sqlite model * Separate movie model from sqlite model * Separate tag model from sqlite model * Separate saved filter model from sqlite model * Separate scene marker model from sqlite model * Separate gallery chapter model from sqlite model * Move ErrNoRows checks into sqlite, improve empty result error messages * Move SQLiteDate and SQLiteTimestamp to sqlite * Use changesetTranslator everywhere, refactor for consistency * Make PerformerStore.DestroyImage private * Fix rating on movie create
70 lines
2.0 KiB
Go
70 lines
2.0 KiB
Go
package models
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/stashapp/stash/pkg/hash/md5"
|
|
)
|
|
|
|
type Movie struct {
|
|
ID int `json:"id"`
|
|
Checksum string `json:"checksum"`
|
|
Name string `json:"name"`
|
|
Aliases string `json:"aliases"`
|
|
Duration *int `json:"duration"`
|
|
Date *Date `json:"date"`
|
|
// Rating expressed in 1-100 scale
|
|
Rating *int `json:"rating"`
|
|
StudioID *int `json:"studio_id"`
|
|
Director string `json:"director"`
|
|
Synopsis string `json:"synopsis"`
|
|
URL string `json:"url"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
type MoviePartial struct {
|
|
Checksum OptionalString
|
|
Name OptionalString
|
|
Aliases OptionalString
|
|
Duration OptionalInt
|
|
Date OptionalDate
|
|
// Rating expressed in 1-100 scale
|
|
Rating OptionalInt
|
|
StudioID OptionalInt
|
|
Director OptionalString
|
|
Synopsis OptionalString
|
|
URL OptionalString
|
|
CreatedAt OptionalTime
|
|
UpdatedAt OptionalTime
|
|
}
|
|
|
|
var DefaultMovieImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4wgVBQsJl1CMZAAAASJJREFUeNrt3N0JwyAYhlEj3cj9R3Cm5rbkqtAP+qrnGaCYHPwJpLlaa++mmLpbAERAgAgIEAEBIiBABERAgAgIEAEBIiBABERAgAgIEAHZuVflj40x4i94zhk9vqsVvEq6AsQqMP1EjORx20OACAgQRRx7T+zzcFBxcjNDfoB4ntQqTm5Awo7MlqywZxcgYQ+RlqywJ3ozJAQCSBiEJSsQA0gYBpDAgAARECACAkRAgAgIEAERECACAmSjUv6eAOSB8m8YIGGzBUjYbAESBgMkbBkDEjZbgITBAClcxiqQvEoatreYIWEBASIgJ4Gkf11ntXH3nS9uxfGWfJ5J9hAgAgJEQAQEiIAAERAgAgJEQAQEiIAAERAgAgJEQAQEiL7qBuc6RKLHxr0CAAAAAElFTkSuQmCC"
|
|
|
|
func NewMovie(name string) *Movie {
|
|
currentTime := time.Now()
|
|
return &Movie{
|
|
Checksum: md5.FromString(name),
|
|
Name: name,
|
|
CreatedAt: currentTime,
|
|
UpdatedAt: currentTime,
|
|
}
|
|
}
|
|
|
|
func NewMoviePartial() MoviePartial {
|
|
updatedTime := time.Now()
|
|
return MoviePartial{
|
|
UpdatedAt: NewOptionalTime(updatedTime),
|
|
}
|
|
}
|
|
|
|
type Movies []*Movie
|
|
|
|
func (m *Movies) Append(o interface{}) {
|
|
*m = append(*m, o.(*Movie))
|
|
}
|
|
|
|
func (m *Movies) New() interface{} {
|
|
return &Movie{}
|
|
}
|