users

package
v0.0.0-...-b68eb45 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2020 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

type Repository interface {
	Create(ctx context.Context, user *User) error
	Get(ctx context.Context, id string) (*User, error)
	GetAll(ctx context.Context) ([]*User, error)
	Update(ctx context.Context, id string, user *UpdateUser) error
	Delete(ctx context.Context, id string) error
}

Repository represent the user's repository contract

type UpdateUser

type UpdateUser struct {
	Email string `json:"email" validate:"email,required"`
	Name  string `json:"name" validate:"gte=1,lte=50"`
	Age   uint32 `json:"age" validate:"gte=0,lte=130"`
}

UpdateUser is used when updating

type Usecase

type Usecase interface {
	Repository
}

Usecase represents the user usecases It shares the same interface than the entity Repository plus something specific to the usecase

func NewUsecase

func NewUsecase(repo Repository) Usecase

NewUsecase creates a new usecase object to implement Usecase interface

type User

type User struct {
	ID    string `json:"id"`
	Email string `json:"email" validate:"email,required"`
	Name  string `json:"name" validate:"required,gte=1,lte=50"`
	Age   uint32 `json:"age" validate:"required,gte=0,lte=130"`
}

User describes a user in the system

Directories

Path Synopsis
repository

Jump to

Keyboard shortcuts

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