model

package
v0.0.0-rc5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RoleUser  = "user"
	RoleAdmin = "admin"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BannedTokenEntity

type BannedTokenEntity struct {
	ID        int       `gorm:"column:id;type:serial;primaryKey"`
	JTI       string    `gorm:"column:jti;type:text;unique;not null"`
	CreatedAt time.Time `gorm:"column:created_at;not null;type:timestamptz;default:now();autoCreateTime"`
	UpdatedAt time.Time `gorm:"column:updated_at;not null;type:timestamptz;default:now();autoUpdateTime"`
	ExpiredAt int64     `gorm:"column:expired_at;not null;type:bigint;index:expired_at_banned_tokens_index"`
}

func (BannedTokenEntity) TableName

func (BannedTokenEntity) TableName() string

type RoleEntity

type RoleEntity struct {
	ID          int       `gorm:"column:id;type:serial;primaryKey"`
	Name        string    `gorm:"column:name;type:text;not null;unique"`
	Description *string   `gorm:"column:description;type:text"`
	CreatedAt   time.Time `gorm:"column:created_at;not null;type:timestamptz;default:now();autoCreateTime"`
	UpdatedAt   time.Time `gorm:"column:updated_at;not null;type:timestamptz;default:now();autoUpdateTime"`
}

func (RoleEntity) TableName

func (RoleEntity) TableName() string

type UserEntity

type UserEntity struct {
	ID              uuid.UUID  `gorm:"column:id;type:uuid;primaryKey;default:uuid_generate_v4()"`
	Username        string     `gorm:"column:username;type:varchar(255);not null;unique"`
	Email           string     `gorm:"column:email;type:text;not null;unique"`
	Password        string     `gorm:"column:password;type:text;not null"`
	Role            RoleEntity `gorm:"foreignkey:RoleID;references:id;constraint:OnUpdate:CASCADE,OnDelete:RESTRICT"`
	RoleID          int        `gorm:"column:role_id;not null"`
	IsEnabled       bool       `gorm:"column:is_enabled;not null;default:true;index:is_enabled_users_index"`
	IsEmailVerified bool       `gorm:"column:is_email_verified;not null;default:false;index:is_email_verified_users_index"`
	IsPasswordTemp  bool       `gorm:"column:is_password_temp;not null;default:true;index:is_password_temp_index"`
	CreatedAt       time.Time  `gorm:"column:created_at;not null;type:timestamptz;default:now();autoCreateTime"`
	UpdatedAt       time.Time  `gorm:"column:updated_at;not null;type:timestamptz;default:now();autoUpdateTime"`
	DeletedAt       *time.Time `gorm:"column:deleted_at;type:timestamptz;index:deleted_at_users_index"`
}

func (*UserEntity) BeforeCreate

func (u *UserEntity) BeforeCreate(tx *gorm.DB) error

BeforeCreate sets default role

func (UserEntity) TableName

func (UserEntity) TableName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL