From ca40bc579cf4311ff025af2564bcaaaa73a2ea4f Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Fri, 23 Feb 2024 13:58:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BA=A2=E7=82=B9=E5=9F=8B?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/dailytask/module.go | 48 ++++++++++++++++---------- modules/gourmet/module.go | 32 +++++++++++++----- modules/guildgve/module.go | 36 +++++++++++++------- modules/hunting/module.go | 32 +++++++++++++----- modules/library/module.go | 66 ++++++++++++++++++++++-------------- modules/mail/module.go | 67 +++++++++++++++++++++++-------------- modules/mainline/module.go | 30 ++++++++++++----- modules/viking/module.go | 35 +++++++++++++------ 8 files changed, 228 insertions(+), 118 deletions(-) diff --git a/modules/dailytask/module.go b/modules/dailytask/module.go index 1872497a0..9e6a0cd08 100644 --- a/modules/dailytask/module.go +++ b/modules/dailytask/module.go @@ -113,36 +113,48 @@ func (this *Dailytask) OpenCmdNotice(session comm.IUserSession, keys ...string) } // 查询每日红点信息 -func (this *Dailytask) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) { +func (this *Dailytask) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) { var ( + selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot25101} + ok bool dtask *pb.DBDailytask progress int32 err error ) - reddot = make(map[comm.ReddotType]*pb.ReddotItem) + items = make(map[comm.ReddotType]*pb.ReddotItem) + for _, v := range selfrid { + if _, ok = rid[v]; ok { + break + } + } + if ok { + return + } if dtask, err = this.modelDailytask.getUserDTasks(session.GetUserId()); err != nil { this.Errorln(err) return } - for _, v := range rid { - switch v { - case comm.Reddot25101: + for _, v := range selfrid { + if _, ok = rid[v]; ok { + switch v { + case comm.Reddot25101: - for _, v := range dtask.Groups { - if v.Complete { - progress++ + for _, v := range dtask.Groups { + if v.Complete { + progress++ + } } + items[comm.Reddot25101] = &pb.ReddotItem{ + Rid: int32(comm.Reddot25101), + Activated: true, + Progress: progress, + Total: int32(len(dtask.Groups)), + } + if len(dtask.Groups) == 0 { + items[comm.Reddot25101].Activated = false + } + break } - reddot[comm.Reddot25101] = &pb.ReddotItem{ - Rid: int32(comm.Reddot25101), - Activated: true, - Progress: progress, - Total: int32(len(dtask.Groups)), - } - if len(dtask.Groups) == 0 { - reddot[comm.Reddot25101].Activated = false - } - break } } return diff --git a/modules/gourmet/module.go b/modules/gourmet/module.go index 5467c6b23..8dcc4e71e 100644 --- a/modules/gourmet/module.go +++ b/modules/gourmet/module.go @@ -45,18 +45,32 @@ func (this *Gourmet) OnInstallComp() { } //红点查询 -func (this *Gourmet) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) { - reddot = make(map[comm.ReddotType]*pb.ReddotItem) - for _, v := range rid { - switch v { - case comm.Reddot23101: // 铁匠铺手册台 - reddot[comm.Reddot23101] = &pb.ReddotItem{ - Rid: int32(comm.Reddot23101), - Activated: this.modelAtlas.checkReddot2301(session.GetUserId()), - } +func (this *Gourmet) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) { + var ( + selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot23101} + ok bool + ) + items = make(map[comm.ReddotType]*pb.ReddotItem) + for _, v := range selfrid { + if _, ok = rid[v]; ok { break } } + if ok { + return + } + for _, v := range selfrid { + if _, ok = rid[v]; ok { + switch v { + case comm.Reddot23101: // 铁匠铺手册台 + items[comm.Reddot23101] = &pb.ReddotItem{ + Rid: int32(comm.Reddot23101), + Activated: this.modelAtlas.checkReddot2301(session.GetUserId()), + } + break + } + } + } return } diff --git a/modules/guildgve/module.go b/modules/guildgve/module.go index 845f4abe1..79d0104d7 100644 --- a/modules/guildgve/module.go +++ b/modules/guildgve/module.go @@ -89,24 +89,36 @@ func (this *GuildGve) Rpc_ModuleGuildBossSettlement(ctx context.Context, req *pb } // 红点 -func (this *GuildGve) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) { +func (this *GuildGve) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) { var ( - member *pb.DBGuildMember - err error + selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot15301} + ok bool + member *pb.DBGuildMember + err error ) - reddot = make(map[comm.ReddotType]*pb.ReddotItem) + items = make(map[comm.ReddotType]*pb.ReddotItem) + for _, v := range selfrid { + if _, ok = rid[v]; ok { + break + } + } + if ok { + return + } if member, err = this.modelGuildMember.inquireGuildMember(session.GetUserId()); err != nil { return } - for _, v := range rid { - switch v { - case comm.Reddot15301: - reddot[comm.Reddot15301] = &pb.ReddotItem{ - Rid: int32(comm.Reddot15301), - Activated: true, - Progress: member.Boosticket, + for _, v := range selfrid { + if _, ok = rid[v]; ok { + switch v { + case comm.Reddot15301: + items[comm.Reddot15301] = &pb.ReddotItem{ + Rid: int32(comm.Reddot15301), + Activated: true, + Progress: member.Boosticket, + } + break } - break } } return diff --git a/modules/hunting/module.go b/modules/hunting/module.go index 60ec8d28b..d2c509996 100644 --- a/modules/hunting/module.go +++ b/modules/hunting/module.go @@ -89,18 +89,32 @@ func (this *Hunting) CheckUserBaseHuntingInfo(uid string) (data []*pb.DBHuntingR } //红点查询 -func (this *Hunting) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) { - reddot = make(map[comm.ReddotType]*pb.ReddotItem) - for _, v := range rid { - switch v { - case comm.Reddot14102: - reddot[comm.Reddot14102] = &pb.ReddotItem{ - Rid: int32(comm.Reddot14102), - Activated: this.modelHunting.checkReddot32(session), - } +func (this *Hunting) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) { + var ( + selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot17} + ok bool + ) + items = make(map[comm.ReddotType]*pb.ReddotItem) + for _, v := range selfrid { + if _, ok = rid[v]; ok { break } } + if ok { + return + } + for _, v := range selfrid { + if _, ok = rid[v]; ok { + switch v { + case comm.Reddot14102: + items[comm.Reddot14102] = &pb.ReddotItem{ + Rid: int32(comm.Reddot14102), + Activated: this.modelHunting.checkReddot32(session), + } + break + } + } + } return } diff --git a/modules/library/module.go b/modules/library/module.go index 1ef89596f..3578462ba 100644 --- a/modules/library/module.go +++ b/modules/library/module.go @@ -282,34 +282,48 @@ func (this *Library) TaskFinishNotify(uid string, taskId, fetterId int32) error } // 红点 -func (this *Library) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) { - reddot = make(map[comm.ReddotType]*pb.ReddotItem) - for _, v := range rid { - switch v { - case comm.Reddot19105: - reddot[comm.Reddot19105] = &pb.ReddotItem{ - Rid: int32(comm.Reddot19105), - Activated: this.modelLibrary.checkReddot19105(session.GetUserId()), - } +func (this *Library) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) { + var ( + selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot19105, comm.Reddot19103, comm.Reddot19109, comm.Reddot19110} + ok bool + ) + items = make(map[comm.ReddotType]*pb.ReddotItem) + for _, v := range selfrid { + if _, ok = rid[v]; ok { break - case comm.Reddot19103: - reddot[comm.Reddot19103] = &pb.ReddotItem{ - Rid: int32(comm.Reddot19103), - Activated: this.modelFetter.checkReddot19103(session.GetUserId()), + } + } + if ok { + return + } + for _, v := range selfrid { + if _, ok = rid[v]; ok { + switch v { + case comm.Reddot19105: + items[comm.Reddot19105] = &pb.ReddotItem{ + Rid: int32(comm.Reddot19105), + Activated: this.modelLibrary.checkReddot19105(session.GetUserId()), + } + break + case comm.Reddot19103: + items[comm.Reddot19103] = &pb.ReddotItem{ + Rid: int32(comm.Reddot19103), + Activated: this.modelFetter.checkReddot19103(session.GetUserId()), + } + break + case comm.Reddot19109: + items[comm.Reddot19109] = &pb.ReddotItem{ + Rid: int32(comm.Reddot19109), + Activated: this.modelLibrary.checkReddot19109(session.GetUserId()), + } + break + case comm.Reddot19110: + items[comm.Reddot19110] = &pb.ReddotItem{ + Rid: int32(comm.Reddot19110), + Activated: this.modelLibrary.checkReddot19110(session.GetUserId()), + } + break } - break - case comm.Reddot19109: - reddot[comm.Reddot19109] = &pb.ReddotItem{ - Rid: int32(comm.Reddot19109), - Activated: this.modelLibrary.checkReddot19109(session.GetUserId()), - } - break - case comm.Reddot19110: - reddot[comm.Reddot19110] = &pb.ReddotItem{ - Rid: int32(comm.Reddot19110), - Activated: this.modelLibrary.checkReddot19110(session.GetUserId()), - } - break } } return diff --git a/modules/mail/module.go b/modules/mail/module.go index 8ebd5c0d7..43f87ccac 100644 --- a/modules/mail/module.go +++ b/modules/mail/module.go @@ -107,36 +107,51 @@ func (this *Mail) SendNewMail(mail *pb.DBMailData, uid ...string) bool { } //红点查询 -func (this *Mail) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) { - reddot = make(map[comm.ReddotType]*pb.ReddotItem) - for _, v := range rid { - switch v { - case comm.Reddot12101: - if isredot := this.modelMail.checkReddot26(session.GetUserId()); isredot { - reddot[comm.Reddot12101] = &pb.ReddotItem{ - Rid: int32(comm.Reddot12101), - Activated: true, - } - } else { - reddot[comm.Reddot12101] = &pb.ReddotItem{ - Rid: int32(comm.Reddot12101), - Activated: false, - } - } +func (this *Mail) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) { + + var ( + selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot12101, comm.Reddot12102} + ok bool + ) + items = make(map[comm.ReddotType]*pb.ReddotItem) + for _, v := range selfrid { + if _, ok = rid[v]; ok { break - case comm.Reddot12102: - if isredot := this.modelMail.checkReddot30(session.GetUserId()); isredot { - reddot[comm.Reddot12102] = &pb.ReddotItem{ - Rid: int32(comm.Reddot12101), - Activated: true, + } + } + if ok { + return + } + for _, v := range selfrid { + if _, ok = rid[v]; ok { + switch v { + case comm.Reddot12101: + if isredot := this.modelMail.checkReddot26(session.GetUserId()); isredot { + items[comm.Reddot12101] = &pb.ReddotItem{ + Rid: int32(comm.Reddot12101), + Activated: true, + } + } else { + items[comm.Reddot12101] = &pb.ReddotItem{ + Rid: int32(comm.Reddot12101), + Activated: false, + } } - } else { - reddot[comm.Reddot12102] = &pb.ReddotItem{ - Rid: int32(comm.Reddot12101), - Activated: false, + break + case comm.Reddot12102: + if isredot := this.modelMail.checkReddot30(session.GetUserId()); isredot { + items[comm.Reddot12102] = &pb.ReddotItem{ + Rid: int32(comm.Reddot12101), + Activated: true, + } + } else { + items[comm.Reddot12102] = &pb.ReddotItem{ + Rid: int32(comm.Reddot12101), + Activated: false, + } } + break } - break } } return diff --git a/modules/mainline/module.go b/modules/mainline/module.go index 2dd6b82bc..bd0e52737 100644 --- a/modules/mainline/module.go +++ b/modules/mainline/module.go @@ -58,17 +58,31 @@ func (this *Mainline) Start() (err error) { } // 红点查询 -func (this *Mainline) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) { - reddot = make(map[comm.ReddotType]*pb.ReddotItem) - for _, v := range rid { - if v == comm.Reddot24101 { - reddot[comm.Reddot24101] = &pb.ReddotItem{ - Rid: int32(comm.Reddot24101), - Activated: this.CheckPoint(session.GetUserId()), - } +func (this *Mainline) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) { + var ( + selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot24101} + ok bool + ) + items = make(map[comm.ReddotType]*pb.ReddotItem) + for _, v := range selfrid { + if _, ok = rid[v]; ok { break } } + if ok { + return + } + for _, v := range selfrid { + if _, ok = rid[v]; ok { + if v == comm.Reddot24101 { + items[comm.Reddot24101] = &pb.ReddotItem{ + Rid: int32(comm.Reddot24101), + Activated: this.CheckPoint(session.GetUserId()), + } + break + } + } + } return } diff --git a/modules/viking/module.go b/modules/viking/module.go index 84ca6c31d..7db21dfc0 100644 --- a/modules/viking/module.go +++ b/modules/viking/module.go @@ -122,17 +122,32 @@ func (this *Viking) CheckUserBaseVikingInfo(uid string) (data []*pb.DBVikingRank } //红点查询 -func (this *Viking) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (reddot map[comm.ReddotType]*pb.ReddotItem) { - reddot = make(map[comm.ReddotType]*pb.ReddotItem) - for _, v := range rid { - switch v { - case comm.Reddot13102: - reddot[comm.Reddot13102] = &pb.ReddotItem{ - Rid: int32(comm.Reddot13102), - Activated: this.modelViking.checkReddot31(session), - } - break +func (this *Viking) Reddot(session comm.IUserSession, rid map[comm.ReddotType]struct{}) (items map[comm.ReddotType]*pb.ReddotItem) { + var ( + selfrid []comm.ReddotType = []comm.ReddotType{comm.Reddot13102} + ok bool + ) + items = make(map[comm.ReddotType]*pb.ReddotItem) + for _, v := range selfrid { + if _, ok = rid[v]; ok { + break + } + } + if ok { + return + } + for _, v := range selfrid { + if _, ok = rid[v]; ok { + switch v { + case comm.Reddot13102: + items[comm.Reddot13102] = &pb.ReddotItem{ + Rid: int32(comm.Reddot13102), + Activated: this.modelViking.checkReddot31(session), + } + break + + } } } return