institution

package
v0.0.0-...-20f649f Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2023 License: BSD-3-Clause Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInstitutionShortNameConflict = errors.New("short name conflicts with existing institution")
	ErrInstitutionNotFound          = errors.New("institution does not exist")
	ErrUnauthorized                 = errors.New("unauthorized")
	ErrInviteLinkNotFound           = errors.New("invite link does not exist")
)

Functions

func NewHTTPHandler

func NewHTTPHandler(u UseCase, c *config.Config, j *jwtauth.JWTAuth) chi.Router

Types

type Reader

type Reader interface {
	FindInstitution(ctx context.Context, shortName string) (*entity.Institution, error)
	FindInstitutions(ctx context.Context) ([]*entity.Institution, error)
	FindInstitutionWithInvites(ctx context.Context, shortName string) (*entity.Institution, error)
	FindInviteLinkWithInstitution(ctx context.Context, code string) (*entity.InstitutionInviteLink, error)
	FindInviteLinks(ctx context.Context, id int) ([]*entity.InstitutionInviteLink, error)
	FindUser(ctx context.Context, principal string) (*entity.User, error)
}

type Repository

type Repository interface {
	Reader
	Writer
	transactor.Transactor
}

func NewEntRepository

func NewEntRepository(l logger.AppLogger, c *ent.Client) Repository

type UseCase

type UseCase interface {
	ListInstitutions(ctx context.Context) ([]*entity.Institution, error)
	CreateInstitution(ctx context.Context, name, shortName, description string) (*entity.Institution, error)

	// UpdateInstitution modifies an institution which has a short name identified by the principal argument.
	UpdateInstitution(ctx context.Context, principal, name, shortName, description string) (*entity.Institution, error)
	DeleteInstitution(ctx context.Context, shortName string) error

	// ListInviteLinks shows invite links for an institution identified by shortName.
	// If the user (identified by principal), has God mode enabled, then all links will be accessible.
	// Else, only users with a role of Admin can list links for the institution they are associated with.
	ListInviteLinks(ctx context.Context, principal, shortName string) ([]*entity.InstitutionInviteLink, error)
	// CreateInviteLink creates a link an institution identified by shortName.
	// If the user (identified by principal) has God mode enabled, any shortName is accepted.
	// ELse, only users with a role of Admin can create links for the institution they are associated with.
	CreateInviteLink(ctx context.Context, principal, shortName string, role institution.Role) (*entity.InstitutionInviteLink, error)
	// DeleteInviteLink deletes a link.
	// If the user (identified by principal) has God mode enabled, any shortName is accepted.
	// ELse, only users with a role of Admin can delete links for the institution they are associated with.
	DeleteInviteLink(ctx context.Context, principal, shortName, code string) error
}

func NewUseCase

func NewUseCase(r Repository) UseCase

type Writer

type Writer interface {
	CreateInstitution(ctx context.Context, name, shortName, description string) (*entity.Institution, error)
	UpdateInstitution(ctx context.Context, id int, name, shortName, description string) (*entity.Institution, error)
	DeleteInstitution(ctx context.Context, id int) error
	CreateInviteLink(ctx context.Context, id int, code string, role institution.Role) (*entity.InstitutionInviteLink, error)
	DeleteInviteLink(ctx context.Context, id int) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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