38 lines
978 B
Go
38 lines
978 B
Go
|
|
package models
|
||
|
|
|
||
|
|
import (
|
||
|
|
"time"
|
||
|
|
|
||
|
|
"gorm.io/gorm"
|
||
|
|
)
|
||
|
|
|
||
|
|
type UserType string
|
||
|
|
type UserStatus string
|
||
|
|
|
||
|
|
const (
|
||
|
|
UserTypeClient UserType = "client"
|
||
|
|
UserTypeSupplier UserType = "supplier"
|
||
|
|
UserTypeDriver UserType = "driver"
|
||
|
|
UserTypeStaff UserType = "staff"
|
||
|
|
UserTypeAdmin UserType = "admin"
|
||
|
|
|
||
|
|
UserStatusActive UserStatus = "active"
|
||
|
|
UserStatusInactive UserStatus = "inactive"
|
||
|
|
UserStatusLocked UserStatus = "locked"
|
||
|
|
)
|
||
|
|
|
||
|
|
type User struct {
|
||
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
||
|
|
UUID string `gorm:"uniqueIndex;not null" json:"uuid"`
|
||
|
|
Username string `gorm:"not null" json:"username"`
|
||
|
|
Password string `gorm:"not null" json:"-"`
|
||
|
|
UserType UserType `gorm:"default:client" json:"user_type"`
|
||
|
|
Status UserStatus `gorm:"default:active" json:"status"`
|
||
|
|
CreatedAt time.Time `json:"created_at"`
|
||
|
|
UpdatedAt time.Time `json:"updated_at"`
|
||
|
|
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
|
||
|
|
}
|
||
|
|
|
||
|
|
func (User) TableName() string {
|
||
|
|
return "users"
|
||
|
|
}
|