generate

package module
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

README

go_generate_tool

根据mysql数据库字段生成业务代码的工具

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateTemplate added in v1.1.3

func GenerateTemplate(table *Table, filePath string, temp string) error

Types

type Column

type Column struct {
	Name         string // 字段名
	ModelName    string // 模板类型
	Type         string // 类型
	ModelType    string // 模板类型
	DomainType   string // 数据类型
	ModelTag     string // 标签
	DomainTag    string // 数据标签
	Comment      string // 注释
	ModelComment string // 模板注释
	Key          string // 索引信息
}

Column represents a table column.

type Executor

type Executor interface {
	// GetTableMetadata 获取库元数据
	GetTableMetadata(db *sql.DB, dbName string) ([]Table, error)
	// GetTableColumns 获取表元数据
	GetTableColumns(tableName string, db *sql.DB, dbName string) ([]Column, error)
	// ColumnMetaHandle 处理列元数据
	ColumnMetaHandle(column *Column) error
	// GenerateModel 生成Model业务代码
	GenerateModel(table *Table) error
	// GenerateDomain 生成数据代码
	GenerateDomain(table *Table) error
	// GenerateService 生成业务层代码
	GenerateService(table *Table) error
	// GenerateController 生成控制层业务代码
	GenerateController(table *Table) error
}

Executor 生成业务代码所需实现的接口

type MySqlExecutor

type MySqlExecutor struct {
}

func (*MySqlExecutor) ColumnMetaHandle

func (m *MySqlExecutor) ColumnMetaHandle(column *Column) error

func (*MySqlExecutor) GenerateController

func (m *MySqlExecutor) GenerateController(table *Table) error

func (*MySqlExecutor) GenerateDomain

func (m *MySqlExecutor) GenerateDomain(table *Table) error

func (*MySqlExecutor) GenerateModel

func (m *MySqlExecutor) GenerateModel(table *Table) error

func (*MySqlExecutor) GenerateService

func (m *MySqlExecutor) GenerateService(table *Table) error

func (*MySqlExecutor) GetTableColumns

func (m *MySqlExecutor) GetTableColumns(tableName string, db *sql.DB, dbName string) ([]Column, error)

func (*MySqlExecutor) GetTableMetadata

func (m *MySqlExecutor) GetTableMetadata(db *sql.DB, dbName string) ([]Table, error)

func (*MySqlExecutor) TableHandle

func (m *MySqlExecutor) TableHandle(table *Table) error

type Table

type Table struct {
	Name        string   // 表名称
	ModelName   string   // 模板表名称
	PrivateName string   // 开头小写的名称
	Columns     []Column // 列属性
}

Table represents a database table.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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