go_dreamfactory/modules/mail/api_getAttachment.go
2022-06-15 14:46:59 +08:00

52 lines
1.3 KiB
Go

package mail
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
)
func (this *Api_Comp) GetUserMailAttachmentReq_Check(session comm.IUserSession, req *pb.DelUserMailReq) (result map[string]interface{}, code pb.ErrorCode) {
return
}
// 领取附件
func (this *Api_Comp) GetUserMailAttachmentReq(session comm.IUserSession, agrs map[string]interface{}, req *pb.GetUserMailAttachmentReq) (err error) {
var (
code pb.ErrorCode
mail *pb.DB_MailData
)
defer func() {
session.SendMsg(string(this.module.GetType()), GetUserMailAttachmentResp, code, &pb.GetUserMailAttachmentResp{Mail: mail})
}()
if session.GetUserId() == "" {
code = pb.ErrorCode_NoLogin
return
}
_bGet := this.module.db_comp.Mail_GetMailAttachmentState(req.ObjID)
if !_bGet {
code = pb.ErrorCode_StateInvalid
return
}
_data, err := this.module.db_comp.Mail_GetMailAttachment(req.ObjID)
if err != nil {
if len(_data) > 0 {
// todo 领取附件
_items := make(map[int32]int32, 0)
for _, v := range _data {
_items[int32(v.ItemId)] += int32(v.ItemCount)
}
bRet := this.pack.AddItemsToUserPack(mail.UserId, _items)
if bRet != nil {
// 修改状态
this.module.db_comp.Mail_UpdateMailAttachmentState(req.ObjID)
mail.Reward = true
return
}
}
code = pb.ErrorCode_SystemError
}
return
}