roles

package
v0.0.0-...-f2fa0db Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2021 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMockRepository

func NewMockRepository() *mockRepository

func ValidateCreateRequest

func ValidateCreateRequest(c *auth.CreateRoleRequest) error

ValidateCreateRequest validates the CreateRoleRequest fields.

func ValidateUpdateRequest

func ValidateUpdateRequest(u *auth.UpdateRoleRequest) error

Validate validates the UpdateRoleRequest fields.

Types

type API

type API interface {
	grpcgw.Controller
}

func New

func New(srv Service) API

type Repository

type Repository interface {
	// Get returns the role with the specified role UUID.
	Get(ctx context.Context, uuid string) (entity.Role, error)
	// GetByTitle returns the role with the specified role title.
	GetByTitle(ctx context.Context, title string) (entity.Role, error)
	// Count returns the number of roles.
	Count(ctx context.Context) (int64, error)
	// Query returns the list of roles with the given offset and limit.
	Query(ctx context.Context, query string, offset, limit int64) ([]entity.Role, int, error)
	// Create saves a new role in the storage.
	Create(ctx context.Context, role entity.Role) (string, error)
	// Update updates the role with given UUID in the storage.
	Update(ctx context.Context, role entity.Role) error
	// Delete removes the role with given UUID from the storage.
	Delete(ctx context.Context, role entity.Role) error
}

Repository encapsulates the logic to access roles from the data source.

func NewRepository

func NewRepository(db *db.DB) Repository

NewRepository creates a new role repository

type Service

type Service interface {
	Get(ctx context.Context, uuid string) (*auth.Role, error)
	Query(ctx context.Context, query string, offset, limit int64) (*auth.ListRolesResponse, error)
	Count(ctx context.Context) (int64, error)
	Create(ctx context.Context, input *auth.CreateRoleRequest) (*auth.Role, error)
	Update(ctx context.Context, input *auth.UpdateRoleRequest) (*auth.Role, error)
	Delete(ctx context.Context, uuid string) (*auth.Role, error)
}

Service encapsulates use case logic for roles.

func NewService

func NewService(repo Repository) Service

NewService creates a new role service.

Jump to

Keyboard shortcuts

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