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.
60 lines
1.3 KiB
60 lines
1.3 KiB
package recook
|
|
|
|
import (
|
|
"net/url"
|
|
"strconv"
|
|
)
|
|
|
|
const (
|
|
actionUserinfo = "/lives/user/userinfo"
|
|
actionUsers = "/lives/user/users"
|
|
)
|
|
|
|
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
|
|
}
|
|
|
|
type ReplyUserItem struct {
|
|
UserId uint `json:"userId" mapstructure:"id"`
|
|
Nickname string `json:"nickname" mapstructure:"nickname"`
|
|
HeadImgUrl string `json:"headImgUrl" mapstructure:"headImgUrl"`
|
|
InvitationNo string `json:"invitationNo" mapstructure:"invitationNo"`
|
|
}
|
|
|
|
// @Title 批量获取会员基础信息
|
|
func (u *user) GetUsers(userIds []uint) (replyUserItem *[]ReplyUserItem, err error) {
|
|
replyUserItem = &[]ReplyUserItem{}
|
|
if len(userIds) == 0 {
|
|
return
|
|
}
|
|
strIds := []string{}
|
|
for _, id := range userIds {
|
|
strIds = append(strIds, strconv.FormatUint(uint64(id), 10))
|
|
}
|
|
err = RecookClient.Exec(actionUsers, url.Values{"ids": strIds}, replyUserItem)
|
|
if err != nil {
|
|
return
|
|
}
|
|
return
|
|
}
|