codegen

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TemplateResponseModelKey       = "responseModel"
	TemplateDatasourceKey          = "datasource"
	TemplateBizKey                 = "biz"
	TemplateBizDeletedKey          = "bizDeleted"
	TemplateApiKey                 = "api"
	TemplateApirouterKey           = "apirouter"
	TemplateApirouterDeletedKey    = "apiRouterDeleted"
	TemplateApiQueryAllKey         = "apiQueryAll"
	TemplateApiQueryByConditionKey = "apiQueryByCondition"
	TemplateApiCreateBatchKey      = "apiCreateBatch"
	TemplateApiCreateKey           = "apiCreate"
	TemplateApiUpdateBatchKey      = "apiUpdateBatch"
	TemplateApiUpdateKey           = "apiUpdate"
	TemplateApiRemoveKey           = "apiRemove"
	TemplateApiDeletedKey          = "apiDeleted"

	TemplateVueElementAdminApiKey              = "vueElementAdminApi"
	TemplateVueElementAdminApiDeletedColumnKey = "vueElementAdminApiDeletedColumn"
	TemplateVueElementAdminViewKey             = "vueElementAdminView"
	TemplateVueElementAdminRouterKey           = "vueElementAdminRouter"

	TemplateRuoyiVue3ApiKey              = "ruoniVue3Api"
	TemplateRuoyiVue3ApiDeletedColumnKey = "ruoniVue3ApiDeletedColumn"
	TemplateRuoyiVue3ViewKey             = "ruoniVue3View"
	TemplateRuoyiVue3MenuKey             = "ruoniVue3Menu"
)

Variables

View Source
var (
	DataSourceTemplateContent = ""
)
View Source
var (
	RuoyiVue3Gen = &RuoyiVue3GenType{}
)
View Source
var (
	TemplateFiles map[string]string = map[string]string{
		TemplateResponseModelKey:       app.RUNTIME_PATH + "/template/model/response/model_list_response.template",
		TemplateDatasourceKey:          app.RUNTIME_PATH + "/template/dal/datasources.template",
		TemplateBizKey:                 app.RUNTIME_PATH + "/template/biz/biz.template",
		TemplateBizDeletedKey:          app.RUNTIME_PATH + "/template/biz/biz_deleted_column.template",
		TemplateApiKey:                 app.RUNTIME_PATH + "/template/api/api.template",
		TemplateApirouterKey:           app.RUNTIME_PATH + "/template/api/api_router.template",
		TemplateApirouterDeletedKey:    app.RUNTIME_PATH + "/template/api/api_router_deleted.template",
		TemplateApiQueryAllKey:         app.RUNTIME_PATH + "/template/api/api_query_all.template",
		TemplateApiQueryByConditionKey: app.RUNTIME_PATH + "/template/api/api_query_by_condition.template",
		TemplateApiCreateBatchKey:      app.RUNTIME_PATH + "/template/api/api_create_batch.template",
		TemplateApiCreateKey:           app.RUNTIME_PATH + "/template/api/api_create.template",
		TemplateApiUpdateBatchKey:      app.RUNTIME_PATH + "/template/api/api_update_batch.template",
		TemplateApiUpdateKey:           app.RUNTIME_PATH + "/template/api/api_update.template",
		TemplateApiRemoveKey:           app.RUNTIME_PATH + "/template/api/api_remove.template",
		TemplateApiDeletedKey:          app.RUNTIME_PATH + "/template/api/api_deleted_column.template",

		TemplateVueElementAdminApiKey:              app.RUNTIME_PATH + "/template/vue_element_admin/vue_api.template",
		TemplateVueElementAdminApiDeletedColumnKey: app.RUNTIME_PATH + "/template/vue_element_admin/vue_api_deleted_column.template",
		TemplateVueElementAdminViewKey:             app.RUNTIME_PATH + "/template/vue_element_admin/vue_view.template",
		TemplateVueElementAdminRouterKey:           app.RUNTIME_PATH + "/template/vue_element_admin/vue_router.template",

		TemplateRuoyiVue3ApiKey:              app.RUNTIME_PATH + "/template/ruoyi_vue3/api.js.template",
		TemplateRuoyiVue3ApiDeletedColumnKey: app.RUNTIME_PATH + "/template/ruoyi_vue3/api_deleted_column.template",
		TemplateRuoyiVue3ViewKey:             app.RUNTIME_PATH + "/template/ruoyi_vue3/index.vue.template",
		TemplateRuoyiVue3MenuKey:             app.RUNTIME_PATH + "/template/ruoyi_vue3/menu.sql.template",
	}
)
View Source
var (
	VueElementAdminGen = &VueElementAdminGenType{}
)

Functions

func CamelCase added in v0.0.2

func CamelCase(columnName string) (tagContent string)

change column to camel format

func ConnectDB

func ConnectDB(dsn string) (db *gorm.DB)

func CopyFile

func CopyFile(srcFile string, dstFile string, isReplace bool)

func FileExist

func FileExist(path string) bool

func GenerateApis

func GenerateApis(config *GenConfig, model *DbModel)

func GenerateAutomigrate

func GenerateAutomigrate(config *GenConfig, models []*DbModel)

func GenerateBizCode

func GenerateBizCode(config *GenConfig, model *DbModel)

func GenerateDalCodes

func GenerateDalCodes(conn *gorm.DB, config *GenConfig)

func GenerateDataSources

func GenerateDataSources(config *GenConfig)

func GenerateFolders

func GenerateFolders(conf *GenConfig)

func GetTemplate

func GetTemplate(key string) string

func ReadFile

func ReadFile(file string) string

func StartGen

func StartGen(configFile string)

func StartGenConfig

func StartGenConfig(config *GenConfig)

func WriteFile

func WriteFile(fileName string, content string)

Types

type DbModel

type DbModel struct {
	StructName             string
	TableName              string
	PrivatePropertyName    string
	PrimaryKeyPropertyName string
	PathName               string
	Fields                 []*DbModelFieldAndColumn
}

func (*DbModel) HasDeletedColumn

func (t *DbModel) HasDeletedColumn() bool

type DbModelFieldAndColumn

type DbModelFieldAndColumn struct {
	ModelFieldName                      string
	PrivateModelFieldName               string
	ColumnName                          string
	ModelFieldType                      string
	ColumnType                          string
	IsPrimaryKey                        bool
	IsAutoIncrement                     bool
	IgnoreGenerateRequestModel          bool
	IgnoreGenerateRequestQueryParameter bool
	IgnoreGenerateResponseModel         bool
}

type GenConfig

type GenConfig struct {
	MySql *GenConfigMysql `yaml:"mysql"`
	Gen   *GenConfigGen   `yaml:"gen"`
}

type GenConfigDataSource

type GenConfigDataSource struct {
	DataSourceName string `yaml:"dataSourceName"`
	Dsn            string `yaml:"dsn"`
	Code           string `yaml:"code"`
}

type GenConfigField

type GenConfigField struct {
	ColumnName string `yaml:"columnName"`
	FieldName  string `yaml:"fieldName"`
	FieldType  string `yaml:"fieldType"`
	IsIgnore   bool   `yaml:"isIgnore"`
}

type GenConfigGen

type GenConfigGen struct {
	DmlFolder          string                       `yaml:"dmlFolder"`
	RunDml             *GenConfigRunDml             `yaml:"runDml"`
	GenRuoyiVue3       *GenConfigGenRuoyiVue3       `yaml:"genRuoyiVue3"`
	GenVueElementAdmin *GenConfigGenVueElementAdmin `yaml:"genVueElementAdmin"`
	GenApi             *GenConfigGenApi             `yaml:"genApi"`
	GenBiz             *GenConfigGenBiz             `yaml:"genBiz"`
	GenDataSource      *GenConfigGenDataSource      `yaml:"genDataSource"`
	GenDal             *GenConfigGenDal             `yaml:"genDal"`
	DataSources        []*GenConfigDataSource       `yaml:"dataSources"`
	GenTables          []*GenConfigTable            `yaml:"genTables"`
	OutputRoot         string                       `yaml:"outputRoot"`
	PackageRoot        string                       `yaml:"packageRoot"`
}

type GenConfigGenApi

type GenConfigGenApi struct {
	Enable                               bool     `yaml:"enable"`
	OverWrite                            bool     `yaml:"overWrite"`
	ApiGroup                             string   `yaml:"apiGroup"`
	GenApis                              []string `yaml:"genApis"`
	ExcludeModelFieldsForQueryParameters []string `yaml:"excludeModelFieldsForQueryParameters"`
	ExcludeModelFieldsForResponse        []string `yaml:"excludeModelFieldsForResponse"`
}

type GenConfigGenBiz

type GenConfigGenBiz struct {
	Enable    bool `yaml:"enable"`
	OverWrite bool `yaml:"overWrite"`
}

type GenConfigGenDal

type GenConfigGenDal struct {
	Enable    bool `yaml:"enable"`
	OverWrite bool `yaml:"overWrite"`
}

type GenConfigGenDataSource

type GenConfigGenDataSource struct {
	Enable    bool `yaml:"enable"`
	OverWrite bool `yaml:"overWrite"`
}

type GenConfigGenRuoyiVue3 added in v0.0.3

type GenConfigGenRuoyiVue3 struct {
	Enable      bool                        `yaml:"enable"`
	ProjectRoot string                      `yaml:"projectRoot"`
	TopMenus    []*GenConfigGenRuoyiVueMenu `yaml:"topMenus"`
}

type GenConfigGenRuoyiVueMenu added in v0.0.3

type GenConfigGenRuoyiVueMenu struct {
	Name       string                      `yaml:"name"`
	Path       string                      `yaml:"path"`
	Icon       string                      `yaml:"icon"`
	OrderNum   string                      `yaml:"orderNum"`
	ChildMenus []*GenConfigGenRuoyiVueMenu `yaml:"childMenus"`
}

type GenConfigGenVueElementAdmin added in v0.0.3

type GenConfigGenVueElementAdmin struct {
	Enable      bool   `yaml:"enable"`
	ProjectRoot string `yaml:"projectRoot"`
}

type GenConfigMysql

type GenConfigMysql struct {
	Host     string `yaml:"host"`
	Port     string `yaml:"port"`
	User     string `yaml:"user"`
	Password string `yaml:"password"`
	Database string `yaml:"database"`
	Coon     string `yaml:"conn"`
}

type GenConfigRunDml

type GenConfigRunDml struct {
	Enable bool `yaml:"enable"`
}

type GenConfigTable

type GenConfigTable struct {
	TableName      string            `yaml:"tableName"`
	DataSourceName string            `yaml:"dataSourceName"`
	ModelName      string            `yaml:"modelName"`
	Fields         []*GenConfigField `yaml:"fields"`
	GenApis        []string          `yaml:"genApis"`
	ParentMenu     string            `yaml:"parentMenu"`
	MenuName       string            `yaml:"menuName"`
}

type RuoyiVue3GenType added in v0.0.3

type RuoyiVue3GenType struct {
}

func (*RuoyiVue3GenType) GenApiJs added in v0.0.3

func (v *RuoyiVue3GenType) GenApiJs(config *GenConfig, model *DbModel)

func (*RuoyiVue3GenType) GenChildMenusSql added in v0.0.3

func (v *RuoyiVue3GenType) GenChildMenusSql(config *GenConfig, models []*DbModel)

func (*RuoyiVue3GenType) GenTopMenusSql added in v0.0.3

func (v *RuoyiVue3GenType) GenTopMenusSql(config *GenConfig)

func (*RuoyiVue3GenType) GenVueViews added in v0.0.3

func (v *RuoyiVue3GenType) GenVueViews(config *GenConfig, model *DbModel)

func (*RuoyiVue3GenType) GenerateRuoyiVue3Codes added in v0.0.3

func (v *RuoyiVue3GenType) GenerateRuoyiVue3Codes(config *GenConfig, model *DbModel)

func (*RuoyiVue3GenType) GenerateVueRouter added in v0.0.3

func (v *RuoyiVue3GenType) GenerateVueRouter(config *GenConfig, models []*DbModel)

type VueElementAdminGenType added in v0.0.3

type VueElementAdminGenType struct {
}

func (*VueElementAdminGenType) GenVueClientApis added in v0.0.3

func (v *VueElementAdminGenType) GenVueClientApis(config *GenConfig, model *DbModel)

func (*VueElementAdminGenType) GenVueViews added in v0.0.3

func (v *VueElementAdminGenType) GenVueViews(config *GenConfig, model *DbModel)

func (*VueElementAdminGenType) GenerateVueCodes added in v0.0.3

func (v *VueElementAdminGenType) GenerateVueCodes(config *GenConfig, model *DbModel)

func (*VueElementAdminGenType) GenerateVueRouter added in v0.0.3

func (v *VueElementAdminGenType) GenerateVueRouter(config *GenConfig, models []*DbModel)

Jump to

Keyboard shortcuts

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