common

package
v0.0.0-...-2b09096 Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileModeConstant = "constant" // 常量模式
	FileModeModel    = "model"    // 模型模式
)
View Source
const (
	LanguageGo = "go" // Go
	LanguageTs = "ts" // TypeScript
)

支持的语言列表

View Source
const (
	// 基础类型,常量仅支持基础类型
	VarTypeAny     = "any"
	VarTypeString  = "string"
	VarTypeUint8   = "uint8"
	VarTypeUint16  = "uint16"
	VarTypeUint32  = "uint32"
	VarTypeUint64  = "uint64"
	VarTypeInt8    = "int8"
	VarTypeInt16   = "int16"
	VarTypeInt32   = "int32"
	VarTypeInt64   = "int64"
	VarTypeBool    = "bool"
	VarTypeFloat32 = "float32"
	VarTypeFloat64 = "float64"
	// (模型专有类型) 扩展类型,数组"[]xxx"和映射"map[xxx]xxx"单独解析(采用Go的语法标准)
	VarTypeJson      = "json"      // JSON字符串,对外表现为字符串,但是需添加Get函数,解析或设置到对应的结构体
	VarTypeExtend    = "extend"    // 继承类型,用于指定模型之间的继承关系
	VarTypeReference = "reference" // 引用类型,对应模型的层级引用关系,需要在Refer中指定引用的模块和文件信息
	VarTypeOther     = "other"     // 其他类型,需根据不同的语言插件,解析其他参数来确定
)

Variables

View Source
var Plugins = map[string]Plugin{}

Functions

This section is empty.

Types

type Context

type Context struct {
	Dir         Directory // 目录信息
	File        File      // 文件信息
	Field       Field     // 字段信息
	CurFileName string    // 当前文件名称
}

上下文信息

func (Context) GetFieldVarType

func (m Context) GetFieldVarType() string

type Directory

type Directory struct {
	Mode  string      `json:"mode"`   // 目录模式,常量还是模型
	ExtGo DirectoryGo `json:"ext-go"` // (Go)目录的扩展属性
	ExtTs DirectoryTs `json:"ext-ts"` // (Ts)目录的扩展属性
}

目录整体配置信息

func (Directory) IsConstant

func (m Directory) IsConstant() bool

func (Directory) IsModel

func (m Directory) IsModel() bool

type DirectoryGo

type DirectoryGo struct {
	CopyExt     []string `json:"copy-ext"`     // 可以拷贝的文件后缀名列表
	PackageName string   `json:"package-name"` // go的包名
}

(Go)目录整体配置信息的扩展参数

func (DirectoryGo) GetPackageName

func (m DirectoryGo) GetPackageName() string

type DirectoryTs

type DirectoryTs struct {
	CopyExt []string `json:"copy-ext"` // 可以拷贝的文件后缀名列表
}

(Ts)目录整体配置信息的扩展参数

type Field

type Field struct {
	Name    string        `json:"name"`    // 变量名
	Type    string        `json:"type"`    // 变量类型
	Json    string        `json:"json"`    // Json字段名
	Label   string        `json:"label"`   // 对应的展示内容
	Comment string        `json:"comment"` // 注释
	Value   string        `json:"value"`   // (mode=constant) 变量值
	Refer   ReferProperty `json:"refer"`   // (type=extend) 扩展属性
	ExtGo   FieldGo       `json:"ext-go"`  // (Go)目录的扩展属性
	ExtTs   FieldTs       `json:"ext-ts"`  // (Ts)目录的扩展属性
}

单个列表项的基础部分

func (Field) GetComment

func (m Field) GetComment() string

func (Field) GetRefFile

func (m Field) GetRefFile() string

func (Field) GetRefName

func (m Field) GetRefName() string

func (Field) IsJsonIgnore

func (m Field) IsJsonIgnore() bool

type FieldGo

type FieldGo struct {
	Gorm string `json:"gorm"` // GORM特定属性
}

(Go)字段配置信息的扩展参数

func (FieldGo) HasGorm

func (m FieldGo) HasGorm() bool

type FieldTs

type FieldTs struct {
}

(Ts)字段配置信息的扩展参数

type File

type File struct {
	Name     string       `json:"name"`     // 模块名称
	Comment  string       `json:"comment"`  // 文件级注释
	Language []string     `json:"language"` // 导出的语言列表
	VarType  string       `json:"vartype"`  // 统一的变量类型,IOTA为必填,其他为选填,优先级不如字段的type
	Iota     IotaProperty `json:"iota"`     // (常量模式) 特定的IOTA自增数字模式
	List     []Field      `json:"list"`     // 常量或字段列表
	ExtGo    FileGo       `json:"ext-go"`   // (Go)目录的扩展属性
	ExtTs    FileTs       `json:"ext-ts"`   // (Ts)目录的扩展属性
}

文件的通用配置信息

func (File) HasComment

func (m File) HasComment() bool

func (File) HasField

func (m File) HasField() bool

type FileGo

type FileGo struct {
	GormTableName string   `json:"gorm-table-name"` // GORM数据库模式时的表名
	ImportPkgs    []string `json:"import-pkgs"`     // 导入的包名列表
	EnableSet     bool     `json:"enable-set"`      // 是否导出获取label的函数
}

(Go)文件配置信息的扩展参数

func (FileGo) HasImportPkgs

func (m FileGo) HasImportPkgs() bool

func (FileGo) IsGormEnabled

func (m FileGo) IsGormEnabled() bool

type FileTs

type FileTs struct {
	EnableSet bool `json:"enable-set"` // 导出展示标签集合
}

(Ts)文件配置信息的扩展参数

type IotaProperty

type IotaProperty struct {
	Enabled bool  `json:"enable"` // 是否启用,默认为false
	Offset  int64 `json:"offset"` // 偏移量
}

type Plugin

type Plugin interface {
	// 获取生成文件的内容
	GetMainFile(ctx Context) (filename string, content string)
	// 获取其他文件的内容
	GetOtherFile(ctx Context) (filename string, content string)
	// 是否可以拷贝
	CanCopy(ctx Context, fileName string) bool
}

func GetPlugin

func GetPlugin(language string) (handle Plugin)

type ReferProperty

type ReferProperty struct {
	Name string `json:"name"` // 引用对象的名称
	File string `json:"file"` // 引用对象的文件名
}

Jump to

Keyboard shortcuts

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