Documentation ¶
Index ¶
Constants ¶
View Source
const APIPath = "/users/"
APIPath is path prefix
Variables ¶
View Source
var EmptyUser = User{}
EmptyUser is empty user model
Functions ¶
This section is empty.
Types ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
Controller is user controller
func NewController ¶
func NewController(repo Repository, passport service.Passport) *Controller
NewController return new user controller instance.
func (*Controller) RegisterRoutes ¶
func (controller *Controller) RegisterRoutes(router gin.IRouter)
RegisterRoutes register handler routes.
type CreateUserRequest ¶
type CreateUserRequest struct { UserName string `json:"username" example:"<new username>" binding:"required,min=4,max=100"` Password string `json:"password" example:"<new password>" binding:"required,min=8,max=50"` }
CreateUserRequest is dto that contains info that require to create user.
type Repository ¶
type Repository interface { CreateUser(User) (User, error) GetUserByUserName(userName string) (User, error) GetUserByUserID(userID int64) (User, error) UpdateUserByUserID(userID int64, user User) (User, error) RemoveUserByUserID(userID int64) (User, error) }
Repository communications with db connection.
func NewRepository ¶
func NewRepository(dbConn *db.Conn) Repository
NewRepository return new instance.
type UpdateUserRequest ¶
type UpdateUserRequest struct {
UserName string `json:"user_name" example:"<new user name>" binding:"min=4,max=100"`
}
UpdateUserRequest is dto that contains info that require to update user.
type User ¶
type User struct { ID int64 `gorm:"primary_key;"` UserName string `gorm:"unique;not null;"` PasswordHash []byte `gorm:"not null;"` CreatedAt int64 `gorm:"not null;"` }
User is user data model
func (User) Response ¶
func (user User) Response() UserResponse
Response return new user response from user entity.
Click to show internal directories.
Click to hide internal directories.