Documentation
¶
Index ¶
- func FromIDMap[T hasID](m map[int]T) []T
- func Keys[T comparable, U any](m map[T]U) []T
- func ToIDMap[T hasID](objs []T) map[int]T
- func ToIDs[T hasID](objs []T) []int
- func ToKeyMap[T hasKey](objs []T) map[string]T
- func Values[T comparable, U any](m map[T]U) []U
- func ValuesFlatten[T comparable, U comparable](m map[T][]U) []U
- type Casts
- type Character
- type CharacterSummary
- type Collection
- type CollectionGroup
- type Credits
- type IntSlice
- type Object
- type Person
- type PersonSummary
- type PersonSummaryByType
- type Request
- type Response
- type Sequel
- type Statistics
- type StatsEntity
- type StringSlice
- type Subject
- type SubjectSummary
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Keys ¶
func Keys[T comparable, U any](m map[T]U) []T
func Values ¶
func Values[T comparable, U any](m map[T]U) []U
func ValuesFlatten ¶
func ValuesFlatten[T comparable, U comparable](m map[T][]U) []U
Types ¶
type Casts ¶
type Character ¶
type Character struct {
ID int `gorm:"column:character_id" json:"id"`
Name string `gorm:"column:character_name" json:"name"`
NameCN string `gorm:"column:character_name_cn" json:"nameCN,omitempty"`
Image string `gorm:"column:character_image" json:"image,omitempty"`
BelongingSubject *Subject `gorm:"-" json:"subject"`
}
type CharacterSummary ¶
type CharacterSummary struct {
Characters []*Character `json:"characters"`
Count int `json:"count"`
}
CharacterSummary 包含一个人物的全部角色
type CollectionGroup ¶
type CollectionGroup struct {
Query bangumi.CollectionQuery
Collections []Collection
}
func (*CollectionGroup) Key ¶
func (e *CollectionGroup) Key() string
func (*CollectionGroup) TTL ¶
func (e *CollectionGroup) TTL() time.Duration
type Credits ¶
type Object ¶
type Object[T any] interface { *T comparable TTL() time.Duration // contains filtered or unexported methods }
type Person ¶
type PersonSummary ¶
type PersonSummary struct {
Person *Person
Subject *SubjectSummary
Series *SubjectSummary
Character *CharacterSummary
}
PersonSummary 一个人物的完整统计结果,用于暂存在服务端
type PersonSummaryByType ¶
type PersonSummaryByType struct {
Person `json:"person"`
*SubjectSummary `json:",omitempty"`
*CharacterSummary `json:",omitempty"`
}
PersonSummaryByType 一个人物的一种统计结果
- subject
- series
- character
subject 和 series 都用 SubjectSummary 类型填充
type Request ¶
type Request struct {
UserID string `json:"userID" binding:"required_unless=isGlobal true"`
Position string `json:"position" binding:"required"`
SubjectType int `json:"subjectType" binding:"required,oneof=1 2 3 4 6"`
CollectionTypes []int `json:"collectionTypes" binding:"required_unless=isGlobal true"`
PositiveTags []string `json:"positiveTags" binding:"omitempty"`
NegativeTags []string `json:"negativeTags" binding:"omitempty"`
RateRange []*float64 `json:"rateRange" binding:"omitempty,len=2,dive,omitempty,min=0,max=10"`
FavoriteRange []*int `json:"favoriteRange" binding:"omitempty,len=2,dive,omitempty,min=0"`
DateRange []*int `json:"dateRange" binding:"omitempty,len=2,dive,omitempty,min=0,max=10"`
IsGlobal *bool `json:"isGlobal" binding:"omitempty"`
ShowNSFW *bool `json:"showNSFW" binding:"omitempty"`
StatisticType *int `json:"statisticType" binding:"omitempty,oneof=1 2 3"`
Page *int `json:"page" binding:"omitempty,min=1"`
PageSize *int `json:"pageSize" binding:"omitempty,min=1"`
SortBy *int `json:"sortBy" binding:"omitempty,oneof=1 2 3"`
Ascend *bool `json:"ascend" binding:"omitempty"`
}
type Response ¶
type Response struct {
Summaries []*PersonSummaryByType `json:"summaries"`
PersonCount int `json:"total"`
ObjectCount int `json:"itemCount"` // 查询到的 条目 / 系列 / 角色 数量
}
type Sequel ¶
type Statistics ¶
type Statistics struct {
PeopleSummary []*PersonSummary
PersonCount int
SubjectCount int
SeriesCount int
CharacterCount int
}
Statistics 包含一次查询的完整结果,用于暂存在服务端
type StatsEntity ¶
type StatsEntity struct {
Request *Request
Statistics *Statistics
}
func (*StatsEntity) Key ¶
func (e *StatsEntity) Key() string
func (*StatsEntity) TTL ¶
func (e *StatsEntity) TTL() time.Duration
type StringSlice ¶
type StringSlice []string
StringSlice 是支持与 []byte 进行序列化和反序列化的 json 列表类型。
func (*StringSlice) Scan ¶
func (s *StringSlice) Scan(value any) error
type Subject ¶
type Subject struct {
ID int `gorm:"column:subject_id" json:"id,omitempty"`
Name string `gorm:"column:subject_name" json:"name,omitempty"`
NameCN string `gorm:"column:subject_name_cn" json:"nameCN,omitempty"`
Rate float64 `gorm:"column:subject_rate" json:"rate,omitempty"`
Image string `gorm:"column:subject_image" json:"image,omitempty"`
Favorite int `gorm:"column:subject_favorite" json:"-"`
Tags StringSlice `gorm:"column:subject_tags" json:"-"`
Date time.Time `gorm:"column:subject_date" json:"-"`
NSFW bool `gorm:"column:subject_nsfw" json:"-"`
SequelOrder int `gorm:"-" json:"-"`
}
Click to show internal directories.
Click to hide internal directories.