Documentation ¶
Index ¶
- func Parse(jsonStr string) (*wJson, error)
- func Test()
- type Config
- type Contrast
- type LinkSQLOptionConfig
- type MaxLinkNumber
- type MysqlDB
- func (s *MysqlDB) AddRecord(table string, keys string, values string, Debug *log.Logger) (int64, error)
- func (db *MysqlDB) Close()
- func (s *MysqlDB) ExecCMD(sqlStr string, Debug *log.Logger) (int64, int64, error)
- func (s *MysqlDB) QueryCMD(sqlStr string, Debug *log.Logger) ([]map[string]string, error)
- type Option
- type SQLConfig
- type Setting
- func (s *Setting) Add(table string, keys []string, values [][]string, Debug *log.Logger) ([]int64, []error)
- func (s *Setting) DecryptID(primaryKey string, ids []string) ([]bool, [][]string, [][]int)
- func (s *Setting) Delete(table string, forKey string, ids []string, Debug *log.Logger, ...) ([]int64, []error)
- func (s *Setting) EncryptPrimaryKey(queryDatas []map[string]string, primaryKey string) []map[string]string
- func (s *Setting) Link(item int) (*MysqlDB, error)
- func (s *Setting) MysqlClose(i int)
- func (s *Setting) MysqlIsRun(item int, options ...LinkSQLOptionConfig) (int, error)
- func (s *Setting) Query(table string, from string, primaryKey string, where string, order string, ...) ([]map[string]string, []error)
- func (s *Setting) QueryID(table string, from string, primaryKey string, ids []string, order string, ...) ([]map[string]string, []error)
- func (s *Setting) SelectLastID(table string, primaryKey string, Debug *log.Logger) (int, int, error)
- func (s *Setting) Update(table string, key []string, value [][]string, forKey string, ids []string, ...) ([]int64, []error)
- type UpdateOptionConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct { MysqlName string `json:"mysql_name"` Mysql []SQLConfig `json:"mysql"` MaxLink MaxLinkNumber `json:"MaxLinkNumber"` Contrast Contrast `json:"contrast"` }
type LinkSQLOptionConfig ¶
type LinkSQLOptionConfig func(*Option)
func OptionWaitCount ¶
func OptionWaitCount(WaitCount int) LinkSQLOptionConfig
func OptionWaitTime ¶
func OptionWaitTime(WaitTime int) LinkSQLOptionConfig
type MaxLinkNumber ¶
type MysqlDB ¶
func (*MysqlDB) AddRecord ¶
func (s *MysqlDB) AddRecord(table string, keys string, values string, Debug *log.Logger) (int64, error)
===============
添加数据 table string 表名 keys string 键名 values string 值 Debug *log.Logger 调试输出 返回值1 int64 最后插入的id 返回值2 error 错误信息
===============
Add data table string table name keys string key name values string value Debug *log.Logger debug output return 1 int64 last insert id return 2 error Error message
func (*MysqlDB) Close ¶
func (db *MysqlDB) Close()
===============
关闭数据库
===============
Close database
func (*MysqlDB) ExecCMD ¶
===============
根据 *Setting 从数据库集中调用单行SQL指令 sqlStr string SQL指令 Debug *log.Logger 调试输出 返回值1 []map[string]string 查询结果 返回值2 []error 错误信息
===============
According to *Setting, call single row SQL instruction from database set sqlStr string SQL instruction Debug *log.Logger Debug output Return 1 []map[string]string Query result Return 2 []error Error message
func (*MysqlDB) QueryCMD ¶
===============
根据 *Setting 从数据库集中调用单行SQL查询指令 sqlStr string SQL指令 Debug *log.Logger 调试输出 返回值1 []map[string]string 查询结果 返回值2 []error 错误信息
===============
According to *Setting, call single row SQL query instruction from database set sqlStr string SQL instruction Debug *log.Logger Debug output Return 1 []map[string]string Query result Return 2 []error Error message
type SQLConfig ¶
type SQLConfig struct { User string `json:"mysql_user"` Password string `json:"mysql_pwd"` Address string `json:"mysql_addr"` Port string `json:"mysql_port"` DB string `json:"mysql_db"` }
func GetSQLConfig ¶
===============
从json字符串中解析MySQL配置 config string 需要解析的json字符串 返回值1 *SQLConfig 解析后的MySQL配置对象 返回值2 error 解析错误 ============== Parse MySQL configuration from json string config string json string return1 *SQLConfig parsed MySQL configuration object return2 error parsing error
func GetSQLConfigMap ¶
===============
从字典中解析MySQL配置 configMap map[string]interface{} 需要解析的字典 返回值1 *SQLConfig 解析后的MySQL配置对象 ============== Parse MySQL configuration from dictionary configMap map[string]interface{} dictionary return1 *SQLConfig parsed MySQL configuration object
type Setting ¶
type Setting struct { SqlConfigs []SQLConfig //数据库配置 DBName string //数据库名 NextAddDBID int //下一个数据库ID号 DBMaxNum int //数据库最大数目 LinkNum int //连接数目 MaxLink int //最大连接数目 MySQLDB []*MysqlDB //数据库连接 SEKey *simpleEncryption.SecretKey // 加密对象 }
func New ¶
===============
数据库配置 configString string 配置文件字符串 nextDBID int 下一个数据库ID号, 从1开始 返回值1 *Setting 数据库配置对象 返回值2 error 错误信息
===============
Database config configString string Configuration file string nextDBID int Next database ID number, starting from 1 Return 1 *Setting Database configuration object Return 2 error Error message
func (*Setting) Add ¶
func (s *Setting) Add(table string, keys []string, values [][]string, Debug *log.Logger) ([]int64, []error)
===============
自动根据 *Setting 向下一个数据库中的指定表添加数据 table string 表名 keys []string 键名 values [][]string 值 Debug *log.Logger 调试输出 返回值1 []int64 插入的行数 返回值2 []error 错误信息
===============
Automatically add data to the specified table in the next database according to *Setting table string table name keys []string key name values [][]string value Debug *log.Logger debug output return 1 []int64 Number of rows inserted return 2 []error Error message
func (*Setting) DecryptID ¶
===============
根据主键和id数组解密出数据库ID和主键ID primaryKey string 主键字段名 ids []string 主键ID数组 返回值1 []string 数据库ID数组 返回值2 []string 主键ID数组 返回值3 []int 主键ID原数组中的位置
===============
Decrypt the database ID and primary key ID based on the primary key and ID array primaryKey string primary key field name ids []string primary key ID array return 1 []string database ID array return 2 []string primary key ID array return 3 []int Position in the original array of primary key IDs
func (*Setting) EncryptPrimaryKey ¶
func (s *Setting) EncryptPrimaryKey(queryDatas []map[string]string, primaryKey string) []map[string]string
===============
加密主键, *Setting.SEKey 为 nil 时不加密 queryDatas []map[string]string 查询结果 primaryKey string 主键字段名 为""时不加密 返回值 []map[string]string 查询结果
===============
Encrypt primary key, *Setting.SEKey is not encrypted when nil queryDatas []map[string]string query result primaryKey string primary key field name No encryption when "" return []map[string]string query result
func (*Setting) Link ¶
===============
连接数据库 item int 需要连接的数据库在配置中的位置 返回值1 *MysqlDB 连接池中的位置 返回值2 error 错误信息
===============
Connect to MySQL database item int Location of the database to be connected in the configuration Return 1 *MysqlDB Location in the connection pool Return 2 error Error message
func (*Setting) MysqlClose ¶
===============
关闭MySQL连接 i int 连接池中的位置
===============
Close MySQL connection i int Position in the connection pool
func (*Setting) MysqlIsRun ¶
func (s *Setting) MysqlIsRun(item int, options ...LinkSQLOptionConfig) (int, error)
===============
连接MySQL数据库并放入连接池 item int 配置文件中的第几个MySQL配置 options []LinkSQLOptionConfig 配置 WaitCount int 等待次数 WaitTime int 每次等待时间,单位毫秒 返回值1 int 连接池中的位置 返回值2 error 错误信息
===============
Connect to MySQL database and put it into Connection pool item int Which MySQL configuration in the configuration file options []LinkSQLOptionConfig Configuration WaitCount int Number of waits WaitTime int Waiting time per time, in milliseconds return 1 int Position in the connection pool return 2 error Error message
func (*Setting) Query ¶
func (s *Setting) Query(table string, from string, primaryKey string, where string, order string, limit string, Debug *log.Logger) ([]map[string]string, []error)
===============
根据 *Setting 从数据库集中查询 table string 表名 from string 查询字段 ""为默认值* primaryKey string 主键 为""时不加密 where string 查询条件 order string 排序 limit string 分页 ""为默认值100 Debug *log.Logger 调试日志对象 返回值1 []map[string]string 查询结果 返回值2 []error 错误信息
===============
According to *Setting, query from the database set table string Table name from string Query field "" is the default value * primaryKey string Primary key "" does not encrypt where string Query condition order string Sorting limit string Paging "" is the default value 100 Debug *log.Logger Debug log object Return 1 []map[string]string Query result Return 2 []error Error message
func (*Setting) QueryID ¶
func (s *Setting) QueryID(table string, from string, primaryKey string, ids []string, order string, Debug *log.Logger) ([]map[string]string, []error)
===============
自动根据 *Setting 从数据库集中,根据加密后的主键查询 table string 表名 from string 查询的字段 primaryKey string 主键 ids []string 加密后的主键 order string 排序 Debug *log.Logger 调试输出 返回值1 []map[string]string 查询到的数据 返回值2 []error 错误信息
===============
Automatically query from the database set according to *Setting, according to the encrypted primary key table string table name from string query field primaryKey string primary key ids []string encrypted primary key order string sort Debug *log.Logger debug output return 1 []map[string]string query data return 2 []error error message
func (*Setting) SelectLastID ¶
func (s *Setting) SelectLastID(table string, primaryKey string, Debug *log.Logger) (int, int, error)
===============
根据 *Setting 从数据库集中查询指定表的最后一条数据的 ID table string 表名 primaryKey string 主键名,主键类型必须为数字类型 Debug *log.Logger Debug 日志对象 返回值1 int 下一条数据所在的数据库索引 返回值2 int 下一条数据的 ID 返回值3 error 错误信息
===============
According to *Setting, query the ID of the last data of the specified table from the database set table string table name primaryKey string primary key name,The primary key type must be a numeric type Debug *log.Logger Debug log object return 1 int The database index where the next data is located return 2 int ID of the next data return 3 error Error message
func (*Setting) Update ¶
func (s *Setting) Update(table string, key []string, value [][]string, forKey string, ids []string, Debug *log.Logger, options ...UpdateOptionConfig) ([]int64, []error)
===============
更新数据 table string 表名 key []string 字段名 value [][]string 值 forKey string 加密用的key ids []string 主键 Debug *log.Logger 调试输出 options []UpdateOptionConfig 配置 IsPrimaryKey bool 是否使用主键 返回值1 []int64 更新的行数 返回值2 error 错误信息
===============
Update data table string Table name key []string Field name value [][]string Value forKey string Encryption key ids []string Primary key Debug *log.Logger Debug output options []UpdateOptionConfig Configuration IsPrimaryKey bool Whether to use the primary key return 1 []int64 Number of rows updated return 2 error Error message
type UpdateOptionConfig ¶
type UpdateOptionConfig func(*Option)
func OptionIsPrimaryKey ¶
func OptionIsPrimaryKey(IsPrimaryKey bool) UpdateOptionConfig
Click to show internal directories.
Click to hide internal directories.