Documentation ¶
Index ¶
- Variables
- func AddDataTypeFunc(dataType string, fun dataTypeFun)
- func ConvertToString(val any) string
- func ConvertToStringSlice(val any) []string
- func DeleteByPk(ctx context.Context, t Table) (rowsAffected int64, lastInsertId int64, err error)
- func GetContextDBConn(ctx context.Context) *sql.DB
- func GetContextTxConn(ctx context.Context) *sql.Tx
- func GetContextTxOptions(ctx context.Context) *sql.TxOptions
- func GetPkColumnName(ctx context.Context) string
- func Hump(column string) (filed string)
- func Insert(ctx context.Context, t Table) (rowsAffected int64, lastInsertId int64, err error)
- func InsertBatch(ctx context.Context, ts *[]Table) (rowsAffected int64, lastInsertId int64, err error)
- func ListenField(lf func(filedInfo *fieldInfo))
- func NewSqlInfo(ctx context.Context, statement string, param ...any) *sqlInfo[Table]
- func PrefixLower(s string) string
- func PrefixUpper(s string) string
- func Select[T Table](ctx context.Context, columns ...string) *sqlInfo[T]
- func SqlScript[T Table](ctx context.Context, statement string, param ...any) *sqlInfo[T]
- func StringInIndex(s string, slice []string) int
- func StringInSlice(s string, slice []string) bool
- func Transaction(ctx context.Context, call func(ctx context.Context) error) error
- func UpdateByPk(ctx context.Context, t Table) (rowsAffected int64, lastInsertId int64, err error)
- func UpdateNotIgnoredEveryColumnByPk(ctx context.Context, t Table) (rowsAffected int64, lastInsertId int64, err error)
- func WithConf(ctx context.Context, conf confString) context.Context
- func WithTX(ctx context.Context, tx *sql.Tx) context.Context
- func WithTxOptions(ctx context.Context, txo *sql.TxOptions) context.Context
- func WriteStruct(ctx context.Context, info *structInfo) error
- func WriteStructTo(ctx context.Context, info *structInfo, absDir string) error
- type CodeFactory
- type Config
- type Page
- type Table
- type TableSlice
Constants ¶
This section is empty.
Variables ¶
View Source
var ( FuncLog = defaultLog FuncSQLLog = defaultLog FuncGenId = genId )
Functions ¶
func AddDataTypeFunc ¶
func AddDataTypeFunc(dataType string, fun dataTypeFun)
AddDataTypeFunc 添加一个自定义类型转换函数,优先级高于 columnTypeParse 函数内所列举的类型
func ConvertToStringSlice ¶
ConvertToStringSlice 将任意数据类型转换成string slice
func DeleteByPk ¶
DeleteByPk 仅根据主键删除
func GetContextDBConn ¶
GetContextDBConn 从上下文中获取链接
func GetContextTxConn ¶
GetContextTxConn 从上下文中获取事务
func GetContextTxOptions ¶
GetContextTxOptions 从上下文中获取配置事务参数
func Insert ¶
Insert 属性默认值遵循go语言基本类型的默认值 int=0;string="";time="0000-01-01 00:00:00" ...等 新增时的主键由调用方处理,可使用主键生成函数(tcode.FuncGenId)生成
func InsertBatch ¶
func InsertBatch(ctx context.Context, ts *[]Table) (rowsAffected int64, lastInsertId int64, err error)
InsertBatch 批量新增
func ListenField ¶
func ListenField(lf func(filedInfo *fieldInfo))
ListenField 监听所有处理后的字段,并可直接根据需求修改信息
func NewSqlInfo ¶
func Transaction ¶
func UpdateByPk ¶
UpdateByPk 仅根据主键更新
func UpdateNotIgnoredEveryColumnByPk ¶
func UpdateNotIgnoredEveryColumnByPk(ctx context.Context, t Table) (rowsAffected int64, lastInsertId int64, err error)
UpdateNotIgnoredEveryColumnByPk 仅根据主键更新
func WriteStruct ¶
WriteStruct 将*StructInfo信息通过模板codeTemplateText解析导出至defaultAbsDir路径
Types ¶
type CodeFactory ¶
type CodeFactory interface { ToStructInfo(ctx context.Context, fullyTableName, tableComment string) (*structInfo, error) ToAllStructInfo(ctx context.Context) ([]*structInfo, error) ToAllStructInfoOtherDb(ctx context.Context, dbName string) ([]*structInfo, error) // contains filtered or unexported methods }
func New ¶
func New(cfg *Config) (actuators confString, codeConstructor CodeFactory, err error)
New 创建一个tcode
type Config ¶
type Config struct { Dsn string DriverName string Dialect string MaxOpenConns int MaxIdleConns int ConnMaxLifetimeSecond int DB *sql.DB DefaultTxOptions *sql.TxOptions PrimaryKeyColumnName string //用于统一主键列,所有表的主键列名称必须为此值,否则无法使用代码生成器 SkipDefaultTransaction bool //是否跳过默认(增,删,改)事务 PackageName string //代码生成器生产代码所使用的包名 }
type Page ¶
type TableSlice ¶
type TableSlice[T Table] []T
Source Files ¶
Click to show internal directories.
Click to hide internal directories.