日志接口查询

This commit is contained in:
meixiongfeng 2022-06-21 11:08:06 +08:00
parent 9a8ac28320
commit 7cf62a2056
10 changed files with 57 additions and 27 deletions

View File

@ -19,6 +19,7 @@ const (
const ( const (
Service_Gateway = "gateway" Service_Gateway = "gateway"
Service_Worker = "worker" Service_Worker = "worker"
Service_DB = "dbservice"
) )
//ERR //ERR

View File

@ -165,6 +165,7 @@ func (this *DB_Comp) Model_UpdateDBByLog(uid string) (err error) {
return return
} }
// 写入日志数据
func (this *DB_Comp) Model_InsertDBByLog(data *comm.Autogenerated) (err error) { func (this *DB_Comp) Model_InsertDBByLog(data *comm.Autogenerated) (err error) {
_, err = this.DB.InsertOne(DB_ModelTable, data) _, err = this.DB.InsertOne(DB_ModelTable, data)
@ -173,3 +174,13 @@ func (this *DB_Comp) Model_InsertDBByLog(data *comm.Autogenerated) (err error) {
} }
return err 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
}

View File

@ -35,7 +35,7 @@ func (this *Api_Comp) GetUserMailAttachment(session comm.IUserSession, agrs map[
for _, v := range _data { for _, v := range _data {
_items[int32(v.ItemId)] += int32(v.ItemCount) _items[int32(v.ItemId)] += int32(v.ItemCount)
} }
bRet := this.pack.AddItemsToUserPack(mail.UserId, _items) bRet := this.pack.AddItemsToUserPack(mail.Uid, _items)
if bRet != nil { if bRet != nil {
// 修改状态 // 修改状态
this.module.db_comp.Mail_UpdateMailAttachmentState(req.ObjID) this.module.db_comp.Mail_UpdateMailAttachmentState(req.ObjID)

View File

@ -43,7 +43,7 @@ func (this *Mail) OnInstallComp() {
func (this *Mail) CreateNewMail(uId string) { func (this *Mail) CreateNewMail(uId string) {
mail := &pb.DB_MailData{ mail := &pb.DB_MailData{
ObjId: primitive.NewObjectID().Hex(), ObjId: primitive.NewObjectID().Hex(),
UserId: uId, Uid: uId,
Title: "系统邮件", Title: "系统邮件",
Contex: "恭喜获得专属礼包一份", Contex: "恭喜获得专属礼包一份",
CreateTime: uint64(time.Now().Unix()), CreateTime: uint64(time.Now().Unix()),

View File

@ -1,10 +1,13 @@
package user package user
import ( import (
"errors"
"go_dreamfactory/modules" "go_dreamfactory/modules"
"go_dreamfactory/lego/base" "go_dreamfactory/lego/base"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
"go.mongodb.org/mongo-driver/bson"
) )
const ( const (
@ -25,3 +28,15 @@ func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core
this.module = module.(*User) this.module = module.(*User)
return 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
}

View File

@ -81,7 +81,7 @@ type DB_MailData struct {
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
ObjId string `protobuf:"bytes,1,opt,name=ObjId,proto3" json:"ObjId" bson:"_id"` // ID 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"` // 邮件标题 Title string `protobuf:"bytes,3,opt,name=Title,proto3" json:"Title"` // 邮件标题
Contex string `protobuf:"bytes,4,opt,name=Contex,proto3" json:"Contex"` // 邮件内容 Contex string `protobuf:"bytes,4,opt,name=Contex,proto3" json:"Contex"` // 邮件内容
CreateTime uint64 `protobuf:"varint,5,opt,name=CreateTime,proto3" json:"CreateTime"` // 发送时间 CreateTime uint64 `protobuf:"varint,5,opt,name=CreateTime,proto3" json:"CreateTime"` // 发送时间
@ -130,9 +130,9 @@ func (x *DB_MailData) GetObjId() string {
return "" return ""
} }
func (x *DB_MailData) GetUserId() string { func (x *DB_MailData) GetUid() string {
if x != nil { if x != nil {
return x.UserId return x.Uid
} }
return "" 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, 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, 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, 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, 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, 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, 0x49, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x55, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x69, 0x03, 0x55, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, 0x20,
0x74, 0x6c, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x43, 0x6f,
0x12, 0x16, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x6e, 0x74, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x43, 0x6f, 0x6e, 0x74,
0x52, 0x06, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x12, 0x1e, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x65, 0x78, 0x12, 0x1e, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65,
0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x43, 0x72, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69,
0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x44, 0x75, 0x65, 0x54, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20,
0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x01, 0x28, 0x04, 0x52, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05,
0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x43, 0x68, 0x65,
0x08, 0x52, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x52, 0x65, 0x77, 0x61, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x08, 0x20, 0x01,
0x72, 0x64, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x28, 0x08, 0x52, 0x06, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x12, 0x25, 0x0a, 0x05, 0x49, 0x74,
0x12, 0x25, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x65, 0x6d, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x4d, 0x61, 0x69, 0x6c,
0x0f, 0x2e, 0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d,
0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x33,
} }
var ( var (

View File

@ -13,7 +13,7 @@ message MailAttachment { // 附件
message DB_MailData { message DB_MailData {
string ObjId = 1; // @go_tags(`bson:"_id"`) ID string ObjId = 1; // @go_tags(`bson:"_id"`) ID
string UserId = 2; string Uid = 2;
string Title = 3; // string Title = 3; //
string Contex = 4; // string Contex = 4; //
uint64 CreateTime = 5; // uint64 CreateTime = 5; //

View File

@ -5,7 +5,7 @@ message Cache_UserData {
string uid = 1; string uid = 1;
string SessionId = 2; string SessionId = 2;
string GatewayServiceId = 3; string GatewayServiceId = 3;
// DB_UserData UserData = 4; DB_UserData UserData = 4;// @go_tags(`json:",inline"`) ID
} }
message DB_UserData { message DB_UserData {

View File

@ -59,7 +59,7 @@ func (this *SComp_GateRouteComp) Init(service core.IService, comp core.IServiceC
this.msgcheck = make(map[string]*msghandle) this.msgcheck = make(map[string]*msghandle)
this.msghandles = make(map[string]*msghandle) this.msghandles = make(map[string]*msghandle)
return err return err
} } //
//组件启动时注册rpc服务监听 //组件启动时注册rpc服务监听
func (this *SComp_GateRouteComp) Start() (err error) { 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 return
} }

View File

@ -31,7 +31,7 @@ func TestMain(m *testing.M) {
//go func() { //go func() {
_mail := &pb.DB_MailData{ _mail := &pb.DB_MailData{
ObjId: primitive.NewObjectID().Hex(), ObjId: primitive.NewObjectID().Hex(),
UserId: "uid123", Uid: "uid123",
Title: "系统邮件", Title: "系统邮件",
Contex: "恭喜获得专属礼包一份", Contex: "恭喜获得专属礼包一份",