res

package
v0.33.19 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2023 License: AGPL-3.0, AGPL-3.0-only Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultImageURL = "https://lain.bgm.tv/img/no_icon_subject.png"
)

Variables

View Source
var ErrNotFound = NewError(http.StatusNotFound, "resource can't be found in the database or has been removed")
View Source
var GenderMap = map[uint8]string{
	1: "male",
	2: "female",
}

Functions

func BadRequest added in v0.30.3

func BadRequest(message string) error

func CharacterStaffString added in v0.31.0

func CharacterStaffString(i uint8) string

func EmptySlice added in v0.30.3

func EmptySlice() []int

func Forbidden added in v0.30.3

func Forbidden(message string) error

func GroupIcon added in v0.30.3

func GroupIcon(base string) string

func InternalError added in v0.12.4

func InternalError(c echo.Context, err error, message string) error

func JSONError added in v0.30.3

func JSONError(c echo.Context, err error) error

func NewError added in v0.30.3

func NewError(code int, message string) error

func NotFound added in v0.30.3

func NotFound(message string) error

func Unauthorized added in v0.30.3

func Unauthorized(message string) error

Types

type Actor

type Actor struct {
	Images       PersonImages   `json:"images"`
	Name         string         `json:"name"`
	ShortSummary string         `json:"short_summary"`
	Career       []string       `json:"career"`
	ID           model.PersonID `json:"id"`
	Type         uint8          `json:"type"`
	Locked       bool           `json:"locked"`
}

type Avatar

type Avatar struct {
	Large  string `json:"large"`
	Medium string `json:"medium"`
	Small  string `json:"small"`
}

func UserAvatar added in v0.30.3

func UserAvatar(s string) Avatar

func (Avatar) Select added in v0.30.3

func (a Avatar) Select(s string) (string, bool)

type CharacterRelatedPerson

type CharacterRelatedPerson struct {
	Images        PersonImages    `json:"images"`
	Name          string          `json:"name"`
	SubjectName   string          `json:"subject_name"`
	SubjectNameCn string          `json:"subject_name_cn"`
	SubjectID     model.SubjectID `json:"subject_id"`
	Staff         string          `json:"staff"`
	ID            model.PersonID  `json:"id"`
	Type          uint8           `json:"type" doc:"person type"`
}

type CharacterRelatedSubject

type CharacterRelatedSubject struct {
	Staff  string          `json:"staff"`
	Name   string          `json:"name"`
	NameCn string          `json:"name_cn"`
	Image  string          `json:"image"`
	ID     model.SubjectID `json:"id"`
}

type CharacterRevision added in v0.12.0

type CharacterRevision struct {
	CreatedAt time.Time                            `json:"created_at"`
	Data      map[string]CharacterRevisionDataItem `json:"data,omitempty"`
	Creator   Creator                              `json:"creator"`
	Summary   string                               `json:"summary"`
	ID        uint32                               `json:"id"`
	Type      uint8                                `json:"type"`
}

type CharacterRevisionDataItem added in v0.12.0

type CharacterRevisionDataItem struct {
	Name    string `json:"name" mapstructure:"crt_name"`
	InfoBox string `json:"infobox" mapstructure:"crt_infobox"`
	Summary string `json:"summary"`
	Extra   Extra  `json:"extra"`
}

type CharacterV0

type CharacterV0 struct {
	BirthMon  *uint8            `json:"birth_mon"`
	Gender    *string           `json:"gender"`
	BirthDay  *uint8            `json:"birth_day"`
	BirthYear *uint16           `json:"birth_year"`
	BloodType *uint8            `json:"blood_type"`
	Images    PersonImages      `json:"images"`
	Summary   string            `json:"summary"`
	Name      string            `json:"name"`
	Infobox   v0wiki            `json:"infobox"`
	Stat      Stat              `json:"stat"`
	ID        model.CharacterID `json:"id"`
	Redirect  model.CharacterID `json:"-"`
	Locked    bool              `json:"locked"`
	Type      uint8             `json:"type"`
	NSFW      bool              `json:"nsfw"`
}

type Count

type Count struct {
	Field1  uint32 `json:"1"`
	Field2  uint32 `json:"2"`
	Field3  uint32 `json:"3"`
	Field4  uint32 `json:"4"`
	Field5  uint32 `json:"5"`
	Field6  uint32 `json:"6"`
	Field7  uint32 `json:"7"`
	Field8  uint32 `json:"8"`
	Field9  uint32 `json:"9"`
	Field10 uint32 `json:"10"`
}

type Creator

type Creator struct {
	Username string `json:"username"`
	Nickname string `json:"nickname"`
}

type Episode

type Episode struct {
	Airdate         string          `json:"airdate"`
	Name            string          `json:"name"`
	NameCN          string          `json:"name_cn"`
	Duration        string          `json:"duration"`
	Description     string          `json:"desc"`
	Ep              float32         `json:"ep"`
	Sort            float32         `json:"sort"`
	ID              model.EpisodeID `json:"id"`
	SubjectID       model.SubjectID `json:"subject_id"`
	Comment         uint32          `json:"comment"`
	Type            episode.Type    `json:"type"`
	Disc            uint8           `json:"disc"`
	DurationSeconds int             `json:"duration_seconds"`
}

func ConvertModelEpisode added in v0.30.3

func ConvertModelEpisode(s episode.Episode) Episode

type EpisodeRevision added in v0.30.3

type EpisodeRevision struct {
	CreatedAt time.Time                          `json:"created_at"`
	Data      map[string]EpisodeRevisionDataItem `json:"data,omitempty"`
	Creator   Creator                            `json:"creator"`
	Summary   string                             `json:"summary"`
	ID        uint32                             `json:"id"`
	Type      uint8                              `json:"type"`
}

type EpisodeRevisionDataItem added in v0.30.3

type EpisodeRevisionDataItem model.EpisodeRevisionDataItem

type Error

type Error struct {
	Title       string `json:"title"`
	Details     any    `json:"details,omitempty"`
	Description string `json:"description"`
}

Error default error response.

type Extra added in v0.10.1

type Extra struct {
	Img string `json:"img,omitempty"`
}

type HTTPError added in v0.11.0

type HTTPError struct {
	Msg  string
	Code int
}

func (HTTPError) Error added in v0.30.3

func (e HTTPError) Error() string

type Index

type Index struct {
	CreatedAt   time.Time     `json:"created_at"`
	UpdatedAt   time.Time     `json:"updated_at"`
	Creator     Creator       `json:"creator"`
	Title       string        `json:"title"`
	Description string        `json:"desc"`
	Total       uint32        `json:"total"`
	ID          model.IndexID `json:"id"`
	Stat        Stat          `json:"stat"`
	NSFW        bool          `json:"nsfw" doc:"if index contains any nsfw subjects"`

	// Deprecated: this will always be false.
	Ban bool `json:"ban"`
}

func IndexModelToResponse added in v0.30.3

func IndexModelToResponse(i *model.Index, u user.User) Index

type IndexSubjectV0 added in v0.30.3

type IndexSubjectV0 struct {
	AddedAt time.Time         `json:"added_at"`
	Date    *string           `json:"date"`
	Image   SubjectImages     `json:"images"`
	Name    string            `json:"name"`
	NameCN  string            `json:"name_cn"`
	Comment string            `json:"comment"`
	Infobox v0wiki            `json:"infobox"`
	ID      model.SubjectID   `json:"id"`
	TypeID  model.SubjectType `json:"type"`
}

type LoginRemain added in v0.12.4

type LoginRemain struct {
	Remain int `json:"remain"`
}

type Paged

type Paged struct {
	Data   any   `json:"data"`
	Total  int64 `json:"total"`
	Limit  int   `json:"limit"`
	Offset int   `json:"offset"`
}

type PagedG added in v0.30.3

type PagedG[T any] struct {
	Data   []T   `json:"data"`
	Total  int64 `json:"total"`
	Limit  int   `json:"limit"`
	Offset int   `json:"offset"`
}

type PersonImages added in v0.12.10

type PersonImages struct {
	Small  string `json:"small"`
	Grid   string `json:"grid"`
	Large  string `json:"large"`
	Medium string `json:"medium"`
}

func PersonImage added in v0.12.10

func PersonImage(s string) PersonImages

func (PersonImages) Select added in v0.30.3

func (i PersonImages) Select(t string) (string, bool)

type PersonRelatedCharacter

type PersonRelatedCharacter struct {
	Images        PersonImages      `json:"images"`
	Name          string            `json:"name"`
	SubjectName   string            `json:"subject_name"`
	SubjectNameCn string            `json:"subject_name_cn"`
	SubjectID     model.SubjectID   `json:"subject_id"`
	Staff         string            `json:"staff"`
	ID            model.CharacterID `json:"id"`
	Type          uint8             `json:"type" doc:"character type"`
}

type PersonRelatedSubject

type PersonRelatedSubject struct {
	Staff     string          `json:"staff"`
	Name      string          `json:"name"`
	NameCn    string          `json:"name_cn"`
	Image     string          `json:"image"`
	SubjectID model.SubjectID `json:"id"`
}

type PersonRevision added in v0.10.1

type PersonRevision struct {
	CreatedAt time.Time                         `json:"created_at"`
	Data      map[string]PersonRevisionDataItem `json:"data"`
	Creator   Creator                           `json:"creator"`
	Summary   string                            `json:"summary"`
	ID        uint32                            `json:"id"`
	Type      uint8                             `json:"type"`
}

type PersonRevisionDataItem added in v0.10.1

type PersonRevisionDataItem struct {
	InfoBox    string     `json:"prsn_infobox"`
	Summary    string     `json:"prsn_summary"`
	Profession Profession `json:"profession"`
	Extra      Extra      `json:"extra"`
	Name       string     `json:"prsn_name"`
}

type PersonV0

type PersonV0 struct {
	LastModified time.Time      `json:"last_modified"`
	BloodType    *uint8         `json:"blood_type"`
	BirthYear    *uint16        `json:"birth_year"`
	BirthDay     *uint8         `json:"birth_day"`
	BirthMon     *uint8         `json:"birth_mon"`
	Gender       *string        `json:"gender"`
	Images       PersonImages   `json:"images"`
	Summary      string         `json:"summary"`
	Name         string         `json:"name"`
	Img          string         `json:"img"`
	Infobox      v0wiki         `json:"infobox"`
	Career       []string       `json:"career"`
	Stat         Stat           `json:"stat"`
	Redirect     model.PersonID `json:"-"`
	ID           model.PersonID `json:"id"`
	Locked       bool           `json:"locked"`
	Type         uint8          `json:"type"`
}

func ConvertModelPerson added in v0.30.3

func ConvertModelPerson(s model.Person) PersonV0

type PrivateGroup added in v0.30.3

type PrivateGroup struct {
	ID           model.GroupID `json:"id"`
	Name         string        `json:"name"`
	CreatedAt    time.Time     `json:"created_at"`
	Title        string        `json:"title"`
	Icon         string        `json:"icon" format:"url"`
	TotalMembers int64         `json:"total_members"`
	Description  string        `json:"description"`
}

type PrivateGroupMember added in v0.30.3

type PrivateGroupMember struct {
	JoinedAt time.Time    `json:"joined_at"`
	Avatar   Avatar       `json:"avatar"`
	UserName string       `json:"username"`
	NickName string       `json:"nickname"`
	ID       model.UserID `json:"id"`
}

type PrivateGroupProfile added in v0.30.3

type PrivateGroupProfile struct {
	CreatedAt    time.Time            `json:"created_at"`
	Name         string               `json:"name"`
	Title        string               `json:"title"`
	Description  string               `json:"description" format:"bbcode"`
	Icon         string               `json:"icon" format:"url"`
	NewMembers   []PrivateGroupMember `json:"new_members"`
	TotalMembers int64                `json:"total_members"`
	ID           model.GroupID        `json:"id"`
}

type PrivateMessage added in v0.30.3

type PrivateMessage struct {
	CreatedAt      time.Time       `json:"created_at"`
	RelatedMessage *PrivateMessage `json:"related_message,omitempty"`
	Sender         *User           `json:"sender,omitempty"`
	Receiver       *User           `json:"receiver,omitempty"`
	Title          string          `json:"title"`
	Content        string          `json:"content"`
	ID             uint32          `json:"id"`
	New            bool            `json:"new"`
}

func ConvertModelPrivateMessage added in v0.30.3

func ConvertModelPrivateMessage(item pm.PrivateMessage, users map[model.UserID]user.User) PrivateMessage

func ConvertModelPrivateMessageListItem added in v0.30.3

func ConvertModelPrivateMessageListItem(
	item pm.PrivateMessageListItem,
	users map[model.UserID]user.User,
) PrivateMessage

type PrivateMessageTypeCounts added in v0.30.3

type PrivateMessageTypeCounts struct {
	Unread int64 `json:"unread"`
	Inbox  int64 `json:"inbox"`
	Outbox int64 `json:"outbox"`
}

type Profession added in v0.10.1

type Profession struct {
	Writer      string `json:"writer,omitempty"`
	Producer    string `json:"producer,omitempty"`
	Mangaka     string `json:"mangaka,omitempty"`
	Artist      string `json:"artist,omitempty"`
	Seiyu       string `json:"seiyu,omitempty"`
	Illustrator string `json:"illustrator,omitempty"`
	Actor       string `json:"actor,omitempty"`
}

type Rating

type Rating struct {
	Rank  uint32  `json:"rank"`
	Total uint32  `json:"total"`
	Count Count   `json:"count"`
	Score float64 `json:"score"`
}

type SlimSubjectV0

type SlimSubjectV0 struct {
	Date            *string           `json:"date"`
	Image           SubjectImages     `json:"images"`
	Name            string            `json:"name"`
	NameCN          string            `json:"name_cn"`
	ShortSummary    string            `json:"short_summary"`
	Tags            []SubjectTag      `json:"tags"`
	Score           float64           `json:"score"`
	Type            model.SubjectType `json:"type"`
	ID              model.SubjectID   `json:"id"`
	Eps             uint32            `json:"eps"`
	Volumes         uint32            `json:"volumes"`
	CollectionTotal uint32            `json:"collection_total"`
	Rank            uint32            `json:"rank"`
}

func ToSlimSubjectV0 added in v0.30.3

func ToSlimSubjectV0(s model.Subject) SlimSubjectV0

type Stat

type Stat struct {
	Comments uint32 `json:"comments"`
	Collects uint32 `json:"collects"`
}

type SubjectCollection added in v0.30.3

type SubjectCollection struct {
	UpdatedAt   time.Time                    `json:"updated_at"`
	Comment     *string                      `json:"comment"`
	Tags        []string                     `json:"tags"`
	Subject     SlimSubjectV0                `json:"subject"`
	SubjectID   model.SubjectID              `json:"subject_id"`
	VolStatus   uint32                       `json:"vol_status"`
	EpStatus    uint32                       `json:"ep_status"`
	SubjectType uint8                        `json:"subject_type"`
	Type        collection.SubjectCollection `json:"type"`
	Rate        uint8                        `json:"rate"`
	Private     bool                         `json:"private"`
}

func ConvertModelSubjectCollection added in v0.30.3

func ConvertModelSubjectCollection(c collection.UserSubjectCollection, subject SlimSubjectV0) SubjectCollection

type SubjectCollectionStat

type SubjectCollectionStat struct {
	OnHold  uint32 `json:"on_hold"`
	Dropped uint32 `json:"dropped"`
	Wish    uint32 `json:"wish"`
	Collect uint32 `json:"collect"`
	Doing   uint32 `json:"doing"`
}

func (SubjectCollectionStat) Sum added in v0.30.3

func (s SubjectCollectionStat) Sum() uint32

type SubjectImages added in v0.12.10

type SubjectImages struct {
	Small  string `json:"small"`
	Grid   string `json:"grid"`
	Large  string `json:"large"`
	Medium string `json:"medium"`
	Common string `json:"common"`
}

func SubjectImage added in v0.12.10

func SubjectImage(s string) SubjectImages

func (SubjectImages) Select added in v0.30.3

func (i SubjectImages) Select(t string) (string, bool)

type SubjectRelatedCharacter

type SubjectRelatedCharacter struct {
	Images   PersonImages      `json:"images"`
	Name     string            `json:"name"`
	Relation string            `json:"relation"`
	Actors   []Actor           `json:"actors"`
	Type     uint8             `json:"type"`
	ID       model.CharacterID `json:"id"`
}

type SubjectRelatedPerson

type SubjectRelatedPerson struct {
	Images   PersonImages   `json:"images"`
	Name     string         `json:"name" doc:"person name"`
	Relation string         `json:"relation"`
	Career   []string       `json:"career"`
	Type     uint8          `json:"type"`
	ID       model.PersonID `json:"id" doc:"person ID"`
}

type SubjectRelatedSubject

type SubjectRelatedSubject struct {
	Images    SubjectImages     `json:"images"`
	Name      string            `json:"name"`
	NameCn    string            `json:"name_cn"`
	Relation  string            `json:"relation"`
	Type      model.SubjectType `json:"type"`
	SubjectID model.SubjectID   `json:"id"`
}

type SubjectRevision added in v0.10.1

type SubjectRevision struct {
	CreatedAt time.Time            `json:"created_at"`
	Data      *SubjectRevisionData `json:"data"`
	Creator   Creator              `json:"creator"`
	Summary   string               `json:"summary"`
	ID        uint32               `json:"id"`
	Type      uint8                `json:"type"`
}

type SubjectRevisionData added in v0.10.1

type SubjectRevisionData struct {
	Name         string          `json:"name"`
	NameCN       string          `json:"name_cn"`
	VoteField    string          `json:"vote_field"`
	FieldInfobox string          `json:"field_infobox"`
	FieldSummary string          `json:"field_summary"`
	Platform     uint16          `json:"platform"`
	TypeID       uint16          `json:"type_id"`
	SubjectID    model.SubjectID `json:"subject_id"`
	FieldEps     uint32          `json:"field_eps"`
	Type         uint8           `json:"type"`
}

type SubjectTag added in v0.30.3

type SubjectTag struct {
	Name  string `json:"name"`
	Count int    `json:"count"`
}

type SubjectV0

type SubjectV0 struct {
	Date          *string               `json:"date"`
	Platform      *string               `json:"platform"`
	Image         SubjectImages         `json:"images"`
	Summary       string                `json:"summary"`
	Name          string                `json:"name"`
	NameCN        string                `json:"name_cn"`
	Tags          []SubjectTag          `json:"tags"`
	Infobox       v0wiki                `json:"infobox"`
	Rating        Rating                `json:"rating"`
	TotalEpisodes int64                 `json:"total_episodes" doc:"episodes count in database"`
	Collection    SubjectCollectionStat `json:"collection"`
	ID            model.SubjectID       `json:"id"`
	Eps           uint32                `json:"eps"`
	Volumes       uint32                `json:"volumes"`
	Redirect      model.SubjectID       `json:"-"`
	Locked        bool                  `json:"locked"`
	NSFW          bool                  `json:"nsfw"`
	TypeID        model.SubjectType     `json:"type"`
}

type User added in v0.11.0

type User struct {
	Avatar    Avatar       `json:"avatar"`
	Sign      string       `json:"sign"`
	URL       string       `json:"url"`
	Username  string       `json:"username"`
	Nickname  string       `json:"nickname"`
	ID        model.UserID `json:"id"`
	UserGroup uint8        `json:"user_group"`
}

func ConvertModelUser added in v0.30.3

func ConvertModelUser(u user.User) User

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL