scaffolds

package
v0.0.0-...-7a3883e Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var FieldTypeMappings = map[string]string{
	"int":        "Int",
	"int8":       "Int",
	"int16":      "Int",
	"int32":      "Int",
	"uint":       "Int",
	"uint8":      "Int",
	"uint16":     "Int",
	"uint32":     "Int",
	"int64":      "BigInt",
	"uint64":     "BigInt",
	"float32":    "Float",
	"float64":    "Double",
	"complex64":  "Varchar(64)",
	"complex128": "Varchar(64)",
	"[]uint8":    "Blob",
	"[]byte":     "Blob",
	"array":      "Text",
	"slice":      "Text",
	"map":        "Text",
	"bool":       "Bool",
	"string":     "Varchar(255)",
	"time.Time":  "DateTime",
}

FieldTypeMappings map[golangType]dbType

Functions

This section is empty.

Types

type ModelField

type ModelField struct {
	Name           string `json:"name"`
	Column         string `json:"column" validate:"required"`
	ColumnType     string `json:"columnType" validate:"required"`
	Type           string `json:"type" validate:"required"`
	Length         int    `json:"length" validate:"optional"`
	IsPrimaryKey   bool   `json:"isPrimaryKey" validate:"optional"`
	IsIndex        bool   `json:"isIndex"`
	AutoIncreament bool   `json:"autoIncreament"`
	IsRequired     bool   `json:"isRequired"`
}

ModelField field structure

func (*ModelField) Encode

func (f *ModelField) Encode(fieldPaces int, typeSpaces int) string

Encode as xorm field defination

type ModelScaffolds

type ModelScaffolds struct {
	Path       string       `json:"path" validate:"required"`
	Name       string       `json:"name" validate:"required"`
	TableName  string       `json:"tableName" validate:"required"`
	Fields     []ModelField `json:"fields" validate:"required"`
	Datasource string       `json:"datasource" validate:"required"`
}

ModelScaffolds scaffolds

func (*ModelScaffolds) Encode

func (m *ModelScaffolds) Encode() string

Encode model context

func (*ModelScaffolds) GetStructName

func (m *ModelScaffolds) GetStructName() string

GetStructName converts name to camel string

type ProjectScaffolds

type ProjectScaffolds struct {
	Name                string   `yaml:"name" json:"name"`
	BaseDir             string   `yaml:"baseDir" json:"baseDir"`
	EtcFolder           string   `yaml:"etcFolder" json:"etcFolder"`
	ModelsFolder        string   `yaml:"modelsFolder" json:"modelsFolder"`
	ControllersFolder   string   `yaml:"controllersFolder" json:"controllersFolder"`
	MiddlewaresFolder   string   `yaml:"middlewaresFolder" json:"middlewaresFolder"`
	ServicesFolder      string   `yaml:"servicesFolder" json:"servicesFolder"`
	RepositoriesFolder  string   `yaml:"repositoriesFolder" json:"repositoriesFolder"`
	Datasources         []string `yaml:"datasources" json:"datasources"`
	DockerfileTemplate  string   `yaml:"dockerfileTempl" json:"dockerfileTempl"`
	JenkinsfileTemplate string   `yaml:"jenkinsfileTempl" json:"jenkinsfileTempl"`
	EtcFileTemplates    []string `yaml:"etcFileTemplates" json:"etcFileTemplates"`
	AppVersion          string   `yaml:"appVersion" json:"appVersion"`
	ConfigFile          string   `yaml:"configFile" json:"configFile"`
	MQConfigFile        string   `yaml:"mqConfigFile" json:"mqConfigFile"`
	// contains filtered or unexported fields
}

ProjectScaffolds scaffolding of project directories

func NewProjectScaffolds

func NewProjectScaffolds(projectName string, projectDir string) *ProjectScaffolds

NewProjectScaffolds new a project scaffolds

func (*ProjectScaffolds) EnsureDirecotries

func (s *ProjectScaffolds) EnsureDirecotries() error

EnsureDirecotries ensure creating directories

func (*ProjectScaffolds) Generate

func (s *ProjectScaffolds) Generate() error

Generate genetates project directory and base source files

func (*ProjectScaffolds) GenerateModel

func (s *ProjectScaffolds) GenerateModel(model *ModelScaffolds) error

GenerateModel by model defination

func (*ProjectScaffolds) GetProjectSubFolderPath

func (s *ProjectScaffolds) GetProjectSubFolderPath(tagName string) string

GetProjectSubFolderPath get path by name

func (*ProjectScaffolds) LoadFromJSON

func (s *ProjectScaffolds) LoadFromJSON(filePath string) error

LoadFromJSON load from configure

func (*ProjectScaffolds) LoadFromYaml

func (s *ProjectScaffolds) LoadFromYaml(filePath string) error

LoadFromYaml load from configure

Jump to

Keyboard shortcuts

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