diff --git a/app/hdl/hdl_add_friend.go b/app/hdl/hdl_add_friend.go index 3ccd910..9a8f445 100644 --- a/app/hdl/hdl_add_friend.go +++ b/app/hdl/hdl_add_friend.go @@ -589,6 +589,11 @@ func MyFans(c *gin.Context) { return } +type ActiveInfo struct { + model.UserRelate `xorm:"extends"` + model.EggSignIn `xorm:"extends"` +} + // MyFansUserList // @Summary 蛋蛋星球-添加好友-粉丝团队-我的粉丝-在线好友列表(获取) // @Tags 添加好友 @@ -668,13 +673,26 @@ func MyFansUserList(c *gin.Context) { } } + session := db.Db.Table("user_relate"). + Join("LEFT OUTER", "user", "user_relate.uid = user.id"). + Join("LEFT OUTER", "egg_sign_in", "user_relate.uid = egg_sign_in.uid") + if len(userRelatesUids) > 0 { + session.In("user_relate.uid", userRelatesUids) + } + session.And("user_relate.parent_uid = ?", user.Id) + session.And("egg_sign_in.start_time > ?", startTime) + session.And("egg_sign_in.is_completed = 0") + activityUserNums, err := session.Count(&ActiveInfo{}) + if err != nil { + e.OutErr(c, e.ERR_DB_ORM, err.Error()) + return + } + scheme, domain := svc.ImageBucket(db.Db) var data []md.OneLineUserNode - var activityUserNums int for _, v := range results { isOnline := false if userSignInMap[utils.AnyToInt64(v["uid"])] != nil { - activityUserNums++ isOnline = true } tempUrl := svc.ImageFormatWithBucket(scheme, domain, v["avatar"]) @@ -688,7 +706,7 @@ func MyFansUserList(c *gin.Context) { resp := md.MyFansUserListResp{ InviteTotal: inviteTotal, - ActivityUserNums: activityUserNums, + ActivityUserNums: int(activityUserNums), List: data, }