作者 yangfu

redis

... ... @@ -7,7 +7,6 @@ import (
"strconv"
"github.com/astaxie/beego"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/pkg/redis"
"gitlab.fjmaimaimai.com/mmm-go/gocomm/time"
)
... ... @@ -60,25 +59,25 @@ func (this *BaseController) Prepare() {
this.RequestHead.SetRequestId(fmt.Sprintf("%v.%v.%s", this.RequestHead.Uid, time.GetTimeByYyyymmddhhmmss(), this.Ctx.Request.URL))
log.Debug(fmt.Sprintf("====>Recv data from uid(%d) client:\nHeadData: %s\nRequestId:%s BodyData: %s", this.RequestHead.Uid, this.Ctx.Request.Header, this.RequestHead.GetRequestId(), string(this.ByteBody)))
}
key := SWITCH_INFO_KEY
str := ""
switchInfo := &TotalSwitchStr{}
if str, _ = redis.Get(key); str == "" {
switchInfo.TotalSwitch = TOTAL_SWITCH_ON
switchInfo.MessageBody = "正常运行"
redis.Set(key, switchInfo, redis.INFINITE)
} else {
json.Unmarshal([]byte(str), switchInfo)
}
if switchInfo.TotalSwitch == TOTAL_SWITCH_OFF {
var msg *Message
msg = NewMessage(3)
msg.Errmsg = switchInfo.MessageBody
log.Info(msg.Errmsg)
this.Data["json"] = msg
this.ServeJSON()
return
}
//key := SWITCH_INFO_KEY
//str := ""
//switchInfo := &TotalSwitchStr{}
//if str, _ = redis.Get(key); str == "" {
// switchInfo.TotalSwitch = TOTAL_SWITCH_ON
// switchInfo.MessageBody = "正常运行"
// redis.Set(key, switchInfo, redis.INFINITE)
//} else {
// json.Unmarshal([]byte(str), switchInfo)
//}
//if switchInfo.TotalSwitch == TOTAL_SWITCH_OFF {
// var msg *Message
// msg = NewMessage(3)
// msg.Errmsg = switchInfo.MessageBody
// log.Info(msg.Errmsg)
// this.Data["json"] = msg
// this.ServeJSON()
// return
//}
}
func (this *BaseController) GetRequestHead() *RequestHead {
... ...