由gopath形式改为module

This commit is contained in:
kongyuebin
2021-04-27 15:33:49 +08:00
parent aef4dbb33c
commit 77d895e83a
1117 changed files with 332447 additions and 20 deletions

View File

@@ -0,0 +1,27 @@
package controllers
import beego "github.com/beego/beego/v2/server/web"
type BaseController struct {
beego.Controller
}
func (c *BaseController) GenerateJSON(dataJSON interface{}) {
c.Data["json"] = dataJSON
c.ServeJSON()
}
func (c *BaseController) Prepare() {
userID, ok := c.GetSession("userID").(string)
if !ok || userID == "" {
//用户没有登录,或者登录到期了,则跳转登录主页面
dataJSON := new(BaseDataJSON)
dataJSON.Code = 404
dataJSON.Msg = "登录已经过期!"
c.Data["json"] = dataJSON
c.ServeJSON()
} else {
//重新赋值给session
c.SetSession("userID", userID)
}
}