From 54a4682a69185dbb07ca76fa98e402d2f868ff9c Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Wed, 29 Mar 2023 10:50:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=BF=80=E6=B4=BB=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/atlas/api_atlasactivate.go | 45 +++++++++++++++--------------- pb/atlas_msg.pb.go | 14 ++++++++-- 2 files changed, 34 insertions(+), 25 deletions(-) diff --git a/modules/atlas/api_atlasactivate.go b/modules/atlas/api_atlasactivate.go index 04abd0170..b84f591e0 100644 --- a/modules/atlas/api_atlasactivate.go +++ b/modules/atlas/api_atlasactivate.go @@ -9,41 +9,40 @@ import ( //参数校验 func (this *apiComp) ActivateCheck(session comm.IUserSession, req *pb.AtlasActivateReq) (code pb.ErrorCode) { - + if req.Id == "" { + code = pb.ErrorCode_ReqParameterError + } return } -// 一键激活所有激活图鉴信息 +// 激活图鉴信息 func (this *apiComp) Activate(session comm.IUserSession, req *pb.AtlasActivateReq) (code pb.ErrorCode, data proto.Message) { - var ( - bUpdate bool - ) if code = this.ActivateCheck(session, req); code != pb.ErrorCode_Success { return } + atlasConf := this.module.configure.GetPandoAtlasConf(req.Id) + if atlasConf == nil { + code = pb.ErrorCode_ConfigNoFound + return + } list, _ := this.module.modelPandaAtlas.getPandaAtlasList(session.GetUserId()) - for k, v := range list.Collect { + if v, ok := list.Collect[req.Id]; ok { if !v.Activate { + update := make(map[string]interface{}) v.Activate = true // 找到图鉴积分 并更新积分 - if atlasConf := this.module.configure.GetPandoAtlasConf(k); atlasConf != nil { - list.Score += atlasConf.AtlasScore - bUpdate = true - } + list.Score += atlasConf.AtlasScore + update["collect"] = list.Collect + update["score"] = list.Score + this.module.modelPandaAtlas.modifyPandaAtlasList(session.GetUserId(), update) + session.SendMsg(string(this.module.GetType()), "activate", &pb.AtlasActivateResp{ + Data: list, + }) + return + } else { + code = pb.ErrorCode_MartialhallAtlasError } } - if bUpdate { // 更新数据 - update := make(map[string]interface{}) - update["collect"] = list.Collect - update["score"] = list.Score - - this.module.modelPandaAtlas.modifyPandaAtlasList(session.GetUserId(), update) - } else { - code = pb.ErrorCode_MartialhallAtlasError - } - - session.SendMsg(string(this.module.GetType()), "activate", &pb.AtlasActivateResp{ - Data: list, - }) + code = pb.ErrorCode_SmithyNoFoundAtlas return } diff --git a/pb/atlas_msg.pb.go b/pb/atlas_msg.pb.go index 1bde889be..10f04b4e8 100644 --- a/pb/atlas_msg.pb.go +++ b/pb/atlas_msg.pb.go @@ -111,6 +111,8 @@ type AtlasActivateReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"` // 图鉴ID } func (x *AtlasActivateReq) Reset() { @@ -145,6 +147,13 @@ func (*AtlasActivateReq) Descriptor() ([]byte, []int) { return file_atlas_atlas_msg_proto_rawDescGZIP(), []int{2} } +func (x *AtlasActivateReq) GetId() string { + if x != nil { + return x.Id + } + return "" +} + type AtlasActivateResp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -297,8 +306,9 @@ var file_atlas_atlas_msg_proto_rawDesc = []byte{ 0x41, 0x74, 0x6c, 0x61, 0x73, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x6e, 0x64, 0x61, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x52, 0x04, 0x64, - 0x61, 0x74, 0x61, 0x22, 0x12, 0x0a, 0x10, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x41, 0x63, 0x74, 0x69, - 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x22, 0x36, 0x0a, 0x11, 0x41, 0x74, 0x6c, 0x61, 0x73, + 0x61, 0x74, 0x61, 0x22, 0x22, 0x0a, 0x10, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x41, 0x63, 0x74, 0x69, + 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x22, 0x36, 0x0a, 0x11, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x41, 0x63, 0x74, 0x69, 0x76, 0x61, 0x74, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x21, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0d, 0x2e, 0x44, 0x42, 0x50, 0x61, 0x6e, 0x64, 0x61, 0x41, 0x74, 0x6c, 0x61, 0x73, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22,