Documentation ¶
Index ¶
- func GeneralInsert(db basic.SQLCommon, tableName string, data map[string]interface{}) (rsp sql.Result, err error)
- func GeneralListGORM(database *gorm.DB, params ListByPageParams) (db *gorm.DB)
- func GeneralListSQL(db basic.SQLCommon, tableName string, params ListByPageParams, whereSql string, ...) (rsp []interface{}, err error)
- func GetGormMySQLConnection(config MySqlConfig) (db *gorm.DB, err error)
- func TransactionGORM(db *gorm.DB, f TransactionFuncGORM) (data interface{}, err error)
- type ListByPageParams
- type MySqlConfig
- type TransactionFuncGORM
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GeneralInsert ¶
func GeneralInsert(db basic.SQLCommon, tableName string, data map[string]interface{}) (rsp sql.Result, err error)
插入数据到数据库表的通用方法
func GeneralListGORM ¶
func GeneralListGORM(database *gorm.DB, params ListByPageParams) (db *gorm.DB)
func GeneralListSQL ¶
func GeneralListSQL(db basic.SQLCommon, tableName string, params ListByPageParams, whereSql string, whereArgs ...interface{}) (rsp []interface{}, err error)
分页查询的通用查询接口
func GetGormMySQLConnection ¶
func GetGormMySQLConnection(config MySqlConfig) (db *gorm.DB, err error)
获取GORM的MySQL数据库连接
func TransactionGORM ¶
func TransactionGORM(db *gorm.DB, f TransactionFuncGORM) (data interface{}, err error)
GORM事务处理
Types ¶
type ListByPageParams ¶
type ListByPageParams struct { Fields []string `json:"fields"` // 查询的字段,若为空数组,则查询全部字段 IgnoreFields []string `json:"ignore_fields"` // 忽略掉哪些字段 PageNumber uint64 `json:"page_number"` // 从1开始的页码 PageSize uint64 `json:"page_size"` // 大于1为有效的页大小 SortBy string `json:"sort_by"` // 按哪个字段名称排序 SortDirection bool `json:"sort_direction"` // true为ASC,false为DESC }
分页查询列表的公共参数
type MySqlConfig ¶
type MySqlConfig struct { Host string `json:"Host"` // 服务器主机地址 Port int `json:"Port"` // 服务器端口号 User string `json:"User"` // 服务器登陆用户 Password string `json:"Password"` // 调试时数据库密码 Scheme string `json:"Scheme"` // 数据库名称 MaxIdleConnection int `json:"MaxIdleConnection"` // 最大闲置连接数 MaxOpenConnection int `json:"MaxOpenConnection"` // 最大打开连接数 Params map[string]string `json:"Params"` // 连接参数 }
MySQL的配置信息格式
Click to show internal directories.
Click to hide internal directories.