models

package
v0.0.0-...-f095a72 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteCizzor

func DeleteCizzor(id uint64) error

func DeleteUser

func DeleteUser(id uint64) error

func Setup

func Setup()

Types

type Cizzor

type Cizzor struct {
	ID           uint64        `json:"id" gorm:"primary_key"`
	Url          string        `json:"url" gorm:"not null"`
	ShortUrl     string        `json:"short_url" gorm:"not null"`
	Count        int           `json:"count"`
	Random       bool          `json:"random"`
	OwnerId      uint64        `json:"owner_id" gorm:"foreignKey:UserID"`
	ClickSources []ClickSource `json:"-" gorm:"foreignKey:CizzorID"`
	CreatedAt    time.Time     `json:"created_at" gorm:"type:timestamp with time zone;autoCreateTime"`
	UpdatedAt    time.Time     `json:"updated_at" gorm:"type:timestamp with time zone;autoUpdateTime"`
}

func CreateCizzor

func CreateCizzor(cizzor Cizzor) (Cizzor, error)

func GetAllCizzors

func GetAllCizzors(userID uint64) ([]Cizzor, error)

func GetCizzorById

func GetCizzorById(id uint64) (Cizzor, error)

func GetCizzorByShortUrl

func GetCizzorByShortUrl(shortUrl string) (Cizzor, error)

func UpdateCizzor

func UpdateCizzor(userID uint64, cizzor Cizzor) (Cizzor, error)

func UpdateCizzorCount

func UpdateCizzorCount(cizzor Cizzor) (Cizzor, error)

func (*Cizzor) UpdateClickSourceCount

func (c *Cizzor) UpdateClickSourceCount(ipAddress, location string)

type ClickSource

type ClickSource struct {
	ID        uint64    `json:"id" gorm:"primary_key"`
	CizzorID  uint64    `json:"cizzor_id" gorm:"foreignKey:CizzorID"`
	IpAddress string    `json:"ip_address" gorm:"not null"`
	Location  string    `json:"location" gorm:"not null"`
	Count     uint64    `json:"count"`
	CreatedAt time.Time `json:"created_at" gorm:"type:timestamp with time zone;autoCreateTime"`
	UpdatedAt time.Time `json:"updated_at" gorm:"type:timestamp with time zone;autoUpdateTime"`
}

func GetClickSources

func GetClickSources(userID, cizzorID uint64) (ClickSource, error)

type User

type User struct {
	ID        uint64    `json:"id" gorm:"primary_key"`
	Username  string    `json:"username" gorm:"not null;unique"`
	Email     string    `json:"email" gorm:"not null;unique"`
	Password  string    `json:"password" gorm:"not null"`
	CreatedAt time.Time `json:"created_at" gorm:"type:timestamp with time zone;autoCreateTime"`
	UpdatedAt time.Time `json:"updated_at" gorm:"type:timestamp with time zone;autoUpdateTime"`
}

func CreateUser

func CreateUser(user User) (User, error)

func GetUserByID

func GetUserByID(id uint64) (User, error)

func LoginUser

func LoginUser(user User) (User, error)

func UpdateUser

func UpdateUser(user User) (User, error)

Jump to

Keyboard shortcuts

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