Documentation
¶
Index ¶
- Variables
- type CreateUserPayload
- type Handler
- func (h *Handler) CreateUser(w http.ResponseWriter, r *http.Request)
- func (h *Handler) LinkEmail(w http.ResponseWriter, r *http.Request)
- func (h *Handler) LinkPhoneNumber(w http.ResponseWriter, r *http.Request)
- func (h *Handler) ListUser(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Login(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Update(w http.ResponseWriter, r *http.Request)
- type LinkEmailPayload
- type LinkPhoneNumberPayload
- type ListUserPayload
- type LoginPayload
- type Repository
- type Service
- type UpdateUserPayload
- type User
- type UserCommentResponse
- type UserGetResponse
- type UserListResponse
- type UserLoginResponse
- type UserRegisterResponse
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUserNotFound = errors.New("user not found") ErrWrongPassword = errors.New("wrong password") ErrUserPhoneNumberAlreadyExists = errors.New("user phone number already exists") ErrUserEmailAlreadyExists = errors.New("user email already exists") ErrUserHasEmail = errors.New("user already has email") ErrUserHasPhoneNumber = errors.New("user already has phone number") ErrValidationFailed = errors.New("validation failed") ErrCredentialMustExists = errors.New("credential must be one of phone/email") )
View Source
var ( SortByFriendCount string = "friendCount" SortByCreatedAt string = "createdAt" )
View Source
var UserSortBys []string = []string{SortByFriendCount, SortByCreatedAt}
Functions ¶
This section is empty.
Types ¶
type CreateUserPayload ¶
type CreateUserPayload struct {
CredentialType string `json:"credentialType"`
CredentialValue string `json:"credentialValue"`
Name string `json:"name"`
Password string `json:"password"`
}
func (CreateUserPayload) Validate ¶
func (p CreateUserPayload) Validate() error
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func (*Handler) CreateUser ¶
func (h *Handler) CreateUser(w http.ResponseWriter, r *http.Request)
func (*Handler) LinkPhoneNumber ¶
func (h *Handler) LinkPhoneNumber(w http.ResponseWriter, r *http.Request)
type LinkEmailPayload ¶
type LinkEmailPayload struct {
Email string `json:"email"`
}
func (LinkEmailPayload) Validate ¶
func (p LinkEmailPayload) Validate() error
type LinkPhoneNumberPayload ¶
type LinkPhoneNumberPayload struct {
Phone string `json:"phone"`
}
func (LinkPhoneNumberPayload) Validate ¶
func (p LinkPhoneNumberPayload) Validate() error
type ListUserPayload ¶
type LoginPayload ¶
type LoginPayload struct {
CredentialType string `json:"credentialType"`
CredentialValue string `json:"credentialValue"`
Password string `json:"password"`
}
func (LoginPayload) Validate ¶
func (p LoginPayload) Validate() error
type Repository ¶
type Repository interface {
CreateWithEmail(ctx context.Context, user *User) error
CreateWithPhoneNumber(ctx context.Context, user *User) error
GetByEmail(ctx context.Context, email string) (*User, error)
GetByPhoneNumber(ctx context.Context, phoneNumber string) (*User, error)
GetByID(ctx context.Context, id string) (*User, error)
Update(ctx context.Context, user *User) error
List(ctx context.Context, filter ListUserPayload) ([]UserListResponse, *response.Pagination, error)
}
func NewRepository ¶
func NewRepository(db *db.DB) Repository
type Service ¶
type Service interface {
Create(ctx context.Context, req CreateUserPayload) (*UserRegisterResponse, error)
Login(ctx context.Context, req LoginPayload) (*UserLoginResponse, error)
LinkEmail(ctx context.Context, req LinkEmailPayload, userID string) error
LinkPhoneNumber(ctx context.Context, req LinkPhoneNumberPayload, userID string) error
Update(ctx context.Context, req UpdateUserPayload, userID string) error
List(ctx context.Context, req ListUserPayload) ([]UserListResponse, *response.Pagination, error)
}
func NewService ¶
func NewService(repository Repository) Service
type UpdateUserPayload ¶
func (UpdateUserPayload) Validate ¶
func (p UpdateUserPayload) Validate() error
type UserCommentResponse ¶
type UserGetResponse ¶
type UserListResponse ¶
type UserLoginResponse ¶
Click to show internal directories.
Click to hide internal directories.