xdb

package
v1.2.6 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2022 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EmptyVal = ""
	PartZero = 0
)
View Source
const (
	// MYSQL dbType
	MYSQL = "mysql"
	// PG dbType
	PG = "postgres"
)

Variables

This section is empty.

Functions

func DB

func DB() *gorm.DB

DB 获取数据库链接

func GetAutoSliceDB added in v1.2.6

func GetAutoSliceDB(db *gorm.DB, userId int64, sf SP) *gorm.DB

GetAutoSliceDB 获取自动分表

func InitQpsDB added in v1.2.6

func InitQpsDB(limit int, interval time.Duration)

InitQpsDB 初始化同步等待QPS DB

func OpenMysqlDB

func OpenMysqlDB(dbType string, dbUrl string, config *gorm.Config, maxIdleConns, maxOpenConns int, models ...interface{}) (instance *gorm.DB, err error)

OpenMysqlDB gorm v2 dbUrl = username:password@tcp(localhost:3306)/db_name?charset=utf8mb4&parseTime=True&loc=Local

func QqsDB added in v1.2.6

func QqsDB() *gorm.DB

QqsDB 获取DB对象,若超时则返回nil

func TestGetSliceDBAuto added in v1.2.6

func TestGetSliceDBAuto(t *testing.T)

Types

type SP added in v1.2.6

type SP struct {
	Value  interface{}
	Part   int64  // 用户ID取余分表
	ByDate string // 通过日期2022-01-01分表,按月,按日
}

type UserFeedback added in v1.2.6

type UserFeedback struct {
	Id       int64  `gorm:"primaryKey;autoIncrement" json:"id" form:"id"`
	UserID   int64  `json:"user_id" gorm:"index"`
	ShowID   int64  `json:"show_id" gorm:"index"`
	UserName string `json:"user_name" gorm:"size:128;"`
	NickName string `json:"nick_name" gorm:"size:128;"`
	// 1兑换/置换   2售后/发货   3建议/投诉   4充值   5其他
	Type    int    `json:"type" gorm:"index"`
	Channel string `json:"channel" gorm:"size:64;"`
	Version string `json:"version"  gorm:"size:16;"`
	Phone   string `json:"phone"  gorm:"size:32;"`
	Content string `json:"content"  gorm:"size:1024;"`
	Time    string `json:"time"  gorm:"size:32;"`
}

Jump to

Keyboard shortcuts

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