common

package
v0.0.0-...-8aeff98 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2020 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DB

func DB() *xorm.Engine

func DBMetas

func DBMetas(t []string, et []string, tryComplete bool) (tables []*core.Table, err error)

DBMetas 如果指定了t,只处理指定表,第一优先级 如果指定了et,处理除了指定表以外的所有表

func GetGormTag

func GetGormTag(table *core.Table, col *core.Column) string

func GetJsonTag

func GetJsonTag(table *core.Table, column *core.Column) string

func GetXormTag

func GetXormTag(table *core.Table, col *core.Column) string

func InStringSlice

func InStringSlice(f string, a []string) bool

func InitDb

func InitDb() (err error)

func LoadConfig

func LoadConfig() (err error)

func NewModel

func NewModel(table *core.Table) (m model)

func NewModelField

func NewModelField(table *core.Table, column *core.Column) (f modelField)

Types

type AppConfigs

type AppConfigs struct {
	TargetDir       string   `toml:"target_dir"`     //生成的model保存的目录
	Driver          string   `toml:"driver"`         //数据库类型
	Source          string   `toml:"source"`         //数据库连接信息
	TagType         []string `toml:"tag_type"`       //生成的tag类型
	Tables          []string `toml:"tables"`         // -t,指定生成的tables
	ExcludeTables   []string `toml:"exclude_tables"` //排除tables
	TryComplete     bool     `toml:"try_complete"`   //是否跳过错误的table
	JSONOmitempty   bool     `toml:"json_omitempty"` //json是否带上omitempty
	JSONIgnoreField []string `toml:"json_ignore_field"`
	//以下是类型转换,按顺序处理,后2者有一个命中就结束
	Tinyint2Bool bool              `toml:"tinyint2bool"` //is_开头的字段,如果是tintint类型,是否转为bool
	ReplaceType  map[string]string `toml:"replace_type"` //替换的类型,如Time替换成自己实现的
	ColumnType   map[string]string `toml:"column_type"`  //指定对应的字段使用的类型
}

func Configs

func Configs() AppConfigs

type GenTool

type GenTool struct {
	// contains filtered or unexported fields
}

func NewGenTool

func NewGenTool() *GenTool

func (*GenTool) Gen

func (genTool *GenTool) Gen() (err error)

Jump to

Keyboard shortcuts

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