go_dreamfactory/modules/mail/api_getAttachment.go
2022-06-27 17:45:02 +08:00

51 lines
1.3 KiB
Go

package mail
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
)
func (this *Api_Comp) GetUserMailAttachment_Check(session comm.IUserSession, req *pb.Mail_GetUserMailAttachment_Req) (result map[string]interface{}, code comm.ErrorCode) {
return
}
// 领取附件
func (this *Api_Comp) GetUserMailAttachment(session comm.IUserSession, agrs map[string]interface{}, req *pb.Mail_GetUserMailAttachment_Req) (code pb.ErrorCode) {
var (
mail *pb.DB_MailData
)
defer func() {
session.SendMsg(string(this.module.GetType()), GetUserMailAttachmentResp, &pb.Mail_GetUserMailAttachment_Resp{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)
}
code = this.items.AddItems(mail.Uid, _items)
if code == pb.ErrorCode_Success {
// 修改状态
this.module.db_comp.Mail_UpdateMailAttachmentState(req.ObjID)
mail.Reward = true
return
}
return
}
}
code = pb.ErrorCode_SystemError
return
}