server

package
v0.0.0-...-4a63614 Latest Latest
Warning

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

Go to latest
Published: May 31, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SQL_FOMATE_TABLES       = "SELECT TABLE_NAME as name, TABLE_COMMENT as comment FROM information_schema.TABLES WHERE table_schema='%s'"
	SQL_FOMATE_TABLE_DETAIL = "" /* 153-byte string literal not displayed */
)

Variables

View Source
var (
	FlagServerType string
	FlagCodesDst   string

	FlagProtoFile     string
	FlagMysqlHost     string
	FlagMysqlDatabase string
	FlagMysqlAuth     string

	PackageName string

	Cmd = &cobra.Command{
		Use:   "server",
		Short: "Generate server code",
		Run:   run,
	}
)
View Source
var MysqlTypes = map[string]string{
	"tinyint":           "int8",
	"tinyint unsigned":  "uint8",
	"smallint":          "int16",
	"smallint unsigned": "uint16",
	"integer":           "int64",
	"int":               "int",
	"int unsigned":      "uint",
	"bigint":            "int64",
	"bigint unsigned":   "uint64",
	"float":             "float32",
	"float unsigned":    "float32",
	"double":            "float64",
	"decimal":           "float64",
	"varchar":           "string",
	"char":              "string",
	"date":              "string",
	"time":              "string",
	"datetime":          "string",
	"timestamp":         "string",
	"json":              "datatypes.JSON",
	"text":              "[]byte",
	"tinytext":          "[]byte",
	"mediumtext":        "[]byte",
	"longtext":          "[]byte",
	"blob":              "[]byte",
	"tinyblob":          "[]byte",
	"mediumblob":        "[]byte",
	"longblob":          "[]byte",
	"enum":              "string",
}

Functions

func GenConfig

func GenConfig(name string) (pkg.File, error)

func GenModelEntities

func GenModelEntities(name string, tables []*Table) ([]pkg.File, error)

func GenModels

func GenModels(name, src string, tree *pkg.Tree) ([]pkg.File, error)

func GenRepository

func GenRepository(name string) (pkg.File, error)

func GenRestApis

func GenRestApis(name, src string, tree *pkg.Tree) ([]pkg.File, error)

func GenRestMain

func GenRestMain(name string) (pkg.File, error)

func GenRpcApis

func GenRpcApis(name, src string, tree *pkg.Tree) ([]pkg.File, error)

func GenRpcMain

func GenRpcMain(name string) (pkg.File, error)

func GenRpcProtos

func GenRpcProtos(name, src, dst string, tree *pkg.Tree) ([]pkg.File, error)

func GenServices

func GenServices(name, src string, tree *pkg.Tree) ([]pkg.File, error)

func MkdirDirs

func MkdirDirs(dst string) error

Types

type Column

type Column struct {
	Name     string
	DataType string
	Tag      string
	Comment  string
}

type MethodTemplateVars

type MethodTemplateVars struct {
	ServiceName string // 模块名
	Name        string // 方法名
	Document    string // 方法文档
	Cmd         string // 方法类型 rest POST / GET / DELETE
	Uri         string // 方法请求路径 rest
	ReqName     string // 入参自定义类型名
	ResName     string // 出参自定义类型名
}

type ServiceTemplateVars

type ServiceTemplateVars struct {
	ServerName string // 服务名 (go mod name、registry name)
	Name       string // 模块名称
	Document   string // 模块文档
	Methods    []*MethodTemplateVars
}

type Table

type Table struct {
	Name         string
	Comment      string
	SingularName string    `gorm:"-"`
	PluralName   string    `gorm:"-"`
	Columns      []*Column `gorm:"-"`
}

func ReadMysqlTables

func ReadMysqlTables(host, database, auth string) ([]*Table, error)

Jump to

Keyboard shortcuts

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