Documentation ¶
Index ¶
- Variables
- func NewHTTP(svc Service, eg *echo.Group)
- type ChangePasswordReq
- type CreateUserReq
- type Crypter
- type HTTP
- type ListUserReq
- type ListUsersResp
- type Service
- type UpdateUserReq
- type User
- func (s *User) ChangePassword(c contextutil.Context, data ChangePasswordReq) error
- func (s *User) Create(c contextutil.Context, data CreateUserReq) (*types.User, error)
- func (s *User) Delete(c contextutil.Context, id string) error
- func (s *User) List(c contextutil.Context, req ListUserReq) (*ListUsersResp, error)
- func (s *User) Me(c contextutil.Context) (*types.User, error)
- func (s *User) Read(c contextutil.Context, id string) (*types.User, error)
- func (s *User) Update(c contextutil.Context, id string, data UpdateUserReq) (*types.User, error)
Constants ¶
This section is empty.
Variables ¶
var ( ErrIncorrectPassword = server.NewHTTPError(http.StatusBadRequest, "INCORRECT_PASSWORD", "Incorrect old password") ErrUserNotFound = server.NewHTTPError(http.StatusBadRequest, "USER_NOTFOUND", "User not found") ErrEmailExisted = server.NewHTTPValidationError("Email already existed") )
Custom errors
Functions ¶
Types ¶
type ChangePasswordReq ¶
type ChangePasswordReq struct { OldPassword string `json:"old_password" validate:"required"` NewPassword string `json:"new_password" validate:"required,min=8"` NewPasswordConfirm string `json:"new_password_confirm" validate:"required,eqfield=NewPassword"` }
ChangePasswordReq contains request data to change user password swagger:model
type CreateUserReq ¶
type CreateUserReq struct { FirstName string `json:"first_name" validate:"required"` LastName string `json:"last_name" validate:"required"` Email string `json:"email" validate:"required,email"` Phone string `json:"phone" validate:"required,phone"` Password string `json:"password" validate:"required,min=8"` Role string `json:"role" validate:"required"` Status string `json:"status"` }
CreateUserReq contains request data to create new user swagger:model
type HTTP ¶
type HTTP struct { contextutil.Context // contains filtered or unexported fields }
HTTP represents user http service
type ListUserReq ¶
type ListUserReq struct { requestutil.ListQueryRequest Name string `json:"name,omitempty" query:"name"` // Search for user(s) by name, email, or phone Search string `json:"search,omitempty" query:"search"` }
ListUserReq contains request data to get list of users swagger:parameters usersList
func (*ListUserReq) ToListCond ¶
func (lq *ListUserReq) ToListCond() *requestutil.ListCondition[repo.UsersFilter]
ToListCond transforms the service request to repo conditions
type ListUsersResp ¶
type ListUsersResp struct { Data []*types.User `json:"data"` TotalCount int64 `json:"total_count"` }
ListUsersResp contains list of paginated users and total numbers after filtered swagger:model
type Service ¶
type Service interface { Create(contextutil.Context, CreateUserReq) (*types.User, error) Read(contextutil.Context, string) (*types.User, error) List(contextutil.Context, ListUserReq) (*ListUsersResp, error) Update(contextutil.Context, string, UpdateUserReq) (*types.User, error) Delete(contextutil.Context, string) error Me(contextutil.Context) (*types.User, error) ChangePassword(contextutil.Context, ChangePasswordReq) error }
Service represents user application interface
type UpdateUserReq ¶
type UpdateUserReq struct { FirstName *string `json:"first_name,omitempty"` LastName *string `json:"last_name,omitempty"` Email *string `json:"email,omitempty" validate:"omitempty,email"` Phone *string `json:"phone,omitempty" validate:"omitempty,phone"` Role *string `json:"role,omitempty"` Status *string `json:"status,omitempty"` }
UpdateUserReq contains request data to update existing user swagger:model
type User ¶
type User struct {
// contains filtered or unexported fields
}
User represents user application service
func (*User) ChangePassword ¶
func (s *User) ChangePassword(c contextutil.Context, data ChangePasswordReq) error
ChangePassword changes user password
func (*User) Create ¶
func (s *User) Create(c contextutil.Context, data CreateUserReq) (*types.User, error)
Create creates new user
func (*User) Delete ¶
func (s *User) Delete(c contextutil.Context, id string) error
Delete deletes user by id
func (*User) List ¶
func (s *User) List(c contextutil.Context, req ListUserReq) (*ListUsersResp, error)
List returns the list of users
func (*User) Update ¶
func (s *User) Update(c contextutil.Context, id string, data UpdateUserReq) (*types.User, error)
Update updates user information