model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 8 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 Generate

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

Generate build code string.生成代码

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
	Extra          string       // Extra (AUTO_INCREMENT 自增加)
	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 GenModel

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

func (*GenModel) GetPackage

func (m *GenModel) GetPackage() genstruct.GenPackage

GetPackage gen struct on table

type GenOutInfo

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

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

type IModel

type IModel interface {
	GenModel() DBInfo
	GetDbName() string
	GetPkgName() string
	GetTableNames() string
}

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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