user

package
v0.0.0-...-97f58fc Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UniqueViolationErr = "23505"
)

Variables

View Source
var (
	ErrNoDatastore       = errors.New("no datastore provided")
	ErrRecordNotFound    = errors.New("record not found")
	ErrInvalidDataType   = errors.New("invalid user data type")
	ErrUniqueKeyViolated = errors.New("duplicated key not allowed")
)
View Source
var ErrSvcUserExists = errors.New("target credential(s) already exist")

service errors

View Source
var ErrSvcUserNotFound = errors.New("target was not found")

Functions

This section is empty.

Types

type HTTPUserRequest

type HTTPUserRequest struct {
	Username string `json:"username" valid:"required"`
	Email    string `json:"email" valid:"email,required"`
}

type HTTPUserResponse

type HTTPUserResponse struct {
	ID       string `json:"id"`
	Username string `json:"username"`
	Email    string `json:"email"`
}

type User

type User struct {
	ID        string `gorm:"primaryKey"`
	Username  string `gorm:"unique"`
	Email     string `gorm:"unique"`
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt gorm.DeletedAt `gorm:"index"`
}

Shared model for Service and Repository layer

type UserHandler

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

func NewUserHandler

func NewUserHandler(service UserServiceManager) *UserHandler

func (*UserHandler) Create

func (h *UserHandler) Create(c echo.Context) error

func (*UserHandler) GetAll

func (h *UserHandler) GetAll(c echo.Context) error

func (*UserHandler) GetUser

func (h *UserHandler) GetUser(c echo.Context) error

type UserRepoManager

type UserRepoManager interface {
	Create(user *User) error
	GetAllUsers() ([]User, error)
	GetUser(user *User) (User, error)
}

func NewUserRepository

func NewUserRepository(db *gorm.DB, inMemStore config.MemoryStore) (UserRepoManager, error)

type UserServiceManager

type UserServiceManager interface {
	CreateUser(user User) (User, error)
	GetAllUsers() ([]User, error)
	GetUser(id string) (User, error)
}

func NewUserService

func NewUserService(r UserRepoManager) UserServiceManager

Jump to

Keyboard shortcuts

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