entities

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ToResponseSlice

func ToResponseSlice[R Entity[E], E any](entities []*R) ([]*E, error)

Types

type BaseEntity

type BaseEntity[E any] struct {
	RespInstance *E `gorm:"-"`
}

func (*BaseEntity[E]) CopyToResponse

func (b *BaseEntity[E]) CopyToResponse(source any) (*E, error)

type Entity

type Entity[E any] interface {
	ToResponse() (*E, error)
}

type Image

type Image struct {
	BaseEntity[response.ImageResponse]
	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) ToResponse

func (a Image) ToResponse() (*response.ImageResponse, error)

Jump to

Keyboard shortcuts

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