From 1a803f49cce2f057b777122d0393667154c47fe6 Mon Sep 17 00:00:00 2001 From: chenweijian <820961417@qq.com> Date: Fri, 28 Jul 2023 14:36:51 +0800 Subject: [PATCH] =?UTF-8?q?4.0.5=20=E6=8E=A5=E5=8F=A3=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cv/billboard_cv/billboard.go | 30 ++++++++++-- cv/group_cv/group.go | 51 ++++++++++--------- cv/user_cv/user.go | 94 ++++++++++++++++++++++++++++++++++++ route/group_r/group_info.go | 3 +- route/group_r/group_list.go | 14 +++--- route/group_r/group_op.go | 6 +++ 6 files changed, 165 insertions(+), 33 deletions(-) diff --git a/cv/billboard_cv/billboard.go b/cv/billboard_cv/billboard.go index 3abd901..9ce2a46 100644 --- a/cv/billboard_cv/billboard.go +++ b/cv/billboard_cv/billboard.go @@ -22,7 +22,15 @@ type BillboardUserInfo struct { Num uint64 `json:"num"` } -func GetGroupTop3Consume(model *domain.Model, groupId string, myUserId uint64) ([]BillboardUserInfo, error) { +//榜单中用户信息 +type GroupTop3ConsumeUser struct { + //用户基本信息 + UserBase user_cv.TopConsumersUser `json:"userBase"` + //数值 + Num uint64 `json:"num"` +} + +func GetGroupTop3Consume(model *domain.Model, groupId string, myUserId uint64) ([]GroupTop3ConsumeUser, error) { now := time.Now() period := now.Format(utils.COMPACT_MONTH_FORMAT) data, err := getGroupTop3Consume(period, groupId) @@ -59,7 +67,15 @@ func GetGroupTop3Consume(model *domain.Model, groupId string, myUserId uint64) ( ret, err := saveGroupTop3Consume(period, groupId, diamonds) model.Log.Infof("GetGroupTop3Consume SAVE ret = %d, err: %v", ret, err) - return result, nil + + list := make([]GroupTop3ConsumeUser, 0, len(result)) + for _, v := range result { + list = append(list, GroupTop3ConsumeUser{ + UserBase: user_cv.TopConsumersUser{Id: v.UserBase.Id, Avatar: v.UserBase.Avatar, ExternalId: v.UserBase.ExternalId, Nick: v.UserBase.Nick}, + }) + } + + return list, nil } userIds := make([]uint64, 0) @@ -86,7 +102,15 @@ func GetGroupTop3Consume(model *domain.Model, groupId string, myUserId uint64) ( }) } } - return result, nil + + list := make([]GroupTop3ConsumeUser, 0, len(result)) + for _, v := range result { + list = append(list, GroupTop3ConsumeUser{ + UserBase: user_cv.TopConsumersUser{Id: v.UserBase.Id, Avatar: v.UserBase.Avatar, ExternalId: v.UserBase.ExternalId, Nick: v.UserBase.Nick}, + }) + } + + return list, nil } func getGroupTop3Consume(period string, groupId string) (map[string]string, error) { diff --git a/cv/group_cv/group.go b/cv/group_cv/group.go index cef9133..13971b1 100644 --- a/cv/group_cv/group.go +++ b/cv/group_cv/group.go @@ -123,6 +123,13 @@ type MemberDetail struct { InRoom bool `json:"inRoom"` // 是否在房间内 } +type GroupVisitorsDetail struct { + user_cv.CvGroupMember + Role group_e.GroupRoleType `json:"role"` + OnlineStatus online_e.OnlineStatusType `json:"onlineStatus"` // IM在线状态 + InRoom bool `json:"inRoom"` // 是否在房间内 +} + type GroupDetail struct { GroupBasicInfo @@ -133,14 +140,14 @@ type GroupDetail struct { ThemeId uint64 `json:"themeId"` ThemeUrl string `json:"themeUrl"` // 1:官方 2:自定义 - ThemeType uint8 `json:"themeType"` - Role group_e.GroupRoleType `json:"role"` - MsgStatus uint8 `json:"msgStatus"` // 消息提醒状态 - WelcomeText string `json:"welcomeText"` // 新成员入群欢迎语 - TotalConsume uint64 `json:"totalConsume"` // 群内消费总额 - TopConsumers []billboard_cv.BillboardUserInfo `json:"topConsumers"` // 月最高消费三甲 - DiceNum uint16 `json:"diceNum"` // 骰子游戏的数量 - DiceType uint16 `json:"diceType"` // 骰子游戏的数字点数 + ThemeType uint8 `json:"themeType"` + Role group_e.GroupRoleType `json:"role"` + MsgStatus uint8 `json:"msgStatus"` // 消息提醒状态 + WelcomeText string `json:"welcomeText"` // 新成员入群欢迎语 + TotalConsume uint64 `json:"totalConsume"` // 群内消费总额 + TopConsumers []billboard_cv.GroupTop3ConsumeUser `json:"topConsumers"` // 月最高消费三甲 + DiceNum uint16 `json:"diceNum"` // 骰子游戏的数量 + DiceType uint16 `json:"diceType"` // 骰子游戏的数字点数 // "AppDefinedData": 群组维度的自定义字段 【暂时不用】 RoleMembers []RoleMemberInfo `json:"role_members"` Owner *user_cv.CvUserDetail `json:"owner"` // 群主信息 @@ -166,20 +173,20 @@ type RoomInfo struct { ThemeId uint64 `json:"themeId"` ThemeUrl string `json:"themeUrl"` // 1:官方 2:自定义 - ThemeType uint8 `json:"themeType"` - Role group_e.GroupRoleType `json:"role"` - DiceNum uint16 `json:"diceNum"` // 骰子游戏的数量 - DiceType uint16 `json:"diceType"` // 骰子游戏类型 - RoleMembers []SimpleRoleInfo `json:"roleMembers"` - WelcomeText string `json:"welcomeText"` // 新成员入群欢迎语 - Banners []BannerElement `json:"banners"` - LuckyWheel LuckyWheelState `json:"luckyWheel"` - TotalConsume uint64 `json:"totalConsume"` - GameConfig *game_m.GameConfig `json:"gameConfig"` - Owner *user_cv.CvUserDetail `json:"owner"` - EntryEffectType int `json:"entryEffectType"` // 进场特效类型 1: CP 2:神秘人 3:贵族 4:vip - CpUserAvatar string `json:"cpUserAvatar"` // cp对象头像 - CpLevel int `json:"cpLevel"` // cp等级 + ThemeType uint8 `json:"themeType"` + Role group_e.GroupRoleType `json:"role"` + DiceNum uint16 `json:"diceNum"` // 骰子游戏的数量 + DiceType uint16 `json:"diceType"` // 骰子游戏类型 + RoleMembers []SimpleRoleInfo `json:"roleMembers"` + WelcomeText string `json:"welcomeText"` // 新成员入群欢迎语 + Banners []BannerElement `json:"banners"` + LuckyWheel LuckyWheelState `json:"luckyWheel"` + TotalConsume uint64 `json:"totalConsume"` + GameConfig *game_m.GameConfig `json:"gameConfig"` + Owner *user_cv.RoomInfoOwner `json:"owner"` + EntryEffectType int `json:"entryEffectType"` // 进场特效类型 1: CP 2:神秘人 3:贵族 4:vip + CpUserAvatar string `json:"cpUserAvatar"` // cp对象头像 + CpLevel int `json:"cpLevel"` // cp等级 } type SupportPageDetail struct { diff --git a/cv/user_cv/user.go b/cv/user_cv/user.go index 0955c84..0969d43 100644 --- a/cv/user_cv/user.go +++ b/cv/user_cv/user.go @@ -1,6 +1,7 @@ package user_cv import ( + "encoding/json" "git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/mylogrus" "git.hilo.cn/hilo-common/resource/mysql" @@ -69,6 +70,25 @@ type CvUserDetail struct { CountryManager *country_cv.CVCountryManager `json:"countryManager,omitempty"` // 国家管理员 } +type RoomInfoOwner struct { + //头像,不存在为nil + Avatar *string `json:"avatar"` + //用户对外ID + ExternalId *string `json:"externalId"` + //昵称,不存在为nil + Nick *string `json:"nick"` + IsPrettyCode bool `json:"isPrettyCode"` // 是否靓号 + //是否VIP用户 + IsVip bool `json:"isVip"` + Svip rpc.CvSvip `json:"svip"` // svip结构,等级+权限 + Medals []uint32 `json:"medals"` // 勋章列表 + Noble noble_cv.CvNoble `json:"noble"` // 当前的 + WealthUserGrade uint32 `json:"wealthUserGrade"` //财富等级 + CharmUserGrade uint32 `json:"charmUserGrade"` //魅力等级 + MyGroupPowerName string `json:"myGroupPowerName"` // 当前用户所在势力绑定群组的名称 + GroupPower GroupPower `json:"groupPower"` // 当前用户势力信息 +} + type GroupPower struct { Id uint64 `json:"id"` // 群主所在的势力ID Icon string `json:"icon"` // 家族头像 @@ -150,6 +170,45 @@ type CvUserExtend struct { ActiveGrade uint32 `json:"activityUserGrade"` } +type CvGroupMember struct { + //不会有返回值 + Id *mysql.ID `json:"id,omitempty"` + //是否默认头像 true:是 false:不是 + DefaultAvatar *bool `json:"defaultAvatar"` + //头像,不存在为nil + Avatar *string `json:"avatar"` + //用户对外ID + ExternalId *string `json:"externalId"` + //昵称,不存在为nil + Nick *string `json:"nick"` + //签名,不存在为nil + Description *string `json:"description"` + Birthday *uint64 `json:"birthday"` + //邀请码 + Code *string `json:"code"` + //国家,不存在为nil + Country *string `json:"country"` + //国旗图标,不存在为nil + CountryIcon *string `json:"countryIcon"` + Sex *uint8 `json:"sex"` + //是否代理管理员, 只有自己查自己的时候才有值,其他情况为nil + IsAgentMgr *bool `json:"isAgentMgr"` + //是否展示年龄, 是本人才有数据,看其他用户均为nil + IsShowAge *uint8 `json:"isShowAge"` + //是否工会成员, 只有是自己查自己,这个才有值,其它全为nil, 20220329 数据开放:原因:产品1对1视频聊天中,公会用户视频需要送礼物。改为: 全部人可以知道是否是公会用户。 + IsTradeUnion *bool `json:"isTradeUnion"` + //工会成员,是否开启了,匹配通知,只有 isTradeUnion值为true,这里才有值, + IsTradeUnionMatchNotification *bool `json:"isTradeUnionMatchNotification"` + //是否VIP用户 + IsVip bool `json:"isVip"` + Ride property_cv.CvProperty `json:"ride"` // 当前使用的座驾 + Noble noble_cv.CvNoble `json:"noble"` // 当前的 + Svip rpc.CvSvip `json:"svip"` // svip结构,等级+权限 + WealthGrade uint32 `json:"wealthUserGrade"` + CharmGrade uint32 `json:"charmUserGrade"` + ActiveGrade uint32 `json:"activityUserGrade"` +} + // 批量获取用户tiny信息 func GetUserTinyMap(userIds []mysql.ID) (map[mysql.ID]CvUserTiny, error) { userTinys, _, err := GetUserTinys(userIds) @@ -1288,3 +1347,38 @@ func getMedalInfo(db *gorm.DB, medals []uint32) ([]uint32, []medal_cv.CvMedal, e } return validMedals, medalInfo, nil } + +func UserDetailToRoomInfoOwner(user *CvUserDetail) *RoomInfoOwner { + return &RoomInfoOwner{ + Avatar: user.Avatar, + ExternalId: user.ExternalId, + Nick: user.Nick, + IsPrettyCode: user.IsPrettyCode, + IsVip: user.IsVip, + Svip: user.Svip, + Medals: user.Medals, + Noble: user.Noble, + WealthUserGrade: user.WealthUserGrade, + CharmUserGrade: user.CharmUserGrade, + MyGroupPowerName: user.MyGroupPowerName, + GroupPower: user.GroupPower, + } +} + +type TopConsumersUser struct { + //不会有返回值 + Id *mysql.ID `json:"id,omitempty"` + //头像,不存在为nil + Avatar *string `json:"avatar"` + //用户对外ID + ExternalId *string `json:"externalId"` + //昵称,不存在为nil + Nick *string `json:"nick"` +} + +func CvUserExtendToCvGroupMember(detail CvUserExtend) CvGroupMember { + jData, _ := json.Marshal(detail) + res := CvGroupMember{} + _ = json.Unmarshal(jData, &res) + return res +} diff --git a/route/group_r/group_info.go b/route/group_r/group_info.go index 68b8a4c..b98de50 100644 --- a/route/group_r/group_info.go +++ b/route/group_r/group_info.go @@ -604,7 +604,8 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) { model.Log.Infof("GetRoomInfo: GetLuckWheelState: %s", err.Error()) } // 群主的详情 - result.Owner, err = user_cv.GetUserDetail(model, groupInfo.Owner, userId) + owner, err := user_cv.GetUserDetail(model, groupInfo.Owner, userId) + result.Owner = user_cv.UserDetailToRoomInfoOwner(owner) if err != nil { model.Log.Errorf("GetRoomInfo: GetUserBase: %s", err.Error()) } diff --git a/route/group_r/group_list.go b/route/group_r/group_list.go index e9d97f2..03e570d 100644 --- a/route/group_r/group_list.go +++ b/route/group_r/group_list.go @@ -796,7 +796,7 @@ func GetMyGroup(c *gin.Context) (*mycontext.MyContext, error) { // @Param groupId path string true "群ID" // @Param pageSize query int false "分页大小 默认:10" default(10) // @Param pageIndex query int false "第几个分页,从1开始 默认:1" default(1) -// @Success 200 {object} GroupMembersRsp +// @Success 200 {object} GetGroupVisitorsRsp // @Router /v1/imGroup/visitors/{groupId} [get] func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) { myContext := mycontext.CreateMyContext(c.Keys) @@ -847,7 +847,7 @@ func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) { } model.Log.Infof("GetGroupVisitors %s: memberNum = %d, user size = %d", groupId, len(rows), len(userIds)) - result := GroupMembersRsp{Total: uint(len(userIds))} + result := GetGroupVisitorsRsp{Total: uint(len(userIds))} beginPos := pageSize * (pageIndex - 1) if uint(beginPos) < result.Total { @@ -961,11 +961,11 @@ func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) { if _, ok := roomUserMap[u]; ok { inRoom = true } - result.Members = append(result.Members, group_cv.MemberDetail{ - CvUserExtend: userExtends[u], - Role: roles[u], - OnlineStatus: statusMap[users[u].ExternalId], - InRoom: inRoom, + result.Members = append(result.Members, group_cv.GroupVisitorsDetail{ + CvGroupMember: user_cv.CvUserExtendToCvGroupMember(userExtends[u]), + Role: roles[u], + OnlineStatus: statusMap[users[u].ExternalId], + InRoom: inRoom, }) } } diff --git a/route/group_r/group_op.go b/route/group_r/group_op.go index f74a21c..120bc8f 100644 --- a/route/group_r/group_op.go +++ b/route/group_r/group_op.go @@ -1238,6 +1238,12 @@ type GroupMembersRsp struct { Total uint `json:"total"` } +type GetGroupVisitorsRsp struct { + Members []group_cv.GroupVisitorsDetail `json:"members"` + Online uint `json:"online"` // 在线人数 + Total uint `json:"total"` +} + // @Tags 群组 // @Summary 获取永久成员列表 // @Accept application/x-www-form-urlencoded -- 2.22.0