Documentation ¶
Index ¶
- type AddUser
- type Handler
- func (h *Handler) Create() http.HandlerFunc
- func (h *Handler) Delete(db *sqlx.DB, s auth.Session) http.HandlerFunc
- func (h *Handler) Get() http.HandlerFunc
- func (h *Handler) GetByID() http.HandlerFunc
- func (h *Handler) QRCode() http.HandlerFunc
- func (h *Handler) Search() http.HandlerFunc
- func (h *Handler) Update() http.HandlerFunc
- type ListUser
- type Repository
- type Service
- type UpdateUser
- type User
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddUser ¶
type AddUser struct { ID string `json:"id"` CartID string `json:"cart_id" db:"cart_id"` Username string `json:"username" validate:"required,max=25"` Email string `json:"email" validate:"email,required"` Password string `json:"password" validate:"required,min=6"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
AddUser is used to create new users.
type Handler ¶
type Handler struct {
Service Service
}
Handler handles user endpoints.
func (*Handler) Create ¶
func (h *Handler) Create() http.HandlerFunc
Create creates a new user and saves it.
func (*Handler) GetByID ¶
func (h *Handler) GetByID() http.HandlerFunc
GetByID lists the user with the id requested.
func (*Handler) QRCode ¶
func (h *Handler) QRCode() http.HandlerFunc
QRCode shows the user id in a qrcode format.
func (*Handler) Search ¶
func (h *Handler) Search() http.HandlerFunc
Search looks for the products with the given value.
func (*Handler) Update ¶
func (h *Handler) Update() http.HandlerFunc
Update updates the user with the given id.
type ListUser ¶
type ListUser struct { ID string `json:"id"` CartID string `json:"cart_id" db:"cart_id"` Username string `json:"username"` Email string `json:"email" validate:"email"` Orders []ordering.Order `json:"orders,omitempty"` Reviews []review.Review `json:"reviews,omitempty"` }
ListUser is the structure used to list users.
type Repository ¶
type Repository interface { Create(ctx context.Context, user *AddUser) error Delete(ctx context.Context, id string) error Get(ctx context.Context) ([]ListUser, error) GetByEmail(ctx context.Context, email string) (User, error) GetByID(ctx context.Context, id string) (ListUser, error) Search(ctx context.Context, search string) ([]ListUser, error) Update(ctx context.Context, u *UpdateUser, id string) error }
Repository provides access to the storage.
type Service ¶
type Service interface { Create(ctx context.Context, user *AddUser) error Delete(ctx context.Context, id string) error Get(ctx context.Context) ([]ListUser, error) GetByEmail(ctx context.Context, email string) (User, error) GetByID(ctx context.Context, id string) (ListUser, error) Search(ctx context.Context, search string) ([]ListUser, error) Update(ctx context.Context, u *UpdateUser, id string) error }
Service provides user operations.
func NewService ¶
func NewService(r Repository, db *sqlx.DB) Service
NewService creates a deleting service with the necessary dependencies.
type UpdateUser ¶
type UpdateUser struct {
Username string `json:"username" validate:"required"`
}
UpdateUser is the structure used to update users.
type User ¶
type User struct { ID string `json:"id" validate:"unique"` CartID string `json:"cart_id" db:"cart_id"` Username string `json:"username"` Email string `json:"email" validate:"email"` Password string `json:"password"` EmailVerifiedAt time.Time `json:"-" db:"email_verified_at"` ConfirmationCode string `json:"-" db:"confirmation_code"` Orders []ordering.Order `json:"orders,omitempty"` Reviews []review.Review `json:"reviews,omitempty"` CreatedAt time.Time `json:"created_at" db:"created_at"` UpdatedAt time.Time `json:"updated_at" db:"updated_at"` }
User represents platform customers. Each user has a unique cart.
Click to show internal directories.
Click to hide internal directories.