users

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2026 License: AGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Plan added in v0.2.0

type Plan string
const (
	PlanFree Plan = "free"
	PlanPro  Plan = "pro"
)

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.

func (*UsersHandler) Activate added in v0.3.1

func (h *UsersHandler) Activate(c *echo.Context) error

Activate handles POST /api/v1/users/me/activate. Sets activated_at on the user if not already set. Always returns 204 No Content.

func (*UsersHandler) GetMe added in v0.3.1

func (h *UsersHandler) GetMe(c *echo.Context) error

GetMe handles GET /api/v1/users/me. Returns the authenticated user's profile including their activation status.

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

func (r *UsersRepository) Activate(ctx context.Context, id uuid.UUID) (User, error)

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) Create

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

func (*UsersRepository) Delete

func (r *UsersRepository) Delete(ctx context.Context, id uuid.UUID) error

func (*UsersRepository) FindByEmail

func (r *UsersRepository) FindByEmail(ctx context.Context, email string) (User, error)

func (*UsersRepository) FindByID

func (r *UsersRepository) FindByID(ctx context.Context, id uuid.UUID) (User, error)

func (*UsersRepository) Update

func (r *UsersRepository) Update(ctx context.Context, user User) (User, error)

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

func (s *UsersService) Activate(ctx context.Context, id uuid.UUID) (User, error)

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.

func (*UsersService) Create

func (s *UsersService) Create(ctx context.Context, user User) (User, error)

Create creates a new user.

func (*UsersService) Delete

func (s *UsersService) Delete(ctx context.Context, id uuid.UUID) error

Delete removes a user by ID.

func (*UsersService) GetByID added in v0.2.0

func (s *UsersService) GetByID(ctx context.Context, id uuid.UUID) (User, error)

GetByID looks up a user by their ID.

func (*UsersService) Update

func (s *UsersService) Update(ctx context.Context, user User) (User, error)

Update persists changes to an existing user.

Jump to

Keyboard shortcuts

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