user

package
v2.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

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

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 InterfaceRepository

type InterfaceRepository interface {
	Create(CreateData) (User, error)
	Read(context.Context, ReadData) (entity.PaginatorResponse, error)
	Update(UpdateData) error
	Delete(DeleteData) error
}

type InterfaceService

type InterfaceService interface {
	Create(CreateData) (User, error)
	Read(context.Context, ReadData) (entity.PaginatorResponse, error)
	Update(UpdateData) error
	Delete(DeleteData) error
}

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(req CreateData) (User, error)

func (*Repository) Delete

func (r *Repository) Delete(req DeleteData) error

func (*Repository) Read

func (*Repository) Update

func (r *Repository) Update(req UpdateData) error

type Service

type Service struct {
	Repository InterfaceRepository
}

func NewService

func NewService(repository InterfaceRepository) *Service

func (*Service) Create

func (s *Service) Create(req CreateData) (User, error)

func (*Service) Delete

func (s *Service) Delete(req DeleteData) error

func (*Service) Read

func (*Service) Update

func (s *Service) Update(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