Documentation ¶
Index ¶
- Variables
- type AccessToken
- type Auth
- type AuthRepo
- type AuthService
- type AuthUserInfo
- type CharacterRepo
- type CollectionRepo
- type CommentType
- type EpisodeFilter
- type EpisodeRepo
- type FriendItem
- type GroupMemberType
- type GroupRepo
- type IndexRepo
- type IndexSubject
- type Permission
- type PersonCharacterRelation
- type PersonRepo
- type PersonService
- type RevisionRepo
- type SubjectCharacterRelation
- type SubjectCollectionUpdate
- type SubjectInternalRelation
- type SubjectPersonRelation
- type SubjectRepo
- type TopicRepo
- type TopicType
- type UserRepo
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCharacterNotFound = errgo.MsgNoTrace(ErrNotFound, "character not found")
View Source
var ErrEpisodeNotFound = errgo.MsgNoTrace(ErrNotFound, "episode not found")
View Source
var ErrInput = errors.New("input not valid")
View Source
var ErrNotFound = errors.New("can't find item")
ErrNotFound should be returned when a repo or service can't find an authorization.
View Source
var ErrPersonNotFound = errgo.MsgNoTrace(ErrNotFound, "person not found")
View Source
var ErrSubjectNotCollected = errgo.MsgNoTrace(ErrNotFound, "subject is not collected by user")
View Source
var ErrSubjectNotFound = errgo.MsgNoTrace(ErrNotFound, "subject not found")
View Source
var ErrUserNotFound = errgo.MsgNoTrace(ErrNotFound, "user not found")
Functions ¶
This section is empty.
Types ¶
type AccessToken ¶ added in v0.18.0
type Auth ¶
type Auth struct { RegTime time.Time ID model.UserID // user id GroupID model.UserGroupID Permission Permission `json:"-"` // disable cache for this field. }
Auth is the basic authorization represent a user.
type AuthRepo ¶
type AuthRepo interface { // GetByToken return an authorized user by a valid access token. GetByToken(ctx context.Context, token string) (AuthUserInfo, error) GetPermission(ctx context.Context, groupID uint8) (Permission, error) CreateAccessToken( ctx context.Context, userID model.UserID, name string, expiration time.Duration, ) (token string, err error) ListAccessToken(ctx context.Context, userID model.UserID) ([]AccessToken, error) DeleteAccessToken(ctx context.Context, tokenID uint32) (bool, error) // GetByEmail return (Auth, HashedPassword, error) GetByEmail(ctx context.Context, email string) (AuthUserInfo, []byte, error) GetTokenByID(ctx context.Context, id uint32) (AccessToken, error) }
AuthRepo presents an authorization.
type AuthService ¶
type AuthService interface { GetByToken(ctx context.Context, token string) (Auth, error) GetByID(ctx context.Context, userID model.UserID) (Auth, error) ComparePassword(hashed []byte, password string) (bool, error) Login(ctx context.Context, email, password string) (Auth, bool, error) GetTokenByID(ctx context.Context, tokenID uint32) (AccessToken, error) CreateAccessToken( ctx context.Context, userID model.UserID, name string, expiration time.Duration, ) (token string, err error) ListAccessToken(ctx context.Context, userID model.UserID) ([]AccessToken, error) DeleteAccessToken(ctx context.Context, tokenID uint32) (bool, error) }
type AuthUserInfo ¶ added in v0.22.1
type CharacterRepo ¶
type CharacterRepo interface { Get(ctx context.Context, id model.CharacterID) (model.Character, error) GetByIDs(ctx context.Context, ids ...model.CharacterID) (map[model.CharacterID]model.Character, error) GetPersonRelated(ctx context.Context, personID model.PersonID) ([]PersonCharacterRelation, error) GetSubjectRelated(ctx context.Context, subjectID model.SubjectID) ([]SubjectCharacterRelation, error) }
type CollectionRepo ¶ added in v0.20.9
type CollectionRepo interface { // WithQuery is used to replace repo's query to txn WithQuery(query *query.Query) CollectionRepo CountSubjectCollections( ctx context.Context, userID model.UserID, subjectType model.SubjectType, collectionType model.SubjectCollection, showPrivate bool, ) (int64, error) ListSubjectCollection( ctx context.Context, userID model.UserID, subjectType model.SubjectType, collectionType model.SubjectCollection, showPrivate bool, limit, offset int, ) ([]model.UserSubjectCollection, error) GetSubjectCollection( ctx context.Context, userID model.UserID, subjectID model.SubjectID, ) (model.UserSubjectCollection, error) GetSubjectEpisodesCollection( ctx context.Context, userID model.UserID, subjectID model.SubjectID, ) (model.UserSubjectEpisodesCollection, error) UpdateSubjectCollection( ctx context.Context, userID model.UserID, subjectID model.SubjectID, data SubjectCollectionUpdate, at time.Time, ) error UpdateEpisodeCollection( ctx context.Context, userID model.UserID, subjectID model.SubjectID, episodeIDs []model.EpisodeID, collection model.EpisodeCollection, at time.Time, ) (model.UserSubjectEpisodesCollection, error) }
type CommentType ¶ added in v0.22.0
type CommentType uint32
const ( CommentTypeUnknown CommentType = iota CommentTypeSubjectTopic CommentTypeGroupTopic CommentIndex CommentCharacter CommentPerson CommentEpisode )
type EpisodeRepo ¶
type EpisodeRepo interface { // WithQuery is used to replace repo's query to txn WithQuery(query *query.Query) EpisodeRepo Get(ctx context.Context, episodeID model.EpisodeID) (model.Episode, error) // Count all episode for a subject. Count(ctx context.Context, subjectID model.SubjectID, filter EpisodeFilter) (int64, error) // List return all episode. List( ctx context.Context, subjectID model.SubjectID, filter EpisodeFilter, limit int, offset int, ) ([]model.Episode, error) }
type FriendItem ¶ added in v0.23.0
type FriendItem struct{}
type GroupMemberType ¶ added in v0.20.9
type GroupMemberType uint8
const ( GroupMemberAll GroupMemberType = 1 << iota / 2 GroupMemberMod GroupMemberNormal )
type GroupRepo ¶ added in v0.20.9
type GroupRepo interface { GetByName(ctx context.Context, name string) (model.Group, error) GetByID(ctx context.Context, id model.GroupID) (model.Group, error) CountMembersByID(ctx context.Context, id model.GroupID, memberType GroupMemberType) (int64, error) ListMembersByID( ctx context.Context, id model.GroupID, memberType GroupMemberType, limit, offset int, ) ([]model.GroupMember, error) }
type IndexRepo ¶
type IndexRepo interface { Get(ctx context.Context, id model.IndexID) (model.Index, error) CountSubjects(ctx context.Context, id model.IndexID, subjectType model.SubjectType) (int64, error) ListSubjects( ctx context.Context, id model.IndexID, subjectType model.SubjectType, limit, offset int, ) ([]IndexSubject, error) }
type IndexSubject ¶
type Permission ¶
type Permission struct { UserList bool ManageUserGroup bool ManageUserPhoto bool ManageTopicState bool ManageReport bool UserBan bool ManageUser bool UserGroup bool UserWikiApply bool `doc:"申请 wiki 人"` UserWikiApprove bool DoujinSubjectErase bool DoujinSubjectLock bool SubjectEdit bool SubjectLock bool SubjectRefresh bool SubjectRelated bool SubjectMerge bool SubjectErase bool SubjectCoverLock bool SubjectCoverErase bool MonoEdit bool MonoLock bool MonoMerge bool MonoErase bool BanPost bool EpEdit bool EpMove bool EpMerge bool EpLock bool EpErase bool Report bool ManageApp bool AppErase bool }
type PersonCharacterRelation ¶
type PersonRepo ¶
type PersonRepo interface { Get(ctx context.Context, id model.PersonID) (model.Person, error) GetByIDs(ctx context.Context, ids ...model.PersonID) (map[model.PersonID]model.Person, error) GetSubjectRelated(ctx context.Context, subjectID model.SubjectID) ([]SubjectPersonRelation, error) GetCharacterRelated(ctx context.Context, subjectID model.CharacterID) ([]PersonCharacterRelation, error) }
type PersonService ¶
type PersonService interface { Get(ctx context.Context, id model.PersonID) (model.Person, error) GetSubjectRelated(ctx context.Context, subjectID model.SubjectID) ([]model.SubjectPersonRelation, error) GetCharacterRelated(ctx context.Context, characterID model.CharacterID) ([]model.PersonCharacterRelation, error) }
type RevisionRepo ¶
type RevisionRepo interface { CountPersonRelated(ctx context.Context, personID model.PersonID) (int64, error) ListPersonRelated( ctx context.Context, personID model.PersonID, limit int, offset int, ) ([]model.PersonRevision, error) GetPersonRelated(ctx context.Context, id model.RevisionID) (model.PersonRevision, error) CountSubjectRelated(ctx context.Context, id model.SubjectID) (int64, error) ListSubjectRelated( ctx context.Context, id model.SubjectID, limit int, offset int, ) ([]model.SubjectRevision, error) GetSubjectRelated(ctx context.Context, id model.RevisionID) (model.SubjectRevision, error) CountCharacterRelated(ctx context.Context, characterID model.CharacterID) (int64, error) ListCharacterRelated( ctx context.Context, characterID model.CharacterID, limit int, offset int, ) ([]model.CharacterRevision, error) GetCharacterRelated(ctx context.Context, id model.RevisionID) (model.CharacterRevision, error) }
type SubjectCharacterRelation ¶
type SubjectCharacterRelation struct { TypeID uint8 SubjectID model.SubjectID CharacterID model.CharacterID }
type SubjectCollectionUpdate ¶ added in v0.23.8
type SubjectInternalRelation ¶
type SubjectInternalRelation struct { TypeID uint16 SourceID model.SubjectID DestinationID model.SubjectID }
func (SubjectInternalRelation) GetDestinationID ¶ added in v0.22.0
func (s SubjectInternalRelation) GetDestinationID() model.SubjectID
func (SubjectInternalRelation) GetSourceID ¶ added in v0.22.0
func (s SubjectInternalRelation) GetSourceID() model.SubjectID
type SubjectPersonRelation ¶
type SubjectPersonRelation struct { TypeID uint16 PersonID model.PersonID SubjectID model.SubjectID }
func (SubjectPersonRelation) GetSubjectID ¶ added in v0.22.0
func (r SubjectPersonRelation) GetSubjectID() model.SubjectID
type SubjectRepo ¶
type SubjectRepo interface { // Get return a repository model. Get(ctx context.Context, id model.SubjectID) (model.Subject, error) GetByIDs(ctx context.Context, ids ...model.SubjectID) (map[model.SubjectID]model.Subject, error) GetPersonRelated(ctx context.Context, personID model.PersonID) ([]SubjectPersonRelation, error) GetCharacterRelated(ctx context.Context, characterID model.CharacterID) ([]SubjectCharacterRelation, error) GetSubjectRelated(ctx context.Context, subjectID model.SubjectID) ([]SubjectInternalRelation, error) GetActors( ctx context.Context, subjectID model.SubjectID, characterIDs ...model.CharacterID, ) (map[model.CharacterID][]model.PersonID, error) }
type TopicRepo ¶ added in v0.22.0
type TopicRepo interface { Get(ctx context.Context, topicType TopicType, id model.TopicID) (model.Topic, error) // Count all topic for a subject/group. Count(ctx context.Context, topicType TopicType, id uint32, statuses []model.TopicStatus) (int64, error) // List return paged topic list of a subject/group. // userID should not be filtered List( ctx context.Context, topicType TopicType, id uint32, statuses []model.TopicStatus, limit int, offset int, ) ([]model.Topic, error) GetTopicContent(ctx context.Context, topicType TopicType, id model.TopicID) (model.Comment, error) // CountReplies top comments for a topic/index/character/person/episode. // 一级回复 // 小组和条目帖子会去除楼主发帖 CountReplies(ctx context.Context, commentType CommentType, id model.TopicID) (int64, error) // ListReplies return paged top comment tree. // // []model.Comment{ // 一级回复 // { // 一级回复对应的 **全部** 二级回复 // SubComments: []model.SubComments{} // } // } ListReplies( ctx context.Context, commentType CommentType, id model.TopicID, limit int, offset int, ) ([]model.Comment, error) }
type UserRepo ¶
type UserRepo interface { // GetByID find a user by uid. GetByID(ctx context.Context, userID model.UserID) (model.User, error) // GetByName find a user by username. GetByName(ctx context.Context, username string) (model.User, error) GetByIDs(ctx context.Context, ids ...model.UserID) (map[model.UserID]model.User, error) GetFriends(ctx context.Context, userID model.UserID) (map[model.UserID]FriendItem, error) }
Click to show internal directories.
Click to hide internal directories.