util

package
v1.0.3-0...-832441f Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2020 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MySQLDriverName represents the mysql driver name.
	MySQLDriverName = "mysql"
)

Variables

This section is empty.

Functions

func ConvertAllTable

func ConvertAllTable(cc CMDConfig) (string, error)

func ConvertTable

func ConvertTable(cc CMDConfig) (string, error)

ConvertTable converts mysql table fields to golang model structure by command config.

Types

type CMDConfig

type CMDConfig struct {
	DBConfig
	PackageName        string `json:"package_name"`
	StructName         string `json:"struct_name"`
	EnableInitialism   bool   `json:"enable_initialism"`
	EnableFieldComment bool   `json:"enable_field_comment"`
	EnableSqlNull      bool   `json:"enable_sql_null"`
	EnableGureguNull   bool   `json:"enable_guregu_null"`
	EnableJsonTag      bool   `json:"enable_json_tag"`
	EnableXmlTag       bool   `json:"enable_xml_tag"`
	EnableGormTag      bool   `json:"enable_gorm_tag"`
	EnableXormTag      bool   `json:"enable_xorm_tag"`
	EnableBeegoTag     bool   `json:"enable_beego_tag"`
	EnableGoroseTag    bool   `json:"enable_gorose_tag"`
	EnableGormV2Tag    bool   `json:"enable_gorm_v2_tag"`
}

CMDConfig represents the config of the running grom command line.

type ColumnInfo

type ColumnInfo struct {
	Name            string       `mysql:"COLUMN_NAME"`
	DataType        string       `mysql:"DATA_TYPE"`
	Type            string       `mysql:"COLUMN_TYPE"`
	Default         string       `mysql:"COLUMN_DEFAULT"`
	Comment         string       `mysql:"COLUMN_COMMENT"`
	Length          int64        `mysql:"CHARACTER_MAXIMUM_LENGTH"`
	Precision       int64        `mysql:"NUMERIC_PRECISION"`
	Scale           int64        `mysql:"NUMERIC_SCALE"`
	Position        int          `mysql:"ORDINAL_POSITION"`
	IsPrimaryKey    bool         `mysql:"COLUMN_KEY"`
	IsAutoIncrement bool         `mysql:"EXTRA"`
	IsUnsigned      bool         `mysql:"COLUMN_TYPE"`
	IsNullable      bool         `mysql:"IS_NULLABLE"`
	Indexes         []*IndexInfo `mysql:"-"`
	UniqueIndexes   []*IndexInfo `mysql:"-"`
}

ColumnInfo represents the information of the column.

type DBConfig

type DBConfig struct {
	Host     string `json:"host"`
	Port     int    `json:"port"`
	User     string `json:"user"`
	Password string `json:"password"`
	Database string `json:"database"`
	Table    string `json:"table"`
	OutDir   string `json:"outdir"`
}

DBConfig represents the config of the connected database.

type IndexInfo

type IndexInfo struct {
	Name       string `mysql:"INDEX_NAME"`
	ColumnName string `mysql:"COLUMN_NAME"`
	Comment    string `mysql:"INDEX_COMMENT"`
	Sequence   int    `mysql:"SEQ_IN_INDEX"`
	IsUnique   bool   `mysql:"NON_UNIQUE"`
}

IndexInfo represents the information of the index.

type StructField

type StructField struct {
	Name    string
	Type    string
	Tag     string
	Comment string
}

StructField represents the field of the generated model structure.

Jump to

Keyboard shortcuts

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