邮件相关
This commit is contained in:
parent
1caf66f729
commit
951e892487
@ -75,7 +75,6 @@ func (x *MailAttachment) GetItemCount() uint32 {
|
||||
return 0
|
||||
}
|
||||
|
||||
//背包格子
|
||||
type MailData struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
@ -163,14 +162,13 @@ func (x *MailData) GetItems() []*MailAttachment {
|
||||
return nil
|
||||
}
|
||||
|
||||
//用户背包
|
||||
type DB_UserMailData struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
UserId uint32 `bson:"_id" json:"UserId,omitempty" protobuf:"varint,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}用户Id
|
||||
Mails []*MailData `protobuf:"bytes,2,rep,name=mails,proto3" json:"mails,omitempty"` // 邮件列表
|
||||
UserId string `bson:"_id" json:"UserId,omitempty" protobuf:"bytes,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}用户Id
|
||||
Mails []*MailData `protobuf:"bytes,2,rep,name=mails,proto3" json:"mails,omitempty"` // 邮件列表
|
||||
}
|
||||
|
||||
func (x *DB_UserMailData) Reset() {
|
||||
@ -205,11 +203,11 @@ func (*DB_UserMailData) Descriptor() ([]byte, []int) {
|
||||
return file_mail_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *DB_UserMailData) GetUserId() uint32 {
|
||||
func (x *DB_UserMailData) GetUserId() string {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return 0
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DB_UserMailData) GetMails() []*MailData {
|
||||
@ -240,7 +238,7 @@ var file_mail_proto_rawDesc = []byte{
|
||||
0x2e, 0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52,
|
||||
0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x4a, 0x0a, 0x0f, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65,
|
||||
0x72, 0x4d, 0x61, 0x69, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65,
|
||||
0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49,
|
||||
0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49,
|
||||
0x64, 0x12, 0x1f, 0x0a, 0x05, 0x6d, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b,
|
||||
0x32, 0x09, 0x2e, 0x4d, 0x61, 0x69, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x6d, 0x61, 0x69,
|
||||
0x6c, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74,
|
||||
|
@ -139,7 +139,7 @@ type DB_UserPackData struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}用户Id
|
||||
UserId string `bson:"_id" json:"UserId,omitempty" protobuf:"bytes,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}用户Id
|
||||
Pack []*GridData `protobuf:"bytes,2,rep,name=Pack,proto3" json:"Pack,omitempty"` //背包列表
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,7 @@ message MailAttachment { // 附件
|
||||
uint32 Itemid = 1; // 道具iD
|
||||
uint32 ItemCount = 2; // 数量
|
||||
}
|
||||
//背包格子
|
||||
|
||||
message MailData {
|
||||
string Title = 1; // 邮件标题
|
||||
string Contex = 2; // 邮件内容
|
||||
@ -15,8 +15,7 @@ message MailData {
|
||||
repeated MailAttachment Items = 6; // 附件
|
||||
}
|
||||
|
||||
//用户背包
|
||||
message DB_UserMailData {
|
||||
uint32 UserId = 1; //tags:{bson:"_id"}用户Id
|
||||
string UserId = 1; //tags:{bson:"_id"}用户Id
|
||||
repeated MailData mails = 2; // 邮件列表
|
||||
}
|
@ -88,7 +88,7 @@ type DB_UserData struct {
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}动态Id
|
||||
UserId string `bson:"_id" json:"UserId,omitempty" protobuf:"bytes,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}动态Id
|
||||
Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"`
|
||||
NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"`
|
||||
Email string `protobuf:"bytes,4,opt,name=Email,proto3" json:"Email,omitempty"`
|
||||
|
1
sys/cache/core.go
vendored
1
sys/cache/core.go
vendored
@ -4,6 +4,7 @@ type (
|
||||
ISys interface {
|
||||
IUser
|
||||
IPack
|
||||
IMail
|
||||
}
|
||||
)
|
||||
|
||||
|
34
sys/cache/mail.go
vendored
34
sys/cache/mail.go
vendored
@ -1,7 +1,35 @@
|
||||
package cache
|
||||
|
||||
const ( //Redis
|
||||
Redis_mailCache string = "mail:%d"
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/db"
|
||||
|
||||
"github.com/liwei1dao/lego/sys/mgo"
|
||||
"github.com/liwei1dao/lego/sys/redis"
|
||||
)
|
||||
|
||||
type IMail interface{}
|
||||
const ( //Redis
|
||||
Redis_MailCache string = "mail:%s"
|
||||
)
|
||||
|
||||
type IMail interface {
|
||||
QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error)
|
||||
}
|
||||
|
||||
// 查询玩家邮件数据
|
||||
func (this *Cache) QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error) {
|
||||
mail = &pb.DB_UserMailData{
|
||||
UserId: uId,
|
||||
}
|
||||
if err = this.redis.Get(fmt.Sprintf(Redis_MailCache, uId), mail); err == nil {
|
||||
return
|
||||
} 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
|
||||
}
|
||||
|
@ -4,15 +4,19 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"github.com/liwei1dao/lego/core"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
type IMail interface {
|
||||
}
|
||||
|
||||
const ( //Redis
|
||||
DB_MailTable core.SqlTable = "mail"
|
||||
)
|
||||
|
||||
type IMain interface {
|
||||
QueryUserMail(uId uint32) (pack *pb.DB_UserPackData, err error)
|
||||
type IMail interface {
|
||||
QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error)
|
||||
}
|
||||
|
||||
func (this *DB) QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error) {
|
||||
mail = &pb.DB_UserMailData{}
|
||||
err = this.mgo.FindOne(DB_MailTable, bson.M{"_id": uId}).Decode(mail)
|
||||
return
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user