user

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package user present full API functionality of the specific object

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthCapableModel added in v0.5.0

type AuthCapableModel interface {
	Model
	EmailModel
	PasswordModel
}

AuthCapableModel combines core user with email and password traits. Use only as constraint for PasswordResetQueryResolver (email → userID → password usecase).

type Base added in v0.5.0

type Base = models.UserBase

Base is the minimal user identity (ID, approve status, timestamps).

type Email added in v0.5.0

type Email = models.UserEmail

Email is the optional email identity trait.

type EmailCapableModel added in v0.5.0

type EmailCapableModel interface {
	Model
	EmailModel
}

EmailCapableModel combines core Model with email trait for email repository/usecase.

type EmailModel added in v0.5.0

type EmailModel interface {
	GetEmail() string
	SetEmail(string)
}

EmailModel is the email identity trait (orthogonal to Model).

type EmailRepository added in v0.5.0

type EmailRepository[T EmailCapableModel] interface {
	GetByEmail(ctx context.Context, email string) (T, error)
}

EmailRepository provides email lookup for models with UserEmail trait.

type EmailUsecase added in v0.5.0

type EmailUsecase[T EmailCapableModel] interface {
	GetByEmail(ctx context.Context, email string) (T, error)
}

EmailUsecase provides email lookup operations.

type FilterBase added in v0.5.0

type FilterBase struct {
	ID []uint64
}

FilterBase contains the core ID filter (Model trait only). Embed into your custom filter struct; call Apply in PrepareQuery.

func (*FilterBase) Apply added in v0.5.0

func (fl *FilterBase) Apply(q *gorm.DB) *gorm.DB

Apply applies the ID filter to the query.

type FilterEmail added in v0.5.0

type FilterEmail struct {
	Emails []string
}

FilterEmail contains the email filter (Email trait only). Embed into your custom filter struct; call Apply in PrepareQuery.

func (*FilterEmail) Apply added in v0.5.0

func (fl *FilterEmail) Apply(q *gorm.DB) *gorm.DB

Apply applies the email filter to the query.

type ListFilter

type ListFilter struct {
	FilterBase
	FilterEmail
}

ListFilter is the backward-compatible composite filter (FilterBase + FilterEmail). Consumer projects should compose FilterBase + FilterEmail (+ custom fields) directly.

func (*ListFilter) PrepareQuery

func (fl *ListFilter) PrepareQuery(q *gorm.DB) *gorm.DB

PrepareQuery applies all embedded filter parts.

type ListOptions added in v0.4.0

type ListOptions = repository.ListOptions

ListOptions is the list options struct

type ListOrder

type ListOrder struct {
	OrderBase
	OrderEmail
}

ListOrder is the backward-compatible composite order (OrderBase + OrderEmail). Consumer projects should compose OrderBase + OrderEmail (+ custom fields) directly.

func (*ListOrder) PrepareQuery

func (ord *ListOrder) PrepareQuery(q *gorm.DB) *gorm.DB

PrepareQuery applies all embedded order parts.

type Model added in v0.5.0

type Model interface {
	auth.IsNillable

	GetID() uint64
	IsAnonymous() bool
	NewWithID(id uint64) Model

	CreatorUserID() uint64
}

Model is the compile-time constraint for core user repository/usecase operations.

type Order added in v0.4.0

type Order = models.Order

Order Ascending or Descending for query fields

type OrderBase added in v0.5.0

type OrderBase struct {
	ID        Order
	Status    Order
	CreatedAt Order
	UpdatedAt Order
}

OrderBase contains core order fields (Model trait only). Embed into your custom order struct; call Apply in PrepareQuery.

func (*OrderBase) Apply added in v0.5.0

func (ord *OrderBase) Apply(q *gorm.DB) *gorm.DB

Apply applies the base order fields to the query.

type OrderEmail added in v0.5.0

type OrderEmail struct {
	Email Order
}

OrderEmail contains the email order field (Email trait only).

func (*OrderEmail) Apply added in v0.5.0

func (ord *OrderEmail) Apply(q *gorm.DB) *gorm.DB

Apply applies the email order to the query.

type OrderUsername added in v0.5.0

type OrderUsername struct {
	Username Order
}

OrderUsername contains the username order field (Username trait only).

func (*OrderUsername) Apply added in v0.5.0

func (ord *OrderUsername) Apply(q *gorm.DB) *gorm.DB

Apply applies the username order to the query.

type Pagination added in v0.4.0

type Pagination = repository.Pagination

Pagination is the pagination object

type Password added in v0.5.0

type Password = models.UserPassword

Password is the optional password authentication trait.

type PasswordCapableModel added in v0.5.0

type PasswordCapableModel interface {
	Model
	PasswordModel
}

PasswordCapableModel combines core Model with password trait for password repository/usecase.

type PasswordModel added in v0.5.0

type PasswordModel interface {
	GetPasswordHash() string
	SetPasswordHash(string)
	RequiredPasswordReset() bool
}

PasswordModel is the password authentication trait (orthogonal to Model and EmailModel).

type PasswordRepository added in v0.5.0

type PasswordRepository[T PasswordCapableModel] interface {
	GetByPassword(ctx context.Context, userID uint64, password string) (T, error)
	CreateWithPassword(ctx context.Context, user T, password string) (uint64, error)
	SetPassword(ctx context.Context, user T, password string) error
	CreateResetPassword(ctx context.Context, userID uint64) (*UserPasswordReset, error)
	GetResetPassword(ctx context.Context, userID uint64, token string) (*UserPasswordReset, error)
	EliminateResetPassword(ctx context.Context, userID uint64) error
}

PasswordRepository provides password auth and reset token operations.

type PasswordUsecase added in v0.5.0

type PasswordUsecase[T PasswordCapableModel] interface {
	Repo() PasswordRepository[T]
	SetPassword(ctx context.Context, user T, password string) error
	ChangePassword(ctx context.Context, currentPassword, newPassword string) error
	ResetPassword(ctx context.Context, userID uint64) (*UserPasswordReset, T, error)
	UpdatePassword(ctx context.Context, userID uint64, token, password string) error
}

PasswordUsecase provides password management operations (no email lookup).

type QOption added in v0.4.0

type QOption = repository.QOption

QOption is the query option interface

type Repository

type Repository[T Model] interface {
	EmptyObject() T
	Get(ctx context.Context, id uint64) (T, error)
	FetchList(ctx context.Context, opts ...QOption) ([]T, error)
	Count(ctx context.Context, opts ...QOption) (int64, error)
	Create(ctx context.Context, user T) (uint64, error)
	Update(ctx context.Context, user T) error
	Delete(ctx context.Context, id uint64) error
}

Repository is the core CRUD repository parameterized by user model type. T must be a pointer type implementing Model (e.g. *MyUser).

type Usecase

type Usecase[T Model] interface {
	EmptyObject() T
	Get(ctx context.Context, id uint64) (T, error)
	FetchList(ctx context.Context, opts ...QOption) ([]T, error)
	Count(ctx context.Context, opts ...QOption) (int64, error)
	Create(ctx context.Context, user T) (uint64, error)
	Update(ctx context.Context, user T) error
	Delete(ctx context.Context, id uint64) error
}

Usecase is core user business logic parameterized by model type. T must be a pointer type (e.g. *MyUser).

type UserPasswordReset added in v0.4.0

type UserPasswordReset = models.UserPasswordReset

UserPasswordReset is the model for password reset tokens.

type Username added in v0.5.0

type Username = models.UserUsername

Username is the optional separate username trait.

Directories

Path Synopsis
delivery
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.
Package usecase user managing
Package usecase user managing

Jump to

Keyboard shortcuts

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