user

package
v0.0.0-...-ec225d0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBRepository

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

func (*DBRepository) Create

func (r *DBRepository) Create(ctx context.Context, user *User) error

func (*DBRepository) Delete

func (r *DBRepository) Delete(ctx context.Context, userID uuid.UUID) error

func (*DBRepository) FindAll

func (r *DBRepository) FindAll(ctx context.Context) (*[]User, error)

func (*DBRepository) FindByEmail

func (r *DBRepository) FindByEmail(ctx context.Context, userEmail string) (*User, error)

func (*DBRepository) FindById

func (r *DBRepository) FindById(ctx context.Context, userID uuid.UUID) (*User, error)

func (*DBRepository) Update

func (r *DBRepository) Update(ctx context.Context, userID uuid.UUID, user *User) error

type User

type User struct {
	ID        uuid.UUID     `gorm:"type:uuid" json:"id"`
	Name      string        `gorm:"type:string;not null" json:"name"`
	Email     string        `gorm:"type:string;uniqueIndex;not null" json:"email"`
	Password  string        `gorm:"type:string;not null" json:"password"`
	Role      []*roles.Role `gorm:"many2many:user_roles;" json:"role"`
	CreatedAt time.Time     `json:"created_at"`
	UpdatedAt time.Time     `json:"updated_at"`
}

func (*User) BeforeCreate

func (user *User) BeforeCreate(tx *gorm.DB) (err error)

func (User) CreateUserValidation

func (r User) CreateUserValidation() error

type UserController

type UserController struct {
	UserUseCase UserUseCase
}

Represents our controller with our use-case / service.

func (*UserController) CheckIfUserExistsMiddleware

func (h *UserController) CheckIfUserExistsMiddleware(c *fiber.Ctx) error

If user does not exist, do not allow one to access the API.

func (*UserController) CreateUserController

func (h *UserController) CreateUserController(c *fiber.Ctx) error

func (*UserController) DeleteUserController

func (h *UserController) DeleteUserController(c *fiber.Ctx) error

func (*UserController) GetUserByEmailController

func (h *UserController) GetUserByEmailController(c *fiber.Ctx) error

func (*UserController) GetUserController

func (h *UserController) GetUserController(c *fiber.Ctx) error

func (*UserController) GetUsersController

func (h *UserController) GetUsersController(c *fiber.Ctx) error

func (*UserController) UpdateUserController

func (h *UserController) UpdateUserController(c *fiber.Ctx) error

type UserRepository

type UserRepository interface {
	FindAll(ctx context.Context) (*[]User, error)
	FindById(ctx context.Context, userID uuid.UUID) (*User, error)
	FindByEmail(ctx context.Context, userEmail string) (*User, error)
	Create(ctx context.Context, user *User) error
	Update(ctx context.Context, userID uuid.UUID, user *User) error
	Delete(ctx context.Context, userID uuid.UUID) error
}

func NewUserRepository

func NewUserRepository(dbConn *gorm.DB) UserRepository

type UserUseCase

type UserUseCase interface {
	GetUsers(ctx context.Context) (*[]User, error)
	GetUser(ctx context.Context, userID uuid.UUID) (*User, error)
	CreateUser(ctx context.Context, user *User) error
	UpdateUser(ctx context.Context, userID uuid.UUID, user *User) error
	DeleteUser(ctx context.Context, userID uuid.UUID) error
	GetUserByEmail(ctx context.Context, email string) (*User, error)
}

func NewUserUseCase

func NewUserUseCase(ur UserRepository, rr roles.RoleRepository) UserUseCase

Create a new 'service' or 'use-case' for 'User' entity.

Jump to

Keyboard shortcuts

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