xlink

package
v0.2.7 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2023 License: BSD-3-Clause-Clear Imports: 5 Imported by: 0

Documentation

Overview

短连接服务

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Create

func Create(bat *Link) error

创建连接信息

func PvCreate

func PvCreate(bat *LinkBrow) error

创建连接信息

bat	连接访问PV信息

func Regedit

func Regedit(c *Config)

配置项注入

Types

type Config

type Config struct {
	DB           *gorm.DB // 数据库连接
	LinkName     string   // 连接存储表
	LinkBrowName string   // 连接点击表
}
type Link struct {
	Id        uint64 `gorm:"column:id;primaryKey;type:BIGINT UNSIGNED;not null;autoIncrement" json:"id" form:"id"`
	UserId    uint   `gorm:"column:user_id;type:INT UNSIGNED;comment:创建人" json:"user_id" form:"user_id"`                         //创建人
	Uri       string `gorm:"column:uri;type:VARCHAR(200);comment:源链接信息" json:"uri" form:"uri"`                                   //源链接信息
	EndDate   string `gorm:"column:end_date;type:DATE;comment:过期时间" json:"end_date" form:"end_date"`                             //过期时间
	Codes     string `gorm:"column:codes;type:CHAR(6);index:codes;comment:短链识别码" json:"codes" form:"codes"`                      //短链识别码
	Status    uint8  `gorm:"column:status;type:TINYINT UNSIGNED;comment:状态 0-正常 1-禁用" json:"status" form:"status"`               //状态 0-正常 1-禁用
	IsDeleted uint8  `gorm:"column:is_deleted;type:TINYINT UNSIGNED;comment:是否删除 0-正常 1-删除" json:"is_deleted" form:"is_deleted"` //是否删除 0-正常 1-删除
	CreatedAt string `gorm:"column:created_at;type:DATETIME;comment:创建时间" json:"created_at" form:"created_at"`                   // 创建时间
	UpdatedAt string `gorm:"column:updated_at;type:DATETIME;comment:最后更新时间" json:"updated_at" form:"updated_at"`                 // 最后更新时间
}

短链接存储表(配置短链接信息)

func Find

func Find(id uint, code string) (*Link, error)

查询连接信息(只查询在有效期内的、有效的连接)

id		连接ID
code	连接code码

func (*Link) TableName

func (c *Link) TableName() string

获取表名

type LinkBrow

type LinkBrow struct {
	Id          uint64 `gorm:"column:id;primaryKey;type:BIGINT UNSIGNED;not null;autoIncrement" json:"id" form:"id"`
	UrlId       uint64 `gorm:"column:url_id;type:BIGINT UNSIGNED;index:url_id;comment:短链接ID" json:"url_id" form:"url_id"`   //短链接ID
	Ua          uint   `gorm:"column:ua;type:INT UNSIGNED;comment:UA,关联KV表" json:"ua" form:"ua"`                            //UA,关联KV表
	System      uint   `gorm:"column:system;type:INT UNSIGNED;comment:系统" json:"system" form:"system"`                      //系统
	Brow        uint   `gorm:"column:brow;type:INT UNSIGNED;comment:浏览器" json:"brow" form:"brow"`                           //浏览器
	BrowVersion uint   `gorm:"column:brow_version;type:INT UNSIGNED;comment:浏览器版本" json:"brow_version" form:"brow_version"` //浏览器版本
	CreatedAt   string `gorm:"column:created_at;type:DATETIME;comment:浏览时间" json:"created_at" form:"created_at"`            // 浏览时间
	Referer     uint   `gorm:"column:referer;type:INT UNSIGNED;comment:referer来源网址,关联KV" json:"referer" form:"referer"`     //来源网址,关联KV表
}

短链接的访问PV记录表

func (*LinkBrow) TableName

func (c *LinkBrow) TableName() string

获取表名

Jump to

Keyboard shortcuts

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