Documentation ¶
Index ¶
- Constants
- Variables
- func CamelCase(str string) string
- func CreateOrmModels(dbmaster, dbslaver, gdir string)
- func CutPath(href string) string
- func DT2UnixTimeStamp(sdt, format string) int64
- func FileExists(path string) bool
- func GetLocalRandomIPv4() (string, error)
- func GetMCache() cache.Cacher
- func IdStr2Slice(idstr, seg, omit string) []string
- func NewMysql() *mysqlSt
- func NumberString(nLen int) string
- func RandString(nLen int) string
- func RemoteIp(req *http.Request) string
- func RuntimeStack(skip int) []byte
- func SetCachePrefix(prefix string)
- func SetDBCache(c cache.Cacher)
- func SnakeCase(str string) string
- func SqlMapDeleteItems(a SqlMap, keys ...string)
- func SwapStringCrypt(lstr string) string
- func TimeStampFormat(sec int64, layout string) string
- type DHandler
- type DbConfig
- type FormatItemHandle
- type ModelSt
- func (self *ModelSt) CacheKey(ckey string) string
- func (self *ModelSt) DBTables() []string
- func (self *ModelSt) Delete(id interface{}) int64
- func (self *ModelSt) EqMod(idx, oidx int64) bool
- func (self *ModelSt) Format(handle FormatItemHandle) *ModelSt
- func (self *ModelSt) GetAsMap(offset, limit int64, cHandler WHandler, fields string) SqlMap
- func (self *ModelSt) GetAsSQL(sql string, offset, limit int64) []SqlMap
- func (self *ModelSt) GetCacheVer() string
- func (self *ModelSt) GetColumn(offset, limit int64, cHandler WHandler, fields string, args ...string) []string
- func (self *ModelSt) GetHash(args ...interface{}) string
- func (self *ModelSt) GetItem(cHandler WHandler, fields string, args ...string) SqlMap
- func (self *ModelSt) GetList(offset, limit int64, cHandler WHandler, fields string, args ...string) []SqlMap
- func (self *ModelSt) GetNameMap(offset, limit int64, cHandler WHandler, fields string, key string) map[string]SqlMap
- func (self *ModelSt) GetOne(id interface{}) SqlMap
- func (self *ModelSt) GetSlot() int
- func (self *ModelSt) GetTable() string
- func (self *ModelSt) GetTotal(cHandler WHandler, fields string) SqlString
- func (self *ModelSt) GetValue(cHandler WHandler, fields string) SqlString
- func (self *ModelSt) IdClearCache(id interface{}) *ModelSt
- func (self *ModelSt) Init(dbPool *XDBPoolSt, data map[string]interface{}, fields map[string]reflect.Kind)
- func (self *ModelSt) IsExists(cHandler WHandler) SqlString
- func (self *ModelSt) MultiDelete(whandler WHandler) int64
- func (self *ModelSt) MultiDeleteCleanID(whandler WHandler) int64
- func (self *ModelSt) MultiUpdate(whandler WHandler, vhandler VHandler) int64
- func (self *ModelSt) MultiUpdateCleanID(whandler WHandler, vhandler VHandler) int64
- func (self *ModelSt) NewOne(fields SqlMap, dupfields SqlMap) int64
- func (self *ModelSt) NewOneFromHandler(vhandler VHandler, dhandler DHandler) int64
- func (self *ModelSt) NoCache() *ModelSt
- func (self *ModelSt) Query() *QuerySt
- func (self *ModelSt) ResetTable() *ModelSt
- func (self *ModelSt) Save(id interface{}, fields SqlMap) int64
- func (self *ModelSt) SaveFromHandler(id interface{}, vhandler VHandler) int64
- func (self *ModelSt) SetCache(cacheSt cache.Cacher) *ModelSt
- func (self *ModelSt) SetCacheVer()
- func (self *ModelSt) SetDevTable(idx int64) *ModelSt
- func (self *ModelSt) SetModTable(idx int64) *ModelSt
- func (self *ModelSt) SetTable(table string) *ModelSt
- func (self *ModelSt) SetTx(tx *sqlx.Tx) *ModelSt
- func (self *ModelSt) SetYmTable(format string) *ModelSt
- type QuerySt
- func (q QuerySt) AsSql(mode string) string
- func (q QuerySt) Clear(parts ...string) *mysqlSt
- func (q *QuerySt) CloseDB()
- func (q *QuerySt) Delete() int64
- func (q QuerySt) Duplicate(field string, value interface{}, args ...string) *mysqlSt
- func (q *QuerySt) Exec(query string) sql.Result
- func (q QuerySt) Field(fields string) *mysqlSt
- func (q *QuerySt) GetAsSql(query string, isFirst bool, offset, limit int64) []SqlMap
- func (q *QuerySt) GetColumn(query string, offset, limit int64) []string
- func (q *QuerySt) GetDb() *sqlx.DB
- func (q *QuerySt) GetFormat() FormatItemHandle
- func (q *QuerySt) GetList(query string, offset, limit int64) []SqlMap
- func (q *QuerySt) GetMap(query string, offset, limit int64) SqlMap
- func (q *QuerySt) GetRow(query string) SqlMap
- func (q *QuerySt) GetTx() *sqlx.Tx
- func (q *QuerySt) GetValue() SqlString
- func (q QuerySt) GetWheres() string
- func (q QuerySt) GroupBy(fields ...string) *mysqlSt
- func (q QuerySt) Having(having string) *mysqlSt
- func (q *QuerySt) Insert(fields SqlMap, isReplace bool) int64
- func (q *QuerySt) NameMap(query, key string, offset, limit int64) map[string]SqlMap
- func (q QuerySt) OrderBy(field, dir string) *mysqlSt
- func (q QuerySt) Reset() *mysqlSt
- func (q *QuerySt) SetDb(db *sqlx.DB) *QuerySt
- func (q *QuerySt) SetFormat(handle FormatItemHandle)
- func (q QuerySt) SetIsReplace(isReplace bool) *mysqlSt
- func (q *QuerySt) SetTx(tx *sqlx.Tx) *QuerySt
- func (q QuerySt) Table(table ...string) *mysqlSt
- func (q *QuerySt) Transaction(handle TransactionHandle) bool
- func (q *QuerySt) Update(fields SqlMap) int64
- func (q QuerySt) Value(field string, value interface{}, args ...string) *mysqlSt
- func (q QuerySt) Where(field string, value interface{}, args ...string) *mysqlSt
- type SqlMap
- type SqlString
- type TransactionHandle
- type VHandler
- type WHandler
- type XDBPoolSt
Constants ¶
View Source
const ( DT_SQL = "sql" DT_AUTO = "auto" OP_AS = "AS" OP_MAX = "MAX" OP_MIN = "MIN" OP_SUM = "SUM" OP_AVG = "AVG" OP_COUNT = "COUNT" OP_EQ = "=" OP_NE = "<>" OP_GT = ">" OP_LT = "<" OP_GE = ">=" OP_LE = "<=" OP_FULLTEXT = "AGAINST" OP_BETWEEN = "BETWEEN" OP_NOTBETWEEN = "NOT BETWEEN" OP_LIKE = "LIKE" OP_NOTLIKE = "NOT LIKE" OP_REGEXP = "REGEXP" OP_ISNULL = "IS NULL" OP_ISNOTNULL = "IS NOT NULL" OP_IN = "IN" OP_NOTIN = "NOT IN" OP_AND = "AND" OP_OR = "OR" OP_NOT = "NOT" OP_SQL = "SQL" ASC = "ASC" DESC = "DESC" )
View Source
const ( DATEBASICFormat = "2006-01-02 15:04:05" DATEYMDFormat = "20060102" DATESTRFormat = "20060102150405" DATEYMDSTRFormat = "2006-01-02" )
View Source
const (
DBVERCKEY = "dbver"
)
Variables ¶
View Source
var ( IsShowSql = true GdbPoolSt = XDBPoolSt{} )
View Source
var Gmodelstpl = `` /* 589-byte string literal not displayed */
Functions ¶
func DT2UnixTimeStamp ¶ added in v1.0.5
根据时间格式获取unix时间的记录
func GetLocalRandomIPv4 ¶ added in v1.2.0
返回本机的随机IP一个内网IP地址
func IdStr2Slice ¶ added in v1.0.5
根据逗号分割的id转slice
func TimeStampFormat ¶ added in v1.2.0
这个时间格式填写golang诞辰 2006-01-02 15:04:05 等
Types ¶
type FormatItemHandle ¶ added in v1.2.0
type FormatItemHandle func(sm SqlMap)
type ModelSt ¶
type ModelSt struct {
// contains filtered or unexported fields
}
定义数据模型的基础结构
func (*ModelSt) Format ¶ added in v1.2.0
func (self *ModelSt) Format(handle FormatItemHandle) *ModelSt
主要用作处理数据的格式化逻辑
func (*ModelSt) GetColumn ¶
func (self *ModelSt) GetColumn(offset, limit int64, cHandler WHandler, fields string, args ...string) []string
只获取数据信息列表
func (*ModelSt) GetList ¶
func (self *ModelSt) GetList(offset, limit int64, cHandler WHandler, fields string, args ...string) []SqlMap
只获取数据信息列表
func (*ModelSt) GetNameMap ¶
func (self *ModelSt) GetNameMap(offset, limit int64, cHandler WHandler, fields string, key string) map[string]SqlMap
获取命名map,key必须属于fields当中的字段
func (*ModelSt) IdClearCache ¶
根据ID删除缓存策略
func (*ModelSt) Init ¶
func (self *ModelSt) Init(dbPool *XDBPoolSt, data map[string]interface{}, fields map[string]reflect.Kind)
初始化模型 业务参数设定
func (*ModelSt) MultiDelete ¶
删除多条记录 单数缓存数据可能还是存在 通过id获取数据的情况
func (*ModelSt) MultiDeleteCleanID ¶ added in v1.2.0
删除多条记录 清理关联记录缓存
func (*ModelSt) MultiUpdate ¶
通过执行匿名函数实现数据更新关系绑定
func (*ModelSt) MultiUpdateCleanID ¶ added in v1.2.0
通过执行匿名函数实现数据更新关系绑定 清理关联记录缓存
func (*ModelSt) NewOneFromHandler ¶
通过执行匿名函数实现数据更新关系绑定
func (*ModelSt) ResetTable ¶
func (*ModelSt) SaveFromHandler ¶
通过执行匿名函数实现数据更新关系绑定
func (*ModelSt) SetDevTable ¶
func (*ModelSt) SetModTable ¶
func (*ModelSt) SetYmTable ¶
这个时间格式填写golang诞辰 2006-01-02 15:04:05 等
type QuerySt ¶
type QuerySt struct {
// contains filtered or unexported fields
}
func (*QuerySt) GetFormat ¶ added in v1.2.0
func (q *QuerySt) GetFormat() FormatItemHandle
主要用作处理数据的格式化逻辑
func (*QuerySt) SetFormat ¶ added in v1.2.0
func (q *QuerySt) SetFormat(handle FormatItemHandle)
主要用作处理数据的格式化逻辑
func (QuerySt) SetIsReplace ¶
func (q QuerySt) SetIsReplace(isReplace bool) *mysqlSt
设定插入的时候执行replace into
func (*QuerySt) Transaction ¶ added in v1.2.0
func (q *QuerySt) Transaction(handle TransactionHandle) bool
执行事务处理的业务逻辑封装
type SqlMap ¶
type SqlMap map[string]interface{}
func (SqlMap) Format ¶ added in v1.2.0
func (s SqlMap) Format(format FormatItemHandle) SqlMap
格式化处理逻辑
type TransactionHandle ¶ added in v1.2.0
type XDBPoolSt ¶ added in v1.0.5
type XDBPoolSt struct {
// contains filtered or unexported fields
}
*****************************************************************************
数据库的适配器,主要调整数据库与配置类 Redis与配置类的衔接,初始化数据库缓存 *****************************************************************************
func (*XDBPoolSt) LoadDbConfig ¶ added in v1.2.0
func (p *XDBPoolSt) LoadDbConfig(confPtr interface{})
*
- 数据库的配置 通过配置导入,配置必须传结构体指针 示例
- @confPtr *Config 配置对象的指针变量
type Config struct { ... Redis cache.RedisConfig `yaml:"redis"` DbMaster DbConfig `yaml:"dbmaster"` DbSlaver DbConfig `yaml:"dbslaver"` }
Directories ¶
Path | Synopsis |
---|---|
Package mapstructure exposes functionality to convert one arbitrary Go type into another, typically to convert a map[string]interface{} into a native Go structure.
|
Package mapstructure exposes functionality to convert one arbitrary Go type into another, typically to convert a map[string]interface{} into a native Go structure. |
Click to show internal directories.
Click to hide internal directories.