Documentation ¶
Index ¶
- Variables
- type ChangePasswordRequest
- type Gender
- type Handler
- func (h *Handler) DeleteUser(w http.ResponseWriter, r *http.Request)
- func (h *Handler) FindUserById(w http.ResponseWriter, r *http.Request)
- func (h *Handler) GetAllUsers(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Register(w http.ResponseWriter, r *http.Request)
- func (h *Handler) Routes() []router.Route
- func (h *Handler) Update(w http.ResponseWriter, r *http.Request)
- type MongoDBRepository
- func (m *MongoDBRepository) CheckEmailIsRegisted(ctx context.Context, email string) error
- func (m *MongoDBRepository) Create(ctx context.Context, user User) (string, error)
- func (m *MongoDBRepository) Delete(ctx context.Context, id string) error
- func (m *MongoDBRepository) FindUserByEmail(ctx context.Context, email string) (*User, error)
- func (m *MongoDBRepository) FindUserById(ctx context.Context, id string) (*User, error)
- func (m *MongoDBRepository) GetAllUsers(ctx context.Context) ([]*User, error)
- func (m *MongoDBRepository) Update(ctx context.Context, user User) error
- type RegisterRequest
- type Service
- func (s *Service) ChangePassword(ctx context.Context, req ChangePasswordRequest) error
- func (s *Service) DeleteUser(ctx context.Context, id string) error
- func (s *Service) FindUserByEmail(ctx context.Context, email string) (*types.UserInfo, error)
- func (s *Service) FindUserById(ctx context.Context, id string) (*types.UserInfo, error)
- func (s *Service) GetAllUsers(ctx context.Context) ([]*types.UserInfo, error)
- func (s *Service) Register(ctx context.Context, req RegisterRequest) (string, error)
- func (s *Service) Update(ctx context.Context, id string, req UpdateInfoRequest) error
- type UpdateInfoRequest
- type User
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrUserNotFound = errors.New("user not found") ErrDB = errors.New("DB error") ErrUpdateUserFailed = errors.New("update user failed") ErrUserAlreadyExist = errors.New("user already exist") ErrGenPasswordFailed = errors.New("generate password failed") ErrCreateUserFailed = errors.New("create user failed") ErrPermissionDeny = errors.New("permission deny") )
Functions ¶
This section is empty.
Types ¶
type ChangePasswordRequest ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func NewHandler(srv service) *Handler
func (*Handler) DeleteUser ¶
func (h *Handler) DeleteUser(w http.ResponseWriter, r *http.Request)
func (*Handler) FindUserById ¶
func (h *Handler) FindUserById(w http.ResponseWriter, r *http.Request)
func (*Handler) GetAllUsers ¶
func (h *Handler) GetAllUsers(w http.ResponseWriter, r *http.Request)
type MongoDBRepository ¶
type MongoDBRepository struct {
// contains filtered or unexported fields
}
func NewMongoDBRepository ¶
func NewMongoDBRepository(session *mgo.Session) *MongoDBRepository
func (*MongoDBRepository) CheckEmailIsRegisted ¶
func (m *MongoDBRepository) CheckEmailIsRegisted(ctx context.Context, email string) error
func (*MongoDBRepository) Delete ¶
func (m *MongoDBRepository) Delete(ctx context.Context, id string) error
func (*MongoDBRepository) FindUserByEmail ¶
func (*MongoDBRepository) FindUserById ¶
func (*MongoDBRepository) GetAllUsers ¶
func (m *MongoDBRepository) GetAllUsers(ctx context.Context) ([]*User, error)
type RegisterRequest ¶
type RegisterRequest struct { FirstName string `validate:"required" json:"first_name"` LastName string `validate:"required" json:"last_name"` Gender Gender `validate:"gte=0,lte=2" json:"gender"` Email string `validate:"required,email" json:"email"` Password string `validate:"required" json:"password"` }
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewService ¶
func NewService(repo repository, policy policyService) *Service
func (*Service) ChangePassword ¶
func (s *Service) ChangePassword(ctx context.Context, req ChangePasswordRequest) error
func (*Service) FindUserByEmail ¶
func (*Service) FindUserById ¶
func (*Service) GetAllUsers ¶
type UpdateInfoRequest ¶
type User ¶
type User struct { ID string `bson:"_id"` FirstName string `bson:"first_name"` LastName string `bson:"last_name"` Gender Gender `bson:"gender"` Email string `bson:"email"` Role string `bson:"role"` Password string `bson:"password"` Locked bool `bson:"locked"` CreatedAt time.Time `bson:"created_at"` UpdatedAt time.Time `bson:"updated_at"` }
func (*User) ConvertUserToUserInfo ¶
func (*User) TrimSecrectUserInfo ¶
Click to show internal directories.
Click to hide internal directories.