entity

package
v0.0.0-...-dbd5446 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Meta

type Meta struct {
	M []MetaValues `json:"meta_collection"`
}

func (*Meta) Scan

func (j *Meta) Scan(value interface{}) error

Scan scan value into Jsonb, implements sql.Scanner interface

func (*Meta) Value

func (j *Meta) Value() (driver.Value, error)

Value return json value, implement driver.Valuer interface

type MetaValues

type MetaValues struct {
	Name   string   `json:"name"`
	Values []string `json:"values"`
}

type Shorty

type Shorty struct {
	ID               uuid.UUID      `json:"id" gorm:"column:id;type:uuid;default:uuid_generate_v4()"`
	PublicID         string         `json:"-" gorm:"column:public_id"`
	Link             string         `json:"link" gorm:"column:link"`
	TTL              *time.Time     `json:"TTL" gorm:"column:ttl"`
	RedirectionLimit *int           `json:"redirection_limit" gorm:"column:redirection_limit"`
	CreatedAt        *time.Time     `json:"created_at" gorm:"column:created_at"`
	DeletedAt        *time.Time     `json:"deleted_at" gorm:"column:deleted_at"`
	ShortyAccesses   []ShortyAccess `json:"accesses,omitempty" gorm:"-"`
	ShortLink        string         `json:"short_link" gorm:"-"`
	Visits           int            `json:"visits" gorm:"-"`
	RedirectCount    int            `json:"redirects" gorm:"-"`
	QRCode           string         `json:"qr_code,omitempty" gorm:"column:qr_code"`
}

func (*Shorty) TableName

func (*Shorty) TableName() string

type ShortyAccess

type ShortyAccess struct {
	ID              uuid.UUID  `json:"id" gorm:"column:id;type:uuid;default:uuid_generate_v4()"`
	CreatedAt       *time.Time `json:"created_at" gorm:"column:created_at"`
	ShortyID        uuid.UUID  `json:"-" gorm:"column:shorty_id"`
	Meta            Meta       `json:"meta" gorm:"column:meta; type:JSONB"`
	UserAgent       string     `json:"user_agent" gorm:"column:user_agent"`
	IPAddress       string     `json:"ip" gorm:"column:ip_address"`
	Extra           string     `json:"extra" gorm:"column:extra"`
	OperatingSystem string     `json:"os" gorm:"column:operating_system"`
	Browser         string     `json:"browser" gorm:"column:browser"`
	Status          string     `json:"status" gorm:"column:status"`
}

func (ShortyAccess) ConvertMeta

func (ShortyAccess) ConvertMeta(a map[string][]string) Meta

func (ShortyAccess) TableName

func (ShortyAccess) TableName() string

type ShortyAccessRepository

type ShortyAccessRepository struct {
	database.Repository
}

func NewShortyAccessRepository

func NewShortyAccessRepository(db *database.Database, log *zap.Logger) *ShortyAccessRepository

func (*ShortyAccessRepository) ListByShortyUUID

func (r *ShortyAccessRepository) ListByShortyUUID(id uuid.UUID, limit, offset int) ([]*ShortyAccess, error)

type ShortyForList

type ShortyForList struct {
	ID               uuid.UUID      `json:"id" gorm:"column:id;type:uuid;default:uuid_generate_v4()"`
	PublicID         string         `json:"public_id" gorm:"column:public_id"`
	Link             string         `json:"link" gorm:"column:link"`
	TTL              *time.Time     `json:"TTL,omitempty" gorm:"column:ttl"`
	RedirectionLimit *int           `json:"redirection_limit,omitempty" gorm:"column:redirection_limit"`
	CreatedAt        *time.Time     `json:"created_at" gorm:"column:created_at"`
	DeletedAt        *time.Time     `json:"deleted_at" gorm:"column:deleted_at"`
	ShortyAccesses   []ShortyAccess `json:"accesses,omitempty" gorm:"-"`
	ShortLink        string         `json:"short_link,omitempty" gorm:"-"`
	Visits           int            `json:"visits" gorm:"visits"`
	Redirects        int            `json:"redirects" gorm:"redirects"`
	QRCode           string         `json:"qr_code,omitempty" gorm:"column:qr_code"`
}

type ShortyRepository

type ShortyRepository struct {
	database.Repository
}

func NewShortyRepository

func NewShortyRepository(db *database.Database, log *zap.Logger) *ShortyRepository

func (*ShortyRepository) Delete

func (r *ShortyRepository) Delete(id uuid.UUID) error

func (*ShortyRepository) List

func (r *ShortyRepository) List(limit, offset int) ([]*Shorty, error)

func (*ShortyRepository) ListWithAccessData

func (r *ShortyRepository) ListWithAccessData(listWithQRCode bool, limit, offset int) ([]*ShortyForList, error)

Jump to

Keyboard shortcuts

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