From c6c2b5daaeae9dd0a936d7cecb2d55ad5d7bd69c Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Wed, 13 Jul 2022 11:25:37 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BC=80=E5=8F=91=E7=B3=BB=E7=BB=9F=E5=85=AC?= =?UTF-8?q?=E5=91=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/comp_model.go | 19 ++++ modules/notify/api.go | 29 +++++ modules/notify/api_getlist.go | 38 +++++++ modules/notify/configure.go | 23 ++++ modules/notify/core.go | 1 + modules/notify/modelNotify.go | 66 +++++++++++ modules/notify/module.go | 44 +++++++ modules/notify/module_test.go | 74 ++++++++++++ pb/notify_db.pb.go | 189 +++++++++++++++++++++++++++++++ pb/notify_msg.pb.go | 179 +++++++++++++++++++++++++---- pb/proto/notify/notify_db.proto | 12 ++ pb/proto/notify/notify_msg.proto | 13 ++- pb/proto/userexpand.proto | 10 ++ pb/userexpand.pb.go | 162 ++++++++++++++++++++++++++ 14 files changed, 835 insertions(+), 24 deletions(-) create mode 100644 modules/notify/api.go create mode 100644 modules/notify/api_getlist.go create mode 100644 modules/notify/configure.go create mode 100644 modules/notify/core.go create mode 100644 modules/notify/modelNotify.go create mode 100644 modules/notify/module.go create mode 100644 modules/notify/module_test.go create mode 100644 pb/notify_db.pb.go create mode 100644 pb/proto/notify/notify_db.proto create mode 100644 pb/proto/userexpand.proto create mode 100644 pb/userexpand.pb.go diff --git a/modules/comp_model.go b/modules/comp_model.go index b666aaf17..5f3999aea 100644 --- a/modules/comp_model.go +++ b/modules/comp_model.go @@ -11,6 +11,7 @@ import ( "go_dreamfactory/lego/sys/log" "go_dreamfactory/lego/sys/mgo" "go_dreamfactory/lego/sys/redis" + "go_dreamfactory/pb" "go_dreamfactory/sys/cache" "go_dreamfactory/sys/db" "reflect" @@ -74,6 +75,7 @@ func (this *MCompModel) InsertModelLogs(table string, uID string, target interfa return err } + func (this *MCompModel) DeleteModelLogs(table string, uID string, where interface{}) (err error) { data := &comm.Autogenerated{ @@ -92,6 +94,7 @@ func (this *MCompModel) DeleteModelLogs(table string, uID string, where interfac return err } + func (this *MCompModel) UpdateModelLogs(table string, uID string, where bson.M, target interface{}) (err error) { data := &comm.Autogenerated{ @@ -357,6 +360,7 @@ func (this *MCompModel) GetList(uid string, data interface{}) (err error) { err = fmt.Errorf("MCompModel: GetList(data not support MarshalMapJson %T)", data) return } + sliceelemType = sliceelemType.(*reflect2.UnsafePtrType).Elem() keys, err = this.Redis.HGetAllToMapString(this.ukey(uid)) if err == nil { n = 0 @@ -462,6 +466,21 @@ func (this *MCompModel) DelListlds(uid string, ids ...string) (err error) { return } +//获取用户通过扩展表 +func (this *MCompModel) GetUserExpand(uid string) (result *pb.DBUserExpand, err error) { + result = &pb.DBUserExpand{} + if err = this.Redis.HGetAll(this.ukey(uid), result); err != nil && err != redis.RedisNil { + return + } + if err == redis.RedisNil { + if err = this.DB.FindOne(core.SqlTable("userexpand"), bson.M{"uid": uid}).Decode(result); err != nil { + return + } + err = this.Redis.HMSet(this.ukey(uid), result) + } + return +} + //日志操作可选项 func (this *MCompModel) logOpt(uid string, data interface{}, attrs ...*cache.OperationAttr) error { ret := cache.OperationAttrs(attrs).Find(cache.ATTR_MGOLOG).Unwrap_Or(nil) diff --git a/modules/notify/api.go b/modules/notify/api.go new file mode 100644 index 000000000..2158dd643 --- /dev/null +++ b/modules/notify/api.go @@ -0,0 +1,29 @@ +package notify + +import ( + "go_dreamfactory/modules" + + "go_dreamfactory/lego/core" +) + +/* +API +*/ +type apiComp struct { + modules.MCompGate + service core.IService + module *Notification +} + +//组件初始化接口 +func (this *apiComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.MCompGate.Init(service, module, comp, options) + this.module = module.(*Notification) + this.service = service + return +} + +func (this *apiComp) Start() (err error) { + err = this.MCompGate.Start() + return +} diff --git a/modules/notify/api_getlist.go b/modules/notify/api_getlist.go new file mode 100644 index 000000000..00c8028a2 --- /dev/null +++ b/modules/notify/api_getlist.go @@ -0,0 +1,38 @@ +package notify + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + + "github.com/golang/protobuf/proto" +) + +//参数校验 +func (this *apiComp) GetlistCheck(session comm.IUserSession, req *pb.NotifyGetListReq) (code pb.ErrorCode) { + + return +} + +///获取系统公告 +func (this *apiComp) Getlist(session comm.IUserSession, req *pb.NotifyGetListReq) (code pb.ErrorCode, data proto.Message) { + var ( + err error + userexpand *pb.DBUserExpand + notify []*pb.DBSystemNotify + ) + defer func() { + session.SendMsg(string(this.module.GetType()), "getlist", &pb.NotifyGetListResp{LastReadTime: userexpand.Lastreadnotiftime, SysNotify: notify}) + }() + if notify, err = this.module.modelNotify.GetFullNotify(); err != nil { + code = pb.ErrorCode_DBError + return + } + if session.GetUserId() != "" { + if userexpand, err = this.module.modelNotify.GetUserExpand(session.GetUserId()); err != nil { + code = pb.ErrorCode_DBError + } + } else { + userexpand = &pb.DBUserExpand{} + } + return +} diff --git a/modules/notify/configure.go b/modules/notify/configure.go new file mode 100644 index 000000000..32b009bf2 --- /dev/null +++ b/modules/notify/configure.go @@ -0,0 +1,23 @@ +package notify + +import ( + "go_dreamfactory/modules" + + "go_dreamfactory/lego/core" +) + +const ( + game_equipment = "game_equipment.json" +) + +///背包配置管理组件 +type configureComp struct { + modules.MCompConfigure +} + +//组件初始化接口 +func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.ModuleCompBase.Init(service, module, comp, options) + + return +} diff --git a/modules/notify/core.go b/modules/notify/core.go new file mode 100644 index 000000000..a3131f139 --- /dev/null +++ b/modules/notify/core.go @@ -0,0 +1 @@ +package notify diff --git a/modules/notify/modelNotify.go b/modules/notify/modelNotify.go new file mode 100644 index 000000000..bd3d19954 --- /dev/null +++ b/modules/notify/modelNotify.go @@ -0,0 +1,66 @@ +package notify + +import ( + "context" + "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" + "go_dreamfactory/modules" + "go_dreamfactory/pb" + + "github.com/go-redis/redis/v8" + "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/mongo" + "go.mongodb.org/mongo-driver/x/bsonx" +) + +///论坛 数据组件 +type modelNotifyComp struct { + modules.MCompModel + module *Notification +} + +//组件初始化接口 +func (this *modelNotifyComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { + this.MCompModel.Init(service, module, comp, opt) + this.module = module.(*Notification) + this.TableName = "notify" + //创建uid索引 + this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{ + Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}}, + }) + return +} + +//获取全部公告 +func (this *modelNotifyComp) GetFullNotify() (result []*pb.DBSystemNotify, err error) { + var ( + notifys map[string]*pb.DBSystemNotify = make(map[string]*pb.DBSystemNotify) + c *mongo.Cursor + ) + if err = this.Redis.HGetAll(this.TableName, notifys); err != nil && err == redis.Nil { + if c, err = this.DB.Find(core.SqlTable(this.TableName), bson.M{}); err == nil { + for c.Next(context.Background()) { + notify := &pb.DBSystemNotify{} + if err = c.Decode(notify); err != nil { + log.Errorf("GetFullNotify err:%v", err) + break + } + notifys[notify.Id] = notify + } + if len(notifys) > 0 { + if err = this.Redis.HMSet(this.TableName, notifys); err != nil { + log.Errorf("GetFullNotify err:%v", err) + } + } + } + } + if len(notifys) > 0 { + n := 0 + result = make([]*pb.DBSystemNotify, len(notifys)) + for _, v := range notifys { + result[n] = v + n++ + } + } + return +} diff --git a/modules/notify/module.go b/modules/notify/module.go new file mode 100644 index 000000000..62e73ee61 --- /dev/null +++ b/modules/notify/module.go @@ -0,0 +1,44 @@ +package notify + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/lego/core" + "go_dreamfactory/modules" +) + +/* +模块名:公告系统 +是否跨服:是 +描述:提供运营后台发布全服公告 +开发:李伟 +*/ +func NewModule() core.IModule { + m := new(Notification) + return m +} + +type Notification struct { + modules.ModuleBase + api_comp *apiComp + configure *configureComp + modelNotify *modelNotifyComp +} + +//模块名 +func (this *Notification) GetType() core.M_Modules { + return comm.ModuleEquipment +} + +//模块初始化接口 注册用户创建角色事件 +func (this *Notification) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { + err = this.ModuleBase.Init(service, module, options) + return +} + +//装备组件 +func (this *Notification) OnInstallComp() { + this.ModuleBase.OnInstallComp() + this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp) + this.modelNotify = this.RegisterComp(new(modelNotifyComp)).(*modelNotifyComp) + this.configure = this.RegisterComp(new(configureComp)).(*configureComp) +} diff --git a/modules/notify/module_test.go b/modules/notify/module_test.go new file mode 100644 index 000000000..40eabc811 --- /dev/null +++ b/modules/notify/module_test.go @@ -0,0 +1,74 @@ +package notify + +import ( + "fmt" + "go_dreamfactory/comm" + "go_dreamfactory/lego" + "go_dreamfactory/lego/base/rpcx" + "go_dreamfactory/lego/core" + "go_dreamfactory/lego/sys/log" + "go_dreamfactory/services" + "go_dreamfactory/sys/cache" + "go_dreamfactory/sys/configure" + "go_dreamfactory/sys/db" + "os" + "testing" + "time" +) + +func newService(ops ...rpcx.Option) core.IService { + s := new(TestService) + s.Configure(ops...) + return s +} + +//梦工厂基础服务对象 +type TestService struct { + rpcx.RPCXService +} + +//初始化相关系统 +func (this *TestService) InitSys() { + this.RPCXService.InitSys() + if err := cache.OnInit(this.GetSettings().Sys["cache"]); err != nil { + panic(fmt.Sprintf("init sys.cache err: %s", err.Error())) + } else { + log.Infof("init sys.cache success!") + } + if err := db.OnInit(this.GetSettings().Sys["db"]); err != nil { + panic(fmt.Sprintf("init sys.db err: %s", err.Error())) + } else { + log.Infof("init sys.db success!") + } + if err := configure.OnInit(this.GetSettings().Sys["configure"]); err != nil { + panic(fmt.Sprintf("init sys.configure err: %s", err.Error())) + } else { + log.Infof("init sys.configure success!") + } +} + +var service core.IService +var s_gateComp comm.ISC_GateRouteComp = services.NewGateRouteComp() +var module = new(Notification) + +//测试环境下初始化db和cache 系统 +func TestMain(m *testing.M) { + service = newService( + rpcx.SetConfPath("../../bin/conf/worker_1.yaml"), + rpcx.SetVersion("1.0.0.0"), + ) + service.OnInstallComp( //装备组件 + s_gateComp, //此服务需要接受用户的消息 需要装备网关组件 + ) + go func() { + lego.Run(service, //运行模块 + module, + ) + }() + time.Sleep(time.Second * 3) + defer os.Exit(m.Run()) +} + +func Test_Module(t *testing.T) { + +} diff --git a/pb/notify_db.pb.go b/pb/notify_db.pb.go new file mode 100644 index 000000000..5c24edd17 --- /dev/null +++ b/pb/notify_db.pb.go @@ -0,0 +1,189 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.0 +// source: notify/notify_db.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 DBSystemNotify struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"` //数据公告Id + Title string `protobuf:"bytes,2,opt,name=title,proto3" json:"title"` //公告标题 + Content string `protobuf:"bytes,3,opt,name=content,proto3" json:"content"` //公告内容 + Istop bool `protobuf:"varint,4,opt,name=istop,proto3" json:"istop"` //是否置顶 + Ctime int64 `protobuf:"varint,5,opt,name=ctime,proto3" json:"ctime"` //创建时间 + Rtime int64 `protobuf:"varint,6,opt,name=rtime,proto3" json:"rtime"` //发布时间 +} + +func (x *DBSystemNotify) Reset() { + *x = DBSystemNotify{} + if protoimpl.UnsafeEnabled { + mi := &file_notify_notify_db_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DBSystemNotify) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DBSystemNotify) ProtoMessage() {} + +func (x *DBSystemNotify) ProtoReflect() protoreflect.Message { + mi := &file_notify_notify_db_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 DBSystemNotify.ProtoReflect.Descriptor instead. +func (*DBSystemNotify) Descriptor() ([]byte, []int) { + return file_notify_notify_db_proto_rawDescGZIP(), []int{0} +} + +func (x *DBSystemNotify) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *DBSystemNotify) GetTitle() string { + if x != nil { + return x.Title + } + return "" +} + +func (x *DBSystemNotify) GetContent() string { + if x != nil { + return x.Content + } + return "" +} + +func (x *DBSystemNotify) GetIstop() bool { + if x != nil { + return x.Istop + } + return false +} + +func (x *DBSystemNotify) GetCtime() int64 { + if x != nil { + return x.Ctime + } + return 0 +} + +func (x *DBSystemNotify) GetRtime() int64 { + if x != nil { + return x.Rtime + } + return 0 +} + +var File_notify_notify_db_proto protoreflect.FileDescriptor + +var file_notify_notify_db_proto_rawDesc = []byte{ + 0x0a, 0x16, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x2f, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x5f, + 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x92, 0x01, 0x0a, 0x0e, 0x44, 0x42, 0x53, + 0x79, 0x73, 0x74, 0x65, 0x6d, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x12, 0x0e, 0x0a, 0x02, 0x69, + 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, + 0x69, 0x74, 0x6c, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x74, 0x69, 0x74, 0x6c, + 0x65, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x63, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x12, 0x14, 0x0a, 0x05, 0x69, + 0x73, 0x74, 0x6f, 0x70, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x69, 0x73, 0x74, 0x6f, + 0x70, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, + 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, + 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x42, 0x06, 0x5a, + 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_notify_notify_db_proto_rawDescOnce sync.Once + file_notify_notify_db_proto_rawDescData = file_notify_notify_db_proto_rawDesc +) + +func file_notify_notify_db_proto_rawDescGZIP() []byte { + file_notify_notify_db_proto_rawDescOnce.Do(func() { + file_notify_notify_db_proto_rawDescData = protoimpl.X.CompressGZIP(file_notify_notify_db_proto_rawDescData) + }) + return file_notify_notify_db_proto_rawDescData +} + +var file_notify_notify_db_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_notify_notify_db_proto_goTypes = []interface{}{ + (*DBSystemNotify)(nil), // 0: DBSystemNotify +} +var file_notify_notify_db_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_notify_notify_db_proto_init() } +func file_notify_notify_db_proto_init() { + if File_notify_notify_db_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_notify_notify_db_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DBSystemNotify); 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_notify_notify_db_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_notify_notify_db_proto_goTypes, + DependencyIndexes: file_notify_notify_db_proto_depIdxs, + MessageInfos: file_notify_notify_db_proto_msgTypes, + }.Build() + File_notify_notify_db_proto = out.File + file_notify_notify_db_proto_rawDesc = nil + file_notify_notify_db_proto_goTypes = nil + file_notify_notify_db_proto_depIdxs = nil +} diff --git a/pb/notify_msg.pb.go b/pb/notify_msg.pb.go index 52fdaef1a..3faf8c211 100644 --- a/pb/notify_msg.pb.go +++ b/pb/notify_msg.pb.go @@ -30,7 +30,7 @@ type NotifyErrorNotifyPush struct { ReqSubType string `protobuf:"bytes,2,opt,name=ReqSubType,proto3" json:"ReqSubType"` // 请求协议函数 例如:login 对应项目中 user的模块中 api_login 的处理函数 Code ErrorCode `protobuf:"varint,3,opt,name=Code,proto3,enum=ErrorCode" json:"Code"` // 执行返回错误码 对应 errorcode.proto 枚举 Message string `protobuf:"bytes,4,opt,name=Message,proto3" json:"Message"` // 错误消息 - Data string `protobuf:"bytes,6,opt,name=Data,proto3" json:"Data"` // 错误数据 + Data string `protobuf:"bytes,5,opt,name=Data,proto3" json:"Data"` // 错误数据 } func (x *NotifyErrorNotifyPush) Reset() { @@ -100,24 +100,128 @@ func (x *NotifyErrorNotifyPush) GetData() string { return "" } +//获取系统公告 请求 +type NotifyGetListReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *NotifyGetListReq) Reset() { + *x = NotifyGetListReq{} + if protoimpl.UnsafeEnabled { + mi := &file_notify_notify_msg_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NotifyGetListReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NotifyGetListReq) ProtoMessage() {} + +func (x *NotifyGetListReq) ProtoReflect() protoreflect.Message { + mi := &file_notify_notify_msg_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 NotifyGetListReq.ProtoReflect.Descriptor instead. +func (*NotifyGetListReq) Descriptor() ([]byte, []int) { + return file_notify_notify_msg_proto_rawDescGZIP(), []int{1} +} + +//获取系统公告 回应 +type NotifyGetListResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + LastReadTime int64 `protobuf:"varint,1,opt,name=LastReadTime,proto3" json:"LastReadTime"` //最后一次阅读时间 + SysNotify []*DBSystemNotify `protobuf:"bytes,2,rep,name=SysNotify,proto3" json:"SysNotify"` //公告列表 +} + +func (x *NotifyGetListResp) Reset() { + *x = NotifyGetListResp{} + if protoimpl.UnsafeEnabled { + mi := &file_notify_notify_msg_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *NotifyGetListResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*NotifyGetListResp) ProtoMessage() {} + +func (x *NotifyGetListResp) ProtoReflect() protoreflect.Message { + mi := &file_notify_notify_msg_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 NotifyGetListResp.ProtoReflect.Descriptor instead. +func (*NotifyGetListResp) Descriptor() ([]byte, []int) { + return file_notify_notify_msg_proto_rawDescGZIP(), []int{2} +} + +func (x *NotifyGetListResp) GetLastReadTime() int64 { + if x != nil { + return x.LastReadTime + } + return 0 +} + +func (x *NotifyGetListResp) GetSysNotify() []*DBSystemNotify { + if x != nil { + return x.SysNotify + } + return nil +} + var File_notify_notify_msg_proto protoreflect.FileDescriptor var file_notify_notify_msg_proto_rawDesc = []byte{ 0x0a, 0x17, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x2f, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, - 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xa7, 0x01, 0x0a, 0x15, 0x4e, - 0x6f, 0x74, 0x69, 0x66, 0x79, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, - 0x50, 0x75, 0x73, 0x68, 0x12, 0x20, 0x0a, 0x0b, 0x52, 0x65, 0x71, 0x4d, 0x61, 0x69, 0x6e, 0x54, - 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x52, 0x65, 0x71, 0x4d, 0x61, - 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x0a, 0x52, 0x65, 0x71, 0x53, 0x75, 0x62, - 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0a, 0x52, 0x65, 0x71, 0x53, - 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, - 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, - 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, - 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x44, 0x61, 0x74, 0x61, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x16, 0x6e, 0x6f, 0x74, 0x69, + 0x66, 0x79, 0x2f, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0xa7, 0x01, 0x0a, 0x15, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x45, 0x72, 0x72, + 0x6f, 0x72, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x50, 0x75, 0x73, 0x68, 0x12, 0x20, 0x0a, 0x0b, + 0x52, 0x65, 0x71, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x0b, 0x52, 0x65, 0x71, 0x4d, 0x61, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, + 0x0a, 0x0a, 0x52, 0x65, 0x71, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x18, 0x02, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x0a, 0x52, 0x65, 0x71, 0x53, 0x75, 0x62, 0x54, 0x79, 0x70, 0x65, 0x12, 0x1e, + 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, + 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x18, + 0x0a, 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x44, 0x61, 0x74, 0x61, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x44, 0x61, 0x74, 0x61, 0x22, 0x12, 0x0a, 0x10, + 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, + 0x22, 0x66, 0x0a, 0x11, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, 0x0a, 0x0c, 0x4c, 0x61, 0x73, 0x74, 0x52, 0x65, 0x61, + 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x0c, 0x4c, 0x61, 0x73, + 0x74, 0x52, 0x65, 0x61, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x2d, 0x0a, 0x09, 0x53, 0x79, 0x73, + 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x44, + 0x42, 0x53, 0x79, 0x73, 0x74, 0x65, 0x6d, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x52, 0x09, 0x53, + 0x79, 0x73, 0x4e, 0x6f, 0x74, 0x69, 0x66, 0x79, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -132,18 +236,22 @@ func file_notify_notify_msg_proto_rawDescGZIP() []byte { return file_notify_notify_msg_proto_rawDescData } -var file_notify_notify_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_notify_notify_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 3) var file_notify_notify_msg_proto_goTypes = []interface{}{ (*NotifyErrorNotifyPush)(nil), // 0: NotifyErrorNotifyPush - (ErrorCode)(0), // 1: ErrorCode + (*NotifyGetListReq)(nil), // 1: NotifyGetListReq + (*NotifyGetListResp)(nil), // 2: NotifyGetListResp + (ErrorCode)(0), // 3: ErrorCode + (*DBSystemNotify)(nil), // 4: DBSystemNotify } var file_notify_notify_msg_proto_depIdxs = []int32{ - 1, // 0: NotifyErrorNotifyPush.Code:type_name -> ErrorCode - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 3, // 0: NotifyErrorNotifyPush.Code:type_name -> ErrorCode + 4, // 1: NotifyGetListResp.SysNotify:type_name -> DBSystemNotify + 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_notify_notify_msg_proto_init() } @@ -152,6 +260,7 @@ func file_notify_notify_msg_proto_init() { return } file_errorcode_proto_init() + file_notify_notify_db_proto_init() if !protoimpl.UnsafeEnabled { file_notify_notify_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { switch v := v.(*NotifyErrorNotifyPush); i { @@ -165,6 +274,30 @@ func file_notify_notify_msg_proto_init() { return nil } } + file_notify_notify_msg_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NotifyGetListReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_notify_notify_msg_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*NotifyGetListResp); 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{ @@ -172,7 +305,7 @@ func file_notify_notify_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_notify_notify_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 3, NumExtensions: 0, NumServices: 0, }, diff --git a/pb/proto/notify/notify_db.proto b/pb/proto/notify/notify_db.proto new file mode 100644 index 000000000..bee9b6d51 --- /dev/null +++ b/pb/proto/notify/notify_db.proto @@ -0,0 +1,12 @@ +syntax = "proto3"; +option go_package = ".;pb"; + +//系统公告数据结构 +message DBSystemNotify { + string id = 1; //数据公告Id + string title = 2; //公告标题 + string content = 3; //公告内容 + bool istop = 4; //是否置顶 + int64 ctime = 5; //创建时间 + int64 rtime = 6; //发布时间 +} \ No newline at end of file diff --git a/pb/proto/notify/notify_msg.proto b/pb/proto/notify/notify_msg.proto index 839c3c924..1008862eb 100644 --- a/pb/proto/notify/notify_msg.proto +++ b/pb/proto/notify/notify_msg.proto @@ -1,6 +1,7 @@ syntax = "proto3"; option go_package = ".;pb"; import "errorcode.proto"; +import "notify/notify_db.proto"; //统一错误码推送 message NotifyErrorNotifyPush { @@ -8,5 +9,15 @@ message NotifyErrorNotifyPush { string ReqSubType = 2; // 请求协议函数 例如:login 对应项目中 user的模块中 api_login 的处理函数 ErrorCode Code = 3; // 执行返回错误码 对应 errorcode.proto 枚举 string Message = 4; // 错误消息 - string Data = 6; // 错误数据 + string Data = 5; // 错误数据 } + +//获取系统公告 请求 +message NotifyGetListReq { +} + +//获取系统公告 回应 +message NotifyGetListResp { + int64 LastReadTime = 1; //最后一次阅读时间 + repeated DBSystemNotify SysNotify = 2; //公告列表 +} \ No newline at end of file diff --git a/pb/proto/userexpand.proto b/pb/proto/userexpand.proto new file mode 100644 index 000000000..d39b2e64c --- /dev/null +++ b/pb/proto/userexpand.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +option go_package = ".;pb"; + + +//用户扩展数据 +message DBUserExpand { + string id = 1; //主键id + string uid = 2; //用户id + int64 lastreadnotiftime = 3; //最后阅读公告时间 +} \ No newline at end of file diff --git a/pb/userexpand.pb.go b/pb/userexpand.pb.go new file mode 100644 index 000000000..c84ca5f69 --- /dev/null +++ b/pb/userexpand.pb.go @@ -0,0 +1,162 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.0 +// source: userexpand.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 DBUserExpand struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id"` //主键id + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid"` //用户id + Lastreadnotiftime int64 `protobuf:"varint,3,opt,name=lastreadnotiftime,proto3" json:"lastreadnotiftime"` //最后阅读公告时间 +} + +func (x *DBUserExpand) Reset() { + *x = DBUserExpand{} + if protoimpl.UnsafeEnabled { + mi := &file_userexpand_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DBUserExpand) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DBUserExpand) ProtoMessage() {} + +func (x *DBUserExpand) ProtoReflect() protoreflect.Message { + mi := &file_userexpand_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 DBUserExpand.ProtoReflect.Descriptor instead. +func (*DBUserExpand) Descriptor() ([]byte, []int) { + return file_userexpand_proto_rawDescGZIP(), []int{0} +} + +func (x *DBUserExpand) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *DBUserExpand) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *DBUserExpand) GetLastreadnotiftime() int64 { + if x != nil { + return x.Lastreadnotiftime + } + return 0 +} + +var File_userexpand_proto protoreflect.FileDescriptor + +var file_userexpand_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x75, 0x73, 0x65, 0x72, 0x65, 0x78, 0x70, 0x61, 0x6e, 0x64, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x22, 0x5e, 0x0a, 0x0c, 0x44, 0x42, 0x55, 0x73, 0x65, 0x72, 0x45, 0x78, 0x70, 0x61, + 0x6e, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, + 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x03, 0x75, 0x69, 0x64, 0x12, 0x2c, 0x0a, 0x11, 0x6c, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x64, + 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x03, 0x52, + 0x11, 0x6c, 0x61, 0x73, 0x74, 0x72, 0x65, 0x61, 0x64, 0x6e, 0x6f, 0x74, 0x69, 0x66, 0x74, 0x69, + 0x6d, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, +} + +var ( + file_userexpand_proto_rawDescOnce sync.Once + file_userexpand_proto_rawDescData = file_userexpand_proto_rawDesc +) + +func file_userexpand_proto_rawDescGZIP() []byte { + file_userexpand_proto_rawDescOnce.Do(func() { + file_userexpand_proto_rawDescData = protoimpl.X.CompressGZIP(file_userexpand_proto_rawDescData) + }) + return file_userexpand_proto_rawDescData +} + +var file_userexpand_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_userexpand_proto_goTypes = []interface{}{ + (*DBUserExpand)(nil), // 0: DBUserExpand +} +var file_userexpand_proto_depIdxs = []int32{ + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_userexpand_proto_init() } +func file_userexpand_proto_init() { + if File_userexpand_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_userexpand_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DBUserExpand); 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_userexpand_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_userexpand_proto_goTypes, + DependencyIndexes: file_userexpand_proto_depIdxs, + MessageInfos: file_userexpand_proto_msgTypes, + }.Build() + File_userexpand_proto = out.File + file_userexpand_proto_rawDesc = nil + file_userexpand_proto_goTypes = nil + file_userexpand_proto_depIdxs = nil +}