Commit 95bd280f authored by hujiebin's avatar hujiebin

to txGroupIds

parent 312d9a7a
......@@ -76,6 +76,18 @@ func ToTxGroupId(model *domain.Model, imGroupId string) (string, error) {
return gi.TxGroupId, nil
}
func ToTxGroupIdMap(model *domain.Model, imGroupIds []string) (map[string]string, error) {
var res = make(map[string]string)
var rows []GroupInfo
if err := model.DB().Model(GroupInfo{}).Where("im_group_id in ?", imGroupIds).Find(&rows).Error; err != nil {
return res, err
}
for _, v := range rows {
res[v.ImGroupId] = v.TxGroupId
}
return res, nil
}
func ToImGroupId(model *domain.Model, txGroupId string) (string, error) {
if len(txGroupId) <= 0 {
return "", nil
......
......@@ -43,6 +43,16 @@ func UserRecommendGift(c *gin.Context) (*mycontext.MyContext, error) {
rooms, err := group_m.RoomLivingUserIdFilter(model, userIds)
if err != nil {
return nil, err
} else if len(rooms) > 0 {
// to txGroupIds
var imGroupIds []string
for _, imGroupId := range rooms {
imGroupIds = append(imGroupIds, imGroupId)
}
txGroupIdsMap, _ := group_m.ToTxGroupIdMap(model, imGroupIds)
for uid, room := range rooms {
rooms[uid] = txGroupIdsMap[room]
}
}
for _, v := range recommendUser {
response = append(response, RecommendUser{user_cv.UserToTiny(users[v.SendUserId]), rooms[v.SendUserId]})
......
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