user.go 22 KB
Newer Older
hujiebin's avatar
hujiebin committed
1 2 3
package user_cv

import (
chenweijian's avatar
chenweijian committed
4
	"encoding/json"
hujiebin's avatar
hujiebin committed
5
	"git.hilo.cn/hilo-common/_const/common"
hujiebin's avatar
hujiebin committed
6 7 8 9 10
	"git.hilo.cn/hilo-common/domain"
	"git.hilo.cn/hilo-common/mylogrus"
	"git.hilo.cn/hilo-common/resource/mysql"
	"git.hilo.cn/hilo-common/rpc"
	"gorm.io/gorm"
hujiebin's avatar
hujiebin committed
11 12
	"hilo-user/_const/enum/country_e"
	"hilo-user/_const/enum/cp_e"
hujiebin's avatar
hujiebin committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
	"hilo-user/cv/headwear_cv"
	"hilo-user/cv/medal_cv"
	"hilo-user/cv/noble_cv"
	"hilo-user/cv/property_cv"
	"hilo-user/domain/model/noble_m"
	"hilo-user/domain/model/res_m"
	"hilo-user/domain/model/user_m"
	"hilo-user/myerr"
)

type UserTiny struct {
	Id           uint64 `json:"id,omitempty"`
	ExternalId   string `json:"externalId"`
	Avatar       string `json:"avatar"`
	Nick         string `json:"nick"`
	Sex          uint8  `json:"sex"`
	Code         string `json:"code"`
	Country      string `json:"country"`
	CountryIcon  string `json:"countryIcon"`
	IsPrettyCode bool   `json:"isPrettyCode"` // 是否靓号
hujiebin's avatar
hujiebin committed
33
	Birthday     uint64 `json:"birthday"`
hujiebin's avatar
hujiebin committed
34 35 36 37 38 39 40 41 42 43 44 45 46
}

func UserToTiny(user user_m.User) *UserTiny {
	return &UserTiny{
		Id:           user.ID,
		ExternalId:   user.ExternalId,
		Avatar:       user.Avatar,
		Nick:         user.Nick,
		Sex:          user.Sex,
		Code:         user.Code,
		Country:      user.Country,
		CountryIcon:  user.CountryIcon,
		IsPrettyCode: user.IsPrettyCode(),
hujiebin's avatar
hujiebin committed
47
		Birthday:     user.Birthday,
hujiebin's avatar
hujiebin committed
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
	}
}

func UserTinyToCvTiny(user *user_m.UserTiny) *UserTiny {
	return &UserTiny{
		Id:           user.ID,
		ExternalId:   user.ExternalId,
		Avatar:       user.Avatar,
		Nick:         user.Nick,
		Sex:          user.Sex,
		Code:         user.Code,
		Country:      user.Country,
		CountryIcon:  user.CountryIcon,
		IsPrettyCode: user.IsPrettyCode,
	}
}

//用户基本信息
type CvUserBase struct {
	//不会有返回值
	Id *mysql.ID `json:"id,omitempty"`
	//头像,不存在为nil
	Avatar *string `json:"avatar"`
	//是否默认头像 true:是 false:不是
	DefaultAvatar *bool `json:"defaultAvatar"`
	//用户对外ID
	ExternalId *string `json:"externalId"`
	//昵称,不存在为nil
	Nick *string `json:"nick"`
	//签名,不存在为nil
	Description *string `json:"description"`
	//性别 1:男 2:女,不存在为nil
	Sex *uint8 `json:"sex"`
	//国家,不存在为nil
	Country *string `json:"country"`
	//国旗图标,不存在为nil
	CountryIcon *string `json:"countryIcon"`
	//邀请码
	Code         *string `json:"code"`
	IsPrettyCode bool    `json:"isPrettyCode"` // 是否靓号
hujiebin's avatar
hujiebin committed
88 89
	IsNew        bool    `json:"isNew"`        // 是否新用户
	IsLogout     bool    `json:"isLogout"`     // 是否注销
hujiebin's avatar
hujiebin committed
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106
	//生日,如果是其它人用户信息,年龄则按照是否展示显示,如果是本人,年龄则按照是否存在展示
	Birthday *uint64 `json:"birthday"`
	//是否展示年龄, 是本人才有数据,看其他用户均为nil
	IsShowAge *uint8 `json:"isShowAge"`
	//是否工会成员, 只有是自己查自己,这个才有值,其它全为nil, 20220329 数据开放:原因:产品1对1视频聊天中,公会用户视频需要送礼物。改为: 全部人可以知道是否是公会用户。
	IsTradeUnion *bool `json:"isTradeUnion"`
	//是否代理管理员, 只有自己查自己的时候才有值,其他情况为nil
	IsAgentMgr *bool `json:"isAgentMgr"`
	//工会成员,是否开启了,匹配通知,只有 isTradeUnion值为true,这里才有值,
	IsTradeUnionMatchNotification *bool `json:"isTradeUnionMatchNotification"`
	//是否VIP用户
	IsVip bool `json:"isVip"`
	//是否是官方人员
	IsOfficialStaff bool `json:"isOfficialStaff"`
	//VIP用户过期时间(只有自己查询自己,才返回)
	VipExpireTime *int64                  `json:"vipExpireTime"`
	Svip          rpc.CvSvip              `json:"svip"`      // svip结构,等级+权限
iamhujiebin's avatar
iamhujiebin committed
107
	Medals        []uint32                `json:"medals"`    // 勋章列表
hujiebin's avatar
hujiebin committed
108 109 110 111
	MedalInfo     []medal_cv.CvMedal      `json:"medalInfo"` // 勋章列表
	Headwear      *headwear_cv.CvHeadwear `json:"headwear"`  // 当前使用的头饰
	Ride          property_cv.CvProperty  `json:"ride"`      // 当前使用的座驾
	Noble         noble_cv.CvNoble        `json:"noble"`     // 当前的
hujiebin's avatar
hujiebin committed
112
	GroupRole     common.GroupRoleType    `json:"groupRole"` // 在群组的角色
hujiebin's avatar
hujiebin committed
113 114
}

chenweijian's avatar
chenweijian committed
115 116 117 118 119 120 121 122 123 124 125
type CvUserLittle struct {
	//不会有返回值
	Id *mysql.ID `json:"id,omitempty"`
	//头像,不存在为nil
	Avatar *string `json:"avatar"`
	//用户对外ID
	ExternalId *string `json:"externalId"`
	//昵称,不存在为nil
	Nick *string `json:"nick"`
}

hujiebin's avatar
hujiebin committed
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168
//批量获取用户基本信息
func GetUserBases(userIds []mysql.ID, myUserId mysql.ID) ([]*CvUserBase, error) {
	if len(userIds) == 0 {
		return []*CvUserBase{}, nil
	}
	var users []user_m.User
	if err := mysql.Db.Model(&user_m.User{}).Where("id in (?)", userIds).Find(&users).Error; err != nil {
		return nil, myerr.WrapErr(err)
	}
	vips, err := user_m.BatchGetVips(userIds)
	if err != nil {
		return nil, myerr.WrapErr(err)
	}
	svips, err := rpc.MGetUserSvip(domain.CreateModelNil(), userIds)
	if err != nil {
		mylogrus.MyLog.Errorf("MGetUserSvip fail:%v", err)
		//return nil, myerr.WrapErr(err)
	}

	headwearMap, err := headwear_cv.BatchGetCvHeadwears(userIds)
	if err != nil {
		return nil, err
	}

	logger := mylogrus.MyLog.WithField("func", "GetUserBases")
	medals, err := user_m.BatchGetUserMedalMerge(logger, mysql.Db, userIds)
	if err != nil {
		return nil, err
	}

	medals, medalInfo, err := getMedalInfoMap(mysql.Db, medals)
	if err != nil {
		return nil, err
	}

	up := user_m.UserProperty{}
	rides, err := up.BatchGet(mysql.Db, userIds)
	if err != nil {
		return nil, err
	}

	//rp := res_m.ResProperty{}
	//properties, err := rp.GetAll(mysql.Db)
chenweijian's avatar
chenweijian committed
169 170 171 172 173 174 175
	propertiesArea := make(map[int]map[uint64]property_cv.CvProperty)
	for _, v := range []int{1, 2} {
		properties, err := GetPropertyAll(mysql.Db, v)
		if err != nil {
			return nil, err
		}
		propertiesArea[v] = properties
chenweijian's avatar
chenweijian committed
176
	}
chenweijian's avatar
chenweijian committed
177
	areaMap, err := user_m.GetUserAreaMap(domain.CreateModelNil(), userIds)
hujiebin's avatar
hujiebin committed
178 179 180 181 182 183 184 185 186
	if err != nil {
		return nil, err
	}

	nobles, err := noble_m.BatchGetActiveNoble(domain.CreateModelNil(), userIds)
	if err != nil {
		return nil, err
	}

hujiebin's avatar
hujiebin committed
187
	superManagerMap, err := user_m.GetSuperManagerMap(userIds)
hujiebin's avatar
hujiebin committed
188 189 190 191 192 193 194
	if err != nil {
		return nil, err
	}

	cvUserBases := []*CvUserBase{}
	for i := 0; i < len(users); i++ {
		user := users[i]
chenweijian's avatar
chenweijian committed
195
		properties := propertiesArea[areaMap[user.ID]]
hujiebin's avatar
hujiebin committed
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216
		invisible := IfLogout(user.LogoutTime)
		invisibleAvatar := ""
		invisibleNick := user.Code
		//for _, p := range svips[user.ID].Privileges {
		//	if p.Type == 17 && p.UserSwitch { // 神秘人特权
		//		invisible = true
		//		invisibleAvatar, invisibleNick = rpc.ReplaceSvipAvatarNick(invisibleAvatar, invisibleNick, svips[user.ID].Privileges)
		//	}
		//}
		cvUserBase := &CvUserBase{
			Id:              &user.ID,
			Avatar:          StrNil(IfLogoutStr(invisible, invisibleAvatar, user.Avatar)),
			DefaultAvatar:   &user.DefaultAvatar,
			ExternalId:      StrToString(&user.ExternalId),
			Nick:            StrNil(IfLogoutNick(invisible, invisibleNick, user.Nick)),
			Description:     StrNil(IfLogoutStr(invisible, "", user.Description)),
			Sex:             TypeToUint8(&user.Sex),
			Country:         StrNil(user.Country),
			CountryIcon:     StrNil(user.CountryIcon),
			Code:            StrToString(&user.Code),
			IsPrettyCode:    user.IsPrettyCode(),
hujiebin's avatar
hujiebin committed
217
			IsNew:           user.IsNew(),
hujiebin's avatar
hujiebin committed
218 219
			IsVip:           vips[user.ID] != nil,
			IsOfficialStaff: superManagerMap[user.ID],
iamhujiebin's avatar
iamhujiebin committed
220
			Medals:          IfLogoutMedals(IfLogout(user.LogoutTime), []uint32{}, medals[user.ID]),
hujiebin's avatar
hujiebin committed
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256
			MedalInfo:       IfLogoutMedalInfo(invisible, []medal_cv.CvMedal{}, medalInfo[user.ID]),
			Ride: IfLogoutRide(IfLogout(user.LogoutTime), property_cv.CvProperty{}, property_cv.CvProperty{
				Id:             rides[user.ID],
				PicUrl:         properties[rides[user.ID]].PicUrl,
				EffectUrl:      properties[rides[user.ID]].EffectUrl,
				Using:          true,
				SenderAvatar:   properties[rides[user.ID]].SenderAvatar,
				ReceiverAvatar: properties[rides[user.ID]].ReceiverAvatar,
			}),
			Noble: noble_cv.CvNoble{
				Level:   nobles[user.ID].Level,
				EndTime: nobles[user.ID].EndTime.Unix(),
			},
		}
		if cvUserBase.Noble.Level <= 0 {
			cvUserBase.Noble.EndTime = 0
		}
		//
		if headwear, flag := headwearMap[user.ID]; flag {
			cvUserBase.Headwear = IfLogoutHeadwear(IfLogout(user.LogoutTime), nil, &headwear)
		}

		if user.ID == myUserId {
			cvUserBase.VipExpireTime = vips[user.ID]
			cvUserBase.IsShowAge = TypeToUint8(&user.IsShowAge)
			cvUserBase.Birthday = BirthdayToUint64(&user.Birthday)
		} else if user.IsShowAge == mysql.OPEN {
			cvUserBase.Birthday = BirthdayToUint64(&user.Birthday)
		}
		cvUserBase.Svip = svips[user.ID]

		cvUserBases = append(cvUserBases, cvUserBase)
	}
	return cvUserBases, nil
}

hujiebin's avatar
hujiebin committed
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
// 获取cp另一半基本信息
func GetUserBaseForCpMap(userIds []mysql.ID) (map[mysql.ID]*CvUserBase, error) {
	var res = make(map[mysql.ID]*CvUserBase)
	users, err := GetUserBasesForCp(userIds)
	if err != nil {
		return nil, err
	}
	for i, v := range users {
		if v.Id != nil {
			res[*v.Id] = users[i]
		}
	}
	return res, nil
}

// 批量获取cp另一半基本信息
func GetUserBasesForCp(userIds []mysql.ID) ([]*CvUserBase, error) {
	if len(userIds) == 0 {
		return []*CvUserBase{}, nil
	}
	var users []user_m.User
	if err := mysql.Db.Model(&user_m.User{}).Where("id in (?)", userIds).Find(&users).Error; err != nil {
		return nil, myerr.WrapErr(err)
	}
	vips, err := user_m.BatchGetVips(userIds)
	if err != nil {
		return nil, myerr.WrapErr(err)
	}
	svips, err := rpc.MGetUserSvip(domain.CreateModelNil(), userIds)
	if err != nil {
		mylogrus.MyLog.Errorf("MGetUserSvip fail:%v", err)
	}

	headwearMap, err := headwear_cv.BatchGetCvHeadwears(userIds)
	if err != nil {
		return nil, err
	}

	nobles, err := noble_m.BatchGetActiveNoble(domain.CreateModelNil(), userIds)
	if err != nil {
		return nil, err
	}

	var cvUserBases []*CvUserBase
	for i := 0; i < len(users); i++ {
		user := users[i]
		invisible := IfLogout(user.LogoutTime)
		invisibleAvatar := ""
		invisibleNick := user.Code
		cvUserBase := &CvUserBase{
			Id:            &user.ID,
			Avatar:        StrNil(IfLogoutStr(invisible, invisibleAvatar, user.Avatar)),
			DefaultAvatar: &user.DefaultAvatar,
			ExternalId:    StrToString(&user.ExternalId),
			Nick:          StrNil(IfLogoutNick(invisible, invisibleNick, user.Nick)),
			Description:   StrNil(IfLogoutStr(invisible, "", user.Description)),
			Sex:           TypeToUint8(&user.Sex),
			Country:       StrNil(user.Country),
			CountryIcon:   StrNil(user.CountryIcon),
			Code:          StrToString(&user.Code),
			IsPrettyCode:  user.IsPrettyCode(),
hujiebin's avatar
hujiebin committed
318
			IsNew:         user.IsNew(),
hujiebin's avatar
hujiebin committed
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338
			IsVip:         vips[user.ID] != nil,
			Noble: noble_cv.CvNoble{
				Level:   nobles[user.ID].Level,
				EndTime: nobles[user.ID].EndTime.Unix(),
			},
		}
		if cvUserBase.Noble.Level <= 0 {
			cvUserBase.Noble.EndTime = 0
		}
		//
		if headwear, flag := headwearMap[user.ID]; flag {
			cvUserBase.Headwear = IfLogoutHeadwear(IfLogout(user.LogoutTime), nil, &headwear)
		}
		cvUserBase.Svip = svips[user.ID]

		cvUserBases = append(cvUserBases, cvUserBase)
	}
	return cvUserBases, nil
}

hujiebin's avatar
hujiebin committed
339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366
func getMedalInfoMap(db *gorm.DB, medals map[uint64][]uint32) (map[uint64][]uint32, map[uint64][]medal_cv.CvMedal, error) {
	resMedals, err := res_m.MedalGetAllMap(db)
	if err != nil {
		return nil, nil, err
	}

	medalIds := make(map[uint64][]uint32)
	medalMap := make(map[uint64][]medal_cv.CvMedal, 0)

	// 只选择合法的勋章
	for u, i := range medals {
		medalIds[u] = make([]uint32, 0)
		medalMap[u] = make([]medal_cv.CvMedal, 0)

		for _, j := range i {
			if e, ok := resMedals[j]; ok {
				medalIds[u] = append(medalIds[u], j)
				medalMap[u] = append(medalMap[u], medal_cv.CvMedal{
					Id:        j,
					PicUrl:    e.PicUrl,
					EffectUrl: e.SvgaUrl,
				})
			}
		}
	}
	return medalIds, medalMap, nil
}

chenweijian's avatar
chenweijian committed
367
func GetPropertyAll(db *gorm.DB, area int) (map[uint64]property_cv.CvProperty, error) {
hujiebin's avatar
hujiebin committed
368 369 370 371 372 373 374
	rp := res_m.ResProperty{}
	properties, err := rp.GetAll(mysql.Db)
	if err != nil {
		return nil, err
	}

	//获取座驾头像
chenweijian's avatar
chenweijian committed
375
	propertyAvatarMap, err := (&res_m.ResPropertyAvatar{Area: area}).GetAll(mysql.Db)
hujiebin's avatar
hujiebin committed
376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451

	var userIds []uint64
	for _, value := range propertyAvatarMap {
		if value.SendUserId > 0 {
			userIds = append(userIds, value.SendUserId)
		}
		if value.ReceiverUserId > 0 {
			userIds = append(userIds, value.ReceiverUserId)
		}
	}
	//获取用户信息
	users := []user_m.User{}
	if err := db.Model(&user_m.User{}).Where("id in (?)", userIds).Find(&users).Error; err != nil {
		return nil, myerr.WrapErr(err)
	}
	userAvatarMap := map[mysql.ID]string{}
	for _, r := range users {
		userAvatarMap[r.ID] = r.Avatar
	}

	result := map[uint64]property_cv.CvProperty{}
	for _, r := range properties {

		var senderAvatar string = ""
		var receiverAvatar string = ""
		if propertyAvatar, flag := propertyAvatarMap[r.ID]; flag {
			if propertyAvatar.SendUserId > 0 {
				if avatar, flag := userAvatarMap[propertyAvatar.SendUserId]; flag {
					senderAvatar = avatar
				}
			}
			if propertyAvatar.ReceiverUserId > 0 {
				if avatar, flag := userAvatarMap[propertyAvatar.ReceiverUserId]; flag {
					receiverAvatar = avatar
				}
			}
		}

		result[r.ID] = property_cv.CvProperty{
			Id:             r.ID,
			PicUrl:         r.PicUrl,
			EffectUrl:      r.EffectUrl,
			SenderAvatar:   senderAvatar,
			ReceiverAvatar: receiverAvatar,
		}
	}
	return result, nil
}

func GetUserBaseMap(userIds []mysql.ID, myUserId mysql.ID) (map[mysql.ID]*CvUserBase, error) {
	userBases, err := GetUserBases(userIds, myUserId)
	if err != nil {
		return nil, err
	}
	//转换成map
	mapIdUser := map[mysql.ID]*CvUserBase{}
	for i := 0; i < len(userBases); i++ {
		mapIdUser[*userBases[i].Id] = userBases[i]
	}
	return mapIdUser, nil
}

type CvUserTiny struct {
	Id           uint64 `json:"id,omitempty"`
	ExternalId   string `json:"externalId"`
	Avatar       string `json:"avatar"`
	Nick         string `json:"nick"`
	Sex          uint8  `json:"sex"`
	Code         string `json:"code"`
	Country      string `json:"country"`
	CountryIcon  string `json:"countryIcon"`
	IsPrettyCode bool   `json:"isPrettyCode"` // 是否靓号
	IsLogout     bool   `json:"isLogout"`     //是否注销 true:已经注销, false:没有注销
	//生日,如果是其它人用户信息,年龄则按照是否展示显示,如果是本人,年龄则按照是否存在展示
	Birthday *uint64 `json:"birthday"`
}
hujiebin's avatar
hujiebin committed
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496

//用户详细信息
type CvUserDetail struct {
	CvUserBase
	//统计:我喜欢多少人
	ILikeCount *uint32 `json:"iLikeCount"`
	//统计:多少人喜欢你, (本才才有数据,不是本人,数据为nil)
	LikeCount *uint32 `json:"likeCount"`
	//统计:多少人访问你
	VisitCount *uint32 `json:"visitCount"`
	//消息提醒, 1:开启,2:关闭
	IsPush *uint8 `json:"isPush"`
	//钻石数量(本人才有数据,不是本人,数据为nil)
	DiamondNum *uint32 `json:"diamondNum"`
	//粉钻数量(本人才有数据,不是本人,数据为nil)
	PinkDiamondNum *uint32 `json:"pinkDiamondNum"`
	//是否喜欢(本人没有数据,//20210205 已废弃nil,产品说:可以自己喜欢自己)
	IsLike *bool `json:"isLike"`
	//ID
	//ID *mysql.ID `json:"id,omitempty"`
	//是否工会成员, 只有是自己查自己,这个才有值,其它全为nil
	//IsTradeUnion *bool `json:"isTradeUnion"`
	//工会成员,是否开启了,匹配通知,只有 isTradeUnion值为true,这里才有值,
	//IsTradeUnionMatchNotification *bool `json:"isTradeUnionMatchNotification"`
	//是否可以免费通话,自己本人没有数据
	//IsVideoFreeCan *bool `json:"isVideoCanFree"`
	//别人是否喜欢我,自己本人没有数据 (20210205 已废弃nil,产品说:可以自己喜欢自己)
	IsLikeMe          *bool                 `json:"isLikeMe"`
	HeartValue        uint32                `json:"heartValue"`               // 与我之间永恒之心的值
	HeartValueMax     uint32                `json:"heartValueMax"`            // 与我之间永恒之心的最大值(0代表没有永恒之心,即没有相互关注)
	MeetDays          uint                  `json:"meetDays"`                 // 成长关系建立的时间(天数)
	WealthUserGrade   uint32                `json:"wealthUserGrade"`          //财富等级
	CharmUserGrade    uint32                `json:"charmUserGrade"`           //魅力等级
	ActivityUserGrade uint32                `json:"activityUserGrade"`        //活跃等级
	CurrentRoom       string                `json:"currentRoom"`              // 当前用户所在房间(产品叫“群组”)
	MyGroupPower      uint64                `json:"myGroupPower"`             // 当前用户所在势力
	MyGroupPowerName  string                `json:"myGroupPowerName"`         // 当前用户所在势力绑定群组的名称
	GroupPower        rpc.CvGroupPowerInfo  `json:"groupPower"`               // 家族
	GroupId           string                `json:"groupId"`                  // 当前用户拥有的群组id(产品叫“群组”),如果没有则为空,拥有多个,返回第一个
	PhoneInfo         *user_m.UserPhoneInfo `json:"phoneInfo"`                // 用户绑定的手机信息
	ThirdList         []int8                `json:"thirdList"`                // 用户绑定的第三方平台列表;类型 1:phone, 2:google, 3:facebook 4:apple 5:wechat" Enums(1,2,3,4,5)
	CountryManager    *CVCountryManager     `json:"countryManager,omitempty"` // 国家管理员
	Cp                *CvCp                 `json:"cp,omitempty"`             // cp信息
}

chenweijian's avatar
chenweijian committed
497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535
//用户详细信息-在房间里面时需要的
type CvUserDetailRoom struct { //不会有返回值
	//不会有返回值
	Id *mysql.ID `json:"id,omitempty"`
	//头像,不存在为nil
	Avatar *string `json:"avatar"`
	//是否默认头像 true:是 false:不是
	DefaultAvatar *bool `json:"defaultAvatar"`
	//用户对外ID
	ExternalId *string `json:"externalId"`
	//昵称,不存在为nil
	Nick *string `json:"nick"`
	//性别 1:男 2:女,不存在为nil
	Sex *uint8 `json:"sex"`
	//国家,不存在为nil
	Country *string `json:"country"`
	//国旗图标,不存在为nil
	CountryIcon *string `json:"countryIcon"`
	//邀请码
	Code         *string `json:"code"`
	IsPrettyCode bool    `json:"isPrettyCode"` // 是否靓号
	//生日,如果是其它人用户信息,年龄则按照是否展示显示,如果是本人,年龄则按照是否存在展示
	Birthday *uint64 `json:"birthday"`
	//是否展示年龄, 是本人才有数据,看其他用户均为nil
	IsShowAge *uint8 `json:"isShowAge"`
	//是否VIP用户
	IsVip             bool                    `json:"isVip"`
	Svip              rpc.CvSvip              `json:"svip"`                     // svip结构,等级+权限
	Medals            []uint32                `json:"medals"`                   // 勋章列表
	Noble             noble_cv.CvNoble        `json:"noble"`                    // 当前的
	CountryManager    *CVCountryManager       `json:"countryManager,omitempty"` // 国家管理员
	Headwear          *headwear_cv.CvHeadwear `json:"headwear"`                 // 当前使用的头饰
	WealthUserGrade   uint32                  `json:"wealthUserGrade"`          //财富等级
	CharmUserGrade    uint32                  `json:"charmUserGrade"`           //魅力等级
	ActivityUserGrade uint32                  `json:"activityUserGrade"`        //活跃等级
	GroupPower        rpc.CvGroupPowerInfo    `json:"groupPower"`               // 家族
	//是否喜欢(本人没有数据,//20210205 已废弃nil,产品说:可以自己喜欢自己)
	IsLike *bool `json:"isLike"`
	//别人是否喜欢我,自己本人没有数据 (20210205 已废弃nil,产品说:可以自己喜欢自己)
chenweijian's avatar
chenweijian committed
536 537
	IsLikeMe *bool     `json:"isLikeMe"`
	Cp       *CvCpTiny `json:"cp,omitempty"` // cp信息
chenweijian's avatar
chenweijian committed
538 539
}

hujiebin's avatar
hujiebin committed
540 541 542 543 544 545 546 547 548 549 550 551 552 553 554
// cv国家管理人员
type CVCountryManager struct {
	Country string                   `json:"country"`                    // 国家name
	Role    country_e.CountryMgrRole `json:"role" swaggertype:"integer"` // 角色 1:国家管理员 2:国家助理
}

// cp信息
type CvCp struct {
	CpUserInfo      *CvUserBase   `json:"cpUserInfo"`      // cp用户信息
	CpLevel         CvCpLevel     `json:"cpLevel"`         // cp等级
	MyPrivilegeList []CvPrivilege `json:"myPrivilegeList"` // 等级特权
	CreatedUnix     int64         `json:"createdUnix"`     // cp创建时间
	CpDays          int           `json:"cpDays"`          // cp天数
}

chenweijian's avatar
chenweijian committed
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581
// cp信息
type CvCpTiny struct {
	CpUserInfo      *CvCpUser     `json:"cpUserInfo"`      // cp用户信息
	CpLevel         CvCpLevel     `json:"cpLevel"`         // cp等级
	MyPrivilegeList []CvPrivilege `json:"myPrivilegeList"` // 等级特权
	CreatedUnix     int64         `json:"createdUnix"`     // cp创建时间
	CpDays          int           `json:"cpDays"`          // cp天数
}

type CvCpUser struct {
	//不会有返回值
	Id *mysql.ID `json:"id,omitempty"`
	//头像,不存在为nil
	Avatar *string `json:"avatar"`
	//用户对外ID
	ExternalId *string `json:"externalId"`
	//昵称,不存在为nil
	Nick *string `json:"nick"`
	//性别 1:男 2:女,不存在为nil
	Sex *uint8 `json:"sex"`
	//邀请码
	Code     *string                 `json:"code"`
	Headwear *headwear_cv.CvHeadwear `json:"headwear"` // 当前使用的头饰
	Svip     rpc.CvSvip              `json:"svip"`     // svip结构,等级+权限
	Noble    noble_cv.CvNoble        `json:"noble"`    // 当前的
}

hujiebin's avatar
hujiebin committed
582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600
// cp关系
type CvCpRelation struct {
	CpId         uint64 `json:"cpId"`
	UserId       uint64 `json:"userId"`
	CpUserId     uint64 `json:"cpUserId"`
	CpUserAvatar string `json:"cpUserAvatar,omitempty"`
}

// cp等级
type CvCpLevel struct {
	Level  cp_e.CpLevel `json:"level"`           // 等级 0:无称号 1:恋爱CP 2:甜蜜CP 3:忠诚CP 4:炽热CP 5:荣耀CP
	Points uint32       `json:"points"`          // CP值
	Title  string       `json:"title,omitempty"` // 称号翻译
}

// 特权信息
type CvPrivilege struct {
	Type cp_e.CpPrivilege `json:"type"` // 特权id 1:空间 2:横幅 3:等级勋章 4:证书 5:进场特效 6:头像头饰 7:动态资料卡 8:麦位特效
}
chenweijian's avatar
chenweijian committed
601 602 603 604 605 606 607 608 609

func UserBaseToUserLittle(base *CvUserBase) *CvUserLittle {
	return &CvUserLittle{
		Id:         base.Id,
		Avatar:     base.Avatar,
		ExternalId: base.ExternalId,
		Nick:       base.Nick,
	}
}
chenweijian's avatar
chenweijian committed
610 611 612 613 614 615 616

func CvUserDetailToCvUserDetailRoom(info *CvUserDetail) *CvUserDetailRoom {
	res := new(CvUserDetailRoom)
	jData, _ := json.Marshal(info)
	_ = json.Unmarshal(jData, &res)
	return res
}