base

package
Version: v1.9.91 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: AGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

共享事件结构定义

功能性方法文件

Index

Constants

View Source
const (
	EnPage = "SQL_CALC_FOUND_ROWS" //开启分页
)

Variables

View Source
var ShowLevel = map[LogLevel]string{
	Waring: "Waring",
	Info:   "Info",
	Err:    "Err",
}

Functions

func AskSwapSort added in v1.3.6

func AskSwapSort(s string) string

字符串中的问号转$序号

func Exec added in v1.9.7

func Exec(e *Event)

func HttpPostByte

func HttpPostByte(url string, param []byte, head map[string]string) ([]byte, error)

func LoadByQuery added in v1.9.7

func LoadByQuery(e *Event)

func Quick

func Quick(arr []int)

func ValToFloat added in v1.7.0

func ValToFloat(v interface{}) float64

数据转浮点

func ValToInt

func ValToInt(v interface{}) (int, error)

数据转int

Types

type DbConfig

type DbConfig struct {
	Host            string
	Port            int
	User            string
	Pwd             string
	DbName          string
	MaxOpenConn     int
	MaxIdleConn     int
	ConnMaxLifetime int
}

数据库连接配置

func (*DbConfig) MySqlConn

func (d *DbConfig) MySqlConn() (err error)

func (*DbConfig) PSqlConn

func (d *DbConfig) PSqlConn() (err error)

type Engine added in v1.8.7

type Engine struct {
	Req  *http.Request
	Res  http.ResponseWriter
	Log  *Logger
	Data map[string]string
}

func (*Engine) GetParam added in v1.8.7

func (e *Engine) GetParam(def interface{}) error

func (*Engine) OutErr added in v1.8.7

func (e *Engine) OutErr(data interface{})

func (*Engine) OutList added in v1.8.7

func (e *Engine) OutList(data interface{})

func (*Engine) OutSuccess added in v1.8.7

func (e *Engine) OutSuccess()

type Event added in v1.8.7

type Event struct {
	IsWrite bool
	Eg      *Engine
	//执行的sql
	ExecSql string
	//查询时主键值,根据此值优先取缓存,执行时是参数填充
	Keys []interface{}
	// contains filtered or unexported fields
}

数据事件对象

func NewEvent added in v1.8.7

func NewEvent(s func(event *Event)) *Event

func (*Event) BuildDataMode added in v1.8.7

func (e *Event) BuildDataMode(mode interface{}, data []map[string]interface{}) (list []interface{})

func (*Event) ExecByPsql added in v1.8.7

func (e *Event) ExecByPsql(sql string, val []interface{}) (sql.Result, error)

func (*Event) Push added in v1.8.7

func (e *Event) Push(data interface{})

事件结果投递

func (*Event) QueryByPsql added in v1.8.7

func (e *Event) QueryByPsql() (objs interface{}, total int, err error)

func (*Event) Rsp added in v1.8.7

func (e *Event) Rsp() interface{}

事件结果响应

func (*Event) SetHandel added in v1.9.7

func (e *Event) SetHandel(s func(event *Event))

事件结果投递

func (*Event) SetSm added in v1.8.7

func (e *Event) SetSm(sm *SqlModify)

事件结果投递

type EventQueue added in v1.8.7

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

func NewEventQueue added in v1.8.7

func NewEventQueue(l int) *EventQueue

func (*EventQueue) Post added in v1.8.7

func (eq *EventQueue) Post(e *Event)

事件投递

type Handle added in v1.8.7

type Handle func(*Engine)

type LogLevel

type LogLevel int
const (
	Waring LogLevel = iota
	Info
	Err
)

type Logger

type Logger struct {
	//开始时间
	StartTime time.Time
	//途经路线集合
	Steps []step
}

func NewLogger

func NewLogger() *Logger

func (*Logger) Err

func (l *Logger) Err(content ...interface{})

func (*Logger) Info

func (l *Logger) Info(content ...interface{})

func (*Logger) SaveFile

func (l *Logger) SaveFile()

func (*Logger) Waring

func (l *Logger) Waring(content ...interface{})

type MySql

type MySql struct {
	// contains filtered or unexported fields
}
var MysqlMgr *MySql

func (*MySql) Begin

func (m *MySql) Begin() (tx *sql.Tx, err error)

func (*MySql) Insert

func (m *MySql) Insert(sql string, val []interface{}) error

func (*MySql) Ping

func (m *MySql) Ping() error

type PSql

type PSql struct {
	// contains filtered or unexported fields
}
var PsqlMgr *PSql

func (*PSql) Begin added in v1.3.7

func (p *PSql) Begin() (*sql.Tx, error)

func (*PSql) GetDB added in v1.5.2

func (p *PSql) GetDB() *sql.DB

func (*PSql) Insert

func (p *PSql) Insert(sql string, val []interface{}) error

func (*PSql) PgQueryList added in v1.6.6

func (p *PSql) PgQueryList(sql string, val ...interface{}) (list []map[string][]byte, total int, err error)

type SqlDiff

type SqlDiff string
const (
	//相等
	Equal SqlDiff = "="
	//小于
	Lt SqlDiff = "<"
	//大于
	Gt SqlDiff = ">"
	//大于
	Like SqlDiff = "like"
	//范围区间
	Range SqlDiff = "between"
	//在列表内
	IN SqlDiff = " IN "
	//不在列表内
	NIN SqlDiff = " NOT IN "
)

type SqlModify

type SqlModify struct {

	//数据库查询出来的数据转对象
	F SwapObj
	// contains filtered or unexported fields
}

sql编辑对象

func (*SqlModify) And

func (sm *SqlModify) And(c string, diff SqlDiff, val ...interface{}) *SqlModify

设置and条件

func (*SqlModify) MysqlLimit

func (sm *SqlModify) MysqlLimit() string

func (*SqlModify) MysqlQuery

func (sm *SqlModify) MysqlQuery() (list []map[string]interface{}, total int, err error)

mysql查询

func (*SqlModify) MysqlQueryBuild added in v1.6.1

func (sm *SqlModify) MysqlQueryBuild() (string, []interface{})

func (*SqlModify) Or

func (sm *SqlModify) Or(c string, diff SqlDiff, val ...interface{}) *SqlModify

设置or条件

func (*SqlModify) PgQueryList added in v1.5.2

func (sm *SqlModify) PgQueryList(db *sql.DB, sql string, val ...interface{}) (list []map[string]interface{}, total int, err error)

func (*SqlModify) PsqlLimit added in v1.2.2

func (sm *SqlModify) PsqlLimit() string

func (*SqlModify) PsqlQueryBuild added in v1.6.1

func (sm *SqlModify) PsqlQueryBuild() (string, []interface{})

func (*SqlModify) SetPage

func (sm *SqlModify) SetPage(p int) *SqlModify

func (*SqlModify) SetSize

func (sm *SqlModify) SetSize(s int) *SqlModify

func (*SqlModify) SetSwapObj added in v1.6.8

func (sm *SqlModify) SetSwapObj(f SwapObj) *SqlModify

func (*SqlModify) SetTable

func (sm *SqlModify) SetTable(table string) *SqlModify

type SwapObj added in v1.6.8

type SwapObj func(*Event, []map[string][]byte) interface{}

Jump to

Keyboard shortcuts

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