Documentation ¶
Index ¶
- Variables
- type Auth
- type AuthRepo
- type AuthService
- type CharacterRepo
- type CharacterService
- type EpisodeRepo
- type GroupID
- 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 Auth ¶
type Auth struct { RegTime time.Time ID model.UIDType // user id GroupID GroupID 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) // GetByEmail return (Auth, HashedPassword, error) GetByEmail(ctx context.Context, email string) (Auth, []byte, error) }
AuthRepo presents an authorization.
type AuthService ¶ added in v0.12.4
type AuthService interface { GetByToken(ctx context.Context, token string) (Auth, error) ComparePassword(hashed []byte, password string) (bool, error) GetByTokenWithCache(ctx context.Context, token string) (Auth, error) Login(ctx context.Context, email, password string) (Auth, bool, error) GetPermission(ctx context.Context, id GroupID) (Permission, error) }
type CharacterRepo ¶
type CharacterRepo interface { Get(ctx context.Context, id model.CharacterIDType) (model.Character, error) GetByIDs(ctx context.Context, ids ...model.CharacterIDType) (map[model.CharacterIDType]model.Character, error) GetPersonRelated(ctx context.Context, personID model.PersonIDType) ([]PersonCharacterRelation, error) GetSubjectRelated(ctx context.Context, subjectID model.SubjectIDType) ([]SubjectCharacterRelation, error) }
type CharacterService ¶ added in v0.10.1
type CharacterService interface { Get(ctx context.Context, id uint32) (model.Character, error) GetPersonRelated(ctx context.Context, personID model.PersonIDType) ([]model.PersonCharacterRelation, error) GetSubjectRelated(ctx context.Context, subjectID model.SubjectIDType) ([]model.SubjectCharacterRelation, error) }
type EpisodeRepo ¶
type EpisodeRepo interface { Get(ctx context.Context, episodeID uint32) (model.Episode, error) // Count all episode for a subject. Count(ctx context.Context, subjectID uint32) (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 uint32, epType model.EpTypeType) (int64, error) // List return all episode. List(ctx context.Context, subjectID uint32, limit int, offset int) ([]model.Episode, error) // ListByType return episodes filtered by episode type. ListByType( ctx context.Context, subjectID uint32, epType enum.EpType, limit int, offset int, ) ([]model.Episode, error) }
type IndexSubject ¶
type Permission ¶ added in v0.12.4
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 ¶ added in v0.10.1
type PersonCharacterRelation struct { CharacterID model.CharacterIDType PersonID model.PersonIDType SubjectID model.SubjectIDType }
type PersonRepo ¶
type PersonRepo interface { Get(ctx context.Context, id uint32) (model.Person, error) GetByIDs(ctx context.Context, ids ...model.PersonIDType) (map[model.PersonIDType]model.Person, error) GetSubjectRelated(ctx context.Context, subjectID model.SubjectIDType) ([]SubjectPersonRelation, error) GetCharacterRelated(ctx context.Context, subjectID model.CharacterIDType) ([]PersonCharacterRelation, error) }
type PersonService ¶ added in v0.10.1
type PersonService interface { Get(ctx context.Context, id uint32) (model.Person, error) GetSubjectRelated(ctx context.Context, subjectID model.SubjectIDType) ([]model.SubjectPersonRelation, error) GetCharacterRelated(ctx context.Context, characterID model.CharacterIDType) ([]model.PersonCharacterRelation, error) }
type RevisionRepo ¶ added in v0.10.1
type RevisionRepo interface { CountPersonRelated(ctx context.Context, personID model.PersonIDType) (int64, error) ListPersonRelated( ctx context.Context, personID model.PersonIDType, limit int, offset int, ) ([]model.Revision, error) GetPersonRelated(ctx context.Context, id model.UIDType) (model.Revision, error) CountSubjectRelated(ctx context.Context, id model.SubjectIDType) (int64, error) ListSubjectRelated( ctx context.Context, id model.SubjectIDType, limit int, offset int, ) ([]model.Revision, error) GetSubjectRelated(ctx context.Context, id model.UIDType) (model.Revision, error) CountCharacterRelated(ctx context.Context, characterID model.CharacterIDType) (int64, error) ListCharacterRelated( ctx context.Context, characterID model.CharacterIDType, limit int, offset int, ) ([]model.CharacterRevision, error) GetCharacterRelated(ctx context.Context, id model.UIDType) (model.CharacterRevision, error) }
type SubjectCharacterRelation ¶ added in v0.10.1
type SubjectCharacterRelation struct { TypeID uint8 SubjectID model.SubjectIDType CharacterID model.CharacterIDType }
type SubjectInternalRelation ¶ added in v0.10.1
type SubjectInternalRelation struct { TypeID uint16 SourceID model.SubjectIDType DestinationID model.SubjectIDType }
type SubjectPersonRelation ¶ added in v0.10.1
type SubjectPersonRelation struct { TypeID uint16 PersonID model.PersonIDType SubjectID model.SubjectIDType }
type SubjectRepo ¶
type SubjectRepo interface { // Get return a repository model. Get(ctx context.Context, id uint32) (model.Subject, error) GetByIDs(ctx context.Context, ids ...model.SubjectIDType) (map[model.SubjectIDType]model.Subject, error) GetPersonRelated(ctx context.Context, personID model.PersonIDType) ([]SubjectPersonRelation, error) GetCharacterRelated(ctx context.Context, characterID model.PersonIDType) ([]SubjectCharacterRelation, error) GetSubjectRelated(ctx context.Context, subjectID model.SubjectIDType) ([]SubjectInternalRelation, error) GetActors( ctx context.Context, subjectID model.SubjectIDType, characterIDs ...model.CharacterIDType, ) (map[model.CharacterIDType][]model.Person, error) }
type SubjectService ¶
type SubjectService interface { // Get return a repository model. Get(ctx context.Context, id uint32) (model.Subject, error) GetPersonRelated(ctx context.Context, personID model.PersonIDType) ([]model.SubjectPersonRelation, error) GetCharacterRelated(ctx context.Context, characterID model.PersonIDType) ([]model.SubjectCharacterRelation, error) GetSubjectRelated(ctx context.Context, subjectID model.SubjectIDType) ([]model.SubjectInternalRelation, error) GetActors( ctx context.Context, subjectID model.SubjectIDType, characterIDs ...model.CharacterIDType, ) (map[model.CharacterIDType][]model.Person, error) }
type UserRepo ¶
type UserRepo interface { // GetByID find a user by uid. GetByID(ctx context.Context, userID uint32) (model.User, error) // GetByName find a user by username. GetByName(ctx context.Context, username string) (model.User, error) GetByIDs(ctx context.Context, ids ...uint32) (map[uint32]model.User, error) CountCollections( ctx context.Context, userID uint32, subjectType model.SubjectType, collectionType uint8, showPrivate bool, ) (int64, error) ListCollections( ctx context.Context, userID uint32, subjectType model.SubjectType, collectionType uint8, showPrivate bool, limit, offset int, ) ([]model.Collection, error) }
Click to show internal directories.
Click to hide internal directories.