database

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Mar 19, 2021 License: LGPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	//新建时要操作的字段
	CreateColumns = []string{"creator_id", "creator", "creator_ip", "created_at"}
	//更新时要操作的字段
	UpdateColumns = []string{"updater_id", "updater", "updater_ip", "updated_at"}
	//删除时要操作得字段
	DeleteColumns = append(UpdateColumns, "delete_tag")
)
View Source
var (
	//DB is sqlx.DB对象
	DB *sqlx.DB
)

Functions

func Init

func Init(dns string) error

Init 初始化数据库

func InitGorm added in v0.0.6

func InitGorm(strConnection string) (dbGorm *gorm.DB)

Types

type PagerQuery

type PagerQuery struct {
	PageSize  int `json:"pagesize"`
	PageIndex int `json:"pageindex"`
}

PagerQuery 分页查询参数

type PagerResult

type PagerResult struct {
	Total     int64 `json:"total,string"`
	PageSize  int   `json:"pagesize"`
	PageIndex int   `json:"pageindex"`
}

PagerResult 分页查询返回值

func NewPagerResult

func NewPagerResult(q PagerQuery) (r PagerResult)

NewPagerResult ...

type Snowflake

type Snowflake struct {
	sync.Mutex
	// contains filtered or unexported fields
}

A Snowflake struct holds the basic information needed for a snowflake generator worker

func NewSnowflake

func NewSnowflake(workerid int64) *Snowflake

NewSnowflake returns a new snowflake worker that can be used to generate snowflake IDs

func (*Snowflake) Generate

func (s *Snowflake) Generate() int64

Generate creates and returns a unique snowflake ID

type TableBase added in v0.0.5

type TableBase struct {
	ID        int64  `json:"id,string" db:"id"`
	CreatorID int64  `json:"creator_id" db:"creator_id"`
	Creator   string `json:"creator" db:"creator"`
	CreatorIP string `json:"creator_ip" db:"creator_ip"`
	CreatedAt string `json:"created_at" db:"created_at"`
	UpdaterID int64  `json:"updater_id" db:"updater_id"`
	Updater   string `json:"updater" db:"updater"`
	UpdaterIP string `json:"updater_ip" db:"updater_ip"`
	UpdatedAt string `json:"updated_at" db:"updated_at" gorm:"default:NULL"`
	DeleteTag int    `json:"delete_tag" db:"delete_tag"`
}

TableBase 包含基础字段

func (*TableBase) Create added in v0.0.5

func (t *TableBase) Create(c *gin.Context)

Create ...

func (*TableBase) Update added in v0.0.5

func (t *TableBase) Update(c *gin.Context)

Modify ...

Jump to

Keyboard shortcuts

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