Documentation
¶
Index ¶
- type Admin
- type ApiKey
- type Artist
- type Artwork
- func (a *Artwork) BeforeCreate(tx *gorm.DB) (err error)
- func (a *Artwork) GetArtist() shared.ArtistLike
- func (a *Artwork) GetDescription() string
- func (a *Artwork) GetID() string
- func (a *Artwork) GetPictures() []shared.PictureLike
- func (a *Artwork) GetR18() bool
- func (a *Artwork) GetSourceURL() string
- func (a *Artwork) GetTags() []string
- func (a *Artwork) GetTagsWithAlias() []string
- func (a *Artwork) GetTitle() string
- func (a *Artwork) GetType() shared.SourceType
- func (a *Artwork) GetUgoiraMetas() []shared.UgoiraMetaLike
- type CachedArtist
- type CachedArtwork
- func (c *CachedArtwork) BeforeCreate(tx *gorm.DB) (err error)
- func (c *CachedArtwork) GetArtist() shared.ArtistLike
- func (c *CachedArtwork) GetDescription() string
- func (c *CachedArtwork) GetID() string
- func (c *CachedArtwork) GetPictures() []shared.PictureLike
- func (c *CachedArtwork) GetR18() bool
- func (c *CachedArtwork) GetSourceURL() string
- func (c *CachedArtwork) GetTags() []string
- func (c *CachedArtwork) GetTitle() string
- func (c *CachedArtwork) GetType() shared.SourceType
- func (c *CachedArtwork) GetUgoiraMetas() []shared.UgoiraMetaLike
- type CachedArtworkData
- func (c *CachedArtworkData) GetArtist() shared.ArtistLike
- func (c *CachedArtworkData) GetDescription() string
- func (c *CachedArtworkData) GetID() string
- func (c *CachedArtworkData) GetPictures() []shared.PictureLike
- func (c *CachedArtworkData) GetR18() bool
- func (c *CachedArtworkData) GetSourceURL() string
- func (c *CachedArtworkData) GetTags() []string
- func (c *CachedArtworkData) GetTitle() string
- func (c *CachedArtworkData) GetType() shared.SourceType
- func (c *CachedArtworkData) GetUgoiraMetas() []shared.UgoiraMetaLike
- func (c *CachedArtworkData) GetViewablePictures() []*CachedPicture
- type CachedPicture
- func (c *CachedPicture) GetIndex() uint
- func (c *CachedPicture) GetOriginal() string
- func (c *CachedPicture) GetSize() (width uint, height uint)
- func (c *CachedPicture) GetStorageInfo() shared.StorageInfo
- func (c *CachedPicture) GetTelegramInfo() shared.TelegramInfo
- func (c *CachedPicture) GetThumbnail() string
- func (c *CachedPicture) IsHide() bool
- type CachedUgoiraMeta
- type DeletedRecord
- type Picture
- func (p *Picture) BeforeCreate(tx *gorm.DB) (err error)
- func (p *Picture) GetIndex() uint
- func (p *Picture) GetOriginal() string
- func (p *Picture) GetSize() (width uint, height uint)
- func (p *Picture) GetStorageInfo() shared.StorageInfo
- func (p *Picture) GetTelegramInfo() shared.TelegramInfo
- func (p *Picture) GetThumbnail() string
- func (p *Picture) IsHide() bool
- type Tag
- type TagAlias
- type UgoiraMeta
- type User
- type UserSettings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Admin ¶
type Admin struct {
ID objectuuid.ObjectUUID `gorm:"primaryKey;type:uuid" json:"id"`
TelegramID int64 `gorm:"index" json:"telegram_id"`
Permissions datatypes.JSONSlice[shared.Permission] `json:"permissions"`
}
func (*Admin) HasPermission ¶
func (a *Admin) HasPermission(perm shared.Permission) bool
type ApiKey ¶
type ApiKey struct {
ID objectuuid.ObjectUUID `gorm:"primaryKey;type:uuid" json:"id"`
Key string `gorm:"type:text;not null;uniqueIndex" json:"key"`
Quota int `gorm:"not null;default:0" json:"quota"`
Used int `gorm:"not null;default:0" json:"used"`
Permissions datatypes.JSONSlice[shared.Permission] `gorm:"type:json" json:"permissions"`
Description string `gorm:"type:text" json:"description"`
}
func (*ApiKey) HasPermission ¶
func (a *ApiKey) HasPermission(p shared.Permission) bool
type Artist ¶
type Artist struct {
ID objectuuid.ObjectUUID `gorm:"primaryKey;type:uuid" json:"id"`
Name string `gorm:"type:text;not null;index" json:"name"`
Type shared.SourceType `gorm:"type:text;not null;index" json:"type"`
UID string `gorm:"type:text;not null;index" json:"uid"`
Username string `gorm:"type:text;not null;index" json:"username"`
// reverse relation
Artworks []*Artwork `gorm:"foreignKey:ArtistID" json:"-"` // json ignore to avoid circular reference
}
func (*Artist) GetUserName ¶
GetUserName implements shared.ArtistLike.
type Artwork ¶
type Artwork struct {
// keep ObjectID as 24-hex string
ID objectuuid.ObjectUUID `gorm:"primaryKey;type:uuid" json:"id"`
Title string `gorm:"type:text;not null;index:idx_artwork_title,sort:asc" json:"title"`
Description string `gorm:"type:text" json:"description"`
R18 bool `gorm:"not null;default:false;index:idx_artwork_r18" json:"r18"`
CreatedAt time.Time `gorm:"not null;autoCreateTime;index:idx_artwork_created_at,sort:desc" json:"created_at"`
UpdatedAt time.Time `gorm:"not null;autoUpdateTime" json:"updated_at"`
SourceType shared.SourceType `gorm:"type:text;not null;index:idx_artwork_source_type" json:"source_type"`
SourceURL string `gorm:"type:text;not null;uniqueIndex" json:"source_url"`
LikeCount uint `gorm:"not null;default:0" json:"like_count"`
ArtistID objectuuid.ObjectUUID `gorm:"type:uuid;index" json:"artist_id"`
Artist *Artist `gorm:"foreignKey:ArtistID;references:ID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL" json:"artist"`
// many2many relationship with tags
Tags []*Tag `gorm:"many2many:artwork_tags;constraint:OnDelete:CASCADE" json:"tags"`
// one-to-many pictures
Pictures []*Picture `gorm:"foreignKey:ArtworkID;constraint:OnDelete:CASCADE" json:"pictures"`
// https://www.pixiv.help/hc/en-us/articles/235584628-What-are-Ugoira
// one-to-many ugoira meta, usually only one
UgoiraMetas []*UgoiraMeta `gorm:"foreignKey:ArtworkID;constraint:OnDelete:CASCADE" json:"ugoira_meta,omitempty"`
}
func (*Artwork) GetArtist ¶
func (a *Artwork) GetArtist() shared.ArtistLike
GetArtist implements ArtworkLike.
func (*Artwork) GetDescription ¶
GetDescription implements ArtworkLike.
func (*Artwork) GetPictures ¶
func (a *Artwork) GetPictures() []shared.PictureLike
GetPictures implements ArtworkLike.
func (*Artwork) GetSourceURL ¶
GetSourceURL implements ArtworkLike.
func (*Artwork) GetTagsWithAlias ¶
func (*Artwork) GetType ¶
func (a *Artwork) GetType() shared.SourceType
GetType implements shared.ArtworkLike.
func (*Artwork) GetUgoiraMetas ¶
func (a *Artwork) GetUgoiraMetas() []shared.UgoiraMetaLike
GetUgoiraMetas implements shared.UgoiraArtworkLike.
type CachedArtist ¶
type CachedArtist struct {
ID string `json:"id"`
Name string `json:"name"`
Type shared.SourceType `json:"type"`
UID string `json:"uid"`
Username string `json:"username"`
}
func (*CachedArtist) GetName ¶
func (c *CachedArtist) GetName() string
GetName implements shared.ArtistLike.
func (*CachedArtist) GetUID ¶
func (c *CachedArtist) GetUID() string
GetUID implements shared.ArtistLike.
func (*CachedArtist) GetUserName ¶
func (c *CachedArtist) GetUserName() string
GetUserName implements shared.ArtistLike.
type CachedArtwork ¶
type CachedArtwork struct {
ID objectuuid.ObjectUUID `gorm:"primaryKey;type:uuid" json:"id"`
SourceURL string `gorm:"type:text;uniqueIndex" json:"source_url"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
Artwork datatypes.JSONType[*CachedArtworkData] `gorm:"type:json" json:"artwork"`
Status shared.ArtworkStatus `gorm:"type:text;index" json:"status"`
}
func (*CachedArtwork) BeforeCreate ¶
func (c *CachedArtwork) BeforeCreate(tx *gorm.DB) (err error)
func (*CachedArtwork) GetArtist ¶
func (c *CachedArtwork) GetArtist() shared.ArtistLike
GetArtist implements ArtworkLike.
func (*CachedArtwork) GetDescription ¶
func (c *CachedArtwork) GetDescription() string
GetDescription implements ArtworkLike.
func (*CachedArtwork) GetID ¶
func (c *CachedArtwork) GetID() string
func (*CachedArtwork) GetPictures ¶
func (c *CachedArtwork) GetPictures() []shared.PictureLike
GetPictures implements ArtworkLike.
func (*CachedArtwork) GetR18 ¶
func (c *CachedArtwork) GetR18() bool
func (*CachedArtwork) GetSourceURL ¶
func (c *CachedArtwork) GetSourceURL() string
GetSourceURL implements ArtworkLike.
func (*CachedArtwork) GetTags ¶
func (c *CachedArtwork) GetTags() []string
GetTags implements ArtworkLike.
func (*CachedArtwork) GetTitle ¶
func (c *CachedArtwork) GetTitle() string
GetTitle implements ArtworkLike.
func (*CachedArtwork) GetType ¶
func (c *CachedArtwork) GetType() shared.SourceType
GetType implements shared.ArtworkLike.
func (*CachedArtwork) GetUgoiraMetas ¶
func (c *CachedArtwork) GetUgoiraMetas() []shared.UgoiraMetaLike
GetUgoiraMetas implements shared.UgoiraArtworkLike.
type CachedArtworkData ¶
type CachedArtworkData struct {
ID string `json:"id"`
Title string `json:"title"`
Description string `json:"description"`
R18 bool `json:"r18"`
SourceType shared.SourceType `json:"source_type"`
SourceURL string `json:"source_url"`
Artist *CachedArtist `json:"artist"`
Tags []string `json:"tags"`
Pictures []*CachedPicture `json:"pictures"`
UgoiraMetas []*CachedUgoiraMeta `json:"ugoira_metas,omitempty"`
Version int `json:"version"` // for future schema changes
}
func (*CachedArtworkData) GetArtist ¶
func (c *CachedArtworkData) GetArtist() shared.ArtistLike
GetArtist implements ArtworkLike.
func (*CachedArtworkData) GetDescription ¶
func (c *CachedArtworkData) GetDescription() string
GetDescription implements ArtworkLike.
func (*CachedArtworkData) GetID ¶
func (c *CachedArtworkData) GetID() string
func (*CachedArtworkData) GetPictures ¶
func (c *CachedArtworkData) GetPictures() []shared.PictureLike
GetPictures implements ArtworkLike.
func (*CachedArtworkData) GetR18 ¶
func (c *CachedArtworkData) GetR18() bool
GetR18 implements ArtworkLike.
func (*CachedArtworkData) GetSourceURL ¶
func (c *CachedArtworkData) GetSourceURL() string
GetSourceURL implements ArtworkLike.
func (*CachedArtworkData) GetTags ¶
func (c *CachedArtworkData) GetTags() []string
GetTags implements ArtworkLike.
func (*CachedArtworkData) GetTitle ¶
func (c *CachedArtworkData) GetTitle() string
GetTitle implements ArtworkLike.
func (*CachedArtworkData) GetType ¶
func (c *CachedArtworkData) GetType() shared.SourceType
func (*CachedArtworkData) GetUgoiraMetas ¶
func (c *CachedArtworkData) GetUgoiraMetas() []shared.UgoiraMetaLike
GetUgoiraMetas implements shared.UgoiraArtworkLike.
func (*CachedArtworkData) GetViewablePictures ¶
func (c *CachedArtworkData) GetViewablePictures() []*CachedPicture
type CachedPicture ¶
type CachedPicture struct {
ID string `json:"id"`
ArtworkID string `json:"artwork_id"`
OrderIndex uint `json:"index"`
Thumbnail string `json:"thumbnail"`
Original string `json:"original"`
Hidden bool `json:"hidden"` // 设为 true 时不发布到 Artwork 中, 但仍在其他接口中返回
Width uint `json:"width"`
Height uint `json:"height"`
Phash string `json:"phash"` // phash
ThumbHash string `json:"thumb_hash"` // thumbhash
StorageInfo shared.StorageInfo `json:"storage_info"`
TelegramInfo shared.TelegramInfo `json:"telegram_info"`
}
func (*CachedPicture) GetIndex ¶
func (c *CachedPicture) GetIndex() uint
GetIndex implements PictureLike.
func (*CachedPicture) GetOriginal ¶
func (c *CachedPicture) GetOriginal() string
GetOriginal implements PictureLike.
func (*CachedPicture) GetSize ¶
func (c *CachedPicture) GetSize() (width uint, height uint)
GetSize implements PictureLike.
func (*CachedPicture) GetStorageInfo ¶
func (c *CachedPicture) GetStorageInfo() shared.StorageInfo
GetStorageInfo implements PictureLike.
func (*CachedPicture) GetTelegramInfo ¶
func (c *CachedPicture) GetTelegramInfo() shared.TelegramInfo
GetTelegramInfo implements PictureLike.
func (*CachedPicture) GetThumbnail ¶
func (c *CachedPicture) GetThumbnail() string
GetThumbnail implements PictureLike.
type CachedUgoiraMeta ¶
type CachedUgoiraMeta struct {
ID string `json:"id"`
ArtworkID string `json:"artwork_id"`
OrderIndex uint `json:"index"`
MetaData shared.UgoiraMetaData `json:"data"`
OriginalStorage shared.StorageDetail `json:"original_storage"`
TelegramInfo shared.TelegramInfo `json:"telegram_info"`
}
func (*CachedUgoiraMeta) GetIndex ¶
func (c *CachedUgoiraMeta) GetIndex() uint
GetIndex implements shared.UgoiraMetaLike.
func (*CachedUgoiraMeta) GetOriginalStorage ¶
func (c *CachedUgoiraMeta) GetOriginalStorage() shared.StorageDetail
GetOriginalStorage implements shared.UgoiraMetaLike.
func (*CachedUgoiraMeta) GetTelegramInfo ¶
func (c *CachedUgoiraMeta) GetTelegramInfo() shared.TelegramInfo
GetTelegramInfo implements shared.UgoiraMetaLike.
func (*CachedUgoiraMeta) GetUgoiraMetaData ¶
func (c *CachedUgoiraMeta) GetUgoiraMetaData() shared.UgoiraMetaData
GetUgoiraMetaData implements shared.UgoiraMetaLike.
type DeletedRecord ¶
type DeletedRecord struct {
ID objectuuid.ObjectUUID `gorm:"primaryKey;type:uuid" json:"id"`
SourceURL string `gorm:"type:text;not null;uniqueIndex" json:"source_url"`
DeletedAt time.Time `gorm:"not null;autoCreateTime" json:"deleted_at"`
}
func (*DeletedRecord) BeforeCreate ¶
func (d *DeletedRecord) BeforeCreate(tx *gorm.DB) (err error)
type Picture ¶
type Picture struct {
ID objectuuid.ObjectUUID `gorm:"primaryKey;type:uuid" json:"id"`
ArtworkID objectuuid.ObjectUUID `gorm:"type:uuid;index" json:"artwork_id"`
Artwork *Artwork `gorm:"foreignKey:ArtworkID;references:ID;constraint:OnDelete:CASCADE" json:"-"`
OrderIndex uint `gorm:"column:order_index;not null;default:0;index:idx_picture_artwork_index,priority:1" json:"index"`
Thumbnail string `gorm:"type:text" json:"thumbnail"`
Original string `gorm:"type:text;index" json:"original"`
Width uint `json:"width"`
Height uint `json:"height"`
Phash string `gorm:"type:text;index" json:"phash"` // phash
ThumbHash string `gorm:"type:text" json:"thumb_hash"` // thumbhash
TelegramInfo datatypes.JSONType[shared.TelegramInfo] `json:"telegram_info"`
StorageInfo datatypes.JSONType[shared.StorageInfo] `json:"storage_info"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
}
func (*Picture) GetOriginal ¶
GetOriginal implements PictureLike.
func (*Picture) GetStorageInfo ¶
func (p *Picture) GetStorageInfo() shared.StorageInfo
GetStorageInfo implements PictureLike.
func (*Picture) GetTelegramInfo ¶
func (p *Picture) GetTelegramInfo() shared.TelegramInfo
GetTelegramInfo implements PictureLike.
func (*Picture) GetThumbnail ¶
GetThumbnail implements PictureLike.
type Tag ¶
type Tag struct {
ID objectuuid.ObjectUUID `gorm:"primaryKey;type:uuid" json:"id"`
Name string `gorm:"type:text;not null;uniqueIndex" json:"name"`
Alias []TagAlias `gorm:"foreignKey:TagID;constraint:OnDelete:CASCADE" json:"alias"` // one-to-many relation
// reverse relation via many2many
Artworks []*Artwork `gorm:"many2many:artwork_tags" json:"-"`
}
type TagAlias ¶
type TagAlias struct {
ID objectuuid.ObjectUUID `gorm:"primaryKey;type:uuid" json:"id"`
TagID objectuuid.ObjectUUID `gorm:"type:uuid;index" json:"tag_id"`
Alias string `gorm:"type:text;not null;index" json:"alias"`
}
type UgoiraMeta ¶
type UgoiraMeta struct {
ID objectuuid.ObjectUUID `gorm:"primaryKey;type:uuid" json:"id"`
ArtworkID objectuuid.ObjectUUID `gorm:"type:uuid;index" json:"artwork_id"`
Artwork *Artwork `gorm:"foreignKey:ArtworkID;references:ID;constraint:OnDelete:CASCADE" json:"-"`
OrderIndex uint `gorm:"column:order_index;not null;default:0;index:idx_ugoira_artwork_index,priority:1" json:"index"`
Data datatypes.JSONType[shared.UgoiraMetaData] `json:"data"`
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
OriginalStorage datatypes.JSONType[shared.StorageDetail] `json:"original_storage"`
TelegramInfo datatypes.JSONType[shared.TelegramInfo] `json:"telegram_info"`
}
func (*UgoiraMeta) BeforeCreate ¶
func (u *UgoiraMeta) BeforeCreate(tx *gorm.DB) (err error)
func (*UgoiraMeta) GetIndex ¶
func (u *UgoiraMeta) GetIndex() uint
GetIndex implements shared.UgoiraMetaLike.
func (*UgoiraMeta) GetOriginalStorage ¶
func (u *UgoiraMeta) GetOriginalStorage() shared.StorageDetail
GetOriginalStorage implements shared.UgoiraMetaLike.
func (*UgoiraMeta) GetTelegramInfo ¶
func (u *UgoiraMeta) GetTelegramInfo() shared.TelegramInfo
GetTelegramInfo implements shared.UgoiraMetaLike.
func (*UgoiraMeta) GetUgoiraMetaData ¶
func (u *UgoiraMeta) GetUgoiraMetaData() shared.UgoiraMetaData
GetUgoiraMetaData implements shared.UgoiraMetaLike.
type User ¶
type User struct {
ID objectuuid.ObjectUUID `gorm:"primaryKey;type:uuid" json:"id"`
Username string `gorm:"type:text;uniqueIndex" json:"username"`
Password string `gorm:"type:text;not null" json:"password"`
Email *string `gorm:"type:text;uniqueIndex" json:"email"`
TelegramID *int64 `gorm:"type:bigint;uniqueIndex" json:"telegram_id"`
Blocked bool `gorm:"not null;default:false;index" json:"blocked"`
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"deleted_at"`
Favorites []*Artwork `gorm:"many2many:user_favorites;constraint:OnDelete:CASCADE" json:"favorites"`
Settings datatypes.JSONType[*UserSettings] `gorm:"type:json" json:"settings"`
}