Documentation ¶
Index ¶
- type Config
- func (cfg *Config) ConvertStructMetas(structs ...interface{}) (metas []*plate.PlateMeta, err error)
- func (cfg *Config) Revise() (err error)
- func (cfg *Config) WithDataTypeMap(newMap map[string]func(columnType gorm.ColumnType) (dataType string))
- func (cfg *Config) WithJSONTagNameStrategy(ns func(columnName string) (tagContent string))
- type Generator
- func (g *Generator) ApplyMetas(plates []*plate.PlateMeta, injects []*inject.AstInjectMeta)
- func (g *Generator) Execute()
- func (g *Generator) GenFieldConfig() *field.FieldConfig
- func (g *Generator) GenerateCommonFile(tableName string, tableComment string) error
- func (g *Generator) GenerateMetasFromModel(tableName, tableComment string, fields []*provider.Field) ([]*plate.PlateMeta, []*inject.AstInjectMeta)
- func (g *Generator) GenerateMetasFromSchema() ([]*plate.PlateMeta, []*inject.AstInjectMeta)
- func (g *Generator) GenerateMetasFromTable(tableName, tableComment string) ([]*plate.PlateMeta, []*inject.AstInjectMeta)
- func (g *Generator) GetTemplateDatas() []*plate.AutoCodeStructData
- func (g *Generator) InitPackage(tableName string)
- func (g *Generator) RollBack()
- func (g *Generator) UseDB(db *gorm.DB)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { Replace bool //是否替换文件 ReplaceCommon bool //是否替换自定义文件 GenerateCommon bool //生成自定义文件 OutPath string // 输出路径 OutFileNS func(tableName string) (fileName string) // 输出文件名称 FieldNullable bool // generate pointer when field is nullable FieldCoverable bool // generate pointer when field has default value, to fix problem zero value cannot be assign: https://gorm.io/docs/create.html#Default-Values FieldSignable bool // detect integer field's unsigned type, adjust generated data type FieldWithIndexTag bool // generate with gorm index tag FieldWithTypeTag bool // generate with gorm column type tag IgnoreMap map[string]string // contains filtered or unexported fields }
func (*Config) ConvertStructMetas ¶
ConvertStructs convert to base structures
func (*Config) WithDataTypeMap ¶
func (cfg *Config) WithDataTypeMap(newMap map[string]func(columnType gorm.ColumnType) (dataType string))
WithDataTypeMap specify data type mapping relationship, only work when syncing table from db
func (*Config) WithJSONTagNameStrategy ¶
WithJSONTagNameStrategy specify json tag naming strategy
type Generator ¶
type Generator struct { *log.Logger InjectMetas []*inject.AstInjectMeta // contains filtered or unexported fields }
func NewGenerator ¶
func (*Generator) ApplyMetas ¶
func (g *Generator) ApplyMetas(plates []*plate.PlateMeta, injects []*inject.AstInjectMeta)
func (*Generator) GenFieldConfig ¶
func (g *Generator) GenFieldConfig() *field.FieldConfig
func (*Generator) GenerateCommonFile ¶
func (*Generator) GenerateMetasFromModel ¶
func (g *Generator) GenerateMetasFromModel(tableName, tableComment string, fields []*provider.Field) ([]*plate.PlateMeta, []*inject.AstInjectMeta)
使用data进行创建
func (*Generator) GenerateMetasFromSchema ¶
func (g *Generator) GenerateMetasFromSchema() ([]*plate.PlateMeta, []*inject.AstInjectMeta)
创建数据库中所有表
func (*Generator) GenerateMetasFromTable ¶
func (g *Generator) GenerateMetasFromTable(tableName, tableComment string) ([]*plate.PlateMeta, []*inject.AstInjectMeta)
创建一个表
func (*Generator) GetTemplateDatas ¶
func (g *Generator) GetTemplateDatas() []*plate.AutoCodeStructData
func (*Generator) InitPackage ¶
Click to show internal directories.
Click to hide internal directories.