Documentation ¶
Overview ¶
* @Author: lisheng * @Date: 2022-10-10 23:46:08 * @LastEditTime: 2023-01-06 14:16:09 * @LastEditors: lisheng * @Description: mysql驱动管理,支持管理多个Mysql数据库连接 * @FilePath: /jf-go-kit/database/mysql/mysql.go
Index ¶
- func CreateDBEngnine(user string, pwd string, addr string, port int, db string) *gorm.DB
- func DeleteRecordByCond(engineName string, tableName string, cond string, objPtr interface{}) (affectedRows int64, err error)
- func FindRecordsByCond(engineName string, tableName string, cond string, resultSlicePtr interface{}) error
- func InitMysqlManager() func() error
- func InsertRecord(engineName string, tableName string, objPtr interface{}) (affectedRows int64, err error)
- func QueryRecordByCond(engineName string, tableName string, cond string, resultSlicePtr interface{}) error
- func RegisterTable(engineName string, tableObj interface{})
- func UpdateRecordByCond(engineName string, tableName string, cond string, ...) (affectedRows int64, err error)
- type MysqlManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CreateDBEngnine ¶
*
- @description: 创建数据库引擎
- @param {string} user
- @param {string} pwd
- @param {string} addr
- @param {int} port
- @param {string} db
- @return {*}
- @author: liqiyuWorks
func DeleteRecordByCond ¶
func DeleteRecordByCond(engineName string, tableName string, cond string, objPtr interface{}) (affectedRows int64, err error)
*
- @description: D - Where 删除 根据条件查询
- @param {string} tableName
- @param {string} cond
- @param {interface{}} objPtr
- @return {*}
- @author: liqiyuWorks
func FindRecordsByCond ¶
func FindRecordsByCond(engineName string, tableName string, cond string, resultSlicePtr interface{}) error
*
- @description: R - Where 多条数据查询 根据条件查询
- @param {string} tableName
- @param {string} cond
- @param {string} condValue
- @param {int} page
- @param {int} pageSize
- @param {interface{}} resultSlicePtr
- @return {*}
- @author: liqiyuWorks
func InitMysqlManager ¶
func InitMysqlManager() func() error
*
- @description: 初始化mysqlManager
- @return {*}
- @author: liqiyuWorks
func InsertRecord ¶
func InsertRecord(engineName string, tableName string, objPtr interface{}) (affectedRows int64, err error)
*
- @description: C - 插入数据 ---- 亲测 gorm的插入有问题
- @param {string} tableName
- @param {string} cond
- @param {interface{}} objPtr
- @return {*}
- @author: liqiyuWorks
func QueryRecordByCond ¶
func QueryRecordByCond(engineName string, tableName string, cond string, resultSlicePtr interface{}) error
*
- @description: R - Where 单条数据查询 根据条件查询
- @param {string} engineName
- @param {string} tableName
- @param {string} cond
- @param {interface{}} resultSlicePtr
- @return {*}
- @author: liqiyuWorks
func RegisterTable ¶
func RegisterTable(engineName string, tableObj interface{})
*
- @description: mysql 自动注册表
- @param {string} engineName
- @param {interface{}} tableObj
- @return {*}
- @author: liqiyuWorks
func UpdateRecordByCond ¶
func UpdateRecordByCond(engineName string, tableName string, cond string, fieldMap map[string]interface{}) (affectedRows int64, err error)
*
- @description: U - Where 更新 根据条件查询
- @param {string} tableName
- @param {string} cond
- @param {map[string]interface{}} fieldMap
- @return {*}
- @author: liqiyuWorks
Types ¶
type MysqlManager ¶
var (
GMysqlManager *MysqlManager = new(MysqlManager)
)
Click to show internal directories.
Click to hide internal directories.