fn

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2023 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

PS 路径分隔符

View Source
const TplRepo = "https://blob.workits.cn/templates/"

TplRepo 远程仓库地址

Variables

View Source
var ErrExist = fmt.Errorf("exist") // 已存在
View Source
var ErrExit = fmt.Errorf("bye") // 退出

Functions

func AppendFile

func AppendFile(filePath, content string)

AppendFile 在文件末尾追加内容

func CamelCaseToUdnderscore

func CamelCaseToUdnderscore(s string) string

CamelCaseToUdnderscore 驼峰单词转下划线单词

func CopyTemplates

func CopyTemplates(projName string, force bool)

CopyTemplates 拷贝模版

func CreateConfig

func CreateConfig(projName string) *viper.Viper

CreateConfig 创建配置

func DownloadTemplates

func DownloadTemplates(force bool)

DownloadTemplates 下载全局模版

func GenCode added in v0.0.2

func GenCode(projDir, moduleName, tableName string)

GenCode 生成代码

func GenerateFile

func GenerateFile(projDir, typ string, data StructInfo) string

GenerateFile 生成文件

func IsFolderName

func IsFolderName(name string) bool

IsFolderName 是否是文件夹名称

func ModGlobalConfig

func ModGlobalConfig(projDir, comp string)

ModGlobalConfig 修改global.go

func NewComponent

func NewComponent(projDir, compName string)

NewComponent 添加组件

func NewModule

func NewModule(projDir, moduleName string)

NewModule 添加模块

func NewProject

func NewProject(projName, comp string)

func ParseTemplate

func ParseTemplate(src, dest string, params any)

ParseTemplate 解析模版

func ReadFileByLine

func ReadFileByLine(filePath string) []string

ReadFileByLine 读取文件

func RollbackGlobalConfig

func RollbackGlobalConfig(projDir, comp string)

RollbackGlobalConfig 回滚global.go

func RollbackGomod

func RollbackGomod(projDir, comp string)

RollbackGomod 回滚go.mod

func Run added in v0.0.3

func Run()

func UderscoreToLowerCamelCase

func UderscoreToLowerCamelCase(s string) string

UderscoreToLowerCamelCase 下划线单词转为小写驼峰单词

func UderscoreToUpperCamelCase

func UderscoreToUpperCamelCase(s string) string

UderscoreToUpperCamelCase 下划线单词转为大写驼峰单词

Types

type ColumnInfo

type ColumnInfo struct {
	Field   string
	Type    string
	Null    string
	Key     string
	Default string
	Comment string
}

ColumnInfo 字段信息

type ColumnInfoMysqlEntity

type ColumnInfoMysqlEntity struct {
	zorm.EntityStruct

	Field   string `column:"Field"`
	Type    string `column:"Type"`
	Null    string `column:"Null"`
	Key     string `column:"Key"`
	Default string `column:"Default"`
	Comment string `column:"Comment"`
}

ColumnInfoMysqlEntity 字段信息实体(MySQL)

type DBConfig

type DBConfig struct {
	Dialect string `mapstructure:"dialect"`
	Host    string `mapstructure:"host"`
	Port    int    `mapstructure:"port"`
	User    string `mapstructure:"user"`
	Pass    string `mapstructure:"pass"`
	Name    string `mapstructure:"name"`
}

DBConfig 数据库配置

func (DBConfig) DSN

func (db DBConfig) DSN() string

DSN 生成数据库连接字符串

type DBTool

type DBTool interface {
	GetTableInfo(dbName, tableName string) *TableInfo
}

func NewDBTool

func NewDBTool(dbCfg dbx.Config) DBTool

type MySQLTool

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

func (*MySQLTool) GetTableInfo

func (t *MySQLTool) GetTableInfo(dbName, tableName string) *TableInfo

GetTableInfo 获取表信息

type StructField

type StructField struct {
	FieldName    string
	ColumnName   string
	JsonName     string
	Type         string
	Required     bool
	Comment      string
	IsPrimaryKey bool
	Default      any
}

StructField 结构体字段信息

type StructInfo

type StructInfo struct {
	GoModule         string
	ProjModule       string
	ModName          string
	Name             string
	StructName       string
	TableName        string
	FileName         string
	PrimaryKeyColumn string
	PrimaryKeyField  string
	PrimaryKeyType   string
	PrimaryKeyName   string
	Fields           []StructField
	HasTime          bool
	HasDecimal       bool
	Comment          string
	IsStandard       bool
}

StructInfo 结构体信息

func TypeConversion

func TypeConversion(isStandard bool, tb *TableInfo) StructInfo

TypeConversion 类型转换

type TableInfo

type TableInfo struct {
	Name    string
	Comment string
	Fields  []ColumnInfo
}

TableInfo 表信息

type TableInfoMysqlEntity

type TableInfoMysqlEntity struct {
	zorm.EntityStruct

	Name    string `column:"Name"`
	Comment string `column:"Comment"`
}

TableInfoMysqlEntity 表信息实体(MySQL)

type VerInfo

type VerInfo struct {
	VBig   int
	VSmall int
	Ver    int
	TDir   string
	Meta   string
}

VerInfo 版本信息

type WkCfg

type WkCfg struct {
	GoModule string   `mapstructure:"go-module"`
	DB       DBConfig `mapstructure:"db"`
}

WkCfg 配置文件

Jump to

Keyboard shortcuts

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