user

package
v0.0.0-...-c60e208 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package user contains user application services

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RBAC

type RBAC interface {
	User(echo.Context) *model.AuthUser
	EnforceUser(echo.Context, int) error
	AccountCreate(echo.Context, model.AccessRole, int, int) error
	IsLowerRole(echo.Context, model.AccessRole) error
}

RBAC represents role-based-access-control interface

type Securer

type Securer interface {
	Hash(string) string
}

Securer represents security interface

type Service

type Service interface {
	Create(echo.Context, model.User) (*model.User, error)
	List(echo.Context, *model.Pagination) ([]model.User, error)
	View(echo.Context, int) (*model.User, error)
	Delete(echo.Context, int) error
	Update(echo.Context, *Update) (*model.User, error)
}

Service represents user application interface

type UDB

type UDB interface {
	Create(orm.DB, model.User) (*model.User, error)
	View(orm.DB, int) (*model.User, error)
	List(orm.DB, *model.ListQuery, *model.Pagination) ([]model.User, error)
	Update(orm.DB, *model.User) error
	Delete(orm.DB, *model.User) error
}

UDB represents user repository interface

type Update

type Update struct {
	ID        int
	FirstName *string
	LastName  *string
	Mobile    *string
	Phone     *string
	Address   *string
}

Update contains user's information used for updating

type User

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

User represents user application service

func Initialize

func Initialize(db *pg.DB, rbac RBAC, sec Securer) *User

Initialize initalizes User application service with defaults

func New

func New(db *pg.DB, udb UDB, rbac RBAC, sec Securer) *User

New creates new user application service

func (*User) Create

func (u *User) Create(c echo.Context, req model.User) (*model.User, error)

Create creates a new user account

func (*User) Delete

func (u *User) Delete(c echo.Context, id int) error

Delete deletes a user

func (*User) List

func (u *User) List(c echo.Context, p *model.Pagination) ([]model.User, error)

List returns list of users

func (*User) Update

func (u *User) Update(c echo.Context, req *Update) (*model.User, error)

Update updates user's contact information

func (*User) View

func (u *User) View(c echo.Context, id int) (*model.User, error)

View returns single user

Directories

Path Synopsis
platform

Jump to

Keyboard shortcuts

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