models

package
v0.0.0-...-08ab0e6 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckParentHas

func CheckParentHas[T any](d *gorm.DB, id uint, parentID uint) bool

func ChildrenPreload

func ChildrenPreload(d *gorm.DB) *gorm.DB

func FormatData

func FormatData[T any](data []T, call func(item *T, index int) map[string]any, page *Pagination) ([]map[string]any, map[string]any)

func GetTableName

func GetTableName(db *gorm.DB, model any) string

func Paginate

func Paginate(pagination *Pagination) func(db *gorm.DB) *gorm.DB

func ParentPreload

func ParentPreload(d *gorm.DB) *gorm.DB

Types

type Fields

type Fields struct {
	ID        uint            `json:"id" gorm:"primaryKey"`
	CreatedAt carbon.DateTime `json:"created_at"`
	UpdatedAt carbon.DateTime `json:"updated_at"`
}

type ID

type ID struct {
	ID uint `json:"id" gorm:"primaryKey"`
}

type LogLogin

type LogLogin struct {
	Fields
	UserType string `gorm:"size:250;comment:关联类型" json:"user_type"`
	UserId   uint   `gorm:"size:20;comment:关联 id" json:"user_id"`
	Browser  string `gorm:"size:250;comment:浏览器" json:"browser"`
	Ip       string `gorm:"size:100;comment:IP" json:"ip"`
	Platform string `gorm:"size:100;comment:平台" json:"platform"`
	Status   *bool  `gorm:"default:true" json:"status"`
}

LogLogin @AutoMigrate()

type LogOperate

type LogOperate struct {
	Fields
	UserType      string         `gorm:"size:250;comment:关联类型" json:"user_type"`
	UserID        uint           `gorm:"size:20;comment:关联 id" json:"user_id"`
	RequestMethod string         `gorm:"size:20;comment:请求方法" json:"request_method"`
	RequestUrl    string         `gorm:"size:20;comment:请求链接" json:"request_url"`
	RequestParams datatypes.JSON `gorm:"size:20;comment:请求链接" json:"request_params"`
	RequestTime   float64        `gorm:"type:decimal(11,2);comment:访客量" json:"request_time"`
	RouteName     string         `gorm:"size:50;comment:关联类型" json:"route_name"`
	RouteTitle    string         `gorm:"size:50;comment:关联标题" json:"route_title"`
	ClientUa      string         `gorm:"size:250;comment:UA" json:"client_ua"`
	ClientIp      string         `gorm:"size:100;comment:IP" json:"client_ip"`
	ClientBrowser string         `gorm:"size:250;comment:浏览器" json:"client_browser"`
	ClientDevice  string         `gorm:"size:250;comment:设备" json:"client_device"`
}

type LogVisit

type LogVisit struct {
	Fields
	HasType string `gorm:"size:250;comment:关联类型" json:"has_type"`
	HasId   uint   `gorm:"size:20;comment:关联 id" json:"has_id"`
	Pv      uint   `gorm:"default:1;comment:访问量" json:"pv"`
	Uv      uint   `gorm:"default:1;comment:访客量" json:"uv"`
}

LogVisit @AutoMigrate()

type LogVisitData

type LogVisitData struct {
	Fields
	Date     carbon.Date `gorm:"type:date;comment:日期" json:"date"`
	HasType  string      `gorm:"size:250;comment:关联类型" json:"has_type"`
	HasId    uint        `gorm:"size:20;comment:关联 id" json:"has_id"`
	UUID     string      `gorm:"size:250;comment:唯一标识" json:"uuid"`
	Driver   string      `gorm:"size:250;comment:设备" json:"driver"`
	Ip       string      `gorm:"size:100;comment:IP" json:"ip"`
	Browser  string      `gorm:"size:250;comment:浏览器" json:"browser"`
	Country  string      `gorm:"size:100;comment:国家" json:"country"`
	Province string      `gorm:"size:100;comment:省份" json:"province"`
	City     string      `gorm:"size:100;comment:城市" json:"city"`
	Num      uint        `gorm:"size:100;default:0;comment:PV" json:"num"`
}

LogVisitData @AutoMigrate()

type LogVisitSpider

type LogVisitSpider struct {
	Fields
	Date    carbon.Date `gorm:"type:date;comment:日期" json:"date"`
	HasType string      `gorm:"size:250;comment:关联类型" json:"has_type"`
	HasId   uint        `gorm:"size:20;comment:关联 id" json:"has_id"`
	Name    string      `gorm:"size:250;comment:蜘蛛名" json:"name"`
	Path    string      `gorm:"size:250;comment:页面路径" json:"path"`
	Num     uint        `gorm:"default:0;comment:访客量" json:"num"`
}

LogVisitSpider @AutoMigrate()

type Pagination

type Pagination struct {
	PageSize int   `json:"pageSize,omitempty"`
	Page     int   `json:"page,omitempty"`
	Total    int64 `json:"total"`
	Pages    int   `json:"pages"`
}

func NewPagination

func NewPagination(page, pageSize int) *Pagination

func (*Pagination) GetLimit

func (p *Pagination) GetLimit() int

func (*Pagination) GetOffset

func (p *Pagination) GetOffset() int

func (*Pagination) GetPage

func (p *Pagination) GetPage() int

type SoftDeletes

type SoftDeletes struct {
	DeletedAt carbon.DateTime `json:"deleted_at" gorm:"index"`
}

type Timestamps

type Timestamps struct {
	CreatedAt carbon.DateTime `json:"created_at"`
	UpdatedAt carbon.DateTime `json:"updated_at"`
}

type Tree

type Tree interface {
	GetChildren() []*Tree
	GetId() uint
}

Jump to

Keyboard shortcuts

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