wangchuanjin vor 2 Jahren
Ursprung
Commit
573711a755
2 geänderte Dateien mit 7 neuen und 2 gelöschten Zeilen
  1. 6 1
      go-xweb/httpsession/redissessionstore.go
  2. 1 1
      go-xweb/httpsession/session.go

+ 6 - 1
go-xweb/httpsession/redissessionstore.go

@@ -4,9 +4,11 @@ package httpsession
 
 import (
 	"encoding/json"
+	"strconv"
 	"sync"
 	"time"
 
+	. "app.yhyue.com/moapp/jybase/common"
 	"app.yhyue.com/moapp/jybase/redis"
 )
 
@@ -32,7 +34,7 @@ func (store *redisStore) SetMaxAge(maxAge time.Duration) {
 
 //取数据,使用redis的超时,来控制session超时
 func (store *redisStore) Get(id Id, key string) interface{} {
-	return store.GetMultiple(id)[key]
+	return store.GetMultiple(id)
 }
 
 //同时获取多个值
@@ -52,6 +54,9 @@ func (store *redisStore) GetMultiple(id Id) map[string]interface{} {
 	redis.SetExpire("session", string(id), timeout)
 	store.last = time.Now()
 	lock(id).Unlock()
+	if m["userId"] != nil && Int64All(m["positionType"]) == 1 {
+		m["userId"] = strconv.FormatInt(Int64All(m["positionId"]), 10)
+	}
 	return m
 }
 

+ 1 - 1
go-xweb/httpsession/session.go

@@ -23,7 +23,7 @@ func (session *Session) Get(key string) interface{} {
 	return session.manager.store.Get(session.id, key)
 }
 
-func (session *Session) GetMultiple(keys ...string) map[string]interface{} {
+func (session *Session) GetMultiple() map[string]interface{} {
 	return session.manager.store.GetMultiple(session.id)
 }