mirror of
https://github.com/kongyuebin1/dongfeng-pay.git
synced 2025-12-15 13:59:57 +08:00
重构了boss系统,添加了逻辑
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
package controllers
|
||||
|
||||
import beego "github.com/beego/beego/v2/server/web"
|
||||
import (
|
||||
"boss/datas"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
type BaseController struct {
|
||||
beego.Controller
|
||||
@@ -8,20 +11,20 @@ type BaseController struct {
|
||||
|
||||
func (c *BaseController) GenerateJSON(dataJSON interface{}) {
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
func (c *BaseController) Prepare() {
|
||||
userID, ok := c.GetSession("userID").(string)
|
||||
if !ok || userID == "" {
|
||||
//用户没有登录,或者登录到期了,则跳转登录主页面
|
||||
dataJSON := new(BaseDataJSON)
|
||||
dataJSON := new(datas.BaseDataJSON)
|
||||
dataJSON.Code = 404
|
||||
dataJSON.Msg = "登录已经过期!"
|
||||
c.Data["json"] = dataJSON
|
||||
c.ServeJSON()
|
||||
_ = c.ServeJSON()
|
||||
} else {
|
||||
//重新赋值给session
|
||||
c.SetSession("userID", userID)
|
||||
_ = c.SetSession("userID", userID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user