Commit 5d300b57 authored by hujiebin's avatar hujiebin

Merge branch 'feature/4.3_cwj' into 'master'

4.0.5 接口优化

See merge request !53
parents d2e3fc55 1a803f49
...@@ -22,7 +22,15 @@ type BillboardUserInfo struct { ...@@ -22,7 +22,15 @@ type BillboardUserInfo struct {
Num uint64 `json:"num"` 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() now := time.Now()
period := now.Format(utils.COMPACT_MONTH_FORMAT) period := now.Format(utils.COMPACT_MONTH_FORMAT)
data, err := getGroupTop3Consume(period, groupId) data, err := getGroupTop3Consume(period, groupId)
...@@ -59,7 +67,15 @@ func GetGroupTop3Consume(model *domain.Model, groupId string, myUserId uint64) ( ...@@ -59,7 +67,15 @@ func GetGroupTop3Consume(model *domain.Model, groupId string, myUserId uint64) (
ret, err := saveGroupTop3Consume(period, groupId, diamonds) ret, err := saveGroupTop3Consume(period, groupId, diamonds)
model.Log.Infof("GetGroupTop3Consume SAVE ret = %d, err: %v", ret, err) 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) userIds := make([]uint64, 0)
...@@ -86,7 +102,15 @@ func GetGroupTop3Consume(model *domain.Model, groupId string, myUserId uint64) ( ...@@ -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) { func getGroupTop3Consume(period string, groupId string) (map[string]string, error) {
......
...@@ -123,6 +123,13 @@ type MemberDetail struct { ...@@ -123,6 +123,13 @@ type MemberDetail struct {
InRoom bool `json:"inRoom"` // 是否在房间内 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 { type GroupDetail struct {
GroupBasicInfo GroupBasicInfo
...@@ -133,14 +140,14 @@ type GroupDetail struct { ...@@ -133,14 +140,14 @@ type GroupDetail struct {
ThemeId uint64 `json:"themeId"` ThemeId uint64 `json:"themeId"`
ThemeUrl string `json:"themeUrl"` ThemeUrl string `json:"themeUrl"`
// 1:官方 2:自定义 // 1:官方 2:自定义
ThemeType uint8 `json:"themeType"` ThemeType uint8 `json:"themeType"`
Role group_e.GroupRoleType `json:"role"` Role group_e.GroupRoleType `json:"role"`
MsgStatus uint8 `json:"msgStatus"` // 消息提醒状态 MsgStatus uint8 `json:"msgStatus"` // 消息提醒状态
WelcomeText string `json:"welcomeText"` // 新成员入群欢迎语 WelcomeText string `json:"welcomeText"` // 新成员入群欢迎语
TotalConsume uint64 `json:"totalConsume"` // 群内消费总额 TotalConsume uint64 `json:"totalConsume"` // 群内消费总额
TopConsumers []billboard_cv.BillboardUserInfo `json:"topConsumers"` // 月最高消费三甲 TopConsumers []billboard_cv.GroupTop3ConsumeUser `json:"topConsumers"` // 月最高消费三甲
DiceNum uint16 `json:"diceNum"` // 骰子游戏的数量 DiceNum uint16 `json:"diceNum"` // 骰子游戏的数量
DiceType uint16 `json:"diceType"` // 骰子游戏的数字点数 DiceType uint16 `json:"diceType"` // 骰子游戏的数字点数
// "AppDefinedData": 群组维度的自定义字段 【暂时不用】 // "AppDefinedData": 群组维度的自定义字段 【暂时不用】
RoleMembers []RoleMemberInfo `json:"role_members"` RoleMembers []RoleMemberInfo `json:"role_members"`
Owner *user_cv.CvUserDetail `json:"owner"` // 群主信息 Owner *user_cv.CvUserDetail `json:"owner"` // 群主信息
...@@ -166,20 +173,20 @@ type RoomInfo struct { ...@@ -166,20 +173,20 @@ type RoomInfo struct {
ThemeId uint64 `json:"themeId"` ThemeId uint64 `json:"themeId"`
ThemeUrl string `json:"themeUrl"` ThemeUrl string `json:"themeUrl"`
// 1:官方 2:自定义 // 1:官方 2:自定义
ThemeType uint8 `json:"themeType"` ThemeType uint8 `json:"themeType"`
Role group_e.GroupRoleType `json:"role"` Role group_e.GroupRoleType `json:"role"`
DiceNum uint16 `json:"diceNum"` // 骰子游戏的数量 DiceNum uint16 `json:"diceNum"` // 骰子游戏的数量
DiceType uint16 `json:"diceType"` // 骰子游戏类型 DiceType uint16 `json:"diceType"` // 骰子游戏类型
RoleMembers []SimpleRoleInfo `json:"roleMembers"` RoleMembers []SimpleRoleInfo `json:"roleMembers"`
WelcomeText string `json:"welcomeText"` // 新成员入群欢迎语 WelcomeText string `json:"welcomeText"` // 新成员入群欢迎语
Banners []BannerElement `json:"banners"` Banners []BannerElement `json:"banners"`
LuckyWheel LuckyWheelState `json:"luckyWheel"` LuckyWheel LuckyWheelState `json:"luckyWheel"`
TotalConsume uint64 `json:"totalConsume"` TotalConsume uint64 `json:"totalConsume"`
GameConfig *game_m.GameConfig `json:"gameConfig"` GameConfig *game_m.GameConfig `json:"gameConfig"`
Owner *user_cv.CvUserDetail `json:"owner"` Owner *user_cv.RoomInfoOwner `json:"owner"`
EntryEffectType int `json:"entryEffectType"` // 进场特效类型 1: CP 2:神秘人 3:贵族 4:vip EntryEffectType int `json:"entryEffectType"` // 进场特效类型 1: CP 2:神秘人 3:贵族 4:vip
CpUserAvatar string `json:"cpUserAvatar"` // cp对象头像 CpUserAvatar string `json:"cpUserAvatar"` // cp对象头像
CpLevel int `json:"cpLevel"` // cp等级 CpLevel int `json:"cpLevel"` // cp等级
} }
type SupportPageDetail struct { type SupportPageDetail struct {
......
package user_cv package user_cv
import ( import (
"encoding/json"
"git.hilo.cn/hilo-common/domain" "git.hilo.cn/hilo-common/domain"
"git.hilo.cn/hilo-common/mylogrus" "git.hilo.cn/hilo-common/mylogrus"
"git.hilo.cn/hilo-common/resource/mysql" "git.hilo.cn/hilo-common/resource/mysql"
...@@ -69,6 +70,25 @@ type CvUserDetail struct { ...@@ -69,6 +70,25 @@ type CvUserDetail struct {
CountryManager *country_cv.CVCountryManager `json:"countryManager,omitempty"` // 国家管理员 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 { type GroupPower struct {
Id uint64 `json:"id"` // 群主所在的势力ID Id uint64 `json:"id"` // 群主所在的势力ID
Icon string `json:"icon"` // 家族头像 Icon string `json:"icon"` // 家族头像
...@@ -150,6 +170,45 @@ type CvUserExtend struct { ...@@ -150,6 +170,45 @@ type CvUserExtend struct {
ActiveGrade uint32 `json:"activityUserGrade"` 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信息 // 批量获取用户tiny信息
func GetUserTinyMap(userIds []mysql.ID) (map[mysql.ID]CvUserTiny, error) { func GetUserTinyMap(userIds []mysql.ID) (map[mysql.ID]CvUserTiny, error) {
userTinys, _, err := GetUserTinys(userIds) userTinys, _, err := GetUserTinys(userIds)
...@@ -1288,3 +1347,38 @@ func getMedalInfo(db *gorm.DB, medals []uint32) ([]uint32, []medal_cv.CvMedal, e ...@@ -1288,3 +1347,38 @@ func getMedalInfo(db *gorm.DB, medals []uint32) ([]uint32, []medal_cv.CvMedal, e
} }
return validMedals, medalInfo, nil 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
}
...@@ -604,7 +604,8 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -604,7 +604,8 @@ func GetRoomInfo(c *gin.Context) (*mycontext.MyContext, error) {
model.Log.Infof("GetRoomInfo: GetLuckWheelState: %s", err.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 { if err != nil {
model.Log.Errorf("GetRoomInfo: GetUserBase: %s", err.Error()) model.Log.Errorf("GetRoomInfo: GetUserBase: %s", err.Error())
} }
......
...@@ -796,7 +796,7 @@ func GetMyGroup(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -796,7 +796,7 @@ func GetMyGroup(c *gin.Context) (*mycontext.MyContext, error) {
// @Param groupId path string true "群ID" // @Param groupId path string true "群ID"
// @Param pageSize query int false "分页大小 默认:10" default(10) // @Param pageSize query int false "分页大小 默认:10" default(10)
// @Param pageIndex query int false "第几个分页,从1开始 默认:1" default(1) // @Param pageIndex query int false "第几个分页,从1开始 默认:1" default(1)
// @Success 200 {object} GroupMembersRsp // @Success 200 {object} GetGroupVisitorsRsp
// @Router /v1/imGroup/visitors/{groupId} [get] // @Router /v1/imGroup/visitors/{groupId} [get]
func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) { func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) {
myContext := mycontext.CreateMyContext(c.Keys) myContext := mycontext.CreateMyContext(c.Keys)
...@@ -847,7 +847,7 @@ func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -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)) 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) beginPos := pageSize * (pageIndex - 1)
if uint(beginPos) < result.Total { if uint(beginPos) < result.Total {
...@@ -961,11 +961,11 @@ func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -961,11 +961,11 @@ func GetGroupVisitors(c *gin.Context) (*mycontext.MyContext, error) {
if _, ok := roomUserMap[u]; ok { if _, ok := roomUserMap[u]; ok {
inRoom = true inRoom = true
} }
result.Members = append(result.Members, group_cv.MemberDetail{ result.Members = append(result.Members, group_cv.GroupVisitorsDetail{
CvUserExtend: userExtends[u], CvGroupMember: user_cv.CvUserExtendToCvGroupMember(userExtends[u]),
Role: roles[u], Role: roles[u],
OnlineStatus: statusMap[users[u].ExternalId], OnlineStatus: statusMap[users[u].ExternalId],
InRoom: inRoom, InRoom: inRoom,
}) })
} }
} }
......
...@@ -1238,6 +1238,12 @@ type GroupMembersRsp struct { ...@@ -1238,6 +1238,12 @@ type GroupMembersRsp struct {
Total uint `json:"total"` Total uint `json:"total"`
} }
type GetGroupVisitorsRsp struct {
Members []group_cv.GroupVisitorsDetail `json:"members"`
Online uint `json:"online"` // 在线人数
Total uint `json:"total"`
}
// @Tags 群组 // @Tags 群组
// @Summary 获取永久成员列表 // @Summary 获取永久成员列表
// @Accept application/x-www-form-urlencoded // @Accept application/x-www-form-urlencoded
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment