From b0d14854e283aba50fb5b5aa2b5b8f9c783b2995 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 17 Jan 2024 09:55:35 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=B7=E5=B2=9B=E6=95=B0=E6=8D=AE=E8=BF=87?= =?UTF-8?q?=E6=BB=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/plunder/model_land.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/modules/plunder/model_land.go b/modules/plunder/model_land.go index 326f79e82..c98ea5b52 100644 --- a/modules/plunder/model_land.go +++ b/modules/plunder/model_land.go @@ -51,6 +51,8 @@ func (this *modelLand) createPlunderLandData(uid string) (land *pb.DBPlunderLand uids []string users []*pb.DBUser info []*pb.DBPlunder + join map[string]struct{} + curUids []string // 过滤后的玩家 ) land = &pb.DBPlunderLand{ Id: primitive.NewObjectID().Hex(), @@ -75,14 +77,21 @@ func (this *modelLand) createPlunderLandData(uid string) (land *pb.DBPlunderLand } } } - // 批量查 + join = make(map[string]struct{}) + // 批量查 是否有加入海岛的 info, _ = this.module.modelPlunder.getPlunderDataByUids(uids) - for i, v := range info { + for _, v := range info { if v.Landid != "" { // 过滤 - uids = append(uids[:i], uids[i+1:]...) + join[v.Uid] = struct{}{} } } - if users, err = this.module.ModuleUser.GetCrossUsers(uids); err != nil { + + for _, v := range uids { // 过滤已经加入海岛的玩家 + if _, ok := join[v]; !ok { + curUids = append(curUids, v) + } + } + if users, err = this.module.ModuleUser.GetCrossUsers(curUids); err != nil { for _, v := range users { land.Uinfo[v.Uid] = comm.GetUserBaseInfo(v) if len(land.Uinfo) > 20 {