kefu/service/token.go

26 lines
513 B
Go
Raw Permalink Normal View History

2024-12-10 02:50:12 +00:00
package service
import (
"kefu/models"
"kefu/tools"
"time"
)
func GenUserToken(info models.User) string {
userinfo := make(map[string]interface{})
userinfo["name"] = info.Name
userinfo["kefu_id"] = info.ID
userinfo["type"] = "kefu"
uRole := models.FindRoleByUserId(info.ID)
if uRole.RoleId != 0 {
userinfo["role_id"] = uRole.RoleId
} else {
userinfo["role_id"] = 2
}
userinfo["create_time"] = time.Now().Unix()
userinfo["pid"] = info.Pid
token, _ := tools.MakeToken(userinfo)
return token
}