crud

package
v0.0.0-...-4479cc4 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CreateRuleName = "create"
	ReadRuleName   = "read"
	UpdateRuleName = "update"
	DeleteRuleName = "delete"
)

Variables

View Source
var (
	AccessCreateRule = AccessRule(new(AccessCreate))
	AccessReadRule   = AccessRule(new(AccessRead))
	AccessUpdateRule = AccessRule(new(AccessUpdate))
	AccessDeleteRule = AccessRule(new(AccessDelete))
)
View Source
var (
	ErrEntityNotRegistered              = errors.New("entity not registered")
	ErrRepositoryNotSupportsCreate      = errors.New("repository not supports create actions")
	ErrRepositoryNotSupportsRead        = errors.New("repository not supports read actions")
	ErrRepositoryNotSupportsUpdate      = errors.New("repository not supports update actions")
	ErrRepositoryNotSupportsDelete      = errors.New("repository not supports delete actions")
	ErrAccessDenied                     = errors.New("access denied")
	ErrIdentifierNotConvertableToString = errors.New("identifier not convertable to string")
	ErrUnexpectedConvertingRecord       = errors.New("something went wrong while converting record")
)

Functions

This section is empty.

Types

type AccessCreate

type AccessCreate struct{}

func (*AccessCreate) RuleName

func (a *AccessCreate) RuleName() string

type AccessDelete

type AccessDelete struct{}

func (*AccessDelete) RuleName

func (a *AccessDelete) RuleName() string

type AccessRead

type AccessRead struct{}

func (*AccessRead) RuleName

func (a *AccessRead) RuleName() string

type AccessRule

type AccessRule interface {
	RuleName() string
}

type AccessUpdate

type AccessUpdate struct{}

func (*AccessUpdate) RuleName

func (a *AccessUpdate) RuleName() string

type Entity

type Entity struct {
	Slug string
	Name string

	Repository Repository

	Link  *navigation.Link
	Group *navigation.Group
}

type Group

type Group struct {
	Title    string
	Priority int64
}
type Link struct {
	Title    string
	Priority int64
}

type Model

type Model interface {
	Identifier() any
}

type Module

type Module struct {
	// contains filtered or unexported fields
}

func New

func New(entities ...Entity) *Module
func (m *Module) GroupLinks() map[*navigation.Group][]*navigation.Link

func (*Module) HttpHandler

func (m *Module) HttpHandler() (http.Handler, error)

func (*Module) HttpPrefix

func (m *Module) HttpPrefix() string

func (*Module) Init

func (m *Module) Init(provider interfaces.DependencyProvider) error
func (m *Module) Links() []*navigation.Link

func (*Module) Name

func (m *Module) Name() string

type Repository

type Repository interface {
	// AccessRules Must return a set of access rules, that allowed for context
	AccessRules(context.Context) ([]AccessRule, error)

	// NewModel Must return a new instance of model
	NewModel() Model
}

type RepositoryCreatable

type RepositoryCreatable interface {
	Create(context.Context, Model) error
}

type RepositoryDeletable

type RepositoryDeletable interface {
	Delete(context.Context, string) error
}

type RepositoryReadable

type RepositoryReadable interface {
	GetByID(context.Context, string) (Model, error)
	GetList(ctx context.Context, page int32, perPage int32) (models []Model, totalCount int64, err error)
}

type RepositoryUpdatable

type RepositoryUpdatable interface {
	Update(context.Context, Model, string) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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