use revel 1.0.0 && go module

This commit is contained in:
lealife
2021-03-26 14:19:53 +08:00
parent 5e61291703
commit 1b006b83ad
801 changed files with 228 additions and 207009 deletions

View File

@ -23,18 +23,18 @@ type ApiBaseContrller struct {
// 得到token, 这个token是在AuthInterceptor设到Session中的
func (c ApiBaseContrller) getToken() string {
return c.Session["_token"]
return c.GetSession("_token")
}
// userId
// _userId是在AuthInterceptor设置的
func (c ApiBaseContrller) getUserId() string {
return c.Session["_userId"]
return c.GetSession("_userId")
}
// 得到用户信息
func (c ApiBaseContrller) getUserInfo() info.User {
userId := c.Session["_userId"]
userId := c.GetSession("_userId")
if userId == "" {
return info.User{}
}

View File

@ -90,7 +90,10 @@ func AuthInterceptor(c *revel.Controller) revel.Result {
if noToken && userId == "" {
// 从session中获取, api/file/getImage, api/file/getAttach, api/file/getAllAttach
// 客户端
userId, _ = c.Session["UserId"]
userIdI, _ := c.Session["UserId"]
if userIdI != nil {
userId = userIdI.(string)
}
}
c.Session["_userId"] = userId