domain

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2022 License: AGPL-3.0, AGPL-3.0-only Imports: 5 Imported by: 0

Documentation

Index

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      uint32
}

Auth is the basic authorization represent a user.

func (Auth) AllowNSFW

func (u Auth) AllowNSFW() bool

AllowNSFW return if current user is allowed to see NSFW resource.

type AuthRepo

type AuthRepo interface {
	// GetByToken return an authorized user by a valid access token.
	GetByToken(ctx context.Context, token string) (Auth, error)
}

AuthRepo presents an authorization.

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, characterID 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 IndexRepo

type IndexRepo interface {
	Get(ctx context.Context, id uint32) (model.Index, error)

	CountSubjects(ctx context.Context, id uint32, subjectType model.SubjectType) (int64, error)
	ListSubjects(
		ctx context.Context, id uint32, subjectType model.SubjectType, limit, offset int,
	) ([]IndexSubject, error)
}

type IndexSubject

type IndexSubject struct {
	Comment string
	AddedAt time.Time
	Subject model.Subject
}

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, subjectID 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.IDType) (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.IDType) (model.Revision, 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)
}

Jump to

Keyboard shortcuts

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