Quellcode durchsuchen

Merge remote-tracking branch 'origin/master'

yxh vor 4 Jahren
Ursprung
Commit
7a8e4c0f29

+ 5 - 1
app/controller/admin/gen_table.go

@@ -5,6 +5,7 @@ import (
 	"gfast/app/service/admin/gen_service"
 	"gfast/app/service/admin/user_service"
 	"gfast/library/response"
+	"github.com/gogf/gf/os/gmutex"
 	"strings"
 
 	"github.com/gogf/gf/encoding/gcompress"
@@ -23,6 +24,8 @@ import (
 
 type Gen struct{}
 
+var mu = gmutex.New()
+
 // @Summary 查询数据库列表
 // @Description 查询数据库列表
 // @Tags 系统工具
@@ -317,7 +320,7 @@ func (c *Gen) genData(tableId int64) (data g.MapStrStr, entity *gen_table.Entity
 	apiJsValue := ""
 	vueKey := "vm/html/" + entity.BusinessName + "_vue.js.vm"
 	vueValue := ""
-
+	mu.Lock()
 	view := gview.New()
 	view.BindFuncMap(g.Map{
 		"UcFirst": func(str string) string {
@@ -331,6 +334,7 @@ func (c *Gen) genData(tableId int64) (data g.MapStrStr, entity *gen_table.Entity
 		"Paths":      []string{"template"},
 		"Delimiters": []string{"${", "}"},
 	})
+	mu.Unlock()
 	//树形菜单选项
 	var options g.Map
 	if entity.TplCategory == "tree" {

+ 7 - 1
library/response/home/response.go

@@ -12,6 +12,7 @@ import (
 	"github.com/gogf/gf/container/gvar"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/net/ghttp"
+	"github.com/gogf/gf/os/gmutex"
 	"github.com/gogf/gf/os/gview"
 	"github.com/gogf/gf/util/gconv"
 )
@@ -20,13 +21,18 @@ type Response struct {
 	*response.Response
 }
 
-var ResponseInstance = new(Response)
+var (
+	ResponseInstance = new(Response)
+	mu               = gmutex.New()
+)
 
 func WriteTpl(r *ghttp.Request, tpl string, params ...gview.Params) error {
 	return ResponseInstance.WriteTpl(r, tpl, params...)
 }
 
 func (res *Response) WriteTpl(r *ghttp.Request, tpl string, params ...gview.Params) error {
+	mu.Lock()
+	defer mu.Unlock()
 	v := g.View()
 	v.SetPath("template/cms")
 	//绑定模板中需要用到的方法

+ 7 - 12
library/response/response.go

@@ -4,6 +4,7 @@ import (
 	"gfast/library/utils"
 	"github.com/gogf/gf/frame/g"
 	"github.com/gogf/gf/net/ghttp"
+	"github.com/gogf/gf/os/gmutex"
 	"github.com/gogf/gf/os/gview"
 	"github.com/gogf/gf/text/gstr"
 	"github.com/gogf/gf/util/gconv"
@@ -23,7 +24,10 @@ type Response struct {
 	Msg string `json:"msg"`
 }
 
-var response = new(Response)
+var (
+	response = new(Response)
+	mu       = gmutex.New()
+)
 
 func JsonExit(r *ghttp.Request, code int, msg string, data ...interface{}) {
 	response.JsonExit(r, code, msg, data...)
@@ -88,6 +92,8 @@ func (res *Response) FailJson(isExit bool, r *ghttp.Request, msg string, data ..
 
 //模板输出
 func (res *Response) WriteTpl(r *ghttp.Request, tpl string, view *gview.View, params ...gview.Params) error {
+	mu.Lock()
+	defer mu.Unlock()
 	//绑定模板中需要用到的方法
 	view.BindFuncMap(g.Map{
 		// 根据长度i来切割字符串
@@ -107,17 +113,6 @@ func (res *Response) WriteTpl(r *ghttp.Request, tpl string, view *gview.View, pa
 		"timeFormatDateTime": func(time interface{}) string {
 			return utils.TimeStampToDateTime(gconv.Int64(time))
 		},
-		// 判断是否有子菜单
-		"isSon": func(id, menus interface{}) bool {
-			i := gconv.Int(id)
-			m := gconv.SliceMap(menus)
-			for _, v := range m {
-				if gconv.Int(v["classification_pid"]) == i {
-					return true
-				}
-			}
-			return false
-		},
 		"add": func(a, b interface{}) int {
 			return gconv.Int(a) + gconv.Int(b)
 		},