view

package
v0.9.6-rc2 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TagSmallCamelCase = "smallCamelCase"
	TagCamelCase      = "camelCase"
	TagSnakeCase      = "snakeCase"
	TagKebab          = "kebab"
)

Variables

This section is empty.

Functions

func InitFlagSetForConfig added in v0.4.0

func InitFlagSetForConfig(s *flag.FlagSet, cc *Config)

func IsDecimal added in v0.5.8

func IsDecimal(t string) bool

Types

type Column

type Column struct {
	Name            string       // column name
	OrdinalPosition int          // column ordinal position
	ColumnGoType    string       // column data go type(string,int...)
	ColumnType      string       // column type(varchar(256)...)
	IsNullable      bool         // column is null or not
	IsAutoIncrement bool         // column auto increment or not
	Default         *string      // default value
	Comment         string       // column comment
	Index           []Index      // index list
	ForeignKeys     []ForeignKey // Foreign key list
}

Column column information

func (*Column) IntoDefinedSQL added in v0.5.8

func (c *Column) IntoDefinedSQL() string

IntoDefinedSQL 转换为定义的字段 SQL

type ColumnKeyType

type ColumnKeyType int

ColumnKeyType column key type

const (
	ColumnKeyNone            ColumnKeyType = iota // default
	ColumnKeyTypePrimary                          // primary key
	ColumnKeyTypeNormalIndex                      // normal index key
	ColumnKeyTypeUniqueKey                        // unique key
	ColumnKeyTypeUnique                           // unique
)

type ColumnSlice

type ColumnSlice []*Column

func (ColumnSlice) Len

func (t ColumnSlice) Len() int

func (ColumnSlice) Less

func (t ColumnSlice) Less(i, j int) bool

func (ColumnSlice) Swap

func (t ColumnSlice) Swap(i, j int)

type Config

type Config struct {
	DbTag              string            `yaml:"dbTag" json:"dbTag"`                         // db标签,默认gorm
	Tags               map[string]string `yaml:"tags" json:"tags"`                           // tags标签列表, support smallCamelCase, camelCase, snakeCase, kebab
	EnableInt          bool              `yaml:"enableInt" json:"enableInt"`                 // 使能int8,uint8,int16,uint16,int32,uint32输出为int,uint
	EnableIntegerInt   bool              `yaml:"enableIntegerInt" json:"enableIntegerInt"`   // 使能int32,uint32输出为int,uint
	EnableBoolInt      bool              `yaml:"enableBoolInt" json:"enableBoolInt"`         // 使能bool输出int
	DisableNullToPoint bool              `yaml:"isNullToPoint" json:"isNullToPoint"`         // 禁用字段为null时输出指针类型,将输出为sql.Nullxx
	DisableCommentTag  bool              `yaml:"disableCommentTag" json:"disableCommentTag"` // 禁用注释放入tag标签中
	EnableForeignKey   bool              `yaml:"enableForeignKey" json:"enableForeignKey"`   // 输出外键
	HasColumn          bool              `yaml:"hasColumn" json:"hasColumn"`                 // 是否输出字段
	SkipColumns        []string          `yaml:"skipColumns" json:"skipColumns"`             // 忽略输出字段, 格式 table.column
	Package            string            `yaml:"package" json:"package"`                     // 包名
	Options            map[string]string `yaml:"options" json:"options"`                     // 选项
	HasHelper          bool              `yaml:"hasHelper" json:"hasHelper"`                 // 是否输出 proto 帮助
	EnableGogo         bool              `yaml:"enableGogo" json:"enableGogo"`               // 使能用 gogo proto (仅 hasHelper = true 有效果)
	EnableSea          bool              `yaml:"enableSea" json:"enableSea"`                 // 使能用 seaql(仅 hasHelper = true 有效果)
}

type DBModel

type DBModel interface {
	GetDatabase() (*Database, error)
	GetTableAttributes() ([]TableAttribute, error)
	GetTables(tb TableAttribute) (*Table, error)
	GetCreateTableSQL(tbName string) (string, error)
}

DBModel Implement the interface to acquire database information.

type Database

type Database struct {
	Name   string   // database name, 数据库名
	Tables []*Table // table information, 表信息
}

Database database information

type ForeignKey

type ForeignKey struct {
	TableName  string // Affected tables .
	ColumnName string // Which column of the affected table
}

ForeignKey Foreign key

type Index

type Index struct {
	KeyType    ColumnKeyType // key type
	KeyName    string        // index key name, 索引名称
	IsMulti    bool          // Multiple key, 是否为复合索引
	SeqInIndex int           // union index sequence in index, 复合索引中的序列
	IndexType  string        // index type, 索引类型(比如: BTREE, HASH, FULLTEXT)
}

Index database index/unique_index list

type Table

type Table struct {
	TableAttribute
	Columns []*Column // column information
}

Table database table information

type TableAttribute

type TableAttribute struct {
	Name           string // table name, 表名
	Comment        string // table comment, 表注释
	CreateTableSQL string // Create SQL statements, 创建表的sql语句
}

TableAttribute database table name, comment and create table sql

type TableSlice

type TableSlice []*Table

func (TableSlice) Len

func (t TableSlice) Len() int

func (TableSlice) Less

func (t TableSlice) Less(i, j int) bool

func (TableSlice) Swap

func (t TableSlice) Swap(i, j int)

type View

type View struct {
	Config
	DBModel
}

View information

func New

func New(m DBModel, c Config) *View

New view instance

func (*View) GetDbFile

func (sf *View) GetDbFile(pkgName string) ([]*ast.File, error)

GetDbFile ast file

func (*View) GetSqlFile added in v0.4.0

func (sf *View) GetSqlFile() (*ast.SqlFile, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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