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 }