libModel

package
v0.0.0-...-480cc5f Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CTypeInt64   = "int64"
	CTypeInt     = "int"
	CTypeUInt    = "uint"
	CTypeString  = "string"
	CTypeFloat64 = "float64"
	CTypeTime    = "time.Time"
	CTypeInt8    = "int8"
	CTypeUInt64  = "uint64"
	CTypeByte    = "byte"
	CUnsigned    = "unsigned"
)

数据库类型与go数据类型之间的转换

View Source
const (
	DTypeInt64   = "numeric"
	DTypeInt     = "numeric"
	DTypeUInt    = "numeric,gt=0"
	DTypeString  = "alphanumunicode"
	DTypeFloat64 = "numeric"
	DTypeTime    = "alphanumunicode"
	DTypeInt8    = "numeric"
	DTypeUInt64  = "numeric,gt=0"
	DTypeByte    = "alphanumunicode"
	DUnsigned    = "numeric,gt=0"
)

数据库类型与validate类型之间的转换

View Source
const DTOCodeTemplate = `` /* 848-byte string literal not displayed */
View Source
const DomainGormDaoCodeTemplate = `` /* 4014-byte string literal not displayed */

完善Gorm Dao模板,根据goapp_account的实践

View Source
const DomainSqlBuilderDaoCodeTemplate = `` /* 3660-byte string literal not displayed */
View Source
const GormStructCodeTemplate = `` /* 1406-byte string literal not displayed */

完善Gorm Model模板,根据goapp_account的实践

View Source
const SchemaDbName = "information_schema"
View Source
const SqlBuilderStructCodeTemplate = `` /* 1300-byte string literal not displayed */

Variables

View Source
var TypeWrappers = []typeWrapper{i64TypeWrapper, byteTypeWrapper, intTypeWrapper, float64TypeWrapper, stringTypeWrapper, timeTypeWrapper}

需要转换成Struct的类型转换函数切片

View Source
var TyperDTOWrappers = []typerDTOWrapper{i64TyperDTOWrapper, byteTyperDTOWrapper, intTyperDTOWrapper, float64TyperDTOWrapper, stringTyperDTOWrapper, timeTyperDTOWrapper}

需要转换成Struct的类型转换函数切片

Functions

func GetDBInstance

func GetDBInstance(params *CmdParams) (*sql.DB, error)

Types

type CmdParams

type CmdParams struct {
	Name        string `json:"name"`
	Driver      string `json:"driver"`
	Host        string `json:"host"`
	Port        int    `json:"port"`
	DbName      string `json:"database"`
	Table       string `json:"table"`
	User        string `json:"user"`
	Password    string `json:"password"`
	OutputPath  string `json:"output_path"`
	DOutputPath string `json:"dto_output_path"`
	Formatter   string `json:"formatter"`
}

命令参数

type Column

type Column struct {
	Name    string `json:"COLUMN_NAME"`
	Type    string `json:"COLUMN_TYPE"`
	DTOTag  string
	Comment string `json:"COLUMN_COMMENT"`
}

Column stands for a column of a table

func GetTableSchema

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

读取数据库schema表结构表,获取表结构的列信息

func (*Column) GetComment

func (c *Column) GetComment() string

func (*Column) GetDTOType

func (c *Column) GetDTOType() (string, error)

func (*Column) GetName

func (c *Column) GetName() string

GetName returns the Cammel Name of the struct

func (*Column) GetType

func (c *Column) GetType() (string, error)

GetType returns which built in type the column should be in generated go code

type Field

type Field struct {
	Name      string
	Type      string
	StructTag string
	Comment   string
}

表列信息结构体

type FormatterDTO

type FormatterDTO struct {
	FormatterStruct
}

func NewFormatterDTOStruct

func NewFormatterDTOStruct() *FormatterDTO

func (*FormatterDTO) Format

func (f *FormatterDTO) Format(name, tableName string, cols []Column) IFormatter

func (*FormatterDTO) WriteOut

func (f *FormatterDTO) WriteOut(writer io.Writer) error

type FormatterGorm

type FormatterGorm struct {
	FormatterStruct
}

func NewFormatterGorm

func NewFormatterGorm() *FormatterGorm

func (*FormatterGorm) Format

func (f *FormatterGorm) Format(name, table string, cols []Column) IFormatter

func (*FormatterGorm) WriteOut

func (f *FormatterGorm) WriteOut(writer io.Writer) error

type FormatterGormDao

type FormatterGormDao struct {
	FormatterStruct
}

func NewFormatterGormDao

func NewFormatterGormDao() *FormatterGormDao

func (*FormatterGormDao) Format

func (f *FormatterGormDao) Format(name, table string, cols []Column) IFormatter

func (*FormatterGormDao) WriteOut

func (f *FormatterGormDao) WriteOut(writer io.Writer) error

type FormatterSqlBuilder

type FormatterSqlBuilder struct {
	FormatterStruct
}

func NewFormatterSqlBuilder

func NewFormatterSqlBuilder() *FormatterSqlBuilder

func (*FormatterSqlBuilder) Format

func (f *FormatterSqlBuilder) Format(name, table string, cols []Column) IFormatter

func (*FormatterSqlBuilder) WriteOut

func (f *FormatterSqlBuilder) WriteOut(writer io.Writer) error

type FormatterSqlBuilderDao

type FormatterSqlBuilderDao struct {
	FormatterStruct
}

func NewFormatterSqlBuilderDao

func NewFormatterSqlBuilderDao() *FormatterSqlBuilderDao

func (*FormatterSqlBuilderDao) Format

func (f *FormatterSqlBuilderDao) Format(name, table string, cols []Column) IFormatter

func (*FormatterSqlBuilderDao) WriteOut

func (f *FormatterSqlBuilderDao) WriteOut(writer io.Writer) error

type FormatterStruct

type FormatterStruct struct {
	PackageName        string
	ImportList         map[string]ImportItem
	StructName         string
	TableName          string
	FieldList          []Field
	ModelFieldList     []Field
	DTOFieldList       []Field
	CreateDTOFieldList []Field
	UpdateDTOFieldList []Field
}

格式化信息结构体

type IFormatter

type IFormatter interface {
	Format(name, table string, cols []Column) IFormatter
	WriteOut(writer io.Writer) error
}

type ImportItem

type ImportItem struct {
	Alias   string
	Package string
}

Jump to

Keyboard shortcuts

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