app

package
v0.0.0-...-e0e6d2e Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	URLPrefix        = "SURL:"
	URLLockPrefix    = "SURL_LOCK:"
	ShortId          = "SURL_SHORT_ID"
	CODEPrefix       = "SURL_CODE:"
	CODEVistedPrefix = "SURL_CODE_VISITED:"
)

Variables

View Source
var (
	DEBUG = env.Bool("DEBUG", true)
)

环境变量

Functions

func ConvertIntToStr

func ConvertIntToStr(num int) string

func ConvertURL

func ConvertURL(url string, h int) string

ConvertURL 转换地址

func GetDB

func GetDB(config ...*DBConfig) *gorm.DB

GetDB get db connection

func GetURL

func GetURL(code string) (string, error)

GetCode 获取地址短码

Types

type DBConfig

type DBConfig struct {
	Server       string `yaml:"server" json:"server"`
	Driver       string `yaml:"driver" json:"driver"`
	Host         string `yaml:"host" json:"host"`
	Port         uint   `yaml:"port" json:"port"`
	User         string `yaml:"user" json:"user"`
	Password     string `yaml:"password" json:"password"`
	Name         string `yaml:"name" json:"name"`
	MaxIdleConns uint   `yaml:"max_idle_conns" json:"max_idle_conns"`
	MaxOpenConns uint   `yaml:"max_open_conns" json:"max_open_conns"`
	EnableLog    bool   `yaml:"enable_log" json:"enable_log"`
}

DBConfig config of relational database

type ShortURL

type ShortURL struct {
	ID        uint   `gorm:"primarykey"`
	URL       string `gorm:"size:500;NOT NULL;comment:长地址"`
	ShortCode string `gorm:"size:10;NOT NULL;comment:短码"`
	Deadline  time.Time
	CreatedAt time.Time
}

ShortURL 短地址

Jump to

Keyboard shortcuts

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