Documentation
¶
Index ¶
- Variables
- type AccessToken
- type Auth
- type AuthRepo
- type AuthService
- type AuthUserInfo
- type CharacterRepo
- type CollectionRepo
- type CommentType
- type EpisodeRepo
- type GroupMemberType
- type GroupRepo
- type IndexRepo
- type IndexSubject
- type Permission
- type PersonCharacterRelation
- type PersonRepo
- type PersonService
- type RevisionRepo
- type SubjectCharacterRelation
- type SubjectInternalRelation
- type SubjectPersonRelation
- type SubjectRepo
- type TopicRepo
- type TopicType
- type UserRepo
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrCharacterNotFound = errgo.Msg(ErrNotFound, "character not found")
View Source
var ErrEpisodeNotFound = errgo.Msg(ErrNotFound, "episode not found")
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.Msg(ErrNotFound, "person not found")
View Source
var ErrSubjectNotFound = errgo.Msg(ErrNotFound, "subject 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 {
CountSubjectCollections(
ctx context.Context,
userID model.UserID,
subjectType model.SubjectType,
collectionType model.CollectionType,
showPrivate bool,
) (int64, error)
ListSubjectCollection(
ctx context.Context,
userID model.UserID,
subjectType model.SubjectType,
collectionType model.CollectionType,
showPrivate bool,
limit, offset int,
) ([]model.SubjectCollection, error)
GetSubjectCollection(
ctx context.Context, userID model.UserID, subjectID model.SubjectID,
) (model.SubjectCollection, 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 {
Get(ctx context.Context, episodeID model.EpisodeID) (model.Episode, error)
// Count all episode for a subject.
Count(ctx context.Context, subjectID model.SubjectID) (int64, error)
// CountByType count episode for a subject and filter by type.
// This is because 0 means episode type normal.
CountByType(ctx context.Context, subjectID model.SubjectID, epType model.EpType) (int64, error)
// List return all episode.
List(ctx context.Context, subjectID model.SubjectID, limit int, offset int) ([]model.Episode, error)
// ListByType return episodes filtered by episode type.
ListByType(
ctx context.Context, subjectID model.SubjectID, epType model.EpType, limit int, offset int,
) ([]model.Episode, error)
}
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)
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 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)
}
Click to show internal directories.
Click to hide internal directories.