You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
536 B
35 lines
536 B
5 years ago
|
package recook
|
||
|
|
||
|
import (
|
||
|
"net/url"
|
||
|
"strconv"
|
||
|
)
|
||
|
|
||
|
const (
|
||
|
actionUserinfo = "/live/user/userinfo"
|
||
|
)
|
||
|
|
||
|
type user struct {
|
||
|
}
|
||
|
|
||
|
var User *user
|
||
|
|
||
|
func init() {
|
||
|
User = &user{}
|
||
|
}
|
||
|
|
||
|
type Userinfo struct {
|
||
|
UserId uint `json:"userId"`
|
||
|
}
|
||
|
|
||
|
func (u *user) GetUserId(id uint, token string) uint {
|
||
|
userinfo := &Userinfo{}
|
||
|
if err := RecookClient.Exec(actionUserinfo, url.Values{}, userinfo, map[string]string{
|
||
|
"X-Recook-ID": strconv.FormatUint(uint64(id), 10),
|
||
|
"X-Recook-Token": token,
|
||
|
}); err != nil {
|
||
|
return 0
|
||
|
}
|
||
|
return userinfo.UserId
|
||
|
}
|