go_dreamfactory/sys/cache/mail.go
2022-06-07 17:28:00 +08:00

52 lines
1.3 KiB
Go

package cache
import (
"go_dreamfactory/pb"
"go_dreamfactory/sys/db"
)
const ( //Redis
Redis_MailCache string = "mail:%s"
)
type IMail interface {
QueryUserMail(uId string) (mail []*pb.DB_MailData, err error)
InsertUserMail(uId string) (mail []*pb.DB_MailData, err error)
ReadOneMail(uId string, ObjId string) (mail *pb.DB_MailData, err error)
}
// 查询玩家邮件数据
func (this *Cache) QueryUserMail(uId string) (mail []*pb.DB_MailData, err error) {
// var result []interface{}
// if result, err = this.redis.HGetAll(fmt.Sprintf(Redis_MailCache, uId), reflect.TypeOf(&pb.DB_MailData{})); err != nil {
// return
// } else {
// mail = make([]*pb.DB_MailData, len(result))
// for i, v := range result {
// mail[i] = v.(*pb.DB_MailData)
// }
// }
// 邮件暂时不写redis
mail, _ = db.Defsys.QueryUserMail(uId)
// } else if err == redis.RedisNil {
// if mail, err = db.Defsys.QueryUserMail(uId); err == nil {
// this.redis.Set(fmt.Sprintf(Redis_MailCache, uId), mail, -1)
// } else if err == mgo.MongodbNil {
// err = nil
// }
// }
return
}
// 创建新的邮件
func (this *Cache) ReadOneMail(uId string, ObjId string) (mail *pb.DB_MailData, err error) {
return
}
func (this *Cache) InsertUserMail(uId string) (mail []*pb.DB_MailData, err error) {
return
}