Documentation
¶
Index ¶
- type Plan
- type User
- type UserResponse
- type UsersHandler
- type UsersRepository
- func (r *UsersRepository) Activate(ctx context.Context, id uuid.UUID) (User, error)
- func (r *UsersRepository) Create(ctx context.Context, user User) (User, error)
- func (r *UsersRepository) Delete(ctx context.Context, id uuid.UUID) error
- func (r *UsersRepository) FindByEmail(ctx context.Context, email string) (User, error)
- func (r *UsersRepository) FindByID(ctx context.Context, id uuid.UUID) (User, error)
- func (r *UsersRepository) Update(ctx context.Context, user User) (User, error)
- type UsersService
- func (s *UsersService) Activate(ctx context.Context, id uuid.UUID) (User, error)
- func (s *UsersService) Create(ctx context.Context, user User) (User, error)
- func (s *UsersService) Delete(ctx context.Context, id uuid.UUID) error
- func (s *UsersService) GetByID(ctx context.Context, id uuid.UUID) (User, error)
- func (s *UsersService) Update(ctx context.Context, user User) (User, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type User ¶
type User struct {
ID uuid.UUID `gorm:"primaryKey;type:uuid;default:gen_random_uuid()"`
Email string `gorm:"not null;unique"`
Name string `gorm:"not null"`
Plan Plan `gorm:"type:varchar(20);not null;default:'free'"`
ActivatedAt *time.Time `gorm:"column:activated_at"`
CreatedAt time.Time `gorm:"autoCreateTime"`
UpdatedAt time.Time `gorm:"autoUpdateTime"`
}
type UserResponse ¶ added in v0.3.1
type UserResponse struct {
ID uuid.UUID `json:"id"`
Name string `json:"name"`
Email string `json:"email"`
ActivatedAt *time.Time `json:"activated_at"`
}
UserResponse is the JSON representation of a user returned from the API.
type UsersHandler ¶
type UsersHandler struct {
// contains filtered or unexported fields
}
UsersHandler handles user-related HTTP requests.
func NewUsersHandler ¶
func NewUsersHandler(service userService) *UsersHandler
NewUsersHandler constructs a UsersHandler with the given service.
type UsersRepository ¶
type UsersRepository struct {
// contains filtered or unexported fields
}
func NewUsersRepository ¶
func NewUsersRepository(db *gorm.DB) *UsersRepository
func (*UsersRepository) Activate ¶ added in v0.3.1
Activate sets activated_at to the current time only when it is currently NULL, making the operation idempotent. It then re-fetches and returns the updated user.
func (*UsersRepository) FindByEmail ¶
type UsersService ¶
type UsersService struct {
// contains filtered or unexported fields
}
func NewUsersService ¶
func NewUsersService(repository repository) *UsersService
func (*UsersService) Activate ¶ added in v0.3.1
Activate sets activated_at on the user if it is currently unset. The operation is idempotent: if the user is already activated the existing timestamp is preserved. Returns the (possibly unchanged) user.
Click to show internal directories.
Click to hide internal directories.