Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hilo-group
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
hujiebin
hilo-group
Commits
387ff1df
Commit
387ff1df
authored
Mar 10, 2023
by
chenweijian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
家族信息接口
parent
f2d5e210
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
217 additions
and
32 deletions
+217
-32
group.go
cv/group_cv/group.go
+168
-6
groupInfo.go
domain/model/group_m/groupInfo.go
+9
-26
group_power.go
route/group_power_r/group_power.go
+39
-0
router.go
route/router.go
+1
-0
No files found.
cv/group_cv/group.go
View file @
387ff1df
...
...
@@ -43,12 +43,12 @@ type GroupBasicInfo struct {
//1:5人 2:10人
MicNumType
int
`json:"micNumType"`
// N天内的进入用户数量(重复进入去重,实时)
GroupInUserDuration
int64
`json:"groupInUserDuration"`
GroupMedals
[]
medal_cv
.
PicElement
`json:"groupMedals"`
// 群勋章
TouristMic
uint8
`json:"touristMic"`
// 游客是否能上麦
TouristSendMsg
uint8
`json:"touristSendMsg"`
// 游客是否能发言
TouristSendPic
uint8
`json:"touristSendPic"`
// 游客是否能发图片
MemberFee
uint64
`json:"memberFee"`
// 加入群组会员需要的黄钻
GroupInUserDuration
int64
`json:"groupInUserDuration"`
// 群热度
GroupMedals
[]
medal_cv
.
PicElement
`json:"groupMedals"`
// 群勋章
TouristMic
uint8
`json:"touristMic"`
// 游客是否能上麦
TouristSendMsg
uint8
`json:"touristSendMsg"`
// 游客是否能发言
TouristSendPic
uint8
`json:"touristSendPic"`
// 游客是否能发图片
MemberFee
uint64
`json:"memberFee"`
// 加入群组会员需要的黄钻
}
type
MemberListInfo
struct
{
...
...
@@ -404,6 +404,168 @@ func BuildJoinedGroupInfo(myService *domain.Service, myUserId uint64, groupIds [
return
result
,
len
(
groupInfo
),
nil
}
func
BuildPopularGroupInfo
(
model
*
domain
.
Model
,
myUserId
uint64
,
groupInfo
[]
*
group_m
.
GroupInfo
)
([]
*
PopularGroupInfo
,
error
)
{
groupIds
:=
make
([]
string
,
0
,
len
(
groupInfo
))
for
_
,
v
:=
range
groupInfo
{
groupIds
=
append
(
groupIds
,
v
.
ImGroupId
)
}
// roomMicUserMap不影响排序
roomMicUserMap
,
err
:=
group_m
.
BatchGetAllMicUser
(
model
,
groupIds
)
if
err
!=
nil
{
return
nil
,
err
}
uids
:=
make
([]
uint64
,
0
)
micUsersMap
:=
make
(
map
[
string
][]
uint64
,
0
)
for
_
,
v
:=
range
groupInfo
{
micUsersMap
[
v
.
ImGroupId
]
=
make
([]
uint64
,
0
)
if
len
(
v
.
Password
)
<=
0
{
// 密码群不显示麦上头像
u
:=
roomMicUserMap
[
v
.
ImGroupId
]
if
len
(
u
)
>=
4
{
micUsersMap
[
v
.
ImGroupId
]
=
u
[
0
:
4
]
}
else
if
len
(
u
)
>
0
{
micUsersMap
[
v
.
ImGroupId
]
=
u
}
uids
=
append
(
uids
,
micUsersMap
[
v
.
ImGroupId
]
...
)
}
}
uids
=
utils
.
UniqueSliceUInt64
(
uids
)
userTiny
,
err
:=
user_cv
.
GetUserTinyMap
(
uids
)
if
err
!=
nil
{
return
nil
,
err
}
roomCount
,
err
:=
group_m
.
BatchGetRoomCount
(
model
,
groupIds
)
if
err
!=
nil
{
return
nil
,
err
}
countryInfo
,
err
:=
res_c
.
GetCountryIconMap
(
model
)
if
err
!=
nil
{
return
nil
,
err
}
supportLevels
,
err
:=
group_s
.
NewGroupService
(
model
.
MyContext
)
.
GetWeekMaxSupportLevelMap
()
if
err
!=
nil
{
return
nil
,
err
}
visitCount
,
err
:=
group_m
.
BatchGetRoomVisitCount
(
model
.
Log
,
groupIds
)
if
err
!=
nil
{
return
nil
,
err
}
roomEnterTime
,
err
:=
room_c
.
GetUserRoomVisit
(
myUserId
)
if
err
!=
nil
{
return
nil
,
err
}
model
.
Log
.
Infof
(
"BuildPopularGroupInfo, roomEnterTime: %v"
,
roomEnterTime
)
// 排序优先级V8.0版本
sort
.
Slice
(
groupIds
,
func
(
i
,
j
int
)
bool
{
gi
:=
groupIds
[
i
]
gj
:=
groupIds
[
j
]
return
roomEnterTime
[
gi
]
>
roomEnterTime
[
gj
]
||
roomEnterTime
[
gi
]
==
roomEnterTime
[
gj
]
&&
visitCount
[
gj
]
>
visitCount
[
gj
]
||
roomEnterTime
[
gi
]
==
roomEnterTime
[
gj
]
&&
visitCount
[
gj
]
==
visitCount
[
gj
]
&&
i
>=
j
})
result
:=
make
([]
*
PopularGroupInfo
,
0
)
owners
:=
make
([]
uint64
,
0
)
for
_
,
v
:=
range
groupInfo
{
owners
=
append
(
owners
,
v
.
Owner
)
}
powerIds
,
powerNames
,
err
:=
group_power_cv
.
BatchGetGroupPower
(
model
.
Db
,
owners
)
if
err
!=
nil
{
return
nil
,
err
}
groupMedals
,
err
:=
group_m
.
BatchGetMedals
(
model
.
Db
,
groupIds
)
if
err
!=
nil
{
return
nil
,
err
}
resMedal
,
err
:=
res_m
.
MedalGetAllMap
(
model
.
Db
)
if
err
!=
nil
{
return
nil
,
err
}
rr
:=
rocket_m
.
RocketResult
{}
maxStageMap
,
err
:=
rr
.
GetMaxStage
(
model
.
Db
,
groupIds
)
if
err
!=
nil
{
return
nil
,
err
}
// 正在进行的游戏
games
:=
game_m
.
GetNotEndGamesMap
(
model
)
for
_
,
v
:=
range
groupInfo
{
g
:=
v
i
:=
v
.
ImGroupId
micUsers
:=
make
([]
user_cv
.
CvUserTiny
,
0
)
for
_
,
j
:=
range
micUsersMap
[
i
]
{
micUsers
=
append
(
micUsers
,
userTiny
[
j
])
}
var
maxStage
*
uint16
=
nil
if
s
,
ok
:=
maxStageMap
[
i
];
ok
{
maxStage
=
&
s
}
medals
:=
make
([]
medal_cv
.
PicElement
,
0
)
if
m
,
ok
:=
groupMedals
[
i
];
ok
{
for
_
,
j
:=
range
m
{
mId
:=
uint32
(
j
)
if
e
,
ok
:=
resMedal
[
mId
];
ok
{
medals
=
append
(
medals
,
medal_cv
.
PicElement
{
PicUrl
:
e
.
PicUrl
,
})
}
}
}
// 补上房间流水勋章
var
pe
*
medal_cv
.
PicElement
_
,
pe
,
err
=
medal_cv
.
GetGroupConsumeMedal
(
model
,
i
)
if
err
!=
nil
{
model
.
Log
.
Infof
(
"BuildPopularGroupInfo: GetGroupConsumeMedal: %s"
,
err
.
Error
())
}
else
if
pe
!=
nil
{
medals
=
append
(
medals
,
medal_cv
.
PicElement
{
PicUrl
:
pe
.
PicUrl
})
}
var
password
*
string
=
nil
if
len
(
g
.
Password
)
>
0
&&
g
.
Owner
!=
myUserId
{
emptyStr
:=
""
password
=
&
emptyStr
}
result
=
append
(
result
,
&
PopularGroupInfo
{
GroupInfo
:
GroupInfo
{
GroupBasicInfo
:
GroupBasicInfo
{
GroupId
:
g
.
TxGroupId
,
Name
:
g
.
Name
,
Notification
:
g
.
Notification
,
Introduction
:
g
.
Introduction
,
FaceUrl
:
g
.
FaceUrl
,
Code
:
g
.
Code
,
CountryIcon
:
countryInfo
[
g
.
Country
],
Password
:
password
,
SupportLevel
:
supportLevels
[
i
],
GroupInUserDuration
:
visitCount
[
i
],
MicNumType
:
int
(
g
.
MicNumType
),
GroupMedals
:
medals
,
},
HasOnMic
:
len
(
micUsers
)
>
0
,
GroupPowerId
:
powerIds
[
g
.
Owner
],
GroupPowerName
:
powerNames
[
g
.
Owner
],
},
MicUsers
:
micUsers
,
RoomUserCount
:
uint
(
roomCount
[
i
]),
MaxStage
:
maxStage
,
GameTypes
:
games
[
g
.
TxGroupId
],
})
}
return
result
,
nil
}
//检查群组中是否有有人在麦上,返回存在的Set[imGroupId]
func
CheckMicHasUserByGroup
(
groupIds
[]
string
)
(
map
[
string
]
struct
{},
error
)
{
groupMap
:=
map
[
string
]
struct
{}{}
...
...
domain/model/group_m/groupInfo.go
View file @
387ff1df
...
...
@@ -515,29 +515,12 @@ func GetLatestGroupInfos(model *domain.Model, limit, lastId int, groupIds []stri
return
}
//func init() {
// // 初始化官方群组
// strGroupIds := strings.Split(config.GetConfigApp().OFFICIAL_GROUP, ",")
// for _, i := range strGroupIds {
// if len(i) > 0 {
// officialGroup = append(officialGroup, i)
// }
// }
// mylogrus.MyLog.Info("Official groups: ", officialGroup)
//
// event.AddUserInfoUpdate(func(model *domain.Model, e interface{}) error {
// event := e.(*event.UserInfoUpdateEvent)
// if event.Country == nil {
// return nil
// } else {
// // v2.3需求:同步更新群组country
// model.Log.Infof("Receive userInfoUpdate: user %d, country %s", event.UserId, *event.Country)
// return UpdateCountryByOwner(model, *event.Country, event.UserId)
// }
// })
// event.AddMgrUserCountryUpdateAsync(func(model *domain.Model, event *event.MgrUserCountryUpdateEvent) error {
// // v2.3需求:同步更新群组country
// model.Log.Infof("Receive MgrUserCountryUpdate: user %d, from %s to %s", event.UserId, event.OldCountry, event.NewCountry)
// return UpdateCountryByOwner(model, event.NewCountry, event.UserId)
// })
//}
func
GetFamilyRooms
(
model
*
domain
.
Model
,
familyId
uint64
,
pageSize
,
pageIndex
int
)
([]
*
GroupInfo
,
error
)
{
rows
:=
make
([]
*
GroupInfo
,
0
)
err
:=
model
.
Db
.
Model
(
GroupInfo
{})
.
Where
(
"owner in (select user_id from group_power_user where group_power_id=? order by field(`role`, 2, 3, 1))"
,
familyId
)
.
Limit
(
pageSize
)
.
Offset
((
pageIndex
-
1
)
*
pageSize
)
.
Find
(
&
rows
)
.
Error
if
err
!=
nil
{
return
nil
,
err
}
return
rows
,
nil
}
route/group_power_r/group_power.go
View file @
387ff1df
...
...
@@ -739,3 +739,42 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) {
resp
.
ResponseOk
(
c
,
res
)
return
myContext
,
nil
}
// @Tags 家族
// @Summary 获取某个家族房间列表
// @Param id query int true "家族id"
// @Param pageSize query int true "分页大小 默认:10" default(10)
// @Param pageIndex query int true "第几个分页,从1开始 默认:1" default(1)
// @Success 200 {object} []group_cv.PopularGroupInfo
// @Router /v1/groupPower/rooms [get]
func
GroupPowerRooms
(
c
*
gin
.
Context
)
(
*
mycontext
.
MyContext
,
error
)
{
myContext
:=
mycontext
.
CreateMyContext
(
c
.
Keys
)
userId
,
err
:=
req
.
GetUserId
(
c
)
if
err
!=
nil
{
return
myContext
,
err
}
familyId
,
err
:=
strconv
.
ParseUint
(
c
.
Query
(
"id"
),
10
,
64
)
if
err
!=
nil
{
return
myContext
,
err
}
pageSize
,
err
:=
strconv
.
Atoi
(
c
.
Query
(
"pageSize"
))
if
err
!=
nil
{
return
myContext
,
err
}
pageIndex
,
err
:=
strconv
.
Atoi
(
c
.
Query
(
"pageIndex"
))
if
err
!=
nil
{
return
myContext
,
err
}
model
:=
domain
.
CreateModelContext
(
myContext
)
rooms
,
err
:=
group_m
.
GetFamilyRooms
(
model
,
familyId
,
pageSize
,
pageIndex
)
if
err
!=
nil
{
return
myContext
,
err
}
resRooms
,
err
:=
group_cv
.
BuildPopularGroupInfo
(
model
,
userId
,
rooms
)
if
err
!=
nil
{
return
myContext
,
err
}
resp
.
ResponseOk
(
c
,
resRooms
)
return
myContext
,
nil
}
route/router.go
View file @
387ff1df
...
...
@@ -127,6 +127,7 @@ func InitRouter() *gin.Engine {
groupPower
.
GET
(
"/billboard/week"
,
wrapper
(
group_power_r
.
GroupPowerBillboardWeek
))
groupPower
.
GET
(
"/billboard/owner/week"
,
wrapper
(
group_power_r
.
GroupPowerBillboardOwnerWeek
))
groupPower
.
GET
(
"/info"
,
wrapper
(
group_power_r
.
GroupPowerInfo
))
groupPower
.
GET
(
"/rooms"
,
wrapper
(
group_power_r
.
GroupPowerRooms
))
}
charge
:=
v1
.
Group
(
"/charge"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment