Documentation ¶
Index ¶
- func CheckPasswordHash(hash, password []byte) error
- func HashPassword(password string) (string, error)
- type CreateUserRequest
- type DeleteUserRequest
- type LoginRequest
- type Repository
- func (r *Repository) CheckUserPassword(user *LoginRequest) error
- func (r *Repository) Close() error
- func (r *Repository) Connect(dbHost string, dbUser string, dbPassword string, dbName string, dbPort int, ...) (*gorm.DB, error)
- func (r *Repository) CreateUser(user *CreateUserRequest) error
- func (r *Repository) DeleteUser(user *DeleteUserRequest) error
- func (r *Repository) GetAllUsers() ([]User, error)
- func (r *Repository) GetUser(user *UserRequest) (*User, error)
- func (r *Repository) Login(user *LoginRequest) error
- func (r *Repository) Migrate() error
- func (r *Repository) Ping() error
- func (r *Repository) UpdateUser(user *UpdateUserRequest) error
- type UpdateUserRequest
- type User
- type UserRequest
- type UserResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckPasswordHash ¶
func HashPassword ¶
Types ¶
type CreateUserRequest ¶
type CreateUserRequest struct { Username string `json:"username" binding:"required" validate:"required,min=1,max=32,alphanum"` Email string `json:"email" binding:"required" validate:"required,min=1,max=255,email"` Password string `json:"password" binding:"required" validate:"required,min=1,max=255"` }
type DeleteUserRequest ¶
type DeleteUserRequest struct {
Username string `json:"username" binding:"required" validate:"required,min=1,max=32,alphanum"`
}
type LoginRequest ¶
type Repository ¶
func NewRepository ¶
func NewRepository(db *gorm.DB, ctx *context.Context) *Repository
func (*Repository) CheckUserPassword ¶
func (r *Repository) CheckUserPassword(user *LoginRequest) error
func (*Repository) Close ¶
func (r *Repository) Close() error
func (*Repository) CreateUser ¶
func (r *Repository) CreateUser(user *CreateUserRequest) error
func (*Repository) DeleteUser ¶
func (r *Repository) DeleteUser(user *DeleteUserRequest) error
func (*Repository) GetAllUsers ¶
func (r *Repository) GetAllUsers() ([]User, error)
func (*Repository) GetUser ¶
func (r *Repository) GetUser(user *UserRequest) (*User, error)
func (*Repository) Login ¶
func (r *Repository) Login(user *LoginRequest) error
func (*Repository) Migrate ¶
func (r *Repository) Migrate() error
func (*Repository) Ping ¶
func (r *Repository) Ping() error
func (*Repository) UpdateUser ¶
func (r *Repository) UpdateUser(user *UpdateUserRequest) error
type UpdateUserRequest ¶
type User ¶
type User struct { Key uint `gorm:"primaryKey"` Username string `gorm:"type:varchar(32);unique;not null" validate:"required,min=1,max=32,alphanum"` Email string `gorm:"type:varchar(255);unique;not null" validate:"required,min=1,max=255,email"` Password string `gorm:"type:varchar(255);not null" validate:"required,min=1,max=255"` CreatedAt time.Time `gorm:"autoCreateTime"` ModifiedAt time.Time `gorm:"autoUpdateTime"` }
type UserRequest ¶
type UserRequest struct {
Username string `json:"username" binding:"required" validate:"required,min=1,max=32,alphanum"`
}
Click to show internal directories.
Click to hide internal directories.