34 lines
902 B
Go
34 lines
902 B
Go
package entity
|
|
|
|
import (
|
|
"time"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
type UserStatus string
|
|
|
|
const (
|
|
UserStatusPending UserStatus = "pending"
|
|
UserStatusApproved UserStatus = "approved"
|
|
UserStatusRejected UserStatus = "rejected"
|
|
)
|
|
|
|
type User struct {
|
|
ID uuid.UUID `json:"id" gorm:"type:uuid;primaryKey"`
|
|
NomorInduk *string `json:"nomor_induk,omitempty" gorm:"unique"`
|
|
RoleID uuid.UUID `json:"role_id" gorm:"type:uuid"`
|
|
Role Role `json:"role" gorm:"foreignKey:RoleID"`
|
|
Name string `json:"name" gorm:"unique"`
|
|
Username string `json:"username" gorm:"unique"`
|
|
Password string `json:"password"`
|
|
Status UserStatus `json:"status" gorm:"type:varchar(20);default:'pending'"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
}
|
|
|
|
func (User) TableName() string {
|
|
return "users"
|
|
}
|
|
|