Merge branch 'dev' into f66
# Conflicts: # comm/core.go # modules/user/login_comp.go
This commit is contained in:
commit
593a036393
@ -18,6 +18,7 @@ const (
|
||||
SM_WebModule core.M_Modules = "web" //web模块
|
||||
SM_UserModule core.M_Modules = "user" //用户模块
|
||||
SM_PackModule core.M_Modules = "pack" //背包模块
|
||||
SM_MailModule core.M_Modules = "mail" //邮件模块
|
||||
)
|
||||
|
||||
const ( //Rpc
|
||||
@ -45,6 +46,7 @@ type IUserSession interface {
|
||||
GetUserId() string
|
||||
GetIP() string
|
||||
GetGatewayServiceId() string
|
||||
IsLogin() bool
|
||||
Build(uid string) (err error)
|
||||
UnBuild(ServiceMethod string, msg proto.Message) (err error)
|
||||
SendMsg(mainType, subType string, code pb.ErrorCode, msg proto.Message) (err error)
|
||||
|
@ -42,6 +42,10 @@ func (this *UserSession) GetGatewayServiceId() string {
|
||||
return this.GatewayServiceId
|
||||
}
|
||||
|
||||
func (this *UserSession) IsLogin() bool {
|
||||
return this.UserId != ""
|
||||
}
|
||||
|
||||
func (this *UserSession) Build(uid string) (err error) {
|
||||
reply := &pb.RPCMessageReply{}
|
||||
if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentBuild), context.Background(), &pb.AgentBuildReq{
|
||||
|
@ -33,6 +33,7 @@ func (this *MComp_GateComp) Init(service core.IService, module core.IModule, com
|
||||
this.service = service.(base.IRPCXService)
|
||||
this.module = module
|
||||
this.comp = comp
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
|
23
modules/mail/api_comp.go
Normal file
23
modules/mail/api_comp.go
Normal file
@ -0,0 +1,23 @@
|
||||
package mail
|
||||
|
||||
import (
|
||||
"go_dreamfactory/modules"
|
||||
|
||||
"github.com/liwei1dao/lego/core"
|
||||
)
|
||||
|
||||
const (
|
||||
QueryUserMailReq = "mail.queryusermailreq"
|
||||
QueryUserMailResp = "mail.queryusermailresp"
|
||||
)
|
||||
|
||||
type Api_Comp struct {
|
||||
modules.MComp_GateComp
|
||||
module *Mail
|
||||
}
|
||||
|
||||
func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.MComp_GateComp.Init(service, module, comp, options)
|
||||
this.module = module.(*Mail)
|
||||
return
|
||||
}
|
16
modules/mail/configure_comp.go
Normal file
16
modules/mail/configure_comp.go
Normal file
@ -0,0 +1,16 @@
|
||||
package mail
|
||||
|
||||
import (
|
||||
"github.com/liwei1dao/lego/core"
|
||||
"github.com/liwei1dao/lego/core/cbase"
|
||||
)
|
||||
|
||||
// 邮件配置管理组件
|
||||
type Configure_Comp struct {
|
||||
cbase.ModuleCompBase
|
||||
}
|
||||
|
||||
func (this *Configure_Comp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
this.ModuleCompBase.Init(service, module, comp, options)
|
||||
return
|
||||
}
|
34
modules/mail/module.go
Normal file
34
modules/mail/module.go
Normal file
@ -0,0 +1,34 @@
|
||||
package mail
|
||||
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules"
|
||||
|
||||
"github.com/liwei1dao/lego/core"
|
||||
)
|
||||
|
||||
/*
|
||||
模块名:Mail
|
||||
描述:邮件系统模块
|
||||
开发:梅雄风
|
||||
*/
|
||||
func NewModule() core.IModule {
|
||||
m := new(Mail)
|
||||
return m
|
||||
}
|
||||
|
||||
type Mail struct {
|
||||
modules.ModuleBase
|
||||
api_comp *Api_Comp
|
||||
configure_comp *Configure_Comp
|
||||
}
|
||||
|
||||
func (this *Mail) GetType() core.M_Modules {
|
||||
return comm.SM_MailModule
|
||||
}
|
||||
|
||||
func (this *Mail) OnInstallComp() {
|
||||
this.ModuleBase.OnInstallComp()
|
||||
this.api_comp = this.RegisterComp(new(Api_Comp)).(*Api_Comp)
|
||||
this.configure_comp = this.RegisterComp(new(Configure_Comp)).(*Configure_Comp)
|
||||
}
|
337
pb/mail.pb.go
Normal file
337
pb/mail.pb.go
Normal file
@ -0,0 +1,337 @@
|
||||
// Code generated by protoc-gen-go. DO NOT EDIT.
|
||||
// versions:
|
||||
// protoc-gen-go v1.28.0
|
||||
// protoc v3.20.0
|
||||
// source: mail.proto
|
||||
|
||||
package pb
|
||||
|
||||
import (
|
||||
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
|
||||
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
|
||||
reflect "reflect"
|
||||
sync "sync"
|
||||
)
|
||||
|
||||
const (
|
||||
// Verify that this generated code is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion)
|
||||
// Verify that runtime/protoimpl is sufficiently up-to-date.
|
||||
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
|
||||
)
|
||||
|
||||
type MailAttachment struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Itemid uint32 `protobuf:"varint,1,opt,name=Itemid,proto3" json:"Itemid,omitempty"` // 道具iD
|
||||
ItemCount uint32 `protobuf:"varint,2,opt,name=ItemCount,proto3" json:"ItemCount,omitempty"` // 数量
|
||||
}
|
||||
|
||||
func (x *MailAttachment) Reset() {
|
||||
*x = MailAttachment{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_mail_proto_msgTypes[0]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *MailAttachment) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*MailAttachment) ProtoMessage() {}
|
||||
|
||||
func (x *MailAttachment) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_mail_proto_msgTypes[0]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use MailAttachment.ProtoReflect.Descriptor instead.
|
||||
func (*MailAttachment) Descriptor() ([]byte, []int) {
|
||||
return file_mail_proto_rawDescGZIP(), []int{0}
|
||||
}
|
||||
|
||||
func (x *MailAttachment) GetItemid() uint32 {
|
||||
if x != nil {
|
||||
return x.Itemid
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *MailAttachment) GetItemCount() uint32 {
|
||||
if x != nil {
|
||||
return x.ItemCount
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
type MailData struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
Title string `protobuf:"bytes,1,opt,name=Title,proto3" json:"Title,omitempty"` // 邮件标题
|
||||
Contex string `protobuf:"bytes,2,opt,name=Contex,proto3" json:"Contex,omitempty"` // 邮件内容
|
||||
CreateTime uint64 `protobuf:"varint,3,opt,name=CreateTime,proto3" json:"CreateTime,omitempty"` // 发送时间
|
||||
DueTime uint64 `protobuf:"varint,4,opt,name=DueTime,proto3" json:"DueTime,omitempty"` // 过期时间
|
||||
Check bool `protobuf:"varint,5,opt,name=Check,proto3" json:"Check,omitempty"` // 是否查看
|
||||
Items []*MailAttachment `protobuf:"bytes,6,rep,name=Items,proto3" json:"Items,omitempty"` // 附件
|
||||
}
|
||||
|
||||
func (x *MailData) Reset() {
|
||||
*x = MailData{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_mail_proto_msgTypes[1]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *MailData) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*MailData) ProtoMessage() {}
|
||||
|
||||
func (x *MailData) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_mail_proto_msgTypes[1]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use MailData.ProtoReflect.Descriptor instead.
|
||||
func (*MailData) Descriptor() ([]byte, []int) {
|
||||
return file_mail_proto_rawDescGZIP(), []int{1}
|
||||
}
|
||||
|
||||
func (x *MailData) GetTitle() string {
|
||||
if x != nil {
|
||||
return x.Title
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MailData) GetContex() string {
|
||||
if x != nil {
|
||||
return x.Contex
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *MailData) GetCreateTime() uint64 {
|
||||
if x != nil {
|
||||
return x.CreateTime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *MailData) GetDueTime() uint64 {
|
||||
if x != nil {
|
||||
return x.DueTime
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (x *MailData) GetCheck() bool {
|
||||
if x != nil {
|
||||
return x.Check
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
func (x *MailData) GetItems() []*MailAttachment {
|
||||
if x != nil {
|
||||
return x.Items
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type DB_UserMailData struct {
|
||||
state protoimpl.MessageState
|
||||
sizeCache protoimpl.SizeCache
|
||||
unknownFields protoimpl.UnknownFields
|
||||
|
||||
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() {
|
||||
*x = DB_UserMailData{}
|
||||
if protoimpl.UnsafeEnabled {
|
||||
mi := &file_mail_proto_msgTypes[2]
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
}
|
||||
|
||||
func (x *DB_UserMailData) String() string {
|
||||
return protoimpl.X.MessageStringOf(x)
|
||||
}
|
||||
|
||||
func (*DB_UserMailData) ProtoMessage() {}
|
||||
|
||||
func (x *DB_UserMailData) ProtoReflect() protoreflect.Message {
|
||||
mi := &file_mail_proto_msgTypes[2]
|
||||
if protoimpl.UnsafeEnabled && x != nil {
|
||||
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
|
||||
if ms.LoadMessageInfo() == nil {
|
||||
ms.StoreMessageInfo(mi)
|
||||
}
|
||||
return ms
|
||||
}
|
||||
return mi.MessageOf(x)
|
||||
}
|
||||
|
||||
// Deprecated: Use DB_UserMailData.ProtoReflect.Descriptor instead.
|
||||
func (*DB_UserMailData) Descriptor() ([]byte, []int) {
|
||||
return file_mail_proto_rawDescGZIP(), []int{2}
|
||||
}
|
||||
|
||||
func (x *DB_UserMailData) GetUserId() string {
|
||||
if x != nil {
|
||||
return x.UserId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DB_UserMailData) GetMails() []*MailData {
|
||||
if x != nil {
|
||||
return x.Mails
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
var File_mail_proto protoreflect.FileDescriptor
|
||||
|
||||
var file_mail_proto_rawDesc = []byte{
|
||||
0x0a, 0x0a, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x46, 0x0a, 0x0e,
|
||||
0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x16,
|
||||
0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06,
|
||||
0x49, 0x74, 0x65, 0x6d, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x49, 0x74, 0x65, 0x6d, 0x43, 0x6f,
|
||||
0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x49, 0x74, 0x65, 0x6d, 0x43,
|
||||
0x6f, 0x75, 0x6e, 0x74, 0x22, 0xaf, 0x01, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6c, 0x44, 0x61, 0x74,
|
||||
0x61, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x74, 0x65,
|
||||
0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x12,
|
||||
0x1e, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20,
|
||||
0x01, 0x28, 0x04, 0x52, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12,
|
||||
0x18, 0x0a, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04,
|
||||
0x52, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x43, 0x68, 0x65,
|
||||
0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12,
|
||||
0x25, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f,
|
||||
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, 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,
|
||||
0x6f, 0x33,
|
||||
}
|
||||
|
||||
var (
|
||||
file_mail_proto_rawDescOnce sync.Once
|
||||
file_mail_proto_rawDescData = file_mail_proto_rawDesc
|
||||
)
|
||||
|
||||
func file_mail_proto_rawDescGZIP() []byte {
|
||||
file_mail_proto_rawDescOnce.Do(func() {
|
||||
file_mail_proto_rawDescData = protoimpl.X.CompressGZIP(file_mail_proto_rawDescData)
|
||||
})
|
||||
return file_mail_proto_rawDescData
|
||||
}
|
||||
|
||||
var file_mail_proto_msgTypes = make([]protoimpl.MessageInfo, 3)
|
||||
var file_mail_proto_goTypes = []interface{}{
|
||||
(*MailAttachment)(nil), // 0: MailAttachment
|
||||
(*MailData)(nil), // 1: MailData
|
||||
(*DB_UserMailData)(nil), // 2: DB_UserMailData
|
||||
}
|
||||
var file_mail_proto_depIdxs = []int32{
|
||||
0, // 0: MailData.Items:type_name -> MailAttachment
|
||||
1, // 1: DB_UserMailData.mails:type_name -> MailData
|
||||
2, // [2:2] is the sub-list for method output_type
|
||||
2, // [2:2] is the sub-list for method input_type
|
||||
2, // [2:2] is the sub-list for extension type_name
|
||||
2, // [2:2] is the sub-list for extension extendee
|
||||
0, // [0:2] is the sub-list for field type_name
|
||||
}
|
||||
|
||||
func init() { file_mail_proto_init() }
|
||||
func file_mail_proto_init() {
|
||||
if File_mail_proto != nil {
|
||||
return
|
||||
}
|
||||
if !protoimpl.UnsafeEnabled {
|
||||
file_mail_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*MailAttachment); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_mail_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*MailData); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
file_mail_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} {
|
||||
switch v := v.(*DB_UserMailData); i {
|
||||
case 0:
|
||||
return &v.state
|
||||
case 1:
|
||||
return &v.sizeCache
|
||||
case 2:
|
||||
return &v.unknownFields
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
type x struct{}
|
||||
out := protoimpl.TypeBuilder{
|
||||
File: protoimpl.DescBuilder{
|
||||
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
|
||||
RawDescriptor: file_mail_proto_rawDesc,
|
||||
NumEnums: 0,
|
||||
NumMessages: 3,
|
||||
NumExtensions: 0,
|
||||
NumServices: 0,
|
||||
},
|
||||
GoTypes: file_mail_proto_goTypes,
|
||||
DependencyIndexes: file_mail_proto_depIdxs,
|
||||
MessageInfos: file_mail_proto_msgTypes,
|
||||
}.Build()
|
||||
File_mail_proto = out.File
|
||||
file_mail_proto_rawDesc = nil
|
||||
file_mail_proto_goTypes = nil
|
||||
file_mail_proto_depIdxs = nil
|
||||
}
|
@ -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"` //背包列表
|
||||
}
|
||||
|
||||
|
21
pb/proto/mail.proto
Normal file
21
pb/proto/mail.proto
Normal file
@ -0,0 +1,21 @@
|
||||
syntax = "proto3";
|
||||
option go_package = ".;pb";
|
||||
|
||||
message MailAttachment { // 附件
|
||||
uint32 Itemid = 1; // 道具iD
|
||||
uint32 ItemCount = 2; // 数量
|
||||
}
|
||||
|
||||
message MailData {
|
||||
string Title = 1; // 邮件标题
|
||||
string Contex = 2; // 邮件内容
|
||||
uint64 CreateTime = 3; // 发送时间
|
||||
uint64 DueTime = 4; // 过期时间
|
||||
bool Check = 5; // 是否查看
|
||||
repeated MailAttachment Items = 6; // 附件
|
||||
}
|
||||
|
||||
message DB_UserMailData {
|
||||
string UserId = 1; //tags:{bson:"_id"}用户Id
|
||||
repeated MailData mails = 2; // 邮件列表
|
||||
}
|
@ -9,7 +9,7 @@ message Cache_UserData {
|
||||
|
||||
message DB_UserData {
|
||||
string UserId = 1; //tags:{bson:"_id"}动态Id
|
||||
string account = 2;
|
||||
string Account = 2;
|
||||
string NiceName = 3;
|
||||
int32 ServerId = 4;
|
||||
}
|
@ -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"`
|
||||
ServerId int32 `protobuf:"varint,4,opt,name=ServerId,proto3" json:"ServerId,omitempty"`
|
||||
|
@ -31,3 +31,4 @@ buildProto('./pb/proto','./pb','user_db')
|
||||
buildProto('./pb/proto','./pb','user_msg')
|
||||
buildProto('./pb/proto','./pb','pack_db')
|
||||
buildProto('./pb/proto','./pb','pack_msg')
|
||||
buildProto('./pb/proto','./pb','mail')
|
@ -3,6 +3,7 @@ package main
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"go_dreamfactory/modules/mail"
|
||||
"go_dreamfactory/modules/pack"
|
||||
"go_dreamfactory/modules/user"
|
||||
"go_dreamfactory/services"
|
||||
@ -32,6 +33,7 @@ func main() {
|
||||
// web.NewModule(),
|
||||
user.NewModule(),
|
||||
pack.NewModule(),
|
||||
mail.NewModule(),
|
||||
)
|
||||
|
||||
}
|
||||
|
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
|
||||
}
|
||||
|
@ -1,4 +1,22 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"go_dreamfactory/pb"
|
||||
|
||||
"github.com/liwei1dao/lego/core"
|
||||
"go.mongodb.org/mongo-driver/bson"
|
||||
)
|
||||
|
||||
const ( //Redis
|
||||
DB_MailTable core.SqlTable = "mail"
|
||||
)
|
||||
|
||||
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