Documentation ¶
Index ¶
- type DBRepository
- func (r *DBRepository) Create(ctx context.Context, user *User) error
- func (r *DBRepository) Delete(ctx context.Context, userID uuid.UUID) error
- func (r *DBRepository) FindAll(ctx context.Context) (*[]User, error)
- func (r *DBRepository) FindByEmail(ctx context.Context, userEmail string) (*User, error)
- func (r *DBRepository) FindById(ctx context.Context, userID uuid.UUID) (*User, error)
- func (r *DBRepository) Update(ctx context.Context, userID uuid.UUID, user *User) error
- type User
- type UserController
- func (h *UserController) CheckIfUserExistsMiddleware(c *fiber.Ctx) error
- func (h *UserController) CreateUserController(c *fiber.Ctx) error
- func (h *UserController) DeleteUserController(c *fiber.Ctx) error
- func (h *UserController) GetUserByEmailController(c *fiber.Ctx) error
- func (h *UserController) GetUserController(c *fiber.Ctx) error
- func (h *UserController) GetUsersController(c *fiber.Ctx) error
- func (h *UserController) UpdateUserController(c *fiber.Ctx) error
- type UserRepository
- type UserUseCase
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) FindByEmail ¶
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) CreateUserValidation ¶
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.
Click to show internal directories.
Click to hide internal directories.