user

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const FeatureName string = "v1/user"

Variables

View Source
var (
	ErrDuplicateEmail          = errors.New("DUPLICATE_EMAIL")
	ErrFailedToCreateUser      = errors.New("FAILED_TO_CREATE_USER")
	ErrFailedToCreateEmail     = errors.New("FAILED_TO_CREATE_EMAIL")
	ErrFailedToReadUserData    = errors.New("FAILED_TO_READ_USER_DATA")
	ErrFailedToUpdateUserData  = errors.New("FAILED_TO_UPDATE_USER_DATA")
	ErrFailedToDeleteUserData  = errors.New("FAILED_TO_DELETE_USER_DATA")
	ErrFailedToDeleteEmailData = errors.New("FAILED_TO_DELETE_EMAIL_DATA")
)

Functions

func Dependency added in v2.1.0

func Dependency() dependency.Feature

func NewHandler

func NewHandler(e *echo.Group, service InterfaceService) *handler

func StatusFor added in v2.1.0

func StatusFor(err error) int

Types

type CreateData

type CreateData struct {
	Name   string   `json:"name"`
	Emails []string `json:"emails"`
}

func (CreateData) Validate

func (r CreateData) Validate() interface{}

type DeleteData

type DeleteData struct {
	ID string `param:"id" json:"id"`
}

func (DeleteData) Validate

func (r DeleteData) Validate() interface{}

type Email

type Email struct {
	ID        string         `gorm:"primaryKey;Column:id;type:varchar(45)" json:"id"`
	CreatedAt time.Time      `gorm:"Column:created_at;type:timestamptz;not null" json:"createdAt"`
	UpdatedAt time.Time      `gorm:"Column:updated_at;type:timestamptz;not null" json:"updatedAt"`
	DeletedAt gorm.DeletedAt `gorm:"Column:deleted_at;type:timestamptz" json:"deletedAt"`
	UserID    string         `gorm:"Column:user_id;type:varchar(45);not null" json:"userId"`
	Email     string         `gorm:"Column:email;type:varchar(255);not null" json:"email"`
}

func (Email) TableName

func (Email) TableName() string

type ReadData

type ReadData struct {
	entity.PaginatorRequest
	ID string `query:"id" json:"id"`
}

func (ReadData) Validate

func (r ReadData) Validate() interface{}

type Repository

type Repository struct {
	TimeLocation *time.Location
	Database     *gorm.DB
}

func NewRepository

func NewRepository(timeLocation *time.Location, db *gorm.DB) *Repository

func (*Repository) Create

func (r *Repository) Create(ctx context.Context, req CreateData) (User, error)

func (*Repository) Delete

func (r *Repository) Delete(ctx context.Context, req DeleteData) error

func (*Repository) Read

func (*Repository) Update

func (r *Repository) Update(ctx context.Context, req UpdateData) error

type Service

type Service struct {
	Repository InterfaceRepository
}

func NewService

func NewService(repository InterfaceRepository) *Service

func (*Service) Create

func (s *Service) Create(ctx context.Context, req CreateData) (User, error)

func (*Service) Delete

func (s *Service) Delete(ctx context.Context, req DeleteData) error

func (*Service) Read

func (*Service) Update

func (s *Service) Update(ctx context.Context, req UpdateData) error

type UpdateData

type UpdateData struct {
	ID     string   `param:"id" json:"id"`
	Name   string   `json:"name"`
	Emails []string `json:"emails"`
}

func (UpdateData) Validate

func (r UpdateData) Validate() interface{}

type User

type User struct {
	ID        string         `gorm:"primaryKey;Column:id;type:varchar(45)" json:"id"`
	CreatedAt time.Time      `gorm:"Column:created_at;type:timestamptz;not null" json:"createdAt"`
	UpdatedAt time.Time      `gorm:"Column:updated_at;type:timestamptz;not null" json:"updatedAt"`
	DeletedAt gorm.DeletedAt `gorm:"Column:deleted_at;type:timestamptz" json:"deletedAt"`
	Name      string         `gorm:"Column:name;type:varchar(255);not null" json:"name"`
	Emails    []Email        `gorm:"foreignKey:UserID;references:ID" json:"emails"`
}

func (User) TableName

func (User) TableName() string

Jump to

Keyboard shortcuts

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