entities

package
v0.3.5 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2025 License: MIT Imports: 1 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Avatar added in v0.3.5

type Avatar struct {
	Id        uint      `gorm:"primaryKey"`
	UserId    uint      `gorm:"uniqueIndex;not null"`
	ImageId   uint      `gorm:"not null"`
	Image     Image     `gorm:"constraint:OnDelete:CASCADE;foreignKey:ImageId"`
	CreatedAt time.Time `gorm:"autoCreateTime"`
}

func (Avatar) MarkerEntity added in v0.3.5

func (user Avatar) MarkerEntity()

func (Avatar) TableName added in v0.3.5

func (Avatar) TableName() string

type Ban added in v0.2.7

type Ban struct {
	Id          uint   `gorm:"primaryKey"`
	UserId      uint   `gorm:"not null"`
	User        User   `gorm:"foreignKey:UserId;constraint:OnDelete:CASCADE"`
	Reason      string `gorm:"type:text"`
	IsPermanent bool   `gorm:"not null;default:false"`
	UnbanDate   *time.Time
	IsActive    bool      `gorm:"not null;default:true"`
	CreatedAt   time.Time `gorm:"default:CURRENT_TIMESTAMP"`
	UpdatedAt   time.Time `gorm:"default:CURRENT_TIMESTAMP"`
}

func (Ban) MarkerEntity added in v0.2.10

func (b Ban) MarkerEntity()

type Entity

type Entity interface {
	MarkerEntity()
}

type Image

type Image struct {
	Id        uint      `gorm:"primaryKey"`
	S3Key     string    `gorm:"size:255;not null"`
	Url       string    `gorm:"size:512;not null"`
	UserID    *uint     `gorm:"index"` // Указатель для nullable
	Size      int       `gorm:""`
	MimeType  string    `gorm:"size:50"`
	ExpiresAt time.Time `gorm:""`
	CreatedAt time.Time `gorm:"default:CURRENT_TIMESTAMP"`
}

func (Image) MarkerEntity added in v0.2.10

func (b Image) MarkerEntity()

type Role

type Role struct {
	Id          uint   `gorm:"primaryKey"`
	Name        string `gorm:"unique;not null"`
	Level       int    `gorm:"not null;default:0"`
	Description string
	CreatedAt   time.Time
	UpdatedAt   time.Time
}

func (Role) HasAccess added in v0.3.5

func (r Role) HasAccess(required int) bool

func (Role) IsValid added in v0.3.5

func (r Role) IsValid() bool

func (Role) MarkerEntity added in v0.2.10

func (r Role) MarkerEntity()

type User

type User struct {
	Id           uint   `gorm:"primaryKey"`
	Username     string `gorm:"unique;not null"`
	Email        string `gorm:"unique;not null" query:"ops:ilike|like|eq|neq"`
	PasswordHash string `gorm:"not null" query:"ignore"`
	FirstName    string
	LastName     string
	RoleId       uint
	IsBanned     bool  `gorm:"default:false"`
	Bans         []Ban `gorm:"foreignKey:UserId"`
	Role         Role  `gorm:"foreignKey:RoleId"`
	IsActive     bool
	LastLogin    *time.Time
	CreatedAt    time.Time `gorm:"default:CURRENT_TIMESTAMP"`
	UpdatedAt    time.Time `gorm:"default:CURRENT_TIMESTAMP"`
	Avatar       *Avatar   `gorm:"foreignKey:UserId;references:Id"`
}

func (User) MarkerEntity added in v0.2.10

func (user User) MarkerEntity()

Jump to

Keyboard shortcuts

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