package mail import ( "go_dreamfactory/comm" "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" "google.golang.org/protobuf/proto" ) func (this *apiComp) GetUserMailAttachmentCheck(session comm.IUserSession, req *pb.MailGetUserMailAttachmentReq) (code pb.ErrorCode) { if req.ObjID == "" { return pb.ErrorCode_ReqParameterError } return } // 领取附件 func (this *apiComp) GetUserMailAttachment(session comm.IUserSession, req *pb.MailGetUserMailAttachmentReq) (code pb.ErrorCode, data proto.Message) { code = this.GetUserMailAttachmentCheck(session, req) // check if code != pb.ErrorCode_Success { return } mail, err := this.module.modelMail.Mail_GetMailAttachmentState(req.ObjID, session.GetUserId()) if err != nil { code = pb.ErrorCode_MailErr return } if mail.Reward || len(mail.GetItems()) == 0 || mail.Uid != session.GetUserId() { code = pb.ErrorCode_StateInvalid return } _data, err := this.module.modelMail.Mail_GetMailAttachment(req.ObjID) if err == nil { if len(_data) > 0 { res := make([]*cfg.Game_atn, 0) for _, v := range _data { d := &cfg.Game_atn{ A: v.A, T: v.T, N: v.N, } res = append(res, d) } code = this.module.api.module.DispenseRes(session, res, true) // 领取附件 if code == pb.ErrorCode_Success { // 修改状态 this.module.modelMail.Mail_UpdateMailAttachmentState(req.ObjID) mail.Reward = true return } } } session.SendMsg(string(this.module.GetType()), "getusermailattachment", &pb.MailGetUserMailAttachmentResp{Mail: mail}) return }