@@ -0,0 +1,83 @@
|
||||
package searcher
|
||||
|
||||
import (
|
||||
"91porn-server/app/service/walletser"
|
||||
"91porn-server/common/log"
|
||||
"91porn-server/models/v/usermod"
|
||||
)
|
||||
|
||||
// UserInfo UserInfo
|
||||
type UserInfo struct {
|
||||
UID *uint64 `json:"uid,omitempty"`
|
||||
Name *string `json:"name,omitempty"`
|
||||
Age *int `json:"age,omitempty"`
|
||||
Gender *string `json:"gender,omitempty"` //性别
|
||||
Portrait *string `json:"portrait,omitempty"` //头像
|
||||
Region *string `json:"region,omitempty"` //地区
|
||||
Summary *string `json:"summary,omitempty"` //简介
|
||||
VipLevel *int `json:"vipLevel,omitempty"` //vip等级
|
||||
RechargeLevel *int `json:"rechargeLevel" ` //头像显示的vip等级,累计充值决定
|
||||
SuperUser *bool `json:"superUser"` //大v
|
||||
ActiveValue *int `json:"activeValue"` //活跃度
|
||||
OfficialCert *bool `json:"officialCert"` //是否官方认证
|
||||
}
|
||||
|
||||
// UserRes UserRes
|
||||
type UserRes struct {
|
||||
UserInfo `bson:",inline"`
|
||||
HasFollowed *bool `json:"hasFollowed,omitempty"` //已关注
|
||||
FansCount *int64 `json:"fansCount,omitempty"` //粉丝数
|
||||
}
|
||||
|
||||
// MapToUserResList MapToUserResList
|
||||
func MapToUserResList(userList []*usermod.User, uid uint64) []UserRes {
|
||||
uidList := make([]uint64, len(userList))
|
||||
for i, u := range userList {
|
||||
uidList[i] = u.UID
|
||||
}
|
||||
mLevel, err := walletser.GetUidsRchgLevel(uidList)
|
||||
if err != nil {
|
||||
log.Error("GetUidsRchgLevel error", log.E(err))
|
||||
return []UserRes{}
|
||||
}
|
||||
userResList := make([]UserRes, len(userList))
|
||||
for i, userp := range userList {
|
||||
age := userp.Age()
|
||||
level := mLevel[userp.UID].Level
|
||||
userInfo := UserInfo{
|
||||
Age: &age,
|
||||
UID: &userp.UID,
|
||||
Name: &userp.Name,
|
||||
Gender: &userp.Gender,
|
||||
Portrait: &userp.Portrait,
|
||||
Region: &userp.Region,
|
||||
Summary: &userp.Summary,
|
||||
VipLevel: &userp.VipLevel,
|
||||
SuperUser: &userp.SuperUser,
|
||||
ActiveValue: &userp.ActiveValue,
|
||||
OfficialCert: &userp.OfficialCert,
|
||||
RechargeLevel: &level,
|
||||
}
|
||||
userResList[i] = UserRes{
|
||||
UserInfo: userInfo,
|
||||
}
|
||||
}
|
||||
return userResList
|
||||
}
|
||||
|
||||
// UserResMap UserResMap
|
||||
func UserResMap(uidList []uint64, uid uint64) (map[uint64]*UserRes, error) {
|
||||
userList, err := usermod.FindUsersByUID(uidList)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
userResList := MapToUserResList(userList, uid)
|
||||
m := make(map[uint64]*UserRes, len(userList))
|
||||
for _, res := range userResList {
|
||||
if res.UID != nil {
|
||||
_res := res
|
||||
m[*res.UID] = &_res
|
||||
}
|
||||
}
|
||||
return m, nil
|
||||
}
|
||||
Reference in New Issue
Block a user