diff --git a/comm/core.go b/comm/core.go index fddbb0a6b..03abb8d1d 100644 --- a/comm/core.go +++ b/comm/core.go @@ -19,6 +19,7 @@ const ( const ( Service_Gateway = "gateway" Service_Worker = "worker" + Service_DB = "dbservice" ) //ERR diff --git a/modules/dbservice/db_comp.go b/modules/dbservice/db_comp.go index c2537fa76..8d91af130 100644 --- a/modules/dbservice/db_comp.go +++ b/modules/dbservice/db_comp.go @@ -165,6 +165,7 @@ func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) { return } +// 写入日志数据 func (this *DB_Comp) Model_InsertDBByLog(data *comm.Autogenerated) (err error) { _, err = this.DB.InsertOne(DB_ModelTable, data) @@ -173,3 +174,13 @@ func (this *DB_Comp) Model_InsertDBByLog(data *comm.Autogenerated) (err error) { } return err } + +// 查询 当前日志列表还有没有处理完条数 +func (this *DB_Comp) Model_TotalCount() int { + + _data, err := this.DB.Find("model_log", bson.M{}) + if err == nil { + return _data.RemainingBatchLength() + } + return 0 +} diff --git a/modules/mail/api_getAttachment.go b/modules/mail/api_getAttachment.go index d76a91677..d43df3b4e 100644 --- a/modules/mail/api_getAttachment.go +++ b/modules/mail/api_getAttachment.go @@ -35,7 +35,7 @@ func (this *Api_Comp) GetUserMailAttachment(session comm.IUserSession, agrs map[ for _, v := range _data { _items[int32(v.ItemId)] += int32(v.ItemCount) } - bRet := this.pack.AddItemsToUserPack(mail.UserId, _items) + bRet := this.pack.AddItemsToUserPack(mail.Uid, _items) if bRet != nil { // 修改状态 this.module.db_comp.Mail_UpdateMailAttachmentState(req.ObjID) diff --git a/modules/mail/module.go b/modules/mail/module.go index 226a87553..ee711327c 100644 --- a/modules/mail/module.go +++ b/modules/mail/module.go @@ -43,7 +43,7 @@ func (this *Mail) OnInstallComp() { func (this *Mail) CreateNewMail(uId string) { mail := &pb.DB_MailData{ ObjId: primitive.NewObjectID().Hex(), - UserId: uId, + Uid: uId, Title: "系统邮件", Contex: "恭喜获得专属礼包一份", CreateTime: uint64(time.Now().Unix()), diff --git a/modules/user/api.go b/modules/user/api.go index ec3681af2..68f641aed 100644 --- a/modules/user/api.go +++ b/modules/user/api.go @@ -1,10 +1,13 @@ package user import ( + "errors" "go_dreamfactory/modules" "go_dreamfactory/lego/base" "go_dreamfactory/lego/core" + + "go.mongodb.org/mongo-driver/bson" ) const ( @@ -25,3 +28,15 @@ func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core this.module = module.(*User) return } + +func (this *Api_Comp) Start() (err error) { + err = this.MComp_GateComp.Start() + _data, err := this.module.modelUser.DB.Find("model_log", bson.M{}) + if err == nil { + if _data.RemainingBatchLength() > 0 { + return errors.New("") + } + } + + return +} diff --git a/pb/mail_db.pb.go b/pb/mail_db.pb.go index 29cd81e91..9309c2e91 100644 --- a/pb/mail_db.pb.go +++ b/pb/mail_db.pb.go @@ -81,7 +81,7 @@ type DB_MailData struct { unknownFields protoimpl.UnknownFields ObjId string `protobuf:"bytes,1,opt,name=ObjId,proto3" json:"ObjId" bson:"_id"` // ID - UserId string `protobuf:"bytes,2,opt,name=UserId,proto3" json:"UserId"` + Uid string `protobuf:"bytes,2,opt,name=Uid,proto3" json:"Uid"` Title string `protobuf:"bytes,3,opt,name=Title,proto3" json:"Title"` // 邮件标题 Contex string `protobuf:"bytes,4,opt,name=Contex,proto3" json:"Contex"` // 邮件内容 CreateTime uint64 `protobuf:"varint,5,opt,name=CreateTime,proto3" json:"CreateTime"` // 发送时间 @@ -130,9 +130,9 @@ func (x *DB_MailData) GetObjId() string { return "" } -func (x *DB_MailData) GetUserId() string { +func (x *DB_MailData) GetUid() string { if x != nil { - return x.UserId + return x.Uid } return "" } @@ -194,24 +194,24 @@ var file_mail_mail_db_proto_rawDesc = []byte{ 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 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, 0xf8, 0x01, 0x0a, + 0x0d, 0x52, 0x09, 0x49, 0x74, 0x65, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xf2, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x4d, 0x61, 0x69, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4f, 0x62, 0x6a, - 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x69, - 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, - 0x12, 0x16, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x18, 0x04, 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, 0x05, 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, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, - 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x08, 0x52, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x52, 0x65, 0x77, 0x61, - 0x72, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, - 0x12, 0x25, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x09, 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, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x55, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x43, 0x6f, + 0x6e, 0x74, 0x65, 0x78, 0x18, 0x04, 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, 0x05, 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, 0x06, 0x20, + 0x01, 0x28, 0x04, 0x52, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, + 0x43, 0x68, 0x65, 0x63, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x43, 0x68, 0x65, + 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x08, 0x20, 0x01, + 0x28, 0x08, 0x52, 0x06, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x12, 0x25, 0x0a, 0x05, 0x49, 0x74, + 0x65, 0x6d, 0x73, 0x18, 0x09, 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, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x33, } var ( diff --git a/pb/proto/mail/mail_db.proto b/pb/proto/mail/mail_db.proto index 425629b70..3db1aa47d 100644 --- a/pb/proto/mail/mail_db.proto +++ b/pb/proto/mail/mail_db.proto @@ -13,7 +13,7 @@ message MailAttachment { // 附件 message DB_MailData { string ObjId = 1; // @go_tags(`bson:"_id"`) ID - string UserId = 2; + string Uid = 2; string Title = 3; // 邮件标题 string Contex = 4; // 邮件内容 uint64 CreateTime = 5; // 发送时间 diff --git a/pb/proto/user/user_db.proto b/pb/proto/user/user_db.proto index 3c103330e..06b8947ae 100644 --- a/pb/proto/user/user_db.proto +++ b/pb/proto/user/user_db.proto @@ -5,7 +5,7 @@ message Cache_UserData { string uid = 1; string SessionId = 2; string GatewayServiceId = 3; - // DB_UserData UserData = 4; + DB_UserData UserData = 4;// @go_tags(`json:",inline"`) ID } message DB_UserData { diff --git a/services/comp_gateroute.go b/services/comp_gateroute.go index 74701f3ec..9b36f4950 100644 --- a/services/comp_gateroute.go +++ b/services/comp_gateroute.go @@ -59,7 +59,7 @@ func (this *SComp_GateRouteComp) Init(service core.IService, comp core.IServiceC this.msgcheck = make(map[string]*msghandle) this.msghandles = make(map[string]*msghandle) return err -} +} // //组件启动时注册rpc服务监听 func (this *SComp_GateRouteComp) Start() (err error) { @@ -76,6 +76,9 @@ func (this *SComp_GateRouteComp) Start() (err error) { } } }) + event.RegisterGO(core.Event_FindNewService, func() { + log.Debugf("find new service") + }) return } diff --git a/sys/cache/init_test.go b/sys/cache/init_test.go index c88fdc5b2..6e4810bbe 100644 --- a/sys/cache/init_test.go +++ b/sys/cache/init_test.go @@ -30,9 +30,9 @@ func TestMain(m *testing.M) { for i := 0; i < 50000; i++ { //go func() { _mail := &pb.DB_MailData{ - ObjId: primitive.NewObjectID().Hex(), - UserId: "uid123", - Title: "系统邮件", + ObjId: primitive.NewObjectID().Hex(), + Uid: "uid123", + Title: "系统邮件", Contex: "恭喜获得专属礼包一份", CreateTime: uint64(time.Now().Unix()),