g2db

package
v2.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2021 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SYSKey = "P6UEgd7ln9mpMz5hGWYqT21cSHOtkJQZ"

	GinContextJWTTokenKey = "JWT_RAW"

	GinContextJWTUIDKey = "JWT_UID"
)

constants

Variables

View Source
var Locker = new(lock)

Locker ...

Functions

func HasError added in v2.0.7

func HasError(e error) (bool, error)

HasError ...

Types

type CompoundIndex

type CompoundIndex struct {
	//索引字段
	Columns map[string]interface{}
	//是否是唯一索引
	Unique bool
	// contains filtered or unexported fields
}

CompoundIndex 复合索引

func (*CompoundIndex) SetSn

func (c *CompoundIndex) SetSn(sn *xorm.Session)

SetSn ...

type ErrorMysqlNotFound

type ErrorMysqlNotFound string

ErrorMysqlNotFound ...

func (ErrorMysqlNotFound) Error

func (e ErrorMysqlNotFound) Error() string

type ItfCompoundIndex

type ItfCompoundIndex interface {
	CompoundIndexes() []*CompoundIndex
}

ItfCompoundIndex 复合索引接口

type ItfGinContext added in v2.0.4

type ItfGinContext interface {
	context.Context
	Set(key string, value interface{})
	GetHeader(key string) string
	Query(key string) string
}

ItfGinContext ...

type ItfInitData

type ItfInitData interface{ InitData() []interface{} }

ItfInitData ...

type ItfMysqlAfterQueryRow added in v2.0.4

type ItfMysqlAfterQueryRow interface {
	MysqlAfterQueryRow()
}

ItfMysqlAfterQueryRow ...

type ItfSessionAfterDelete added in v2.1.3

type ItfSessionAfterDelete interface {
	SessionAfterDelete(sn *xorm.Session) (err error)
}

ItfSessionAfterDelete ...

type ItfSessionAfterInsert added in v2.1.3

type ItfSessionAfterInsert interface {
	SessionAfterInsert(sn *xorm.Session) (err error)
}

ItfSessionAfterInsert ...

type ItfSessionAfterUpdate added in v2.1.3

type ItfSessionAfterUpdate interface {
	SessionAfterUpdate(sn *xorm.Session) (err error)
}

ItfSessionAfterUpdate ...

type ItfSessionBeforeDelete added in v2.1.3

type ItfSessionBeforeDelete interface {
	SessionBeforeDelete(sn *xorm.Session) (err error)
}

ItfSessionBeforeDelete ...

type ItfSessionBeforeInsert added in v2.1.3

type ItfSessionBeforeInsert interface {
	SessionBeforeInsert(sn *xorm.Session) (err error)
}

ItfSessionBeforeInsert ...

type ItfSessionBeforeUpdate added in v2.1.3

type ItfSessionBeforeUpdate interface {
	SessionBeforeUpdate(sn *xorm.Session) (err error)
}

ItfSessionBeforeUpdate ...

type MapString

type MapString map[string]string

MapString ...

type MyBase

type MyBase struct {
	MyBase1 `xorm:"extends"`
	Updated *g2util.JSONTime `json:"updated,omitempty" xorm:"notnull default CURRENT_TIMESTAMP updated comment('更新时间')"`
	Version int64            `json:"version,omitempty" xorm:"notnull default 1 version comment('乐观锁')"`
}

MyBase xorm MySQL model base

func (*MyBase) ClearColumns

func (m *MyBase) ClearColumns()

ClearColumns ...

type MyBase1

type MyBase1 struct {
	ID      int64            `json:"id,omitempty" xorm:"pk autoincr"`
	Created *g2util.JSONTime `json:"created,omitempty" xorm:"notnull default CURRENT_TIMESTAMP created index comment('创建时间')"`
}

MyBase1 id and created

type Mysql

type Mysql struct {
	Config    *g2util.Config   `inject:""`
	Grace     *g2util.Graceful `inject:""`
	AbFile    *g2util.AbFile   `inject:""`
	Redis     *redisObj        `inject:""`
	Cache     *cacheMem        `inject:""`
	CacheBind *cacheBind       `inject:""`
	// contains filtered or unexported fields
}

Mysql ...

func (*Mysql) AfterShutdown

func (m *Mysql) AfterShutdown()

AfterShutdown ...

func (*Mysql) CacheGet

func (m *Mysql) CacheGet(bean interface{}, condition ...interface{}) (err error)

CacheGet ...

func (*Mysql) CacheGetWrapSession added in v2.2.1

func (m *Mysql) CacheGetWrapSession(bean interface{}, arg interface{}, condition ...interface{}) (err error)

CacheGetWrapSession ...

func (*Mysql) Constructor

func (m *Mysql) Constructor()

Constructor New ...

func (*Mysql) DelCache

func (m *Mysql) DelCache(bean interface{}, condition ...interface{}) (err error)

DelCache ...

func (*Mysql) Delete

func (m *Mysql) Delete(bean interface{}) (err error)

Delete ...

func (*Mysql) Dial

func (m *Mysql) Dial()

Dial MySQL连接拨号

func (*Mysql) Engine

func (m *Mysql) Engine() *xorm.Engine

Engine ...

func (*Mysql) GetBeanByTableName added in v2.1.2

func (m *Mysql) GetBeanByTableName(tableStr string) (bean interface{}, err error)

GetBeanByTableName ...

func (*Mysql) GetOut

func (m *Mysql) GetOut() io.Writer

GetOut ...

func (*Mysql) Insert

func (m *Mysql) Insert(bean interface{}) error

Insert ...

func (*Mysql) Migrate

func (m *Mysql) Migrate()

Migrate ...数据库初始化

func (*Mysql) QueryRows added in v2.0.4

func (m *Mysql) QueryRows(val interface{}, params *MysqlQueryRowsParams) (rows *MysqlRows, err error)

QueryRows ...分页查询,可以指定表名

func (*Mysql) QueryTableRows added in v2.0.5

func (m *Mysql) QueryTableRows(tableStr string, params *MysqlQueryRowsParams) (rows *MysqlRows, err error)

QueryTableRows ...查询经过注册的表

func (*Mysql) Sync

func (m *Mysql) Sync() (err error)

Sync ...初始化数据表,结构,数据等

func (*Mysql) TXCallback

func (m *Mysql) TXCallback(fn func(sn *xorm.Session) (err error)) (err error)

TXCallback ...

func (*Mysql) TableRegister

func (m *Mysql) TableRegister(tables ...interface{})

TableRegister ...注册表,用于同步数据表 ... 等

func (*Mysql) Tables added in v2.1.2

func (m *Mysql) Tables() []interface{}

Tables ...

func (*Mysql) Update

func (m *Mysql) Update(bean interface{}, params ...interface{}) (newBean interface{}, err error)

Update ... @Description: @receiver m @param bean @param params @return newBean @return err

type MysqlQueryRowsParams added in v2.0.4

type MysqlQueryRowsParams struct {
	Page        int      `json:"page,omitempty"`
	PageCount   int      `json:"page_count,omitempty"`
	Conditions  []string `json:"conditions,omitempty"`
	OrderBy     string   `json:"order_by,omitempty"`
	Asc         bool     `json:"asc,omitempty"`
	TimeColumn  string   `json:"time_column"`
	TimeBetween string   `json:"time_between"`
}

MysqlQueryRowsParams ...

type MysqlRows added in v2.0.4

type MysqlRows struct {
	Pages int         `json:"pages,omitempty"`
	Data  interface{} `json:"data,omitempty"`
	Count int64       `json:"count,omitempty"`
}

MysqlRows ...

type Query added in v2.1.0

type Query struct {
	// contains filtered or unexported fields
}

Query ... new(Query).SetDb(*xorm.Engine).QueryRows(val, params) new(Query).SetDb(*xorm.Engine).SetTable(string).QueryRows(val, params)

func NewQuery added in v2.1.0

func NewQuery(engine *xorm.Engine) *Query

NewQuery ...

func (*Query) QueryRows added in v2.1.0

func (q *Query) QueryRows(val interface{}, params *MysqlQueryRowsParams) (rows *MysqlRows, err error)

QueryRows ...

func (*Query) SetTable added in v2.1.0

func (q *Query) SetTable(table string) *Query

SetTable ...

type RedisSubHandlerFunc

type RedisSubHandlerFunc func(payload []byte)

RedisSubHandlerFunc ...

type Slice

type Slice []interface{}

Slice ...

func (Slice) Asc

func (s Slice) Asc(call interface{}) Slice

Asc ...

type Token added in v2.0.4

type Token struct {
	Config *g2util.Config `inject:""`

	Redis *redisObj `inject:""`
	Cache *cacheMem `inject:""`
	// contains filtered or unexported fields
}

Token ...

func (*Token) AfterLogin added in v2.0.4

func (t *Token) AfterLogin(ctx context.Context, id int64) (td *TokenData, err error)

AfterLogin ...

func (*Token) Constructor added in v2.0.4

func (t *Token) Constructor()

Constructor ...

func (*Token) Logout added in v2.0.4

func (t *Token) Logout(ctx context.Context, id int64) (err error)

Logout ...

func (*Token) NewCopy added in v2.2.1

func (t *Token) NewCopy(key string) *Token

NewCopy ...

func (*Token) Option added in v2.0.4

func (t *Token) Option() *TokenOption

Option ...

func (*Token) Verify added in v2.0.4

func (t *Token) Verify(ctx ItfGinContext, fns ...func() error) (err error)

Verify ...

type TokenData added in v2.0.4

type TokenData struct {
	ID     int64      `json:"id,omitempty"`
	Token  string     `json:"token,omitempty"`
	Expire *time.Time `json:"expire,omitempty"`
}

TokenData ...

func (*TokenData) String added in v2.0.4

func (t *TokenData) String() string

type TokenOption added in v2.0.4

type TokenOption struct {
	CacheKey string
	//有效期时间
	Timeout time.Duration
	//距离到期时间剩余n时刷新
	MaxRefresh time.Duration
	//加密秘钥
	EncryptKey []byte
	//是否允许多点登录
	MultiLogin func(id int64) bool
}

TokenOption ...

Jump to

Keyboard shortcuts

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