Documentation ¶
Index ¶
- Variables
- type AccessToken
- type Auth
- type AuthRepo
- type AuthService
- type CharacterRepo
- type CharacterService
- type CollectionRepo
- 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 SubjectService
- type UserRepo
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("can't find item")
ErrNotFound should be returned when a repo or service can't find an authorization.
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) (Auth, 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) (Auth, []byte, error) GetTokenByID(ctx context.Context, id uint32) (AccessToken, error) }
AuthRepo presents an authorization.
type AuthService ¶
type AuthService interface { GetByID(ctx context.Context, userID model.UserID) (Auth, error) GetByToken(ctx context.Context, token string) (Auth, error) GetByTokenWithCache(ctx context.Context, token string) (Auth, error) GetByIDWithCache(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) GetPermission(ctx context.Context, id model.UserGroupID) (Permission, error) }
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 CharacterService ¶
type CharacterService interface { Get(ctx context.Context, id model.CharacterID) (model.Character, error) GetPersonRelated(ctx context.Context, personID model.PersonID) ([]model.PersonCharacterRelation, error) GetSubjectRelated(ctx context.Context, subjectID model.SubjectID) ([]model.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 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) CountsBySubjectID(ctx context.Context, subjectID ...model.SubjectID) (map[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 enum.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 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 SubjectPersonRelation ¶
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.Person, error) }
type SubjectService ¶
type SubjectService 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) ([]model.SubjectPersonRelation, error) GetCharacterRelated(ctx context.Context, characterID model.CharacterID) ([]model.SubjectCharacterRelation, error) GetSubjectRelated(ctx context.Context, subjectID model.SubjectID) ([]model.SubjectInternalRelation, error) GetActors( ctx context.Context, subjectID model.SubjectID, characterIDs ...model.CharacterID, ) (map[model.CharacterID][]model.Person, 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.