48 lines
1.5 KiB
Go
48 lines
1.5 KiB
Go
package domain
|
|
|
|
import (
|
|
"encoding/json"
|
|
)
|
|
|
|
const (
|
|
UnverifiedUser = 0
|
|
VerificatedUser = 1
|
|
AdminUser = 100
|
|
)
|
|
|
|
type User struct {
|
|
ID int `json:"id" db:"id"`
|
|
Role int `json:"-" db:"role"`
|
|
Username string `json:"username" db:"username"`
|
|
Email string `json:"email" db:"email"`
|
|
HashedPassword string `json:"-" db:"hashed_password"`
|
|
AvatarImage string `json:"avatar_image" db:"avatar_image"`
|
|
BlackPhoenix bool `json:"black_phoenix" db:"black_phoenix"`
|
|
DateOfBirth CustomDate `json:"date_of_birth" db:"date_of_birth"`
|
|
DateOfRegistration CustomDate `json:"date_of_registration" db:"date_of_registration"`
|
|
}
|
|
|
|
func (u *User) UnmarshalBinary(b []byte) error {
|
|
return json.Unmarshal(b, u)
|
|
}
|
|
|
|
func (u *User) MarshalBinary() ([]byte, error) {
|
|
return json.Marshal(u)
|
|
}
|
|
|
|
type UserFilter struct {
|
|
Username string `json:"username" validate:"omitempty,min=2,max=30"`
|
|
Email string `json:"email" validate:"omitempty,email"`
|
|
}
|
|
|
|
type UserPassword struct {
|
|
UserPassword string `json:"user_password" validate:"min=8"`
|
|
}
|
|
|
|
type UserRegister struct {
|
|
Email string `json:"email" validate:"email"`
|
|
Username string `json:"username" validate:"min=2,max=30"`
|
|
Password string `json:"password" validate:"min=8"`
|
|
Password2 string `json:"password2" validate:"eqfield=Password"`
|
|
DateOfBirth CustomDate `json:"date_of_birth" validate:"date_of_birth"`
|
|
}
|