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 }