Kaynağa Gözat

Merge remote-tracking branch 'origin/master'

yxh 5 yıl önce
ebeveyn
işleme
062aded52d

+ 61 - 13
app/controller/admin/gen_table.go

@@ -5,6 +5,8 @@ import (
 	"gfast/app/service/admin/gen_service"
 	"gfast/app/service/admin/user_service"
 	"gfast/library/response"
+	"strings"
+
 	"github.com/gogf/gf/encoding/gcompress"
 	"github.com/gogf/gf/encoding/gjson"
 	"github.com/gogf/gf/errors/gerror"
@@ -17,7 +19,6 @@ import (
 	"github.com/gogf/gf/util/gconv"
 	"github.com/gogf/gf/util/grand"
 	"github.com/gogf/gf/util/gvalid"
-	"strings"
 )
 
 type Gen struct{}
@@ -222,10 +223,25 @@ func (c *Gen) BatchGenCode(r *ghttp.Request) {
 					response.FailJson(true, r, err.Error())
 				}
 			case "vm/go/" + entity.BusinessName + "_model.go.vm":
+				err = gfile.PutContents(dataFilePath+"/gen/"+dataFileRange+"/go/"+pathMap["gfgenModel"], val)
+				if err != nil {
+					response.FailJson(true, r, err.Error())
+				}
+			case "vm/go/" + entity.BusinessName + "_entity.go.vm":
+				err = gfile.PutContents(dataFilePath+"/gen/"+dataFileRange+"/go/"+pathMap["gfgenEntity"], val)
+				if err != nil {
+					response.FailJson(true, r, err.Error())
+				}
+			case "vm/go/" + entity.BusinessName + ".go.vm":
 				err = gfile.PutContents(dataFilePath+"/gen/"+dataFileRange+"/go/"+pathMap["model"], val)
 				if err != nil {
 					response.FailJson(true, r, err.Error())
 				}
+			case "vm/go/" + entity.BusinessName + "_route.go.vm":
+				err = gfile.PutContents(dataFilePath+"/gen/"+dataFileRange+"/go/路由说明.txt", val)
+				if err != nil {
+					response.FailJson(true, r, err.Error())
+				}
 			case "vm/html/" + entity.BusinessName + "_api.js.vm":
 				err = gfile.PutContents(dataFilePath+"/gen/"+dataFileRange+"/vue/"+pathMap["api"], val)
 				if err != nil {
@@ -259,14 +275,18 @@ func (c *Gen) getPath(entity *gen_table.EntityExtend) g.MapStrStr {
 	controller := "app/controller/" + entity.ModuleName + "/" + entity.ClassName + ".go"
 	service := "app/service/" + entity.ModuleName + "/" + entity.BusinessName + "_service/" + entity.ClassName + ".go"
 	model := "app/model/" + entity.ModuleName + "/" + entity.BusinessName + "/" + entity.ClassName + ".go"
+	gfgenModel := "app/model/" + entity.ModuleName + "/" + entity.BusinessName + "/" + entity.ClassName + "_model.go"
+	gfgenEntity := "app/model/" + entity.ModuleName + "/" + entity.BusinessName + "/" + entity.ClassName + "_entity.go"
 	vue := "views/" + entity.ModuleName + "/" + entity.BusinessName + "/index.vue"
 	api := "api/" + entity.ModuleName + "/" + entity.BusinessName + ".js"
 	return g.MapStrStr{
-		"controller": controller,
-		"service":    service,
-		"model":      model,
-		"vue":        vue,
-		"api":        api,
+		"controller":  controller,
+		"service":     service,
+		"model":       model,
+		"gfgenModel":  gfgenModel,
+		"gfgenEntity": gfgenEntity,
+		"vue":         vue,
+		"api":         api,
 	}
 }
 
@@ -285,8 +305,14 @@ func (c *Gen) genData(tableId int64) (data g.MapStrStr, entity *gen_table.Entity
 	controllerValue := ""
 	serviceKey := "vm/go/" + entity.BusinessName + "_service.go.vm"
 	serviceValue := ""
-	modelKey := "vm/go/" + entity.BusinessName + "_model.go.vm"
+	modelKey := "vm/go/" + entity.BusinessName + ".go.vm"
 	modelValue := ""
+	routeKey := "vm/go/" + entity.BusinessName + "_route.go.vm"
+	routeValue := ""
+	gfgenModelKey := "vm/go/" + entity.BusinessName + "_model.go.vm"
+	gfgenModelValue := ""
+	gfgenEntityKey := "vm/go/" + entity.BusinessName + "_entity.go.vm"
+	gfgenEntityValue := ""
 	apiJsKey := "vm/html/" + entity.BusinessName + "_api.js.vm"
 	apiJsValue := ""
 	vueKey := "vm/html/" + entity.BusinessName + "_vue.js.vm"
@@ -303,7 +329,7 @@ func (c *Gen) genData(tableId int64) (data g.MapStrStr, entity *gen_table.Entity
 	})
 	view.SetConfigWithMap(g.Map{
 		"Paths":      []string{"template"},
-		"Delimiters": []string{"{{", "}}"},
+		"Delimiters": []string{"${", "}"},
 	})
 	//树形菜单选项
 	var options g.Map
@@ -343,12 +369,34 @@ func (c *Gen) genData(tableId int64) (data g.MapStrStr, entity *gen_table.Entity
 		return
 	}
 
+	var tmpRouter string
+	if tmpRouter, err = view.Parse("vm/go/common/route.template", g.Map{"table": entity}); err == nil {
+		routeValue = tmpRouter
+	} else {
+		return
+	}
+	var tmpGfModel string
+	if tmpGfModel, err = view.Parse("vm/go/common/model.template", g.Map{"table": entity}); err == nil {
+		gfgenModelValue = tmpGfModel
+	} else {
+		return
+	}
+	var tmpGfEntity string
+	if tmpGfEntity, err = view.Parse("vm/go/common/entity.template", g.Map{"table": entity}); err == nil {
+		gfgenEntityValue = tmpGfEntity
+	} else {
+		return
+	}
+
 	data = g.MapStrStr{
-		modelKey:      modelValue,
-		serviceKey:    serviceValue,
-		controllerKey: controllerValue,
-		apiJsKey:      apiJsValue,
-		vueKey:        vueValue,
+		routeKey:       routeValue,
+		gfgenModelKey:  gfgenModelValue,
+		gfgenEntityKey: gfgenEntityValue,
+		modelKey:       modelValue,
+		serviceKey:     serviceValue,
+		controllerKey:  controllerValue,
+		apiJsKey:       apiJsValue,
+		vueKey:         vueValue,
 	}
 	return
 }

+ 6 - 3
app/service/admin/gen_service/table.go

@@ -3,6 +3,8 @@ package gen_service
 import (
 	"gfast/app/model/admin/gen_table"
 	"gfast/app/model/admin/gen_table_column"
+	"strings"
+
 	"github.com/gogf/gf/database/gdb"
 	"github.com/gogf/gf/encoding/gjson"
 	"github.com/gogf/gf/errors/gerror"
@@ -11,7 +13,6 @@ import (
 	"github.com/gogf/gf/text/gregex"
 	"github.com/gogf/gf/text/gstr"
 	"github.com/gogf/gf/util/gconv"
-	"strings"
 )
 
 //根据条件分页查询数据
@@ -164,7 +165,7 @@ func InitColumnField(column *gen_table_column.Entity, table *gen_table.Entity) {
 	} else if gen_table_column.IsTimeObject(dataType) {
 		//字段为时间类型
 		column.GoType = "Time"
-		column.HtmlType = "datatime"
+		column.HtmlType = "datetime"
 	} else if gen_table_column.IsNumberObject(dataType) {
 		//字段为数字类型
 		column.HtmlType = "input"
@@ -333,7 +334,9 @@ func ConvertClassName(tableName string) string {
 	if autoRemovePre && tablePrefix != "" {
 		searchList := strings.Split(tablePrefix, ",")
 		for _, str := range searchList {
-			tableName = strings.ReplaceAll(tableName, str, "")
+			if strings.HasPrefix(tableName, str) {
+				tableName = strings.Replace(tableName, str, "", 1) //注意,只替换一次
+			}
 		}
 	}
 	return tableName

+ 2 - 2
data/db.sql

@@ -213,7 +213,7 @@ CREATE TABLE `cms_category` (
   `list_template` varchar(150) DEFAULT NULL COMMENT '列表页模板',
   `content_template` varchar(150) DEFAULT NULL COMMENT '内容页模板',
   PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8mb4 ROW_FORMAT=COMPACT;
+) ENGINE=InnoDB AUTO_INCREMENT=39 DEFAULT CHARSET=utf8mb4;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --
@@ -1203,7 +1203,7 @@ CREATE TABLE `wf_flow_process` (
   `work_sql` longtext,
   `work_msg` longtext,
   PRIMARY KEY (`id`) USING BTREE
-) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=utf8 ROW_FORMAT=COMPACT;
+) ENGINE=InnoDB AUTO_INCREMENT=67 DEFAULT CHARSET=utf8;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --

+ 6 - 0
middleWare/middleware.go

@@ -8,6 +8,7 @@ import (
 	"gfast/app/service/casbin_adapter_service"
 	"gfast/library/response"
 	"gfast/library/service"
+
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/net/ghttp"
 	"github.com/gogf/gf/text/gstr"
@@ -32,6 +33,11 @@ func Auth(r *ghttp.Request) {
 	}
 	//获取登陆用户id
 	adminId := user_service.GetLoginID(r)
+	//glog.Debugf("adminId:%d", adminId)
+	if adminId < 1 {
+		response.FailJson(true, r, "没有访问权限")
+	}
+
 	//获取无需验证权限的用户id
 	for _, v := range service.NotCheckAuthAdminIds {
 		if gconv.Uint64(v) == adminId {

+ 76 - 0
template/vm/go/common/entity.template

@@ -0,0 +1,76 @@
+// ==========================================================================
+// 生成日期:${.table.CreateTime}
+// 生成人:${.table.FunctionAuthor}
+// ==========================================================================
+
+package ${.table.BusinessName}
+
+import (
+	"database/sql"
+
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/os/gtime"
+)
+
+// Entity is the golang structure for table ${.table.TableName}.
+type Entity struct {
+	${range $index, $column := .table.Columns} 
+	${$column.GoField}		${if eq $column.GoType "Time"}*gtime.Time${else}${$column.GoType}${end}	`orm:"${$column.ColumnName}${if eq $column.IsPk "1"},primary${end}" json:"${$column.ColumnName}"`	// ${$column.ColumnComment} ${end} 
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+// Deprecated.
+func (r *Entity) OmitEmpty() *arModel {
+	return Model.Data(r).OmitEmpty()
+}
+
+// Inserts does "INSERT...INTO..." statement for inserting current object into table.
+// Deprecated.
+func (r *Entity) Insert() (result sql.Result, err error) {
+	return Model.Data(r).Insert()
+}
+
+// InsertIgnore does "INSERT IGNORE INTO ..." statement for inserting current object into table.
+// Deprecated.
+func (r *Entity) InsertIgnore() (result sql.Result, err error) {
+	return Model.Data(r).InsertIgnore()
+}
+
+// Replace does "REPLACE...INTO..." statement for inserting current object into table.
+// If there's already another same record in the table (it checks using primary key or unique index),
+// it deletes it and insert this one.
+// Deprecated.
+func (r *Entity) Replace() (result sql.Result, err error) {
+	return Model.Data(r).Replace()
+}
+
+// Save does "INSERT...INTO..." statement for inserting/updating current object into table.
+// It updates the record if there's already another same record in the table
+// (it checks using primary key or unique index).
+// Deprecated.
+func (r *Entity) Save() (result sql.Result, err error) {
+	return Model.Data(r).Save()
+}
+
+// Update does "UPDATE...WHERE..." statement for updating current object from table.
+// It updates the record if there's already another same record in the table
+// (it checks using primary key or unique index).
+// Deprecated.
+func (r *Entity) Update() (result sql.Result, err error) {
+	where, args, err := gdb.GetWhereConditionOfStruct(r)
+	if err != nil {
+		return nil, err
+	}
+	return Model.Data(r).Where(where, args).Update()
+}
+
+// Delete does "DELETE FROM...WHERE..." statement for deleting current object from table.
+// Deprecated.
+func (r *Entity) Delete() (result sql.Result, err error) {
+	where, args, err := gdb.GetWhereConditionOfStruct(r)
+	if err != nil {
+		return nil, err
+	}
+	return Model.Where(where, args).Delete()
+}

+ 304 - 0
template/vm/go/common/model.template

@@ -0,0 +1,304 @@
+// ==========================================================================
+// 生成日期:${.table.CreateTime}
+// 生成人:${.table.FunctionAuthor}
+// ==========================================================================
+
+package ${.table.BusinessName}
+
+import (
+	"context"
+	"database/sql"
+	"github.com/gogf/gf/database/gdb"
+	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/frame/gmvc"
+	"time"
+)
+
+// arModel is a active record design model for table ${.table.TableName} operations.
+type arModel struct {
+	gmvc.M
+}
+
+var (
+	// Table is the table name of ${.table.TableName}.
+	Table = "${.table.TableName}"
+	// Model is the model object of ${.table.TableName}.
+	Model = &arModel{g.DB("default").Model(Table).Safe()}
+	// Columns defines and stores column names for table ${.table.TableName}.
+	Columns = struct {
+	${range $index, $column := .table.Columns}
+		${$column.GoField}		string // ${$column.ColumnComment} ${end}
+	}{
+	${range $index, $column := .table.Columns}
+		${$column.GoField}:		"${$column.ColumnName}", ${end}
+	}
+)
+
+// Ctx is a chaining function, which creates and returns a new DB that is a shallow copy
+// of current DB object and with given context in it.
+// Note that this returned DB object can be used only once, so do not assign it to
+// a global or package variable for long using.
+func (m *arModel) Ctx(ctx context.Context) *arModel {
+	return &arModel{m.M.Ctx(ctx)}
+}
+
+// As sets an alias name for current table.
+func (m *arModel) As(as string) *arModel {
+	return &arModel{m.M.As(as)}
+}
+
+// TX sets the transaction for current operation.
+func (m *arModel) TX(tx *gdb.TX) *arModel {
+	return &arModel{m.M.TX(tx)}
+}
+
+// Master marks the following operation on master node.
+func (m *arModel) Master() *arModel {
+	return &arModel{m.M.Master()}
+}
+
+// Slave marks the following operation on slave node.
+// Note that it makes sense only if there's any slave node configured.
+func (m *arModel) Slave() *arModel {
+	return &arModel{m.M.Slave()}
+}
+
+// LeftJoin does "LEFT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").LeftJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").LeftJoin("user_detail", "ud", "ud.uid=u.uid")
+func (m *arModel) LeftJoin(table ...string) *arModel {
+	return &arModel{m.M.LeftJoin(table ...)}
+}
+
+// RightJoin does "RIGHT JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").RightJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").RightJoin("user_detail", "ud", "ud.uid=u.uid")
+func (m *arModel) RightJoin(table ...string) *arModel {
+	return &arModel{m.M.RightJoin(table ...)}
+}
+
+// InnerJoin does "INNER JOIN ... ON ..." statement on the model.
+// The parameter <table> can be joined table and its joined condition,
+// and also with its alias name, like:
+// Table("user").InnerJoin("user_detail", "user_detail.uid=user.uid")
+// Table("user", "u").InnerJoin("user_detail", "ud", "ud.uid=u.uid")
+func (m *arModel) InnerJoin(table ...string) *arModel {
+	return &arModel{m.M.InnerJoin(table ...)}
+}
+
+// Fields sets the operation fields of the model, multiple fields joined using char ','.
+func (m *arModel) Fields(fieldNamesOrMapStruct ...interface{}) *arModel {
+	return &arModel{m.M.Fields(fieldNamesOrMapStruct...)}
+}
+
+// FieldsEx sets the excluded operation fields of the model, multiple fields joined using char ','.
+func (m *arModel) FieldsEx(fieldNamesOrMapStruct ...interface{}) *arModel {
+	return &arModel{m.M.FieldsEx(fieldNamesOrMapStruct...)}
+}
+
+// Option sets the extra operation option for the model.
+func (m *arModel) Option(option int) *arModel {
+	return &arModel{m.M.Option(option)}
+}
+
+// OmitEmpty sets OPTION_OMITEMPTY option for the model, which automatically filers
+// the data and where attributes for empty values.
+func (m *arModel) OmitEmpty() *arModel {
+	return &arModel{m.M.OmitEmpty()}
+}
+
+// Filter marks filtering the fields which does not exist in the fields of the operated table.
+func (m *arModel) Filter() *arModel {
+	return &arModel{m.M.Filter()}
+}
+
+// Where sets the condition statement for the model. The parameter <where> can be type of
+// string/map/gmap/slice/struct/*struct, etc. Note that, if it's called more than one times,
+// multiple conditions will be joined into where statement using "AND".
+// Eg:
+// Where("uid=10000")
+// Where("uid", 10000)
+// Where("money>? AND name like ?", 99999, "vip_%")
+// Where("uid", 1).Where("name", "john")
+// Where("status IN (?)", g.Slice{1,2,3})
+// Where("age IN(?,?)", 18, 50)
+// Where(User{ Id : 1, UserName : "john"})
+func (m *arModel) Where(where interface{}, args ...interface{}) *arModel {
+	return &arModel{m.M.Where(where, args...)}
+}
+
+// WherePri does the same logic as Model.Where except that if the parameter <where>
+// is a single condition like int/string/float/slice, it treats the condition as the primary
+// key value. That is, if primary key is "id" and given <where> parameter as "123", the
+// WherePri function treats the condition as "id=123", but Model.Where treats the condition
+// as string "123".
+func (m *arModel) WherePri(where interface{}, args ...interface{}) *arModel {
+	return &arModel{m.M.WherePri(where, args...)}
+}
+
+// And adds "AND" condition to the where statement.
+func (m *arModel) And(where interface{}, args ...interface{}) *arModel {
+	return &arModel{m.M.And(where, args...)}
+}
+
+// Or adds "OR" condition to the where statement.
+func (m *arModel) Or(where interface{}, args ...interface{}) *arModel {
+	return &arModel{m.M.Or(where, args...)}
+}
+
+// Group sets the "GROUP BY" statement for the model.
+func (m *arModel) Group(groupBy string) *arModel {
+	return &arModel{m.M.Group(groupBy)}
+}
+
+// Order sets the "ORDER BY" statement for the model.
+func (m *arModel) Order(orderBy ...string) *arModel {
+	return &arModel{m.M.Order(orderBy...)}
+}
+
+// Limit sets the "LIMIT" statement for the model.
+// The parameter <limit> can be either one or two number, if passed two number is passed,
+// it then sets "LIMIT limit[0],limit[1]" statement for the model, or else it sets "LIMIT limit[0]"
+// statement.
+func (m *arModel) Limit(limit ...int) *arModel {
+	return &arModel{m.M.Limit(limit...)}
+}
+
+// Offset sets the "OFFSET" statement for the model.
+// It only makes sense for some databases like SQLServer, PostgreSQL, etc.
+func (m *arModel) Offset(offset int) *arModel {
+	return &arModel{m.M.Offset(offset)}
+}
+
+// Page sets the paging number for the model.
+// The parameter <page> is started from 1 for paging.
+// Note that, it differs that the Limit function start from 0 for "LIMIT" statement.
+func (m *arModel) Page(page, limit int) *arModel {
+	return &arModel{m.M.Page(page, limit)}
+}
+
+// Batch sets the batch operation number for the model.
+func (m *arModel) Batch(batch int) *arModel {
+	return &arModel{m.M.Batch(batch)}
+}
+
+// Cache sets the cache feature for the model. It caches the result of the sql, which means
+// if there's another same sql request, it just reads and returns the result from cache, it
+// but not committed and executed into the database.
+//
+// If the parameter <duration> < 0, which means it clear the cache with given <name>.
+// If the parameter <duration> = 0, which means it never expires.
+// If the parameter <duration> > 0, which means it expires after <duration>.
+//
+// The optional parameter <name> is used to bind a name to the cache, which means you can later
+// control the cache like changing the <duration> or clearing the cache with specified <name>.
+//
+// Note that, the cache feature is disabled if the model is operating on a transaction.
+func (m *arModel) Cache(duration time.Duration, name ...string) *arModel {
+	return &arModel{m.M.Cache(duration, name...)}
+}
+
+// Data sets the operation data for the model.
+// The parameter <data> can be type of string/map/gmap/slice/struct/*struct, etc.
+// Eg:
+// Data("uid=10000")
+// Data("uid", 10000)
+// Data(g.Map{"uid": 10000, "name":"john"})
+// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"})
+func (m *arModel) Data(data ...interface{}) *arModel {
+	return &arModel{m.M.Data(data...)}
+}
+
+// All does "SELECT FROM ..." statement for the model.
+// It retrieves the records from table and returns the result as []*Entity.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+func (m *arModel) All(where ...interface{}) ([]*Entity, error) {
+	all, err := m.M.All(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*Entity
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// One retrieves one record from table and returns the result as *Entity.
+// It returns nil if there's no record retrieved with the given conditions from table.
+//
+// The optional parameter <where> is the same as the parameter of Model.Where function,
+// see Model.Where.
+func (m *arModel) One(where ...interface{}) (*Entity, error) {
+	one, err := m.M.One(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *Entity
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindOne retrieves and returns a single Record by Model.WherePri and Model.One.
+// Also see Model.WherePri and Model.One.
+func (m *arModel) FindOne(where ...interface{}) (*Entity, error) {
+	one, err := m.M.FindOne(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entity *Entity
+	if err = one.Struct(&entity); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entity, nil
+}
+
+// FindAll retrieves and returns Result by by Model.WherePri and Model.All.
+// Also see Model.WherePri and Model.All.
+func (m *arModel) FindAll(where ...interface{}) ([]*Entity, error) {
+	all, err := m.M.FindAll(where...)
+	if err != nil {
+		return nil, err
+	}
+	var entities []*Entity
+	if err = all.Structs(&entities); err != nil && err != sql.ErrNoRows {
+		return nil, err
+	}
+	return entities, nil
+}
+
+// Chunk iterates the table with given size and callback function.
+func (m *arModel) Chunk(limit int, callback func(entities []*Entity, err error) bool) {
+	m.M.Chunk(limit, func(result gdb.Result, err error) bool {
+		var entities []*Entity
+		err = result.Structs(&entities)
+		if err == sql.ErrNoRows {
+			return false
+		}
+		return callback(entities, err)
+	})
+}
+
+// LockUpdate sets the lock for update for current operation.
+func (m *arModel) LockUpdate() *arModel {
+	return &arModel{m.M.LockUpdate()}
+}
+
+// LockShared sets the lock in share mode for current operation.
+func (m *arModel) LockShared() *arModel {
+	return &arModel{m.M.LockShared()}
+}
+
+// Unscoped enables/disables the soft deleting feature.
+func (m *arModel) Unscoped() *arModel {
+	return &arModel{m.M.Unscoped()}
+}

+ 19 - 0
template/vm/go/common/route.template

@@ -0,0 +1,19 @@
+// ==========================================================================
+// 生成日期:${.table.CreateTime}
+// 生成人:${.table.FunctionAuthor}
+// ==========================================================================
+
+
+// 请手工复制以下内容,到 /route/routerAdmin.go 文件的合适位置
+
+
+import "${.table.PackageName}/app/controller/${.table.ModuleName}"
+
+
+group.Group("/${.table.ModuleName}", func(group *ghttp.RouterGroup) {
+	//${.table.FunctionName}
+	group.ALL("/${.table.BusinessName}", new(${.table.ModuleName}.${.table.BusinessName|UcFirst}))
+})
+
+
+

+ 49 - 30
template/vm/go/crud/controller.template

@@ -1,31 +1,37 @@
 // ==========================================================================
-// 生成日期:{{.table.CreateTime}}
-// 生成人:{{.table.FunctionAuthor}}
+// 生成日期:${.table.CreateTime}
+// 生成人:${.table.FunctionAuthor}
 // ==========================================================================
-package {{.table.ModuleName}}
+package ${.table.ModuleName}
 
 import (
+	${.table.BusinessName}Model "${.table.PackageName}/app/model/${.table.ModuleName}/${.table.BusinessName}"
+	${.table.BusinessName}Service "${.table.PackageName}/app/service/${.table.ModuleName}/${.table.BusinessName}_service"
+	"${.table.PackageName}/library/response"
+
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/net/ghttp"
-	{{.table.BusinessName}}Model "{{.table.PackageName}}/app/model/{{.table.ModuleName}}/{{.table.BusinessName}}"
-	{{.table.BusinessName}}Service "{{.table.PackageName}}/app/service/{{.table.ModuleName}}/{{.table.BusinessName}}_service"
-	"{{.table.PackageName}}/library/response"
+	"github.com/gogf/gf/util/gvalid"
 )
 
 //控制器
-type {{.table.BusinessName|UcFirst}} struct{}
+type ${.table.BusinessName|UcFirst} struct{}
 
 
-//列表页
-func (c *{{.table.BusinessName|UcFirst}}) List(r *ghttp.Request) {
+// List 列表页
+func (c *${.table.BusinessName|UcFirst}) List(r *ghttp.Request) {
 	// 定义一个结构体存储请求参数
-	var req *{{.table.BusinessName}}Model.SelectPageReq
+	var req *${.table.BusinessName}Model.SelectPageReq
 	// 获取参数
 	err := r.Parse(&req)
 	if err != nil {
-		response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+		if _,ok := err.(*gvalid.Error); ok {
+			response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+		} else {
+			response.FailJson(true, r, err.Error())
+		}
 	}
-	total, page, list, err := {{.table.BusinessName}}Service.SelectListByPage(req)
+	total, page, list, err := ${.table.BusinessName}Service.SelectListByPage(req)
 	if err != nil {
 		response.FailJson(true, r, err.Error())
 	}
@@ -38,17 +44,21 @@ func (c *{{.table.BusinessName|UcFirst}}) List(r *ghttp.Request) {
 }
 
 
-// 新增
-func (c *{{.table.BusinessName|UcFirst}}) Add(r *ghttp.Request) {
+// Add 新增
+func (c *${.table.BusinessName|UcFirst}) Add(r *ghttp.Request) {
 	if r.Method == "POST" {
-		var req *{{.table.BusinessName}}Model.AddReq
+		var req *${.table.BusinessName}Model.AddReq
 		// 通过Parse方法解析获取参数
 		err := r.Parse(&req)
 		if err != nil {
-			response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+			if _,ok := err.(*gvalid.Error); ok {
+				response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+			} else {
+				response.FailJson(true, r, err.Error())
+			}
 		}
 		// 调用service中的添加函数添加
-		err = {{.table.BusinessName}}Service.AddSave(req)
+		err = ${.table.BusinessName}Service.AddSave(req)
 		if err != nil {
 			response.FailJson(true, r, err.Error())
 		}
@@ -57,25 +67,30 @@ func (c *{{.table.BusinessName|UcFirst}}) Add(r *ghttp.Request) {
 }
 
 
-// 修改
-func (c *{{.table.BusinessName|UcFirst}}) Edit(r *ghttp.Request) {
+// Edit 修改
+func (c *${.table.BusinessName|UcFirst}) Edit(r *ghttp.Request) {
 	// 如果是post提交的请求就执行修改操作
 	if r.Method == "POST" {
-		var editReq *{{.table.BusinessName}}Model.EditReq
+		var editReq *${.table.BusinessName}Model.EditReq
 		// 通过Parse方法解析获取参数
 		err := r.Parse(&editReq)
 		if err != nil {
-			response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+			if _,ok := err.(*gvalid.Error); ok {
+				response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+			} else {
+				response.FailJson(true, r, err.Error())
+			}
 		}
-		err = {{.table.BusinessName}}Service.EditSave(editReq)
+		err = ${.table.BusinessName}Service.EditSave(editReq)
 		if err != nil {
 		response.FailJson(true, r, err.Error())
 		}
 		response.SusJson(true, r, "修改参数成功")
 	}
 	// 不是post提交的请求就到修改页面后查询出要修改的记录
-	id := r.GetInt("id")
-	params, err := {{.table.BusinessName}}Service.GetByID(int64(id))
+	id := r.Get${.table.PkColumn.GoType|UcFirst}("id")
+	params, err := ${.table.BusinessName}Service.GetByID(id)
+
 	if err != nil {
 		response.FailJson(true, r, err.Error())
 	}
@@ -83,16 +98,20 @@ func (c *{{.table.BusinessName|UcFirst}}) Edit(r *ghttp.Request) {
 }
 
 
-// 删除
-func (c *{{.table.BusinessName|UcFirst}}) Delete(r *ghttp.Request) {
-	var req *{{.table.BusinessName}}Model.RemoveReq
+// Delete 删除
+func (c *${.table.BusinessName|UcFirst}) Delete(r *ghttp.Request) {
+	var req *${.table.BusinessName}Model.RemoveReq
 	//获取参数
 	if err := r.Parse(&req); err != nil {
-		response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+		if _,ok := err.(*gvalid.Error); ok {
+			response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+		} else {
+			response.FailJson(true, r, err.Error())
+		}
 	}
-	err := {{.table.BusinessName}}Service.DeleteByIds(req.Ids)
+	err := ${.table.BusinessName}Service.DeleteByIds(req.Ids)
 	if err != nil {
 	response.FailJson(true, r, "删除失败")
 	}
 	response.SusJson(true, r, "删除成功")
-}
+}

+ 63 - 50
template/vm/go/crud/model.template

@@ -1,42 +1,43 @@
 // ==========================================================================
-// 生成日期:{{.table.CreateTime}}
-// 生成人:{{.table.FunctionAuthor}}
+// 生成日期:${.table.CreateTime}
+// 生成人:${.table.FunctionAuthor}
 // ==========================================================================
 
-package {{.table.BusinessName}}
+package ${.table.BusinessName}
 
 import (
 	"github.com/gogf/gf/errors/gerror"
 	"github.com/gogf/gf/frame/g"
+	"github.com/gogf/gf/os/gtime"
 )
 
-{{$pk:=""}}
-{{$pkGoField:=""}}
-{{range $index, $column := .table.Columns}} {{if eq $column.IsPk "1"}}
-    {{$pk = $column.ColumnName}}
-    {{$pkGoField = $column.GoField}}
-{{end}}{{end}}
+${$pk:=""}
+${$pkGoField:=""}
+${range $index, $column := .table.Columns} ${if eq $column.IsPk "1"}
+    ${$pk = $column.ColumnName}
+    ${$pkGoField = $column.GoField}
+${end}${end}
 
 // AddReq 用于存储新增请求的请求参数
 type AddReq struct {
-	{{range $index, $column := .table.Columns}}
-	{{if and (eq $column.IsInsert "1") (ne $column.IsPk "1")}} {{$column.GoField}}  {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}}   `p:"{{$column.HtmlField}}" {{if eq $column.IsRequired "1"}}v:"required#{{$column.ColumnComment}}不能为空"{{end}}` {{end}} {{end}}
+	${range $index, $column := .table.Columns}
+	${if and (eq $column.IsInsert "1") (ne $column.IsPk "1")} ${$column.GoField}  ${if eq $column.GoType "Time"}*gtime.Time${else}${$column.GoType}${end}   `p:"${$column.ColumnName}" ${if eq $column.IsRequired "1"}v:"required#${$column.ColumnComment}不能为空"${end}` ${end} ${end}
 }
 
 // EditReq 用于存储修改请求参数
 type EditReq struct {
-	{{.table.PkColumn.GoField}}    {{.table.PkColumn.GoType}}  `p:"{{.table.PkColumn.HtmlField}}" v:"required#主键ID不能为空"` {{range $index, $column := .table.Columns}} {{if eq $column.IsEdit "1"}}
-	{{$column.GoField}}  {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}} `p:"{{$column.HtmlField}}" {{if eq $column.IsRequired "1"}}v:"required#{{$column.ColumnComment}}不能为空"{{end}}` {{end}} {{end}}
+	${.table.PkColumn.GoField}    ${.table.PkColumn.GoType}  `p:"${.table.PkColumn.ColumnName}" v:"required#主键ID不能为空"` ${range $index, $column := .table.Columns} ${if eq $column.IsEdit "1"}
+	${$column.GoField}  ${if eq $column.GoType "Time"}*gtime.Time${else}${$column.GoType}${end} `p:"${$column.ColumnName}" ${if eq $column.IsRequired "1"}v:"required#${$column.ColumnComment}不能为空"${end}` ${end} ${end}
 }
 
 // RemoveReq 用于存储删除请求参数
 type RemoveReq struct {
-	Ids []int `p:"ids"` //删除id
+	Ids [] ${.table.PkColumn.GoType}  `p:"ids"` //删除id
 }
 
 // SelectPageReq 用于存储分页查询的请求参数
-type SelectPageReq struct { {{range $index, $column := .table.Columns}} {{if eq $column.IsQuery "1"}}
-	{{$column.GoField}}  {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}} `p:"{{$column.HtmlField}}"` //{{$column.ColumnComment}} {{end}} {{end}}
+type SelectPageReq struct { ${range $index, $column := .table.Columns} ${if eq $column.IsQuery "1"}
+	${$column.GoField}  ${if eq $column.GoType "Time"}*gtime.Time${else}${$column.GoType}${end} `p:"${$column.ColumnName}"` //${$column.ColumnComment} ${end} ${end}
 	BeginTime  string `p:"beginTime"`  //开始时间
 	EndTime    string `p:"endTime"`    //结束时间
 	PageNum    int    `p:"pageNum"`    //当前页码
@@ -44,7 +45,7 @@ type SelectPageReq struct { {{range $index, $column := .table.Columns}} {{if eq
 }
 
 // GetByID 根据ID查询记录
-func GetByID(id int64) (*Entity, error) {
+func GetByID(id ${.table.PkColumn.GoType}) (*Entity, error) {
 	entity, err := Model.FindOne(id)
 	if err != nil {
 		g.Log().Error(err)
@@ -59,8 +60,8 @@ func GetByID(id int64) (*Entity, error) {
 // AddSave 添加
 func AddSave(req *AddReq) error {
 	entity:= new(Entity)
-	{{range $index, $column := .table.Columns}} {{if eq $column.IsInsert "1"}}
-	entity.{{$column.GoField}} = req.{{$column.GoField}}{{end}} {{end}}
+	${range $index, $column := .table.Columns} ${if and (eq $column.IsInsert "1") (ne $column.IsPk "1")}
+	entity.${$column.GoField} = req.${$column.GoField}${end} ${end}
 
 	result, err := Model.Save(entity)
 	if err != nil {
@@ -74,8 +75,8 @@ func AddSave(req *AddReq) error {
 }
 
 // DeleteByIds 删除
-func DeleteByIds(Ids []int) error {
-	_, err := Model.Delete("{{.table.PkColumn.ColumnName}} in(?)", Ids)
+func DeleteByIds(Ids [] ${.table.PkColumn.GoType}) error {
+	_, err := Model.Delete("${.table.PkColumn.ColumnName} in(?)", Ids)
 	if err != nil {
 		g.Log().Error(err)
 		return gerror.New("删除失败")
@@ -86,14 +87,14 @@ func DeleteByIds(Ids []int) error {
 // EditSave 根据ID来修改信息
 func EditSave(req *EditReq) error {
 	// 先根据ID来查询要修改的记录
-	entity, err := GetByID(req.{{$pkGoField}})
+	entity, err := GetByID(req.${$pkGoField})
 	if err != nil {
 		return err
 	}
 
 	// 修改实体
-	{{range $index, $column := .table.Columns}} {{if eq $column.IsEdit "1"}}
-	entity.{{$column.GoField}} = req.{{$column.GoField}}{{end}} {{end}}
+	${range $index, $column := .table.Columns} ${if eq $column.IsEdit "1"}
+	entity.${$column.GoField} = req.${$column.GoField}${end} ${end}
 	_, err = Model.Save(entity)
 	if err != nil {
 		g.Log().Error(err)
@@ -103,21 +104,33 @@ func EditSave(req *EditReq) error {
 }
 
 // SelectListByPage 分页查询,返回值total总记录数,page当前页
-func SelectListByPage(req *SelectPageReq) (total int, page int64, list []*Entity, err error) {
+func SelectListByPage(req *SelectPageReq) (total int, page int, list []*Entity, err error) {
 	model := Model
 	if req != nil {
-		{{range $index, $column := .table.Columns}} {{if eq $column.IsQuery "1"}}
-		{{if eq $column.QueryType "LIKE"}}
-			if req.{{$column.GoField}} != "" {
-				model = model.Where("{{$column.ColumnName}} like ?", "%"+req.{{$column.GoField}}+"%")
-			} {{else if eq $column.QueryType "EQ"}} {{if eq $column.GoType "string"}}
-			if req.{{$column.GoField}} != "" {
-				model = model.Where("{{$column.ColumnName}} = ?", req.{{$column.GoField}})
-			} {{else if eq $column.GoType "int" "int64"}}
-			if req.{{$column.GoField}} != 0 {
-				model = model.Where("{{$column.ColumnName}} = ?", req.{{$column.GoField}})
-			}
-		{{end}} {{end}} {{end}} {{end}}
+${range $index, $column := .table.Columns} ${if eq $column.IsQuery "1"}
+	${if eq $column.QueryType "LIKE"}
+		if req.${$column.GoField} != "" {
+			model = model.Where("${$column.ColumnName} like ?", "%"+req.${$column.GoField}+"%")
+		} ${end}
+	${if eq $column.QueryType "EQ"} ${if eq $column.GoType "string"}
+		if req.${$column.GoField} != "" {
+			model = model.Where("${$column.ColumnName} = ?", req.${$column.GoField})
+		} 
+	${else if eq $column.GoType "Time"}
+		if req.${$column.GoField} != nil {
+			model = model.Where("${$column.ColumnName} = ?", req.${$column.GoField})
+		}
+	${else if or (eq $column.GoType "int") (eq $column.GoType "int64") (eq $column.GoType "uint") (eq $column.GoType "uint64") }
+		if req.${$column.GoField} != 0 {
+			model = model.Where("${$column.ColumnName} = ?", req.${$column.GoField})
+		}
+	${end} ${end} 
+	${if and (eq $column.QueryType "BETWEEN") (eq $column.ColumnType "datetime") }
+		if req.${$column.GoField} != nil {
+			model = model.Where("${$column.ColumnName} >= ? AND ${$column.ColumnName} < ?", req.${$column.GoField}, req.${$column.GoField}.Add(gtime.D))
+		}
+	${end}
+${end} ${end}
 	}
 	// 查询总记录数(总行数)
 	total, err = model.Count()
@@ -134,7 +147,7 @@ func SelectListByPage(req *SelectPageReq) (total int, page int64, list []*Entity
 		req.PageSize = 10
 	}
 	// 分页排序查询
-	list, err = model.Page(int(page), int(req.PageSize)).Order("{{$pk}} asc").All()
+	list, err = model.Page(int(page), int(req.PageSize)).Order("${$pk} desc").All()
 	if err != nil {
 		g.Log().Error(err)
 		err = gerror.New("分页查询失败")
@@ -149,21 +162,21 @@ func SelectListByPage(req *SelectPageReq) (total int, page int64, list []*Entity
 func SelectListAll(req *SelectPageReq) (list []*Entity, err error) {
 	model := Model
 	if req != nil {
-	{{range $index, $column := .table.Columns}} {{if eq $column.IsQuery "1"}}
-		{{if eq $column.QueryType "LIKE"}}
-			if req.{{$column.GoField}} != "" {
-			model.Where("{{$column.ColumnName}} like ?", "%"+req.{{$column.GoField}}+"%")
-			} {{else if eq $column.QueryType "EQ"}} {{if eq $column.GoType "string"}}
-			if req.{{$column.GoField}} != "" {
-			model.Where("{{$column.ColumnName}} = ?", req.{{$column.GoField}})
-			} {{else if eq $column.GoType "int" "int64"}}
-			if req.{{$column.GoField}} != 0 {
-			model.Where("{{$column.ColumnName}} = ?", req.{{$column.GoField}})
+	${range $index, $column := .table.Columns} ${if eq $column.IsQuery "1"}
+		${if eq $column.QueryType "LIKE"}
+			if req.${$column.GoField} != "" {
+			model.Where("${$column.ColumnName} like ?", "%"+req.${$column.GoField}+"%")
+			} ${else if eq $column.QueryType "EQ"} ${if eq $column.GoType "string"}
+			if req.${$column.GoField} != "" {
+			model.Where("${$column.ColumnName} = ?", req.${$column.GoField})
+			} ${else if eq $column.GoType "int" "int64"}
+			if req.${$column.GoField} != 0 {
+			model.Where("${$column.ColumnName} = ?", req.${$column.GoField})
 			}
-		{{end}} {{end}} {{end}} {{end}}
+		${end} ${end} ${end} ${end}
 	}
 	// 查询
-	list, err = model.Order("{{$pk}} asc").All()
+	list, err = model.Order("${$pk} desc").All()
 	if err != nil {
 		g.Log().Error(err)
 		err = gerror.New("查询失败")

+ 19 - 19
template/vm/go/crud/service.template

@@ -1,35 +1,35 @@
 // ==========================================================================
-// 生成日期:{{.table.CreateTime}}
-// 生成人:{{.table.FunctionAuthor}}
+// 生成日期:${.table.CreateTime}
+// 生成人:${.table.FunctionAuthor}
 // ==========================================================================
-package {{.table.BusinessName}}_service
+package ${.table.BusinessName}_service
 
 import (
-	{{.table.BusinessName}}Model "{{.table.PackageName}}/app/model/{{.table.ModuleName}}/{{.table.BusinessName}}"
+	${.table.BusinessName}Model "${.table.PackageName}/app/model/${.table.ModuleName}/${.table.BusinessName}"
 )
 
 
-// 添加
-func AddSave(req *{{.table.BusinessName}}Model.AddReq) error {
-	return {{.table.BusinessName}}Model.AddSave(req)
+// AddSave 添加
+func AddSave(req *${.table.BusinessName}Model.AddReq) error {
+	return ${.table.BusinessName}Model.AddSave(req)
 }
 
-// 删除
-func DeleteByIds(Ids []int) error {
-	return {{.table.BusinessName}}Model.DeleteByIds(Ids)
+// DeleteByIds 删除
+func DeleteByIds(Ids [] ${.table.PkColumn.GoType}) error {
+	return ${.table.BusinessName}Model.DeleteByIds(Ids)
 }
 
-//修改
-func EditSave(editReq *{{.table.BusinessName}}Model.EditReq) error {
-	return {{.table.BusinessName}}Model.EditSave(editReq)
+// EditSave 修改
+func EditSave(editReq *${.table.BusinessName}Model.EditReq) error {
+	return ${.table.BusinessName}Model.EditSave(editReq)
 }
 
-// 根据ID查询
-func GetByID(id int64) (*{{.table.BusinessName}}Model.Entity, error) {
-	return {{.table.BusinessName}}Model.GetByID(id)
+// GetByID 根据ID查询
+func GetByID(id ${.table.PkColumn.GoType}) (*${.table.BusinessName}Model.Entity, error) {
+	return ${.table.BusinessName}Model.GetByID(id)
 }
 
-// 分页查询
-func SelectListByPage(req *{{.table.BusinessName}}Model.SelectPageReq) (total int, page int64, list []*{{.table.BusinessName}}Model.Entity, err error) {
-	return {{.table.BusinessName}}Model.SelectListByPage(req)
+// SelectListByPage 分页查询
+func SelectListByPage(req *${.table.BusinessName}Model.SelectPageReq) (total int, page int, list []*${.table.BusinessName}Model.Entity, err error) {
+	return ${.table.BusinessName}Model.SelectListByPage(req)
 }

+ 51 - 35
template/vm/go/tree/controller.template

@@ -1,33 +1,37 @@
 // ==========================================================================
-// 生成日期:{{.table.CreateTime}}
-// 生成人:{{.table.FunctionAuthor}}
+// 生成日期:${.table.CreateTime}
+// 生成人:${.table.FunctionAuthor}
 // ==========================================================================
-package {{.table.ModuleName}}
+package ${.table.ModuleName}
 
 import (
-    "{{.table.PackageName}}/app/service/cache_service"
+    "${.table.PackageName}/app/service/cache_service"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/net/ghttp"
-	{{.table.BusinessName}}Model "{{.table.PackageName}}/app/model/{{.table.ModuleName}}/{{.table.BusinessName}}"
-	{{.table.BusinessName}}Service "{{.table.PackageName}}/app/service/{{.table.ModuleName}}/{{.table.BusinessName}}_service"
-	"{{.table.PackageName}}/library/response"
+	${.table.BusinessName}Model "${.table.PackageName}/app/model/${.table.ModuleName}/${.table.BusinessName}"
+	${.table.BusinessName}Service "${.table.PackageName}/app/service/${.table.ModuleName}/${.table.BusinessName}_service"
+	"${.table.PackageName}/library/response"
     "github.com/gogf/gf/util/gvalid"
 )
 
 //控制器
-type {{.table.BusinessName|UcFirst}} struct{}
+type ${.table.BusinessName|UcFirst} struct{}
 
 
-//列表页
-func (c *{{.table.BusinessName|UcFirst}}) List(r *ghttp.Request) {
+// List 列表页
+func (c *${.table.BusinessName|UcFirst}) List(r *ghttp.Request) {
 	// 定义一个结构体存储请求参数
-	var req *{{.table.BusinessName}}Model.ReqSearchList
+	var req *${.table.BusinessName}Model.ReqSearchList
 	// 获取参数
 	err := r.Parse(&req)
 	if err != nil {
-		response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+		if _,ok := err.(*gvalid.Error); ok {
+			response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+		} else {
+			response.FailJson(true, r, err.Error())
+		}
 	}
-	list, err := {{.table.BusinessName}}Service.GetListSearch(req)
+	list, err := ${.table.BusinessName}Service.GetListSearch(req)
 	if err != nil {
 		response.FailJson(true, r, err.Error())
 	}
@@ -38,25 +42,29 @@ func (c *{{.table.BusinessName|UcFirst}}) List(r *ghttp.Request) {
 }
 
 
-// 新增
-func (c *{{.table.BusinessName|UcFirst}}) Add(r *ghttp.Request) {
+// Add 新增
+func (c *${.table.BusinessName|UcFirst}) Add(r *ghttp.Request) {
 	if r.Method == "POST" {
-		var req *{{.table.BusinessName}}Model.ReqAdd
+		var req *${.table.BusinessName}Model.ReqAdd
 		// 通过Parse方法解析获取参数
 		err := r.Parse(&req)
 		if err != nil {
-			response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+			if _,ok := err.(*gvalid.Error); ok {
+				response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+			} else {
+				response.FailJson(true, r, err.Error())
+			}
 		}
 		// 调用service中的添加函数添加
-		err = {{.table.BusinessName}}Service.AddSave(req)
+		err = ${.table.BusinessName}Service.AddSave(req)
 		if err != nil {
 			response.FailJson(true, r, err.Error())
 		}
-		cache_service.New().RemoveByTag("{{.table.ModuleName}}_{{.table.BusinessName}}_tag")
+		cache_service.New().RemoveByTag("${.table.ModuleName}_${.table.BusinessName}_tag")
 		response.SusJson(true, r, "添加成功")
 	}
 	//获取上级分类
-    cates, err := {{.table.BusinessName}}Service.GetList()
+    cates, err := ${.table.BusinessName}Service.GetList()
     if err != nil {
         response.FailJson(true, r, err.Error())
     }
@@ -66,32 +74,36 @@ func (c *{{.table.BusinessName|UcFirst}}) Add(r *ghttp.Request) {
 }
 
 
-// 修改
-func (c *{{.table.BusinessName|UcFirst}}) Edit(r *ghttp.Request) {
+// Edit 修改
+func (c *${.table.BusinessName|UcFirst}) Edit(r *ghttp.Request) {
 	// 如果是post提交的请求就执行修改操作
 	if r.Method == "POST" {
-		var editReq *{{.table.BusinessName}}Model.ReqEdit
+		var editReq *${.table.BusinessName}Model.ReqEdit
 		// 通过Parse方法解析获取参数
 		err := r.Parse(&editReq)
 		if err != nil {
-			response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+			if _,ok := err.(*gvalid.Error); ok {
+				response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+			} else {
+				response.FailJson(true, r, err.Error())
+			}
 		}
-		err = {{.table.BusinessName}}Service.EditSave(editReq)
+		err = ${.table.BusinessName}Service.EditSave(editReq)
 		if err != nil {
 		    response.FailJson(true, r, err.Error())
 		}
-		cache_service.New().RemoveByTag("{{.table.ModuleName}}_{{.table.BusinessName}}_tag")
+		cache_service.New().RemoveByTag("${.table.ModuleName}_${.table.BusinessName}_tag")
 		response.SusJson(true, r, "修改成功")
 	}
 	// 不是post提交的请求就到修改页面后查询出要修改的记录
 	//获取上级
-    cates, err := {{.table.BusinessName}}Service.GetList()
+    cates, err := ${.table.BusinessName}Service.GetList()
     if err != nil {
         response.FailJson(true, r, err.Error())
     }
 	//获取信息
     id := r.GetUint("id")
-    menuInfo, err := {{.table.BusinessName}}Service.GetInfoById(id)
+    menuInfo, err := ${.table.BusinessName}Service.GetInfoById(id)
     if err != nil {
         response.FailJson(true, r, err.Error())
     }
@@ -105,17 +117,21 @@ func (c *{{.table.BusinessName|UcFirst}}) Edit(r *ghttp.Request) {
 }
 
 
-// 删除
-func (c *{{.table.BusinessName|UcFirst}}) Delete(r *ghttp.Request) {
-	var req *{{.table.BusinessName}}Model.RemoveReq
+// Delete 删除
+func (c *${.table.BusinessName|UcFirst}) Delete(r *ghttp.Request) {
+	var req *${.table.BusinessName}Model.RemoveReq
 	//获取参数
 	if err := r.Parse(&req); err != nil {
-		response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+		if _,ok := err.(*gvalid.Error); ok {
+			response.FailJson(true, r, err.(*gvalid.Error).FirstString())
+		} else {
+			response.FailJson(true, r, err.Error())
+		}
 	}
-	err := {{.table.BusinessName}}Service.DeleteByIds(req.Ids)
+	err := ${.table.BusinessName}Service.DeleteByIds(req.Ids)
 	if err != nil {
 	    response.FailJson(true, r, "删除失败")
 	}
-	cache_service.New().RemoveByTag("{{.table.ModuleName}}_{{.table.BusinessName}}_tag")
+	cache_service.New().RemoveByTag("${.table.ModuleName}_${.table.BusinessName}_tag")
 	response.SusJson(true, r, "删除成功")
-}
+}

+ 33 - 33
template/vm/go/tree/model.template

@@ -1,35 +1,35 @@
 // ==========================================================================
-// 生成日期:{{.table.CreateTime}}
-// 生成人:{{.table.FunctionAuthor}}
+// 生成日期:${.table.CreateTime}
+// 生成人:${.table.FunctionAuthor}
 // ==========================================================================
 
-package {{.table.BusinessName}}
+package ${.table.BusinessName}
 
 import (
-	"{{.table.PackageName}}/app/service/cache_service"
+	"${.table.PackageName}/app/service/cache_service"
     "github.com/gogf/gf/container/gset"
     "github.com/gogf/gf/errors/gerror"
     "github.com/gogf/gf/frame/g"
     "github.com/gogf/gf/util/gconv"
 )
 
-{{$pk:=""}}
-{{$pkGoField:=""}}
-{{range $index, $column := .table.Columns}} {{if eq $column.IsPk "1"}}
-    {{$pk = $column.ColumnName}}
-    {{$pkGoField = $column.GoField}}
-{{end}}{{end}}
+${$pk:=""}
+${$pkGoField:=""}
+${range $index, $column := .table.Columns} ${if eq $column.IsPk "1"}
+    ${$pk = $column.ColumnName}
+    ${$pkGoField = $column.GoField}
+${end}${end}
 
 // ReqAdd 用于存储新增请求的请求参数
 type ReqAdd struct {
-	{{range $index, $column := .table.Columns}}
-	{{if and (eq $column.IsInsert "1") (ne $column.IsPk "1")}} {{$column.GoField}} 	{{if eq $column.GoType "Time"}}	*gtime.Time	{{else}}	{{$column.GoType}} {{end}}	  `p:"{{$column.HtmlField}}"  {{if eq $column.IsRequired "1"}}v:"required#{{$column.ColumnComment}}不能为空"{{end}}` {{end}} {{end}}
+	${range $index, $column := .table.Columns}
+	${if and (eq $column.IsInsert "1") (ne $column.IsPk "1")} ${$column.GoField} 	${if eq $column.GoType "Time"}	*gtime.Time	${else}	${$column.GoType} ${end}	  `p:"${$column.HtmlField}"  ${if eq $column.IsRequired "1"}v:"required#${$column.ColumnComment}不能为空"${end}` ${end} ${end}
 }
 
 // ReqEdit 用于存储修改请求参数
 type ReqEdit struct {
-	{{.table.PkColumn.GoField}}    {{.table.PkColumn.GoType}}  `p:"{{.table.PkColumn.HtmlField}}" v:"required#主键ID不能为空"` {{range $index, $column := .table.Columns}} {{if eq $column.IsEdit "1"}}
-	{{$column.GoField}}  {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}} `p:"{{$column.HtmlField}}" {{if eq $column.IsRequired "1"}}v:"required#{{$column.ColumnComment}}不能为空"{{end}}` {{end}} {{end}}
+	${.table.PkColumn.GoField}    ${.table.PkColumn.GoType}  `p:"${.table.PkColumn.HtmlField}" v:"required#主键ID不能为空"` ${range $index, $column := .table.Columns} ${if eq $column.IsEdit "1"}
+	${$column.GoField}  ${if eq $column.GoType "Time"}*gtime.Time${else}${$column.GoType}${end} `p:"${$column.HtmlField}" ${if eq $column.IsRequired "1"}v:"required#${$column.ColumnComment}不能为空"${end}` ${end} ${end}
 }
 
 // RemoveReq 用于存储删除请求参数
@@ -38,8 +38,8 @@ type RemoveReq struct {
 }
 
 // ReqSearchList 用于存储查询的请求参数
-type ReqSearchList struct { {{range $index, $column := .table.Columns}} {{if eq $column.IsQuery "1"}}
-	{{$column.GoField}}  {{if eq $column.GoType "Time"}}*gtime.Time{{else}}{{$column.GoType}}{{end}} `p:"{{$column.HtmlField}}"` //{{$column.ColumnComment}} {{end}} {{end}}
+type ReqSearchList struct { ${range $index, $column := .table.Columns} ${if eq $column.IsQuery "1"}
+	${$column.GoField}  ${if eq $column.GoType "Time"}*gtime.Time${else}${$column.GoType}${end} `p:"${$column.HtmlField}"` //${$column.ColumnComment} ${end} ${end}
 }
 
 // GetByID 根据ID查询记录
@@ -58,11 +58,11 @@ func GetByID(id int64) (*Entity, error) {
 // AddSave 添加
 func AddSave(req *ReqAdd) error {
 	entity:= new(Entity)
-    {{range $index, $column := .table.Columns}}
-	    {{if and (eq $column.IsInsert "1") (ne $column.IsPk "1")}}
-        entity.{{$column.GoField}} = req.{{$column.GoField}}
-        {{end}}
-    {{end}}
+    ${range $index, $column := .table.Columns}
+	    ${if and (eq $column.IsInsert "1") (ne $column.IsPk "1")}
+        entity.${$column.GoField} = req.${$column.GoField}
+        ${end}
+    ${end}
 
 	result, err := entity.Insert()
 	if err != nil {
@@ -77,7 +77,7 @@ func AddSave(req *ReqAdd) error {
 
 // DeleteByIds 删除
 func DeleteByIds(Ids []int) error {
-	_, err := Model.Delete("{{.table.PkColumn.ColumnName}} in(?)", Ids)
+	_, err := Model.Delete("${.table.PkColumn.ColumnName} in(?)", Ids)
 	if err != nil {
 		g.Log().Error(err)
 		return gerror.New("删除失败")
@@ -88,14 +88,14 @@ func DeleteByIds(Ids []int) error {
 // EditSave 根据ID来修改信息
 func EditSave(req *ReqEdit) error {
 	// 先根据ID来查询要修改的记录
-	entity, err := GetByID(req.{{$pkGoField}})
+	entity, err := GetByID(req.${$pkGoField})
 	if err != nil {
 		return err
 	}
 
 	// 修改实体
-	{{range $index, $column := .table.Columns}} {{if eq $column.IsEdit "1"}}
-	entity.{{$column.GoField}} = req.{{$column.GoField}}{{end}} {{end}}
+	${range $index, $column := .table.Columns} ${if eq $column.IsEdit "1"}
+	entity.${$column.GoField} = req.${$column.GoField}${end} ${end}
 	_, err = entity.Update()
 	if err != nil {
 		g.Log().Error(err)
@@ -111,15 +111,15 @@ func GetListSearch(req *ReqSearchList) (list []*Entity, err error) {
 	    filterKey := gset.New(false)
 	    tagWhere := true
         for key, entity := range list {
-	    {{range $index, $column := .table.Columns}}
-	        {{if eq $column.IsQuery "1" }}
-            if tagWhere && gconv.String(req.{{$column.GoField}}) != "" && entity.{{$column.GoField}}!= req.{{$column.GoField}} {
+	    ${range $index, $column := .table.Columns}
+	        ${if eq $column.IsQuery "1" }
+            if tagWhere && gconv.String(req.${$column.GoField}) != "" && entity.${$column.GoField}!= req.${$column.GoField} {
                 tagWhere = true
             }else{
                 tagWhere = false
             }
-            {{end}}
-        {{end}}
+            ${end}
+        ${end}
             if tagWhere{
                 filterKey.Add(key)
             }
@@ -139,18 +139,18 @@ func GetListSearch(req *ReqSearchList) (list []*Entity, err error) {
 func GetList() (list []*Entity, err error) {
 	cache := cache_service.New()
 	//从缓存获取数据
-	iList := cache.Get("{{.table.ModuleName}}_{{.table.BusinessName}}_{{.table.TableId}}")
+	iList := cache.Get("${.table.ModuleName}_${.table.BusinessName}_${.table.TableId}")
 	if iList != nil {
 		list = iList.([]*Entity)
 		return
 	}
-	list, err = Model.Order(Columns.{{$pkGoField}}+" ASC").All()
+	list, err = Model.Order(Columns.${$pkGoField}+" ASC").All()
 	if err != nil {
 		g.Log().Error()
 		err = gerror.New("获取数据失败")
 		return
 	}
 	//缓存数据
-	cache.Set("{{.table.ModuleName}}_{{.table.BusinessName}}_{{.table.TableId}}", list, 0, "{{.table.ModuleName}}_{{.table.BusinessName}}_tag")
+	cache.Set("${.table.ModuleName}_${.table.BusinessName}_${.table.TableId}", list, 0, "${.table.ModuleName}_${.table.BusinessName}_tag")
 	return
 }

+ 27 - 25
template/vm/go/tree/service.template

@@ -1,44 +1,46 @@
 // ==========================================================================
-// 生成日期:{{.table.CreateTime}}
-// 生成人:{{.table.FunctionAuthor}}
+// 生成日期:${.table.CreateTime}
+// 生成人:${.table.FunctionAuthor}
 // ==========================================================================
-package {{.table.BusinessName}}_service
+package ${.table.BusinessName}_service
 
 import (
-	{{.table.BusinessName}}Model "{{.table.PackageName}}/app/model/{{.table.ModuleName}}/{{.table.BusinessName}}"
+	${.table.BusinessName}Model "${.table.PackageName}/app/model/${.table.ModuleName}/${.table.BusinessName}"
 )
 
 
-// 添加
-func AddSave(req *{{.table.BusinessName}}Model.ReqAdd) error {
-	return {{.table.BusinessName}}Model.AddSave(req)
+// AddSave 添加
+func AddSave(req *${.table.BusinessName}Model.ReqAdd) error {
+	return ${.table.BusinessName}Model.AddSave(req)
 }
 
-// 删除
+// DeleteByIds 删除
 func DeleteByIds(ids []int) (err error) {
     ids, err = GetChildrenIds(ids)
     	if err != nil {
     		return
     	}
-	return {{.table.BusinessName}}Model.DeleteByIds(ids)
+	return ${.table.BusinessName}Model.DeleteByIds(ids)
 }
 
-//修改
-func EditSave(ReqEdit *{{.table.BusinessName}}Model.ReqEdit) error {
-	return {{.table.BusinessName}}Model.EditSave(ReqEdit)
+// EditSave 修改
+func EditSave(ReqEdit *${.table.BusinessName}Model.ReqEdit) error {
+	return ${.table.BusinessName}Model.EditSave(ReqEdit)
 }
 
-// 根据ID查询
-func GetInfoById(id int64) (*{{.table.BusinessName}}Model.Entity, error) {
-	return {{.table.BusinessName}}Model.GetByID(id)
+// GetInfoById 根据ID查询
+func GetInfoById(id int64) (*${.table.BusinessName}Model.Entity, error) {
+	return ${.table.BusinessName}Model.GetByID(id)
 }
 
-// 列表查询
-func GetListSearch(req *{{.table.BusinessName}}Model.ReqSearchList) (list []*{{.table.BusinessName}}Model.Entity, err error) {
-	return {{.table.BusinessName}}Model.GetListSearch(req)
+// GetListSearch 列表查询
+func GetListSearch(req *${.table.BusinessName}Model.ReqSearchList) (list []*${.table.BusinessName}Model.Entity, err error) {
+	return ${.table.BusinessName}Model.GetListSearch(req)
 }
 
-//通过ID获取子级ID
+
+
+// GetChildrenIds 通过ID获取子级ID
 func GetChildrenIds(ids []int) ([]int, error) {
 	//获取所有
 	menus, err := GetList()
@@ -50,15 +52,15 @@ func GetChildrenIds(ids []int) ([]int, error) {
 		menuList[k] = gconv.Map(menu)
 	}
 	for _, id := range ids {
-		children := utils.FindSonByParentId(menuList, id, "{{index .options "tree_code"}}", "{{index .options "tree_parent_code"}}")
+		children := utils.FindSonByParentId(menuList, id, "${index .options "tree_code"}", "${index .options "tree_parent_code"}")
 		for _, cid := range children {
-			ids = append(ids, gconv.Int(cid["{{index .options "tree_code"}}"]))
+			ids = append(ids, gconv.Int(cid["${index .options "tree_code"}"]))
 		}
 	}
 	return ids, nil
 }
 
-//获取所有数据列表
-func GetList() (list []*{{.table.BusinessName}}Model.Entity, err error) {
-	return {{.table.BusinessName}}Model.GetList()
-}
+// GetList 获取所有数据列表
+func GetList() (list []*${.table.BusinessName}Model.Entity, err error) {
+	return ${.table.BusinessName}Model.GetList()
+}

+ 15 - 15
template/vm/html/js.template

@@ -1,45 +1,45 @@
 import request from '@/utils/request'
 
-// 查询{{.table.BusinessName}}列表
-export function list{{.table.BusinessName|UcFirst}}(query) {
+// 查询${.table.BusinessName}列表
+export function list${.table.BusinessName|UcFirst}(query) {
     return request({
-        url: '/{{.table.ModuleName}}/{{.table.BusinessName}}/list',
+        url: '/${.table.ModuleName}/${.table.BusinessName}/list',
         method: 'get',
         params: query
     })
 }
 
-// 查询{{.table.BusinessName}}详细
-export function get{{.table.BusinessName|UcFirst}} (id) {
+// 查询${.table.BusinessName}详细
+export function get${.table.BusinessName|UcFirst} (id) {
     return request({
-        url: '/{{.table.ModuleName}}/{{.table.BusinessName}}/edit?id='+id,
+        url: '/${.table.ModuleName}/${.table.BusinessName}/edit?id='+id,
         method: 'get'
     })
 }
 
 
-// 新增{{.table.BusinessName}}
-export function add{{.table.BusinessName|UcFirst}}(data) {
+// 新增${.table.BusinessName}
+export function add${.table.BusinessName|UcFirst}(data) {
     return request({
-        url: '/{{.table.ModuleName}}/{{.table.BusinessName}}/add',
+        url: '/${.table.ModuleName}/${.table.BusinessName}/add',
         method: 'post',
         data: data
     })
 }
 
-// 修改{{.table.BusinessName}}
-export function update{{.table.BusinessName|UcFirst}}(data) {
+// 修改${.table.BusinessName}
+export function update${.table.BusinessName|UcFirst}(data) {
     return request({
-        url: '/{{.table.ModuleName}}/{{.table.BusinessName}}/edit',
+        url: '/${.table.ModuleName}/${.table.BusinessName}/edit',
         method: 'post',
         data: data
     })
 }
 
-// 删除{{.table.BusinessName}}
-export function del{{.table.BusinessName|UcFirst}}(ids) {
+// 删除${.table.BusinessName}
+export function del${.table.BusinessName|UcFirst}(ids) {
     return request({
-        url: '/{{.table.ModuleName}}/{{.table.BusinessName}}/delete',
+        url: '/${.table.ModuleName}/${.table.BusinessName}/delete',
         method: 'delete',
         data:{ids:ids}
     })

+ 163 - 163
template/vm/html/vue_crud.template

@@ -1,57 +1,57 @@
-{{$columns:=.table.Columns}}
-{{$pk:=""}}
-{{$pkColumnName:=""}}
-{{range $index, $column := .table.Columns}} {{if eq $column.IsPk "1"}}
-    {{$pk = $column.ColumnName}}
-    {{$pkColumnName = $column.ColumnName}}
-{{end}}{{end}}
+${$columns:=.table.Columns}
+${$pk:=""}
+${$pkColumnName:=""}
+${range $index, $column := .table.Columns} ${if eq $column.IsPk "1"}
+    ${$pk = $column.ColumnName}
+    ${$pkColumnName = $column.ColumnName}
+${end}${end}
 <template>
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
-{{range $index,$column := $columns}}
-{{if eq $column.IsQuery "1"}}
-{{$dictType:=$column.DictType}}
-{{$AttrName:=$column.ColumnName }}
-{{$comment:=$column.ColumnComment}}
-{{if eq $column.HtmlType "input"}}
-      <el-form-item label="{{$comment}}" prop="{{$column.ColumnName}}">
+${range $index,$column := $columns}
+${if eq $column.IsQuery "1"}
+${$dictType:=$column.DictType}
+${$AttrName:=$column.ColumnName }
+${$comment:=$column.ColumnComment}
+${if eq $column.HtmlType "input"}
+      <el-form-item label="${$comment}" prop="${$column.ColumnName}">
         <el-input
-          v-model="queryParams.{{$column.ColumnName}}"
-          placeholder="请输入{{$comment}}"
+          v-model="queryParams.${$column.ColumnName}"
+          placeholder="请输入${$comment}"
           clearable
           size="small"
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
-{{else if and (or (eq $column.HtmlType  "select" )  (eq $column.HtmlType  "radio"))  (ne $dictType "") }}
-      <el-form-item label="{{$comment}}" prop="{{$column.ColumnName}}">
-        <el-select v-model="queryParams.{{$column.ColumnName}}" placeholder="请选择{{$comment}}" clearable size="small">
+${else if and (or (eq $column.HtmlType  "select" )  (eq $column.HtmlType  "radio"))  (ne $dictType "") }
+      <el-form-item label="${$comment}" prop="${$column.ColumnName}">
+        <el-select v-model="queryParams.${$column.ColumnName}" placeholder="请选择${$comment}" clearable size="small">
           <el-option
-            v-for="dict in {{$column.ColumnName}}Options"
+            v-for="dict in ${$column.HtmlField}Options"
             :key="dict.key"
             :label="dict.value"
             :value="dict.key"
           />
         </el-select>
       </el-form-item>
-{{else if and (or (eq $column.HtmlType  "select" )  (eq $column.HtmlType  "radio"))  (eq $dictType "") }}
-      <el-form-item label="{{$comment}}" prop="{{$column.ColumnName}}">
-        <el-select v-model="queryParams.{{$column.ColumnName}}" placeholder="请选择{{$comment}}" clearable size="small">
+${else if and (or (eq $column.HtmlType  "select" )  (eq $column.HtmlType  "radio"))  (eq $dictType "") }
+      <el-form-item label="${$comment}" prop="${$column.ColumnName}">
+        <el-select v-model="queryParams.${$column.ColumnName}" placeholder="请选择${$comment}" clearable size="small">
           <el-option label="请选择字典生成" value="" />
         </el-select>
       </el-form-item>
-{{else if eq $column.HtmlType  "datetime"}}
-      <el-form-item label="{{$comment}}" prop="{{$column.ColumnName}}">
+${else if eq $column.HtmlType  "datetime"}
+      <el-form-item label="${$comment}" prop="${$column.ColumnName}">
         <el-date-picker clearable size="small" style="width: 200px"
-          v-model="queryParams.{{$column.ColumnName}}"
+          v-model="queryParams.${$column.ColumnName}"
           type="date"
           value-format="yyyy-MM-dd"
-          placeholder="选择{{$comment}}">
+          placeholder="选择${$comment}">
         </el-date-picker>
       </el-form-item>
-{{end}}
-{{end}}
-{{end}}
+${end}
+${end}
+${end}
 
         <el-form-item>
             <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
@@ -88,26 +88,26 @@
       </el-col>
     </el-row>
 
-    <el-table v-loading="loading" :data="{{.table.BusinessName}}List" @selection-change="handleSelectionChange">
+    <el-table v-loading="loading" :data="${.table.BusinessName}List" @selection-change="handleSelectionChange">
           <el-table-column type="selection" width="55" align="center" />
-    {{range $index,$column := $columns}}
-    {{$ColumnName:=$column.ColumnName}}
-    {{$comment:=$column.ColumnComment}}
-   {{if eq $column.IsPk "1"}}
-             <el-table-column label="{{$comment}}" align="center" prop="{{$ColumnName}}" />
-       {{else if and (eq $column.IsList "1")  (eq $column.HtmlType "datetime")}}
-             <el-table-column label="{{$comment}}" align="center" prop="{{$ColumnName}}" width="180">
+    ${range $index,$column := $columns}
+    ${$ColumnName:=$column.ColumnName}
+    ${$comment:=$column.ColumnComment}
+   ${if eq $column.IsPk "1"}
+             <el-table-column label="${$comment}" align="center" prop="${$ColumnName}" />
+       ${else if and (eq $column.IsList "1")  (eq $column.HtmlType "datetime")}
+             <el-table-column label="${$comment}" align="center" prop="${$ColumnName}" width="180">
                <template slot-scope="scope">
-                 <span>{{ "{{" }} parseTime(scope.row.{{$ColumnName}}, '{y}-{m}-{d}') {{"}}"}}</span>
+                 <span>{{ parseTime(scope.row.${$ColumnName}, '{y}-{m}-{d}') }}</span>
                </template>
              </el-table-column>
-       {{else if and (eq $column.IsList "1")  (ne $column.DictType "")}}
-             <el-table-column label="{{$comment}}" align="center" prop="{{$ColumnName}}" :formatter="{{$ColumnName}}Format" />
-       {{else if and (eq $column.IsList "1")  (ne $ColumnName "")}}
-             <el-table-column label="{{$comment}}" align="center" prop="{{$ColumnName}}" />
-       {{end}}
+       ${else if and (eq $column.IsList "1")  (ne $column.DictType "")}
+             <el-table-column label="${$comment}" align="center" prop="${$ColumnName}" :formatter="${$column.HtmlField}Format" />
+       ${else if and (eq $column.IsList "1")  (ne $ColumnName "")}
+             <el-table-column label="${$comment}" align="center" prop="${$ColumnName}" />
+       ${end}
 
-    {{end}}
+    ${end}
           <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
             <template slot-scope="scope">
               <el-button
@@ -134,84 +134,84 @@
               @pagination="getList"
             />
 
-            <!-- 添加或修改{{.table.FunctionName}}对话框 -->
+            <!-- 添加或修改${.table.FunctionName}对话框 -->
                 <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
                   <el-form ref="form" :model="form" :rules="rules" label-width="80px">
-            {{range $index,$column := $columns}}
-            {{$field := $column.ColumnName}}
-            {{if and (eq $column.IsInsert "1")  (ne $column.IsPk "1") }}
-            {{$comment  :=$column.ColumnComment}}
-            {{$dictType := $column.DictType }}
-            {{if eq $column.HtmlType "input"}}
-                    <el-form-item label="{{$comment}}" prop="{{$field}}">
-                      <el-input v-model="form.{{$field}}" placeholder="请输入{{$comment}}" />
+            ${range $index,$column := $columns}
+            ${$field := $column.ColumnName}
+            ${if and (eq $column.IsInsert "1")  (ne $column.IsPk "1") }
+            ${$comment  :=$column.ColumnComment}
+            ${$dictType := $column.DictType }
+            ${if eq $column.HtmlType "input"}
+                    <el-form-item label="${$comment}" prop="${$field}">
+                      <el-input v-model="form.${$field}" placeholder="请输入${$comment}" />
                     </el-form-item>
-            {{else if and (eq $column.HtmlType  "select") (ne $dictType "") }}
-                    <el-form-item label="{{$comment}}">
-                      <el-select v-model="form.{{$field}}" placeholder="请选择{{$comment}}">
+            ${else if and (eq $column.HtmlType  "select") (ne $dictType "") }
+                    <el-form-item label="${$comment}">
+                      <el-select v-model="form.${$field}" placeholder="请选择${$comment}">
                         <el-option
-                          v-for="dict in {{$field}}Options"
+                          v-for="dict in ${$column.HtmlField}Options"
                           :key="dict.key"
                           :label="dict.value"
-                          {{if or (eq $column.GoType "int") (eq $column.GoType "int64")}}:value="parseInt(dict.key)"{{else}}:value="dict.key"{{end}}
+                          ${if or (eq $column.GoType "int") (eq $column.GoType "int64")}:value="parseInt(dict.key)"${else}:value="dict.key"${end}
                         ></el-option>
                       </el-select>
                     </el-form-item>
-            {{else if and (eq $column.HtmlType  "select") $dictType}}
-                    <el-form-item label="{{$comment}}">
-                      <el-select v-model="form.{{$field}}" placeholder="请选择{{$comment}}">
+            ${else if and (eq $column.HtmlType  "select") $dictType}
+                    <el-form-item label="${$comment}">
+                      <el-select v-model="form.${$field}" placeholder="请选择${$comment}">
                         <el-option label="请选择字典生成" value="" />
                       </el-select>
                     </el-form-item>
-            {{else if and (eq $column.HtmlType  "checkbox") (ne $dictType "")}}
-                    <el-form-item label="{{$comment}}">
-                      <el-checkbox-group v-model="form.{{$field}}">
+            ${else if and (eq $column.HtmlType  "checkbox") (ne $dictType "")}
+                    <el-form-item label="${$comment}">
+                      <el-checkbox-group v-model="form.${$field}">
                         <el-checkbox
-                          v-for="dict in {{$field}}Options"
+                          v-for="dict in ${$column.HtmlField}Options"
                           :key="dict.key"
                           :label="dict.key">
-                          {{"{{"}}dict.value{{"}}"}}
+                          ${"${"}dict.value${"}"}
                         </el-checkbox>
                       </el-checkbox-group>
                     </el-form-item>
-            {{else if and (eq $column.HtmlType  "checkbox") $dictType }}
-                    <el-form-item label="{{$comment}}">
-                      <el-checkbox-group v-model="form.{{$field}}">
+            ${else if and (eq $column.HtmlType  "checkbox") $dictType }
+                    <el-form-item label="${$comment}">
+                      <el-checkbox-group v-model="form.${$field}">
                         <el-checkbox>请选择字典生成</el-checkbox>
                       </el-checkbox-group>
                     </el-form-item>
-            {{else if and (eq $column.HtmlType  "radio") (ne $dictType "") }}
-                    <el-form-item label="{{$comment}}">
-                      <el-radio-group v-model="form.{{$field}}">
+            ${else if and (eq $column.HtmlType  "radio") (ne $dictType "") }
+                    <el-form-item label="${$comment}">
+                      <el-radio-group v-model="form.${$field}">
                         <el-radio
-                          v-for="dict in {{$field}}Options"
+                          v-for="dict in ${$column.HtmlField}Options"
                           :key="dict.key"
-                          {{if or (eq $column.GoType "int")  (eq $column.GoType  "int64")}}:label="parseInt(dict.key)"{{else}}:label="dict.key"{{end}}
-                        >{{"{{"}}dict.value{{"}}"}}</el-radio>
+                          ${if or (eq $column.GoType "int")  (eq $column.GoType  "int64")}:label="parseInt(dict.key)"${else}:label="dict.key"${end}
+                        >${"${"}dict.value${"}"}</el-radio>
                       </el-radio-group>
                     </el-form-item>
-            {{else if and (eq $column.HtmlType "radio") $dictType }}
-                    <el-form-item label="{{$comment}}">
-                      <el-radio-group v-model="form.{{$field}}">
+            ${else if and (eq $column.HtmlType "radio") $dictType }
+                    <el-form-item label="${$comment}">
+                      <el-radio-group v-model="form.${$field}">
                         <el-radio label="1">请选择字典生成</el-radio>
                       </el-radio-group>
                     </el-form-item>
-            {{else if eq $column.HtmlType  "datetime"}}
-                    <el-form-item label="{{$comment}}" prop="{{$field}}">
+            ${else if eq $column.HtmlType  "datetime"}
+                    <el-form-item label="${$comment}" prop="${$field}">
                       <el-date-picker clearable size="small" style="width: 200px"
-                        v-model="form.{{$field}}"
+                        v-model="form.${$field}"
                         type="date"
                         value-format="yyyy-MM-dd"
-                        placeholder="选择{{$comment}}">
+                        placeholder="选择${$comment}">
                       </el-date-picker>
                     </el-form-item>
-            {{else if eq $column.HtmlType  "textarea"}}
-                    <el-form-item label="{{$comment}}" prop="{{$field}}">
-                      <el-input v-model="form.{{$field}}" type="textarea" placeholder="请输入内容" />
+            ${else if eq $column.HtmlType  "textarea"}
+                    <el-form-item label="${$comment}" prop="${$field}">
+                      <el-input v-model="form.${$field}" type="textarea" placeholder="请输入内容" />
                     </el-form-item>
-            {{end}}
-            {{end}}
-            {{end}}
+            ${end}
+            ${end}
+            ${end}
 
           </el-form>
           <div slot="footer" class="dialog-footer">
@@ -223,10 +223,10 @@
 </template>
 
 <script>
-import { list{{.table.BusinessName|UcFirst}}, get{{.table.BusinessName|UcFirst}}, del{{.table.BusinessName|UcFirst}}, add{{.table.BusinessName|UcFirst}}, update{{.table.BusinessName|UcFirst}} } from '@/api/{{.table.ModuleName}}/{{.table.BusinessName}}'
+import { list${.table.BusinessName|UcFirst}, get${.table.BusinessName|UcFirst}, del${.table.BusinessName|UcFirst}, add${.table.BusinessName|UcFirst}, update${.table.BusinessName|UcFirst} } from '@/api/${.table.ModuleName}/${.table.BusinessName}'
 
 export default {
-  name: "{{.table.BusinessName}}",
+  name: "${.table.BusinessName}",
   data() {
     return {
           // 遮罩层
@@ -241,76 +241,76 @@ export default {
           showSearch: true,
           // 总条数
           total: 0,
-          // {{.table.FunctionName}}表格数据
-          {{.table.BusinessName}}List: [],
+          // ${.table.FunctionName}表格数据
+          ${.table.BusinessName}List: [],
           // 弹出层标题
           title: "",
           // 是否显示弹出层
           open: false,
-          {{range  $index,$column := $columns}}
-           {{$comment :=$column.ColumnComment}}
-           {{if ne $column.DictType ""}}
-                 // $comment字典
-                 {{$column.ColumnName}}Options: [],
-           {{end}}
-          {{end}}
-          // 查询参数
+          ${range  $index,$column := $columns}
+           ${$comment :=$column.ColumnComment}
+           ${if ne $column.DictType ""}
+            // ${$column.ColumnName}字典
+            ${$column.HtmlField}Options: [],
+           ${end}
+          ${end}
+        // 查询参数
         queryParams: {
           pageNum: 1,
           pageSize: 10,
-          {{range  $index,$column := $columns}}
-          {{$velocityCount := add $index 1}}
-          {{if eq $column.IsQuery "1"}}
-          {{$column.ColumnName}}: null,
-          {{end}}
-          {{end}}
+          ${range  $index,$column := $columns}
+          ${$velocityCount := add $index 1}
+          ${if eq $column.IsQuery "1"}
+          ${$column.ColumnName}: null,
+          ${end}
+          ${end}
         },
         // 表单参数
           form: {},
           // 表单校验
           rules: {
-              {{range  $index,$column := $columns}}
-              {{$velocityCount := add $index 1}}
-              {{if and (eq $column.IsRequired "1") (eq $column.IsPk "0")}}
-              {{$comment:=$column.ColumnComment}}
-              {{$column.ColumnName}}: [
-                { required: true, message: "{{$comment}}不能为空", trigger: "blur" }
-              ]{{if ne $velocityCount (len $columns)}},{{end}}
-              {{end}}
-              {{end}}
+              ${range  $index,$column := $columns}
+              ${$velocityCount := add $index 1}
+              ${if and (eq $column.IsRequired "1") (eq $column.IsPk "0")}
+              ${$comment:=$column.ColumnComment}
+              ${$column.ColumnName}: [
+                { required: true, message: "${$comment}不能为空", trigger: "blur" }
+              ]${if ne $velocityCount (len $columns)},${end}
+              ${end}
+              ${end}
           }
       };
     },
     created() {
         this.getList();
-    {{range  $index,$column := $columns}}
-    {{if ne $column.DictType ""}}
-        this.getDicts("{{$column.DictType}}").then(response => {
-          this.{{$column.ColumnName}}Options = response.data.values || [];
+    ${range  $index,$column := $columns}
+    ${if ne $column.DictType ""}
+        this.getDicts("${$column.DictType}").then(response => {
+          this.${$column.HtmlField}Options = response.data.values || [];
         });
-    {{end}}
-    {{end}}
+    ${end}
+    ${end}
     },
 
     methods: {
-        /** 查询{{.table.FunctionName}}列表 */
+        /** 查询${.table.FunctionName}列表 */
         getList() {
           this.loading = true;
-          list{{.table.BusinessName|UcFirst}}(this.queryParams).then(response => {
-            this.{{.table.BusinessName}}List = response.data.list;
+          list${.table.BusinessName|UcFirst}(this.queryParams).then(response => {
+            this.${.table.BusinessName}List = response.data.list;
             this.total = response.data.total;
             this.loading = false;
           });
         },
-        {{range  $index,$column := $columns}}
-        {{if ne $column.DictType ""}}
-        {{$comment:=$column.ColumnComment}}
+        ${range  $index,$column := $columns}
+        ${if ne $column.DictType ""}
+        ${$comment:=$column.ColumnComment}
         // $comment字典翻译
-        {{$column.ColumnName}}Format(row, column) {
-          return this.selectDictLabel{{if eq $column.HtmlType "checkbox"}}s{{end}}(this.{{$column.ColumnName}}Options, row.{{$column.ColumnName}});
+        ${$column.HtmlField}Format(row, column) {
+          return this.selectDictLabel${if eq $column.HtmlType "checkbox"}s${end}(this.${$column.HtmlField}Options, row.${$column.ColumnName});
         },
-        {{end}}
-        {{end}}
+        ${end}
+        ${end}
         // 取消按钮
         cancel() {
           this.open = false;
@@ -319,18 +319,18 @@ export default {
         // 表单重置
         reset() {
           this.form = {
-    {{range  $index,$column := $columns}}
-    {{$velocityCount := add $index 1}}
-    {{if eq $column.HtmlType  "radio"}}
-            {{$column.ColumnName}}: {{if or (eq $column.GoType  "int")  (eq $column.GoType "int64") }}0{{else}}"0"{{end}} {{if ne $velocityCount  (len $columns)}},{{end}}
+    ${range  $index,$column := $columns}
+    ${$velocityCount := add $index 1}
+    ${if eq $column.HtmlType  "radio"}
+            ${$column.ColumnName}: ${if or (eq $column.GoType  "int")  (eq $column.GoType "int64") }0${else}"0"${end} ${if ne $velocityCount  (len $columns)},${end}
 
-    {{else if eq $column.HtmlType  "checkbox"}}
-            {{$column.ColumnName}}: []{{if ne $velocityCount  (len $columns)}},{{end}}
+    ${else if eq $column.HtmlType  "checkbox"}
+            ${$column.ColumnName}: []${if ne $velocityCount  (len $columns)},${end}
 
-    {{else}}
-            {{$column.ColumnName}}: null{{if ne $velocityCount  (len $columns)}},{{end}}
-    {{end}}
-    {{end}}
+    ${else}
+            ${$column.ColumnName}: null${if ne $velocityCount  (len $columns)},${end}
+    ${end}
+    ${end}
           };
           this.resetForm("form");
         },
@@ -347,7 +347,7 @@ export default {
     },
     // 多选框选中数据
     handleSelectionChange(selection) {
-      this.ids = selection.map(item => item.{{$pkColumnName}})
+      this.ids = selection.map(item => item.${$pkColumnName})
       this.single = selection.length!==1
       this.multiple = !selection.length
     },
@@ -355,34 +355,34 @@ export default {
     handleAdd() {
       this.reset();
       this.open = true;
-      this.title = "添加{{.table.FunctionName}}";
+      this.title = "添加${.table.FunctionName}";
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
       this.reset();
-      const {{$pkColumnName}} = row.{{$pkColumnName}} || this.ids
-      get{{.table.BusinessName|UcFirst}}({{$pkColumnName}}).then(response => {
+      const ${$pkColumnName} = row.${$pkColumnName} || this.ids
+      get${.table.BusinessName|UcFirst}(${$pkColumnName}).then(response => {
         this.form = response.data;
-{{range  $index,$column := $columns}}
-{{if eq $column.HtmlType  "checkbox"}}
-        this.form.{{$column.ColumnName}} = this.form.{{$column.ColumnName}}.split(",");
-{{end}}
-{{end}}
+${range  $index,$column := $columns}
+${if eq $column.HtmlType  "checkbox"}
+        this.form.${$column.ColumnName} = this.form.${$column.ColumnName}.split(",");
+${end}
+${end}
         this.open = true;
-        this.title = "修改{{.table.FunctionName}}";
+        this.title = "修改${.table.FunctionName}";
       });
     },
     /** 提交按钮 */
     submitForm() {
       this.$refs["form"].validate(valid => {
         if (valid) {
-{{range  $index,$column := $columns}}
-{{if eq $column.HtmlType  "checkbox"}}
-          this.form.{{$column.ColumnName}} = this.form.{{$column.ColumnName}}.join(",");
-{{end}}
-{{end}}
-          if (this.form.{{$pkColumnName}} != null) {
-            update{{.table.BusinessName|UcFirst}}(this.form).then(response => {
+${range  $index,$column := $columns}
+${if eq $column.HtmlType  "checkbox"}
+          this.form.${$column.ColumnName} = this.form.${$column.ColumnName}.join(",");
+${end}
+${end}
+          if (this.form.${$pkColumnName} != null) {
+            update${.table.BusinessName|UcFirst}(this.form).then(response => {
               if (response.code === 0) {
                 this.msgSuccess("修改成功");
                 this.open = false;
@@ -390,7 +390,7 @@ export default {
               }
             });
           } else {
-            add{{.table.BusinessName|UcFirst}}(this.form).then(response => {
+            add${.table.BusinessName|UcFirst}(this.form).then(response => {
               if (response.code === 0) {
                 this.msgSuccess("新增成功");
                 this.open = false;
@@ -403,13 +403,13 @@ export default {
     },
     /** 删除按钮操作 */
     handleDelete(row) {
-      const {{$pkColumnName}}s = row.{{$pkColumnName}} || this.ids;
-      this.$confirm('是否确认删除{{.table.FunctionName}}编号为"' + {{$pkColumnName}}s + '"的数据项?', "警告", {
+      const ${$pkColumnName}s = row.${$pkColumnName} || this.ids;
+      this.$confirm('是否确认删除${.table.FunctionName}编号为"' + ${$pkColumnName}s + '"的数据项?', "警告", {
           confirmButtonText: "确定",
           cancelButtonText: "取消",
           type: "warning"
         }).then(function() {
-          return del{{.table.BusinessName|UcFirst}}({{$pkColumnName}}s);
+          return del${.table.BusinessName|UcFirst}(${$pkColumnName}s);
         }).then(() => {
           this.getList();
           this.msgSuccess("删除成功");

+ 175 - 175
template/vm/html/vue_tree.template

@@ -1,60 +1,60 @@
-{{$columns:=.table.Columns}}
-{{$pk:=""}}
-{{$pkColumnName:=""}}
-{{range $index, $column := .table.Columns}} {{if eq $column.IsPk "1"}}
-    {{$pk = $column.ColumnName}}
-    {{$pkColumnName = $column.ColumnName}}
-{{end}}{{end}}
-{{$treeCode:=index .options "tree_code"}}
-{{$treeName:=index .options "tree_name"}}
-{{$treeParentCode:=index .options "tree_parent_code"}}
+${$columns:=.table.Columns}
+${$pk:=""}
+${$pkColumnName:=""}
+${range $index, $column := .table.Columns} ${if eq $column.IsPk "1"}
+    ${$pk = $column.ColumnName}
+    ${$pkColumnName = $column.ColumnName}
+${end}${end}
+${$treeCode:=index .options "tree_code"}
+${$treeName:=index .options "tree_name"}
+${$treeParentCode:=index .options "tree_parent_code"}
 <template>
   <div class="app-container">
     <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
-{{range $index,$column := $columns}}
-{{if eq $column.IsQuery "1"}}
-{{$dictType:=$column.DictType}}
-{{$AttrName:=$column.ColumnName }}
-{{$comment:=$column.ColumnComment}}
-{{if eq $column.HtmlType "input"}}
-      <el-form-item label="{{$comment}}" prop="{{$column.ColumnName}}">
+${range $index,$column := $columns}
+${if eq $column.IsQuery "1"}
+${$dictType:=$column.DictType}
+${$AttrName:=$column.ColumnName }
+${$comment:=$column.ColumnComment}
+${if eq $column.HtmlType "input"}
+      <el-form-item label="${$comment}" prop="${$column.ColumnName}">
         <el-input
-          v-model="queryParams.{$column.ColumnName}}"
-          placeholder="请输入{{$comment}}"
+          v-model="queryParams.{$column.ColumnName}"
+          placeholder="请输入${$comment}"
           clearable
           size="small"
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
-{{else if and (or (eq $column.HtmlType  "select" )  (eq $column.HtmlType  "radio"))  (ne $dictType "") }}
-      <el-form-item label="{{$comment}}" prop="{{$column.ColumnName}}">
-        <el-select v-model="queryParams.{{$column.ColumnName}}" placeholder="请选择{{$comment}}" clearable size="small">
+${else if and (or (eq $column.HtmlType  "select" )  (eq $column.HtmlType  "radio"))  (ne $dictType "") }
+      <el-form-item label="${$comment}" prop="${$column.ColumnName}">
+        <el-select v-model="queryParams.${$column.ColumnName}" placeholder="请选择${$comment}" clearable size="small">
           <el-option
-            v-for="dict in {{$column.ColumnName}}Options"
+            v-for="dict in ${$column.ColumnName}Options"
             :key="dict.key"
             :label="dict.value"
             :value="dict.key"
           />
         </el-select>
       </el-form-item>
-{{else if and (or (eq $column.HtmlType  "select" )  (eq $column.HtmlType  "radio"))  (eq $dictType "") }}
-      <el-form-item label="{{$comment}}" prop="{{$column.ColumnName}}">
-        <el-select v-model="queryParams.{{$column.ColumnName}}" placeholder="请选择{{$comment}}" clearable size="small">
+${else if and (or (eq $column.HtmlType  "select" )  (eq $column.HtmlType  "radio"))  (eq $dictType "") }
+      <el-form-item label="${$comment}" prop="${$column.ColumnName}">
+        <el-select v-model="queryParams.${$column.ColumnName}" placeholder="请选择${$comment}" clearable size="small">
           <el-option label="请选择字典生成" value="" />
         </el-select>
       </el-form-item>
-{{else if eq $column.HtmlType  "datetime"}}
-      <el-form-item label="{{$comment}}" prop="{{$column.ColumnName}}">
+${else if eq $column.HtmlType  "datetime"}
+      <el-form-item label="${$comment}" prop="${$column.ColumnName}">
         <el-date-picker clearable size="small" style="width: 200px"
-          v-model="queryParams.{{$column.ColumnName}}"
+          v-model="queryParams.${$column.ColumnName}"
           type="date"
           value-format="yyyy-MM-dd"
-          placeholder="选择{{$comment}}">
+          placeholder="选择${$comment}">
         </el-date-picker>
       </el-form-item>
-{{end}}
-{{end}}
-{{end}}
+${end}
+${end}
+${end}
 
         <el-form-item>
             <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
@@ -75,29 +75,29 @@
 
 <el-table
       v-loading="loading"
-      :data="{{.table.BusinessName}}List"
-      row-key="{{$treeCode}}"
+      :data="${.table.BusinessName}List"
+      row-key="${$treeCode}"
       default-expand-all
       :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
     >
-{{range $index,$column := $columns}}
-{{$ColumnName:=$column.ColumnName}}
-{{$comment:=$column.ColumnComment}}
-{{if eq $column.IsPk "1"}}
+${range $index,$column := $columns}
+${$ColumnName:=$column.ColumnName}
+${$comment:=$column.ColumnComment}
+${if eq $column.IsPk "1"}
 
-{{else if and (eq $column.IsList "1")  (eq $column.HtmlType "datetime")}}
-     <el-table-column label="{{$comment}}" align="center" prop="{{$ColumnName}}" width="180">
+${else if and (eq $column.IsList "1")  (eq $column.HtmlType "datetime")}
+     <el-table-column label="${$comment}" align="center" prop="${$ColumnName}" width="180">
        <template slot-scope="scope">
-         <span>{{ "{{" }} parseTime(scope.row.{{$ColumnName}}, '{y}-{m}-{d}') {{"}}"}}</span>
+         <span>${ "${" } parseTime(scope.row.${$ColumnName}, '{y}-{m}-{d}') ${"}"}</span>
        </template>
      </el-table-column>
-{{else if and (eq $column.IsList "1")  (ne $column.DictType "")}}
-     <el-table-column label="{{$comment}}" align="center" prop="{{$ColumnName}}" :formatter="{{$ColumnName}}Format" />
-{{else if and (eq $column.IsList "1")  (ne $ColumnName "")}}
-     <el-table-column label="{{$comment}}" align="center" prop="{{$ColumnName}}" />
-{{end}}
+${else if and (eq $column.IsList "1")  (ne $column.DictType "")}
+     <el-table-column label="${$comment}" align="center" prop="${$ColumnName}" :formatter="${$ColumnName}Format" />
+${else if and (eq $column.IsList "1")  (ne $ColumnName "")}
+     <el-table-column label="${$comment}" align="center" prop="${$ColumnName}" />
+${end}
 
-{{end}}
+${end}
   <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
     <template slot-scope="scope">
       <el-button
@@ -116,89 +116,89 @@
   </el-table-column>
 </el-table>
 
-<!-- 添加或修改{{.table.FunctionName}}对话框 -->
+<!-- 添加或修改${.table.FunctionName}对话框 -->
     <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
-{{range $index,$column := $columns}}
-{{$field := $column.ColumnName}}
-{{if and (eq $column.IsInsert "1")  (ne $column.IsPk "1") }}
-{{$comment  :=$column.ColumnComment}}
-{{$dictType := $column.DictType }}
+${range $index,$column := $columns}
+${$field := $column.ColumnName}
+${if and (eq $column.IsInsert "1")  (ne $column.IsPk "1") }
+${$comment  :=$column.ColumnComment}
+${$dictType := $column.DictType }
 
-{{if and (ne  $treeParentCode "") (eq $column.ColumnName $treeParentCode) }}
-        <el-form-item label="{{$comment}}" prop="{{$treeParentCode}}">
-          <treeselect v-model="form.{{$treeParentCode}}" :options="{{$.table.BusinessName}}Options" :normalizer="normalizer" placeholder="请选择{{$comment}}" />
+${if and (ne  $treeParentCode "") (eq $column.ColumnName $treeParentCode) }
+        <el-form-item label="${$comment}" prop="${$treeParentCode}">
+          <treeselect v-model="form.${$treeParentCode}" :options="${$.table.BusinessName}Options" :normalizer="normalizer" placeholder="请选择${$comment}" />
         </el-form-item>
-{{else if eq $column.HtmlType "input"}}
-        <el-form-item label="{{$comment}}" prop="{{$field}}">
-          <el-input v-model="form.{{$field}}" placeholder="请输入{{$comment}}" />
+${else if eq $column.HtmlType "input"}
+        <el-form-item label="${$comment}" prop="${$field}">
+          <el-input v-model="form.${$field}" placeholder="请输入${$comment}" />
         </el-form-item>
-{{else if and (eq $column.HtmlType  "select") (ne $dictType "") }}
-        <el-form-item label="{{$comment}}">
-          <el-select v-model="form.{{$field}}" placeholder="请选择{{$comment}}">
+${else if and (eq $column.HtmlType  "select") (ne $dictType "") }
+        <el-form-item label="${$comment}">
+          <el-select v-model="form.${$field}" placeholder="请选择${$comment}">
             <el-option
-              v-for="dict in {{$field}}Options"
+              v-for="dict in ${$field}Options"
               :key="dict.key"
               :label="dict.value"
-              {{if or (eq $column.GoType "int") (eq $column.GoType "int64")}}:value="parseInt(dict.key)"{{else}}:value="dict.key"{{end}}
+              ${if or (eq $column.GoType "int") (eq $column.GoType "int64")}:value="parseInt(dict.key)"${else}:value="dict.key"${end}
             ></el-option>
           </el-select>
         </el-form-item>
-{{else if and (eq $column.HtmlType  "select") $dictType}}
-        <el-form-item label="{{$comment}}">
-          <el-select v-model="form.{{$field}}" placeholder="请选择{{$comment}}">
+${else if and (eq $column.HtmlType  "select") $dictType}
+        <el-form-item label="${$comment}">
+          <el-select v-model="form.${$field}" placeholder="请选择${$comment}">
             <el-option label="请选择字典生成" value="" />
           </el-select>
         </el-form-item>
-{{else if and (eq $column.HtmlType  "checkbox") (ne $dictType "")}}
-        <el-form-item label="{{$comment}}">
-          <el-checkbox-group v-model="form.{{$field}}">
+${else if and (eq $column.HtmlType  "checkbox") (ne $dictType "")}
+        <el-form-item label="${$comment}">
+          <el-checkbox-group v-model="form.${$field}">
             <el-checkbox
-              v-for="dict in {{$field}}Options"
+              v-for="dict in ${$field}Options"
               :key="dict.key"
               :label="dict.key">
-              {{"{{"}}dict.value{{"}}"}}
+              ${"${"}dict.value${"}"}
             </el-checkbox>
           </el-checkbox-group>
         </el-form-item>
-{{else if and (eq $column.HtmlType  "checkbox") $dictType }}
-        <el-form-item label="{{$comment}}">
-          <el-checkbox-group v-model="form.{{$field}}">
+${else if and (eq $column.HtmlType  "checkbox") $dictType }
+        <el-form-item label="${$comment}">
+          <el-checkbox-group v-model="form.${$field}">
             <el-checkbox>请选择字典生成</el-checkbox>
           </el-checkbox-group>
         </el-form-item>
-{{else if and (eq $column.HtmlType  "radio") (ne $dictType "") }}
-        <el-form-item label="{{$comment}}">
-          <el-radio-group v-model="form.{{$field}}">
+${else if and (eq $column.HtmlType  "radio") (ne $dictType "") }
+        <el-form-item label="${$comment}">
+          <el-radio-group v-model="form.${$field}">
             <el-radio
-              v-for="dict in {{$field}}Options"
+              v-for="dict in ${$field}Options"
               :key="dict.key"
-              {{if or (eq $column.GoType "int")  (eq $column.GoType  "int64")}}:label="parseInt(dict.key)"{{else}}:label="dict.key"{{end}}
-            >{{"{{"}}dict.value{{"}}"}}</el-radio>
+              ${if or (eq $column.GoType "int")  (eq $column.GoType  "int64")}:label="parseInt(dict.key)"${else}:label="dict.key"${end}
+            >${"${"}dict.value${"}"}</el-radio>
           </el-radio-group>
         </el-form-item>
-{{else if and (eq $column.HtmlType "radio") $dictType }}
-        <el-form-item label="{{$comment}}">
-          <el-radio-group v-model="form.{{$field}}">
+${else if and (eq $column.HtmlType "radio") $dictType }
+        <el-form-item label="${$comment}">
+          <el-radio-group v-model="form.${$field}">
             <el-radio label="1">请选择字典生成</el-radio>
           </el-radio-group>
         </el-form-item>
-{{else if eq $column.HtmlType  "datetime"}}
-        <el-form-item label="{{$comment}}" prop="{{$field}}">
+${else if eq $column.HtmlType  "datetime"}
+        <el-form-item label="${$comment}" prop="${$field}">
           <el-date-picker clearable size="small" style="width: 200px"
-            v-model="form.{{$field}}"
+            v-model="form.${$field}"
             type="date"
             value-format="yyyy-MM-dd"
-            placeholder="选择{{$comment}}">
+            placeholder="选择${$comment}">
           </el-date-picker>
         </el-form-item>
-{{else if eq $column.HtmlType  "textarea"}}
-        <el-form-item label="{{$comment}}" prop="{{$field}}">
-          <el-input v-model="form.{{$field}}" type="textarea" placeholder="请输入内容" />
+${else if eq $column.HtmlType  "textarea"}
+        <el-form-item label="${$comment}" prop="${$field}">
+          <el-input v-model="form.${$field}" type="textarea" placeholder="请输入内容" />
         </el-form-item>
-{{end}}
-{{end}}
-{{end}}
+${end}
+${end}
+${end}
 
           </el-form>
           <div slot="footer" class="dialog-footer">
@@ -211,12 +211,12 @@
 
 
 <script>
-import { list{{.table.BusinessName|UcFirst}}, get{{.table.BusinessName|UcFirst}}, del{{.table.BusinessName|UcFirst}}, add{{.table.BusinessName|UcFirst}}, update{{.table.BusinessName|UcFirst}} } from '@/api/{{.table.ModuleName}}/{{.table.BusinessName}}'
+import { list${.table.BusinessName|UcFirst}, get${.table.BusinessName|UcFirst}, del${.table.BusinessName|UcFirst}, add${.table.BusinessName|UcFirst}, update${.table.BusinessName|UcFirst} } from '@/api/${.table.ModuleName}/${.table.BusinessName}'
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 
 export default {
-  name: "{{.table.BusinessName}}",
+  name: "${.table.BusinessName}",
   components: { Treeselect },
   data() {
     return {
@@ -224,95 +224,95 @@ export default {
           loading: true,
           // 显示搜索条件
           showSearch: true,
-          // {{.table.FunctionName}}表格数据
-          {{.table.BusinessName}}List: [],
-           // ${functionName}树选项
-           {{.table.BusinessName}}Options: [],
+          // ${.table.FunctionName}表格数据
+          ${.table.BusinessName}List: [],
+           // ${.table.FunctionName}树选项
+           ${.table.BusinessName}Options: [],
           // 弹出层标题
           title: "",
           // 是否显示弹出层
           open: false,
-          {{range  $index,$column := $columns}}
-           {{$comment :=$column.ColumnComment}}
-           {{if ne $column.DictType ""}}
+          ${range  $index,$column := $columns}
+           ${$comment :=$column.ColumnComment}
+           ${if ne $column.DictType ""}
                  // $comment字典
-                 {{$column.ColumnName}}Options: [],
-           {{end}}
-          {{end}}
+                 ${$column.ColumnName}Options: [],
+           ${end}
+          ${end}
           // 查询参数
         queryParams: {
-          {{range  $index,$column := $columns}}
-          {{$velocityCount := add $index 1}}
-          {{if eq $column.IsQuery "1"}}
-          {{$column.ColumnName}}: null
-          {{end}}
-          {{end}}
+          ${range  $index,$column := $columns}
+          ${$velocityCount := add $index 1}
+          ${if eq $column.IsQuery "1"}
+          ${$column.ColumnName}: null
+          ${end}
+          ${end}
         },
         // 表单参数
           form: {},
           // 表单校验
           rules: {
-              {{range  $index,$column := $columns}}
-              {{$velocityCount := add $index 1}}
-              {{if and (eq $column.IsRequired "1") (eq $column.IsPk "0")}}
-              {{$comment:=$column.ColumnComment}}
-              {{$column.ColumnName}}: [
-                { required: true, message: "{{$comment}}不能为空", trigger: "blur" }
-              ]{{if ne $velocityCount (len $columns)}},{{end}}
-              {{end}}
-              {{end}}
+              ${range  $index,$column := $columns}
+              ${$velocityCount := add $index 1}
+              ${if and (eq $column.IsRequired "1") (eq $column.IsPk "0")}
+              ${$comment:=$column.ColumnComment}
+              ${$column.ColumnName}: [
+                { required: true, message: "${$comment}不能为空", trigger: "blur" }
+              ]${if ne $velocityCount (len $columns)},${end}
+              ${end}
+              ${end}
           }
       };
     },
     created() {
         this.getList();
-    {{range  $index,$column := $columns}}
-    {{if ne $column.DictType ""}}
-        this.getDicts("{{$column.DictType}}").then(response => {
-          this.{{$column.ColumnName}}Options = response.data.values || [];
+    ${range  $index,$column := $columns}
+    ${if ne $column.DictType ""}
+        this.getDicts("${$column.DictType}").then(response => {
+          this.${$column.ColumnName}Options = response.data.values || [];
         });
-    {{end}}
-    {{end}}
+    ${end}
+    ${end}
     },
 
     methods: {
-        /** 查询{{.table.FunctionName}}列表 */
+        /** 查询${.table.FunctionName}列表 */
         getList() {
           this.loading = true;
-          list{{.table.BusinessName|UcFirst}}(this.queryParams).then(response => {
-            this.{{.table.BusinessName}}List = this.handleTree(response.data, "{{$treeCode}}", "{{$treeParentCode}}");
+          list${.table.BusinessName|UcFirst}(this.queryParams).then(response => {
+            this.${.table.BusinessName}List = this.handleTree(response.data, "${$treeCode}", "${$treeParentCode}");
             this.loading = false;
           });
         },
-        /** 转换${functionName}数据结构 */
+        /** 转换${.table.FunctionName}数据结构 */
         normalizer(node) {
           if (node.children && !node.children.length) {
             delete node.children;
           }
           return {
-            id: node.{{$treeCode}},
-            label: node.{{$treeName}},
+            id: node.${$treeCode},
+            label: node.${$treeName},
             children: node.children
           };
         },
         /** 查询部门下拉树结构 */
         getTreeselect() {
-          list{{.table.BusinessName}}().then(response => {
-            this.{{.table.BusinessName}}Options = [];
-            const data = { {{$treeCode}}: 0, {{$treeName}}: '顶级节点', children: [] };
-            data.children = this.handleTree(response.data, "{{$treeCode}}", "{{$treeParentCode}}");
-            this.{{.table.BusinessName}}Options.push(data);
+          list${.table.BusinessName}().then(response => {
+            this.${.table.BusinessName}Options = [];
+            const data = { ${$treeCode}: 0, ${$treeName}: '顶级节点', children: [] };
+            data.children = this.handleTree(response.data, "${$treeCode}", "${$treeParentCode}");
+            this.${.table.BusinessName}Options.push(data);
           });
         },
-        {{range  $index,$column := $columns}}
-        {{if ne $column.DictType ""}}
-        {{$comment:=$column.ColumnComment}}
+        ${range  $index,$column := $columns}
+        ${if ne $column.DictType ""}
+        ${$comment:=$column.ColumnComment}
         // $comment字典翻译
-        {{$column.ColumnName}}Format(row, column) {
-          return this.selectDictLabel{{if eq $column.HtmlType "checkbox"}}s{{end}}(this.{{$column.ColumnName}}Options, row.{{$column.ColumnName}});
+        ${$column.ColumnName}Format(row, column) {
+          return this.selectDictLabel${if eq $column.HtmlType "checkbox"}s${end}(this.${$column.ColumnName}Options, row.${$column.ColumnName});
         },
-        {{end}}
-        {{end}}
+        ${end}
+        ${end}
         // 取消按钮
         cancel() {
           this.open = false;
@@ -321,18 +321,18 @@ export default {
         // 表单重置
         reset() {
           this.form = {
-    {{range  $index,$column := $columns}}
-    {{$velocityCount := add $index 1}}
-    {{if eq $column.HtmlType  "radio"}}
-            {{$column.ColumnName}}: {{if or (eq $column.GoType  "int")  (eq $column.GoType "int64") }}0{{else}}"0"{{end}} {{if ne $velocityCount  (len $columns)}},{{end}}
+    ${range  $index,$column := $columns}
+    ${$velocityCount := add $index 1}
+    ${if eq $column.HtmlType  "radio"}
+            ${$column.ColumnName}: ${if or (eq $column.GoType  "int")  (eq $column.GoType "int64") }0${else}"0"${end} ${if ne $velocityCount  (len $columns)},${end}
 
-    {{else if eq $column.HtmlType  "checkbox"}}
-            {{$column.ColumnName}}: []{{if ne $velocityCount  (len $columns)}},{{end}}
+    ${else if eq $column.HtmlType  "checkbox"}
+            ${$column.ColumnName}: []${if ne $velocityCount  (len $columns)},${end}
 
-    {{else}}
-            {{$column.ColumnName}}: null{{if ne $velocityCount  (len $columns)}},{{end}}
-    {{end}}
-    {{end}}
+    ${else}
+            ${$column.ColumnName}: null${if ne $velocityCount  (len $columns)},${end}
+    ${end}
+    ${end}
           };
           this.resetForm("form");
         },
@@ -352,37 +352,37 @@ export default {
       this.reset();
       this.getTreeselect();
       this.open = true;
-      this.title = "添加{{.table.FunctionName}}";
+      this.title = "添加${.table.FunctionName}";
     },
     /** 修改按钮操作 */
     handleUpdate(row) {
       this.reset();
       this.getTreeselect();
       if (row != null) {
-        this.form.{{$treeParentCode}} = row.{{$treeCode}};
+        this.form.${$treeParentCode} = row.${$treeCode};
       }
-      get{{.table.BusinessName}}({{$pkColumnName}}).then(response => {
+      get${.table.BusinessName}(${$pkColumnName}).then(response => {
          this.form = response.data;
-{{range  $index,$column := $columns}}
-{{if eq $column.HtmlType  "checkbox"}}
-        this.form.{{$column.ColumnName}} = this.form.{{$column.ColumnName}}.split(",");
-{{end}}
-{{end}}
+${range  $index,$column := $columns}
+${if eq $column.HtmlType  "checkbox"}
+        this.form.${$column.ColumnName} = this.form.${$column.ColumnName}.split(",");
+${end}
+${end}
         this.open = true;
-        this.title = "修改{{.table.FunctionName}}";
+        this.title = "修改${.table.FunctionName}";
       });
     },
     /** 提交按钮 */
     submitForm() {
       this.$refs["form"].validate(valid => {
         if (valid) {
-{{range  $index,$column := $columns}}
-{{if eq $column.HtmlType  "checkbox"}}
-          this.form.{{$column.ColumnName}} = this.form.{{$column.ColumnName}}.join(",");
-{{end}}
-{{end}}
-          if (this.form.{{$pkColumnName}} != null) {
-            update{{.table.BusinessName|UcFirst}}(this.form).then(response => {
+${range  $index,$column := $columns}
+${if eq $column.HtmlType  "checkbox"}
+          this.form.${$column.ColumnName} = this.form.${$column.ColumnName}.join(",");
+${end}
+${end}
+          if (this.form.${$pkColumnName} != null) {
+            update${.table.BusinessName|UcFirst}(this.form).then(response => {
               if (response.code === 0) {
                 this.msgSuccess("修改成功");
                 this.open = false;
@@ -390,7 +390,7 @@ export default {
               }
             });
           } else {
-            add{{.table.BusinessName|UcFirst}}(this.form).then(response => {
+            add${.table.BusinessName|UcFirst}(this.form).then(response => {
               if (response.code === 0) {
                 this.msgSuccess("新增成功");
                 this.open = false;
@@ -403,12 +403,12 @@ export default {
     },
     /** 删除按钮操作 */
     handleDelete(row) {
-      this.$confirm('是否确认删除{{.table.FunctionName}}编号为"' + row.{{$pkColumnName}} + '"的数据项?', "警告", {
+      this.$confirm('是否确认删除${.table.FunctionName}编号为"' + row.${$pkColumnName} + '"的数据项?', "警告", {
           confirmButtonText: "确定",
           cancelButtonText: "取消",
           type: "warning"
         }).then(function() {
-          return del{{.table.BusinessName|UcFirst}}(row.{{$pkColumnName}});
+          return del${.table.BusinessName|UcFirst}(row.${$pkColumnName});
         }).then(() => {
           this.getList();
           this.msgSuccess("删除成功");