Documentation
¶
Index ¶
- Constants
- Variables
- type AutoSQLEngine
- func (autoSQLModel *AutoSQLEngine) DeleteByPrimaryKey(table string, delete interface{}) (sql string, params []interface{}, err error)
- func (autoSQLModel *AutoSQLEngine) Insert(table string, adds ...interface{}) (sql string, params []interface{}, err error)
- func (autoSQLModel *AutoSQLEngine) SelectByPrimaryKey(table string, sele interface{}) (sql string, params []interface{}, err error)
- func (autoSQLModel *AutoSQLEngine) SetPrimaryKeyAutoFunc(f func() string)
- func (autoSQLModel *AutoSQLEngine) UpdateByPrimaryKey(table string, update interface{}) (sql string, params []interface{}, err error)
- type AutoSQLEngineInterface
- type Column
- type PrimaryKeyAutoType
Constants ¶
View Source
const (
PrimaryKeyIsEmpty = "primary key is empty"
)
Variables ¶
View Source
var AutoSQL autoSQLInterface = (*autoSQL)(nil)
Functions ¶
This section is empty.
Types ¶
type AutoSQLEngine ¶ added in v1.0.3
type AutoSQLEngine struct { PrimaryKeyColumnTag string // id字段列标签 ColumnTag string // 列标签 Val interface{} // 主表结构体 PrimaryKeyAutoType PrimaryKeyAutoType // 主键自动生成方式 // contains filtered or unexported fields }
AutoSQLEngine 自动生成SQL语句引擎结构体 -> 实际主体方法由其提供
func (*AutoSQLEngine) DeleteByPrimaryKey ¶ added in v1.0.3
func (autoSQLModel *AutoSQLEngine) DeleteByPrimaryKey(table string, delete interface{}) (sql string, params []interface{}, err error)
DeleteByPrimaryKey 自动生成依据主键删除结构体数据sql语句 table 删除的表名 delete 被修改的参数结构体 sql 生成的sql语句 params 生成对应占位符的值 err 如果生成错误或其它异常情况时返回
func (*AutoSQLEngine) Insert ¶ added in v1.0.3
func (autoSQLModel *AutoSQLEngine) Insert(table string, adds ...interface{}) (sql string, params []interface{}, err error)
Insert 自动生成insert语句 table 写入的表名 adds 需生成sql语句的对象数组 sql 返回的sql语句 params 返回对应值数组 err 如果生成错误或其它异常情况时返回
func (*AutoSQLEngine) SelectByPrimaryKey ¶ added in v1.0.3
func (autoSQLModel *AutoSQLEngine) SelectByPrimaryKey(table string, sele interface{}) (sql string, params []interface{}, err error)
SelectByPrimaryKey 自动生成依据主键查询结构体数据sql语句 table 查询的表名 update 被修改的参数结构体 sql 生成的sql语句 params 生成对应占位符的值 err 如果生成错误或其它异常情况时返回
func (*AutoSQLEngine) SetPrimaryKeyAutoFunc ¶ added in v1.0.3
func (autoSQLModel *AutoSQLEngine) SetPrimaryKeyAutoFunc(f func() string)
SetPrimaryKeyAutoFunc 设置主键自动生成方法
func (*AutoSQLEngine) UpdateByPrimaryKey ¶ added in v1.0.3
func (autoSQLModel *AutoSQLEngine) UpdateByPrimaryKey(table string, update interface{}) (sql string, params []interface{}, err error)
UpdateByPrimaryKey 自动生成依据主键修改结构体数据sql语句 table 修改的表名 update 被修改的参数结构体 sql 生成的sql语句 params 生成对应占位符的值 err 如果生成错误或其它异常情况时返回
type AutoSQLEngineInterface ¶ added in v1.0.3
type AutoSQLEngineInterface interface { SetPrimaryKeyAutoFunc(f func() string) // SetPrimaryKeyAutoFunc 设置主键自动生成方法 Insert(table string, adds ...interface{}) (sql string, params []interface{}, err error) // Insert 自动生成insert语句 SelectByPrimaryKey(table string, sele interface{}) (sql string, params []interface{}, err error) // SelectByPrimaryKey 自动生成依据主键查询结构体数据sql语句 UpdateByPrimaryKey(table string, update interface{}) (sql string, params []interface{}, err error) // UpdateByPrimaryKey 自动生成依据主键修改结构体数据sql语句 DeleteByPrimaryKey(table string, delete interface{}) (sql string, params []interface{}, err error) // DeleteByPrimaryKey 自动生成依据主键删除结构体数据sql语句 // contains filtered or unexported methods }
AutoSQLEngineInterface 自动生成SQL语句引擎接口
type Column ¶ added in v1.0.3
type Column struct { IsPrimaryKey bool // 是否为主键 Name string // 字段名称 Value interface{} // 字段值 TypeOf reflect.Type // 字段类型 }
Column 列字段结构体
type PrimaryKeyAutoType ¶
type PrimaryKeyAutoType int64
const ( None PrimaryKeyAutoType = iota // 不自动生成 AutoNumber // 自增长 AutoUUID // 随机生成UUID 随机生成的UUID将会是32位并去除了'-'符号并以大写形式出现 AutoTime // 取当前时间戳->不建议使用该类型 如果要使用该类型 则需要将数据库主键改为 bigint AutoFunc // 由调用者提供自动生成方法进行方法调用后获取对于key并写入 )
Click to show internal directories.
Click to hide internal directories.