model

package
v0.0.0-...-b34c890 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2022 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ColumnsKeyDefault default
	ColumnsKeyDefault = iota
	// ColumnsKeyPrimary primary key.主键
	ColumnsKeyPrimary // 主键
	// ColumnsKeyUnique unique key.唯一索引
	ColumnsKeyUnique // unix 唯一索引
	// ColumnsKeyIndex index key.复合索引
	ColumnsKeyIndex // 可重复 index 索引
	// ColumnsKeyUniqueIndex unique index key.唯一复合索引
	ColumnsKeyUniqueIndex // 唯一复合索引
)

Variables

This section is empty.

Functions

func CapLowercase

func CapLowercase(name string) string

CapLowercase 小写.且兼容 golint 驼峰命名规则

func FilterKeywords

func FilterKeywords(src string) string

func GenFListIndex

func GenFListIndex(info FList, status int) string

GenFListIndex 生成list status(1:获取函数名,2:获取参数列表,3:获取sql case,4:值列表)

func GenPreloadList

func GenPreloadList(list []PreloadInfo, multi bool) string

GenPreloadList 生成list

func GetTablePrefixName

func GetTablePrefixName(name string) string

GetTablePrefixName 获取带表前缀名字的tablename

Types

type BaseInfo

type BaseInfo struct {
	Name  string // table name.表名
	Notes string // table comment . 表注释
}

BaseInfo base common attribute. 基础属性

type ColumnsInfo

type ColumnsInfo struct {
	BaseInfo
	IsNull         bool         // null if db is set null
	Type           string       // Type.类型标记
	Gormt          string       // 默认值
	Index          []KList      // index list.index列表
	ForeignKeyList []ForeignKey // Foreign key list . 表的外键信息
}

ColumnsInfo Columns list .表列信息

type ColumnsKey

type ColumnsKey int

ColumnsKey Columns type elem. 类型枚举

type DBInfo

type DBInfo struct {
	DbName      string    // database name
	PackageName string    // package name
	TabList     []TabInfo // table list .表列表
}

DBInfo database default info

type EmInfo

type EmInfo struct {
	IsMulti       bool
	Notes         string // 注释
	Type          string // 类型
	ColName       string // 列名
	ColNameEx     string // `列名`
	ColStructName string // 列结构体
}

EmInfo element of func info

type FEm

type FEm struct {
	Type          string // 类型
	ColName       string // 列名
	ColStructName string // 列结构体
}

FEm ...

type FList

type FList struct {
	Key     ColumnsKey // non_unique of (show keys from [table])
	KeyName string     // key_name of (show keys from [table])
	Kem     []FEm
}

FList index of list

type ForeignKey

type ForeignKey struct {
	TableName  string // Affected tables . 该索引受影响的表
	ColumnName string // Which column of the affected table.该索引受影响的表的哪一列
}

ForeignKey Foreign key of db info . 表的外键信息

type GenOutInfo

type GenOutInfo struct {
	FileName string // output file name .输出文件名
	FileCtx  string // output file context. 输出文件内容
}

GenOutInfo generate file list. 生成的文件列表

func Generate

func Generate(info DBInfo) (out []GenOutInfo, m _Model)

Generate build code string.生成代码

type IModel

type IModel interface {
	GenModel() DBInfo
	GetDbName() string
	GetPkgName() string    // Getting package names through config outdir configuration.通过config outdir 配置获取包名
	GetTableNames() string // Getting tableNames by config. 获取设置的表名
}

IModel Implement the interface to acquire database information and initialize it.实现接口获取数据库信息获取并初始化

type KList

type KList struct {
	Key     ColumnsKey // non_unique of (show keys from [table])
	Multi   bool       // Multiple .是否多个(复合组建)
	KeyName string     // key_name of (show keys from [table])
	KeyType string     // Key_type of (show keys from [Index_type])
}

KList database index /unique_index list.数据库index /unique_index 列表

type PreloadInfo

type PreloadInfo struct {
	IsMulti              bool
	Notes                string // 注释
	ForeignkeyStructName string // 外键类目
	ForeignkeyTableName  string // 外键表名
	ForeignkeyCol        string // 外键列表
	ColName              string // 表名
	ColStructName        string // 表结构体
}

PreloadInfo 预加载列表

type TabInfo

type TabInfo struct {
	BaseInfo
	SQLBuildStr string        // Create SQL statements.创建sql语句
	Em          []ColumnsInfo // Columns list .表列表组合
}

TabInfo database table default attribute

Jump to

Keyboard shortcuts

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