users

package
v0.0.0-...-d0fcf2f Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2024 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUserNotFound = errors.New("user not found")
)

Functions

This section is empty.

Types

type MockUserRepository

type MockUserRepository struct {
	GetUsersFunc   func(ctx context.Context) ([]*User, error)
	GetByIDFunc    func(ctx context.Context, id int) (*User, error)
	GetByEmailFunc func(ctx context.Context, email string) (*User, error)
	SaveFunc       func(ctx context.Context, user *User) error
	DeleteFunc     func(ctx context.Context, id int) error
	UpdateFunc     func(ctx context.Context, user *User) error
}

func (*MockUserRepository) Delete

func (m *MockUserRepository) Delete(ctx context.Context, id int) error

func (*MockUserRepository) GetByEmail

func (m *MockUserRepository) GetByEmail(ctx context.Context, email string) (*User, error)

func (*MockUserRepository) GetByID

func (m *MockUserRepository) GetByID(ctx context.Context, id int) (*User, error)

func (*MockUserRepository) GetUsers

func (m *MockUserRepository) GetUsers(ctx context.Context) ([]*User, error)

func (*MockUserRepository) Save

func (m *MockUserRepository) Save(ctx context.Context, user *User) error

func (*MockUserRepository) Update

func (m *MockUserRepository) Update(ctx context.Context, user *User) error

type User

type User struct {
	ID        int
	FirstName string    `json:"first_name,omitempty" validate:"required,min=2,max=100"`
	LastName  string    `json:"last_name,omitempty" validate:"required,min=2,max=100"`
	Email     string    `json:"email,omitempty" validate:"required,email"`
	Password  string    `json:"password,omitempty" validate:"required,min=8"`
	CreatedAt time.Time `json:"created_at,omitempty"`
	UpdatedAt time.Time `json:"updated_at,omitempty"`
	Role      string    `json:"role,omitempty" validate:"oneof=admin user"`
	Status    string    `json:"status,omitempty" validate:"oneof=active inactive"`
}

type UserRepository

type UserRepository interface {
	GetUsers(ctx context.Context) ([]*User, error)
	GetByID(ctx context.Context, id int) (*User, error)
	GetByEmail(ctx context.Context, email string) (*User, error)
	Save(ctx context.Context, user *User) error
	Delete(ctx context.Context, id int) error
	Update(ctx context.Context, user *User) error
}

Jump to

Keyboard shortcuts

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