forked from lock-upme/OPMS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
base.go
executable file
·54 lines (45 loc) · 1.25 KB
/
base.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package controllers
import (
//"opms/initial"
"fmt"
. "opms/models/messages"
"strconv"
"strings"
"github.com/astaxie/beego"
)
type BaseController struct {
beego.Controller
IsLogin bool
//UserInfo string
UserUserId int64
UserUsername string
UserAvatar string
}
func (this *BaseController) Prepare() {
userLogin := this.GetSession("userLogin")
if userLogin == nil {
this.IsLogin = false
} else {
this.IsLogin = true
tmp := strings.Split((this.GetSession("userLogin")).(string), "||")
userid, _ := strconv.Atoi(tmp[0])
longid := int64(userid)
this.Data["LoginUserid"] = longid
this.Data["LoginUsername"] = tmp[1]
this.Data["LoginAvatar"] = tmp[2]
this.UserUserId = longid
this.UserUsername = tmp[1]
this.UserAvatar = tmp[2]
this.Data["PermissionModel"] = this.GetSession("userPermissionModel")
this.Data["PermissionModelc"] = this.GetSession("userPermissionModelc")
//消息
msgcondArr := make(map[string]string)
msgcondArr["touserid"] = fmt.Sprintf("%d", longid)
msgcondArr["view"] = "1"
countTopMessage := CountMessages(msgcondArr)
_, _, topMessages := ListMessages(msgcondArr, 1, 10)
this.Data["topMessages"] = topMessages
this.Data["countTopMessage"] = countTopMessage
}
this.Data["IsLogin"] = this.IsLogin
}