Documentation
¶
Index ¶
Constants ¶
View Source
const (
ResultToJSONObjectTmpl = `` /* 140-byte string literal not displayed */
)
View Source
const (
SqlInsertTmpl = `` /* 360-byte string literal not displayed */
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EnumField ¶
type EnumField struct {
StructField
EnumFieldValues []EnumFieldValue
}
type EnumFieldValue ¶
type EnumFieldValue struct {
StructField
EnumName string
EnumValue string
EnumValueProcess string // 如果是字符串类型,需要在EnumValue基础上添加双引号
EnumComment string
}
type InsertField ¶
type InsertFieldValue ¶
type InsertParam ¶
type InsertParam struct {
Ignore bool
Table string
Fields []InsertField
Values []InsertValue
}
func InsertParamFromStruct ¶
func InsertParamFromStruct(s *Struct, opt *Option) *InsertParam
type InsertValue ¶
type InsertValue struct {
FieldValues []InsertFieldValue
NoDot bool
}
type Option ¶
type Option struct {
StructNameMapper func(string) string // 名称映射
IgnoreField []string // 忽略字段
FieldNameMapper func(string) string // 字段名称映射
FieldTypeMapper func(string) string // 字段类型映射
FieldTagMapper func(string, string) string // 可根据名称和类型自行决定字段tag
RandomFieldValueByType func(string) any // 根据字段类型生成随机值
TrimTablePrefix string // 表名前缀,若有则在转为结构体名前去掉
Amount int // 数据条数
}
type ParseOption ¶
type ParseOption struct {
// contains filtered or unexported fields
}
type ParseSetter ¶
type ParseSetter func(*ParseOption)
func WithTablePrefix ¶
func WithTablePrefix(tablePrefix string) ParseSetter
type ResultToJSONObject ¶
type ResultToJSONObject struct {
Fields []ResultToJSONObjectField
}
func FromStructForTmpl ¶
func FromStructForTmpl(s *StructForTmpl) *ResultToJSONObject
type ResultToJSONObjectField ¶
type Struct ¶
type Struct struct {
PkgName string
Name string
TableName string
Comment string
Fields []Field
HaveEnum bool
// contains filtered or unexported fields
}
func ParseCreateSQL ¶
func ParseCreateSQLBatch ¶
func ParseCreateSQLBatch(sql string, opts ...ParseSetter) []*Struct
type StructField ¶
type StructForTmpl ¶
type StructForTmpl struct {
PkgName string
Imports []string
TableName string
StructName string
StructComment string
Fields []StructField
EnumFields []EnumField
HaveEnum bool
}
func FromStruct ¶
func FromStruct(s *Struct, opt Option) StructForTmpl
Click to show internal directories.
Click to hide internal directories.