stash/pkg/models/model_studio.go
DingDongSoLong4 5580525c2d
SQLite model refactoring, part 2 (#3839)
* Treat empty image input as null
* Add validation to models.Date
* Allow zero dates in database
* Make scene_markers.scene_id non-nullable
* Drop scraped_items table
* Remove movie/studio checksum
* Add migration notes
---------
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
2023-07-13 12:15:02 +10:00

56 lines
1.1 KiB
Go

package models
import (
"time"
)
type Studio struct {
ID int `json:"id"`
Name string `json:"name"`
URL string `json:"url"`
ParentID *int `json:"parent_id"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
// Rating expressed in 1-100 scale
Rating *int `json:"rating"`
Details string `json:"details"`
IgnoreAutoTag bool `json:"ignore_auto_tag"`
}
type StudioPartial struct {
Name OptionalString
URL OptionalString
ParentID OptionalInt
CreatedAt OptionalTime
UpdatedAt OptionalTime
// Rating expressed in 1-100 scale
Rating OptionalInt
Details OptionalString
IgnoreAutoTag OptionalBool
}
func NewStudio(name string) *Studio {
currentTime := time.Now()
return &Studio{
Name: name,
CreatedAt: currentTime,
UpdatedAt: currentTime,
}
}
func NewStudioPartial() StudioPartial {
updatedTime := time.Now()
return StudioPartial{
UpdatedAt: NewOptionalTime(updatedTime),
}
}
type Studios []*Studio
func (s *Studios) Append(o interface{}) {
*s = append(*s, o.(*Studio))
}
func (s *Studios) New() interface{} {
return &Studio{}
}