修改引用头部,不是用ctx
This commit is contained in:
@@ -2,7 +2,6 @@ package act{id}
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
service2 "github.com/ayflying/utility_go/service"
|
service2 "github.com/ayflying/utility_go/service"
|
||||||
"github.com/gogf/gf/v2/os/gctx"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type sAct{id} struct {
|
type sAct{id} struct {
|
||||||
@@ -14,7 +13,7 @@ func New() *sAct{id} {
|
|||||||
|
|
||||||
var (
|
var (
|
||||||
ActId = {id}
|
ActId = {id}
|
||||||
ctx = gctx.New()
|
Name = ""
|
||||||
)
|
)
|
||||||
|
|
||||||
type Data struct {
|
type Data struct {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ type s{name} struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ctx = gctx.New()
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func New() *s{name} {
|
func New() *s{name} {
|
||||||
|
|||||||
@@ -62,9 +62,9 @@ func MiddlewareAdmin(r *ghttp.Request) {
|
|||||||
ip := r.GetClientIp()
|
ip := r.GetClientIp()
|
||||||
r.SetCtxVar("ip", ip)
|
r.SetCtxVar("ip", ip)
|
||||||
|
|
||||||
get := r.Cookie.Get("uid")
|
getUid := r.Cookie.Get("uid")
|
||||||
|
|
||||||
if get == nil {
|
if getUid == nil {
|
||||||
//调试模式允许不验证用户名
|
//调试模式允许不验证用户名
|
||||||
debug, _ := g.Cfg().GetWithEnv(nil, "debug")
|
debug, _ := g.Cfg().GetWithEnv(nil, "debug")
|
||||||
if !debug.Bool() {
|
if !debug.Bool() {
|
||||||
@@ -82,7 +82,13 @@ func MiddlewareAdmin(r *ghttp.Request) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uid := get.Int()
|
uid := getUid.Int()
|
||||||
|
|
||||||
|
//获取所有请求的信息
|
||||||
|
get := r.GetRequestMapStrStr()
|
||||||
|
if _, ok := get["uid"]; ok {
|
||||||
|
r.SetCtxVar("uid", get["uid"])
|
||||||
|
}
|
||||||
|
|
||||||
r.Middleware.Next()
|
r.Middleware.Next()
|
||||||
|
|
||||||
|
|||||||
@@ -223,3 +223,33 @@ func ReverseSlice[T comparable](s []T) []T {
|
|||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 道具数量合并
|
||||||
|
func (m *tools) ItemsMerge(_items ...[][]int64) [][]int64 {
|
||||||
|
var items [][]int64
|
||||||
|
for _, v := range _items {
|
||||||
|
items = append(items, v...)
|
||||||
|
}
|
||||||
|
if len(items) == 0 {
|
||||||
|
return [][]int64{}
|
||||||
|
}
|
||||||
|
var temp = make(map[int64]int64)
|
||||||
|
for _, v := range items {
|
||||||
|
if len(v) < 2 {
|
||||||
|
g.Log().Errorf(ctx, "分解的物品格式不对:%v", v)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if _, ok := temp[v[0]]; !ok {
|
||||||
|
temp[v[0]] = 0
|
||||||
|
}
|
||||||
|
temp[v[0]] += v[1]
|
||||||
|
}
|
||||||
|
|
||||||
|
items = make([][]int64, len(temp))
|
||||||
|
i := 0
|
||||||
|
for k, v := range temp {
|
||||||
|
items[i] = []int64{k, v}
|
||||||
|
i++
|
||||||
|
}
|
||||||
|
return items
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user