user

package
v0.0.0-...-43d6508 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2025 License: LGPL-2.1 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInternal     = errors.New("api: user: the user service encountered an unexpected condition that prevented it from fulfilling the request")
	ErrNotFoundByID = errors.New("api: user: could not find any user with provided ID")
	ErrInvalidRole  = errors.New("api: user: role is not valid")
)

Functions

This section is empty.

Types

type CreateRequest

type CreateRequest struct {
	User *User
}

type CreateResponse

type CreateResponse struct {
	User *User
}

type FindByIDRequest

type FindByIDRequest struct {
	ID uuid.UUID
}

type FindByIDResponse

type FindByIDResponse struct {
	User *User
}

type Repoer

type Repoer interface {
	Insert(context.Context, *User) error
	FindByID(context.Context, uuid.UUID) (*User, error)
	UpdateByID(context.Context, uuid.UUID, *User) error
	SoftDeleteByID(context.Context, uuid.UUID) error
}

type Role

type Role string
const (
	Default Role = "default"
	Admin   Role = "admin"
)

func NewRole

func NewRole(role string) (Role, error)

func (*Role) Scan

func (r *Role) Scan(src any) error

func (*Role) Value

func (r *Role) Value() (driver.Value, error)

type Service

type Service struct {
	Repo Repoer
}

func (*Service) Create

func (s *Service) Create(ctx context.Context, req CreateRequest) (CreateResponse, error)

func (*Service) FindByID

func (s *Service) FindByID(ctx context.Context, req FindByIDRequest) (FindByIDResponse, error)

func (*Service) SoftDeleteByID

func (s *Service) SoftDeleteByID(ctx context.Context, req SoftDeleteByIDRequest) error

func (*Service) UpdateByID

func (s *Service) UpdateByID(ctx context.Context, req UpdateByIDRequest) (UpdateByIDResponse, error)

type SoftDeleteByIDRequest

type SoftDeleteByIDRequest struct {
	ID uuid.UUID
}

type UpdateByIDRequest

type UpdateByIDRequest struct {
	ID   uuid.UUID
	User *User
}

type UpdateByIDResponse

type UpdateByIDResponse struct {
	User *User
}

type User

type User struct {
	ID        uuid.UUID
	FirstName string
	LastName  *string
	Role      Role
	CreatedAt time.Time
	UpdatedAt time.Time
	DeletedAt *time.Time
}

Directories

Path Synopsis
repo

Jump to

Keyboard shortcuts

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