gen

package
v0.0.0-...-7607688 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultTableTemplate = `package {{.packageName}}
	{{$isHaveUUID := ""}}
// {{UnderScoreToCamel .tableName}} {{.tableDesc}}
type {{UnderScoreToCamel .tableName}} struct { {{range .fields}} {{if Contains .Desc "uuid"}} {{$isHaveUUID = UnderScoreToCamel .Name}} {{end}}
	{{UnderScoreToCamel .Name}} {{.Type}} ` + "`json:\"{{.Name}}\"`" + ` // {{.Desc}}{{end}}
}

func (c *{{UnderScoreToCamel .tableName}}) TableName() string {
	return "{{.tableName}}"
}
{{ if ne $isHaveUUID "" }}
func (c *{{UnderScoreToCamel .tableName}}) AfterCreate(tx *gorm.DB) error {
	if c.{{$isHaveUUID}} != "" {
		c.{{$isHaveUUID}} = uuid.New().String()
	}
	return nil
}
{{end}}
`
	DefaultFileNameTemplate = `{{.tableName}}_gen.go`
)

Functions

func GenEntity

func GenEntity(input *GenInput, tables []*util.Table, f bool) error

func GetGeneratedModel

func GetGeneratedModel(path string) map[string]bool

Types

type GenInput

type GenInput struct {
	Link             string `json:"link"`             // Database link.
	RemovePrefix     string `json:"removePrefix"`     // Remove table prefix.
	OutputDir        string `json:"outputDir"`        // 绝对输出目录
	TableTemplate    string `json:"tableTemplate"`    // Table template.
	FileNameTemplate string `json:"fileNameTemplate"` // Model file name template.

}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL