Documentation
¶
Index ¶
- Constants
- Variables
- func Dependency() dependency.Feature
- func NewHandler(e *echo.Group, service InterfaceService) *handler
- func StatusFor(err error) int
- type CreateData
- type DeleteData
- type Email
- type InterfaceRepository
- type InterfaceService
- type ReadData
- type Repository
- func (r *Repository) Create(ctx context.Context, req CreateData) (User, error)
- func (r *Repository) Delete(ctx context.Context, req DeleteData) error
- func (r *Repository) Read(ctx context.Context, req ReadData) (entity.PaginatorResponse, error)
- func (r *Repository) Update(ctx context.Context, req UpdateData) error
- type Service
- func (s *Service) Create(ctx context.Context, req CreateData) (User, error)
- func (s *Service) Delete(ctx context.Context, req DeleteData) error
- func (s *Service) Read(ctx context.Context, req ReadData) (entity.PaginatorResponse, error)
- func (s *Service) Update(ctx context.Context, req UpdateData) error
- type UpdateData
- type User
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
Types ¶
type CreateData ¶
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"`
}
type InterfaceRepository ¶
type InterfaceRepository interface {
Create(context.Context, CreateData) (User, error)
Read(context.Context, ReadData) (entity.PaginatorResponse, error)
Update(context.Context, UpdateData) error
Delete(context.Context, DeleteData) error
}
type InterfaceService ¶
type InterfaceService interface {
Create(context.Context, CreateData) (User, error)
Read(context.Context, ReadData) (entity.PaginatorResponse, error)
Update(context.Context, UpdateData) error
Delete(context.Context, DeleteData) error
}
type ReadData ¶
type ReadData struct {
entity.PaginatorRequest
ID string `query:"id" json:"id"`
}
type Repository ¶
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 (r *Repository) Read(ctx context.Context, req ReadData) (entity.PaginatorResponse, error)
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
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"`
}
Click to show internal directories.
Click to hide internal directories.