Feat(ktm-booking): Initial commit
Some checks failed
ktm-booking-bot/ktm-booking-bot/pipeline/head Something is wrong with the build of this commit

This commit is contained in:
2022-09-27 02:50:07 +08:00
commit 7cf10b07d4
44 changed files with 4569 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
package user
import (
"net/http"
"time"
"github.com/google/uuid"
"gorm.io/gorm"
)
type User struct {
ID uuid.UUID `gorm:"primaryKey;type:uuid;default:uuid_generate_v4()"`
CreatedAt time.Time
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
Username string
PasswordBcrypt string
Profile Profile
Sessions []Session
}
type UserResponse struct {
ID uuid.UUID `json:"id"`
Username string `json:"username"`
Profile *ProfileResponse `json:"profile"`
}
type UserRegisterRequest struct {
Username string `json:"username" validate:"required,min=2,max=100"`
Password string `json:"password" validate:"required,min=6,max=100"`
}
type UserLoginRequest struct {
Username string `json:"username" validate:"required,min=2,max=100"`
Password string `json:"password" validate:"required"`
}
func (userResponse *UserResponse) Render(w http.ResponseWriter, r *http.Request) error {
// Pre-processing before a response is marshalled and sent across the wire
return nil
}
func (env *Env) NewUserResponse(user *User) *UserResponse {
profileResponse := env.NewProfileResponse(&user.Profile)
userResponse := &UserResponse{
ID: user.ID,
Username: user.Username,
Profile: profileResponse,
}
return userResponse
}