Version: v1.9.91 Latest Latest

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







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


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


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)



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
	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

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


func (*SqlModify) And

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


func (*SqlModify) MysqlLimit

func (sm *SqlModify) MysqlLimit() string

func (*SqlModify) MysqlQuery

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


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


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