models

package
v0.0.0-...-bcca52d Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UrlShortenPerTableCnt = 1 * 2000 * 10000

	// change to use more table
	// max value: (utils/shorten.maxNum) / UrlShortenPerTableCnt ~= 1981
	UrlShortenTableCnt = 2
)
View Source
const (
	AccessHistoryTableCnt = 2
)

Variables

This section is empty.

Functions

func DBTx

func DBTx(table string) *gorm.DB

func GetAccessHistoryTableById

func GetAccessHistoryTableById(id int64) string

func GetDB

func GetDB() *gorm.DB

func GetUrlShortenTable

func GetUrlShortenTable(url string) string

GetUrlShortenTable for write

func GetUrlShortenTableById

func GetUrlShortenTableById(id int64) string

GetUrlShortenTableById for read

func IsIDValid

func IsIDValid(id int64) bool

func SetDefaultDB

func SetDefaultDB(db *gorm.DB)

Types

type AccessHistory

type AccessHistory struct {
	ID    int64  `gorm:"column:id" json:"id"`
	Code  string `gorm:"column:code" json:"code"`
	Ip    string `gorm:"column:ip" json:"ip"`
	Ctime int64  `gorm:"column:ctime" json:"ctime"`
}

type UrlShorten

type UrlShorten struct {
	ID    int64  `gorm:"column:id" json:"id"`
	Url   string `gorm:"column:url" json:"url"`
	Ip    string `gorm:"column:ip" json:"ip"`
	Ctime int64  `gorm:"column:ctime" json:"ctime"`
	Extra string `gorm:"column:extra" json:"extra"`
}

Jump to

Keyboard shortcuts

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