diff --git a/comm/imodule.go b/comm/imodule.go index 24c105337..a2a754055 100644 --- a/comm/imodule.go +++ b/comm/imodule.go @@ -230,4 +230,10 @@ type ( //计算新作图属性 ComputeHeroNumeric(uid string, hero ...*pb.DBHero) } + IPrivilege interface { + // 创建一个新的特权卡 + CreatePrivilegeCard(session IUserSession, cid int32) (data *pb.DBPrivilege, code pb.ErrorCode) + // 续费特权卡 + RenewPrivilegeCard(session IUserSession, cid int32) (data *pb.DBPrivilege, code pb.ErrorCode) + } ) diff --git a/modules/privilege/api.go b/modules/privilege/api.go index 35949af67..732c99e83 100644 --- a/modules/privilege/api.go +++ b/modules/privilege/api.go @@ -6,6 +6,10 @@ import ( "go_dreamfactory/lego/core" ) +const ( + PrivilegeGetListResp = "getlist" +) + type apiComp struct { modules.MCompGate service core.IService diff --git a/modules/privilege/api_getlist.go b/modules/privilege/api_getlist.go index ed54c70fa..52d6c8e2d 100644 --- a/modules/privilege/api_getlist.go +++ b/modules/privilege/api_getlist.go @@ -8,13 +8,17 @@ import ( ) //参数校验 -func (this *apiComp) GetlistCheck(session comm.IUserSession, req *pb.ShopGetListReq) (code pb.ErrorCode) { +func (this *apiComp) GetlistCheck(session comm.IUserSession, req *pb.PrivilegeGetListReq) (code pb.ErrorCode) { return } ///获取特权列表 -func (this *apiComp) Getlist(session comm.IUserSession, req *pb.ShopGetListReq) (code pb.ErrorCode, data proto.Message) { - +func (this *apiComp) Getlist(session comm.IUserSession, req *pb.PrivilegeGetListReq) (code pb.ErrorCode, data proto.Message) { + list, err := this.module.modelPrivilege.getPrivilegeList(session.GetUserId()) + if err != nil { + this.module.Errorf("can't get privilege list :%v", err) + } + session.SendMsg(string(this.module.GetType()), PrivilegeGetListResp, &pb.PrivilegeGetListResp{Data: list}) return } diff --git a/modules/privilege/configure.go b/modules/privilege/configure.go index bed2b3097..1df82e04b 100644 --- a/modules/privilege/configure.go +++ b/modules/privilege/configure.go @@ -4,13 +4,12 @@ import ( "fmt" "go_dreamfactory/lego/core" "go_dreamfactory/modules" - "go_dreamfactory/pb" cfg "go_dreamfactory/sys/configure/structs" ) const ( - game_shop = "game_shop.json" - game_shopitem = "game_shopitem.json" + game_privilegecard = "game_privilegecard.json" + game_privilege = "game_privilege.json" ) ///背包配置管理组件 @@ -23,22 +22,25 @@ type configureComp struct { func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { this.MCompConfigure.Init(service, module, comp, options) this.module = module.(*Privilege) - this.LoadConfigure(game_shop, cfg.NewGameShop) - this.LoadConfigure(game_shopitem, cfg.NewGameShopitem) + this.LoadConfigure(game_privilegecard, cfg.NewGamePrivilegeCard) + this.LoadConfigure(game_privilege, cfg.NewGamePrivilege) + + // _d, err := this.GetPrivilegeCard(1) + // _d1, err := this.GetPrivilegeData(10003) + // fmt.Errorf("%v,%v", _d, _d1) return } -//获取装备配置数据 -func (this *configureComp) GetShopConfigure(id int32) (configure *cfg.GameShopData, err error) { +func (this *configureComp) GetPrivilegeCard(id int32) (configure *cfg.GamePrivilegeCardData, err error) { var ( v interface{} ok bool ) - if v, err = this.GetConfigure(game_shop); err != nil { + if v, err = this.GetConfigure(game_privilegecard); err != nil { this.module.Errorf("err:%v", err) return } else { - if configure, ok = v.(*cfg.GameShop).GetDataMap()[id]; !ok { + if configure, ok = v.(*cfg.GamePrivilegeCard).GetDataMap()[id]; !ok { err = fmt.Errorf("ShopConfigure not found:%d ", id) this.module.Errorf("err:%v", err) return @@ -47,70 +49,20 @@ func (this *configureComp) GetShopConfigure(id int32) (configure *cfg.GameShopDa return } -//读取商品 -func (this *configureComp) GetShopItemsConfigure(key int32) (result *cfg.GameShopitemData, err error) { +func (this *configureComp) GetPrivilegeData(id int32) (result *cfg.GamePrivilegeData, err error) { var ( v interface{} ok bool ) - if v, err = this.GetConfigure(game_shopitem); err != nil { + if v, err = this.GetConfigure(game_privilege); err != nil { this.module.Errorf("err:%v", err) return } else { - if result, ok = v.(*cfg.GameShopitem).GetDataMap()[key]; !ok { - err = fmt.Errorf("ShopConfigure not found:%d ", key) + if result, ok = v.(*cfg.GamePrivilege).GetDataMap()[id]; !ok { + err = fmt.Errorf("ShopConfigure not found:%d ", id) this.module.Errorf("err:%v", err) return } } return } - -//读取商品组 -func (this *configureComp) GetShopItemsConfigureByGroups(groupid int32, user *pb.DBUser) (result []*cfg.GameShopitemData, err error) { - result = make([]*cfg.GameShopitemData, 0, 10) - var ( - v interface{} - table *cfg.GameShopitem - ) - if v, err = this.GetConfigure(game_shopitem); err != nil { - this.module.Errorf("err:%v", err) - return - } else { - table = v.(*cfg.GameShopitem) - for _, v := range table.GetDataMap() { - if v.Id == groupid && - user.Lv >= v.Lvmin && - user.Lv <= v.Lvmax && - user.Vip >= v.Vip { - result = append(result, v) - } - } - } - return -} - -//读取商品 -func (this *configureComp) GetShopItemsConfigureByIds(keys ...int32) (result []*cfg.GameShopitemData, err error) { - result = make([]*cfg.GameShopitemData, 0, len(keys)) - var ( - v interface{} - table *cfg.GameShopitem - item *cfg.GameShopitemData - ok bool - ) - if v, err = this.GetConfigure(game_shopitem); err != nil { - this.module.Errorf("err:%v", err) - return - } else { - table = v.(*cfg.GameShopitem) - for _, v := range keys { - if item, ok = table.GetDataMap()[v]; ok { - result = append(result, item) - } else { - this.module.Errorf("no found GetShopItemsConfigureByIds:%d", v) - } - } - } - return -} diff --git a/modules/privilege/model_privilege.go b/modules/privilege/model_privilege.go index 747b8322e..6878bd55b 100644 --- a/modules/privilege/model_privilege.go +++ b/modules/privilege/model_privilege.go @@ -4,19 +4,19 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" + "go_dreamfactory/pb" "go.mongodb.org/mongo-driver/mongo" "go.mongodb.org/mongo-driver/x/bsonx" ) -///论坛 数据组件 -type modelShopComp struct { +type ModelPrivilege struct { modules.MCompModel module *Privilege } //组件初始化接口 -func (this *modelShopComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { +func (this *ModelPrivilege) 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.(*Privilege) this.TableName = comm.TableShop @@ -26,3 +26,25 @@ func (this *modelShopComp) Init(service core.IService, module core.IModule, comp }) return } + +// 获取特权信息 +func (this *ModelPrivilege) getPrivilegeList(uid string) (privilege []*pb.DBPrivilege, err error) { + privilege = make([]*pb.DBPrivilege, 0) + err = this.GetList(uid, &privilege) + return +} + +// 修改特权信息 +func (this *ModelPrivilege) modifyPrivilegeData(uid string, objid string, data map[string]interface{}) error { + return this.module.modelPrivilege.ChangeList(uid, objid, data) +} + +// 增加新的特权信息 +func (this *ModelPrivilege) addNewPrivilegeData(uId string, data *pb.DBPrivilege) (err error) { + + if err = this.AddList(uId, data.Id, data); err != nil { + this.module.Errorf("err:%v", err) + return + } + return nil +} diff --git a/modules/privilege/module.go b/modules/privilege/module.go index a431ef16a..84c3cde50 100644 --- a/modules/privilege/module.go +++ b/modules/privilege/module.go @@ -4,7 +4,11 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/lego/core" "go_dreamfactory/modules" + "go_dreamfactory/pb" "go_dreamfactory/sys/db" + "time" + + "go.mongodb.org/mongo-driver/bson/primitive" ) func NewModule() core.IModule { @@ -14,9 +18,9 @@ func NewModule() core.IModule { type Privilege struct { modules.ModuleBase - api_comp *apiComp - configure *configureComp - modelShop *modelShopComp + api_comp *apiComp + configure *configureComp + modelPrivilege *ModelPrivilege } //模块名 @@ -34,11 +38,72 @@ func (this *Privilege) Init(service core.IService, module core.IModule, options func (this *Privilege) OnInstallComp() { this.ModuleBase.OnInstallComp() this.api_comp = this.RegisterComp(new(apiComp)).(*apiComp) - this.modelShop = this.RegisterComp(new(modelShopComp)).(*modelShopComp) + this.modelPrivilege = this.RegisterComp(new(ModelPrivilege)).(*ModelPrivilege) this.configure = this.RegisterComp(new(configureComp)).(*configureComp) } //Event------------------------------------------------------------------------------------------------------------ func (this *Privilege) EventUserOffline(session comm.IUserSession) { - this.modelShop.DelByUId(session.GetUserId(), db.SetDBMgoLog(false)) + this.modelPrivilege.DelByUId(session.GetUserId(), db.SetDBMgoLog(false)) +} + +// 购买了一个新的特权 +func (this *Privilege) CreatePrivilegeCard(session comm.IUserSession, cid int32) (data *pb.DBPrivilege, code pb.ErrorCode) { + data = &pb.DBPrivilege{ + Id: primitive.NewObjectID().Hex(), + Uid: session.GetUserId(), + Cid: cid, + PrivilegeID: []int32{}, + CTime: time.Now().Unix(), + ETime: 0, + RewardTime: time.Now().Unix(), + } + conf, err := this.configure.GetPrivilegeCard(cid) + if err != nil { + code = pb.ErrorCode_ConfigNoFound + return nil, code + } + data.ETime = time.Now().Unix() + int64(conf.AssertDay*24*3600) // 设置过期时间 + for _, v := range conf.PrivilegeId { + data.PrivilegeID = append(data.PrivilegeID, v) + } + this.modelPrivilege.addNewPrivilegeData(session.GetUserId(), data) + + // 推送 + session.SendMsg(string(this.GetType()), PrivilegeGetListResp, &pb.PrivilegeGetListResp{Data: []*pb.DBPrivilege{data}}) + return +} + +// 续费特权 +func (this *Privilege) RenewPrivilegeCard(session comm.IUserSession, cid int32) (data *pb.DBPrivilege, code pb.ErrorCode) { + + list, err := this.modelPrivilege.getPrivilegeList(session.GetUserId()) + if err != nil { + return + } + for _, v := range list { + if v.Cid == cid { + conf, err := this.configure.GetPrivilegeCard(cid) + if err != nil { + code = pb.ErrorCode_ConfigNoFound + return nil, code + } + if conf.RenewDay >= int32(time.Now().Unix()-v.ETime)/(24*3600) { + v.ETime += int64(conf.AssertDay) * 24 * 3600 + mapData := make(map[string]interface{}, 0) + mapData["eTime"] = v.ETime + this.modelPrivilege.modifyPrivilegeData(session.GetUserId(), v.Id, mapData) + data = v + session.SendMsg(string(this.GetType()), PrivilegeGetListResp, &pb.PrivilegeGetListResp{Data: []*pb.DBPrivilege{v}}) + return + } else { + code = pb.ErrorCode_PrivilegeRenewTime + data = nil + return + } + } + } + code = pb.ErrorCode_PrivilegeNotFound + data = nil + return } diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index 6b5097ad8..c1bae8e0a 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -248,6 +248,9 @@ const ( // horoscope ErrorCode_HoroscopeNotTurnedOn ErrorCode = 3401 //未开启 ErrorCode_HoroscopeRestCDNoEnd ErrorCode = 3402 //重置cd未结束 + // privileges + ErrorCode_PrivilegeNotFound ErrorCode = 3501 // 特权没找到 + ErrorCode_PrivilegeRenewTime ErrorCode = 3502 // 特权续费时间没到 ) // Enum value maps for ErrorCode. @@ -455,6 +458,8 @@ var ( 3305: "TrollRepeatedReward", 3401: "HoroscopeNotTurnedOn", 3402: "HoroscopeRestCDNoEnd", + 3501: "PrivilegeNotFound", + 3502: "PrivilegeRenewTime", } ErrorCode_value = map[string]int32{ "Success": 0, @@ -659,6 +664,8 @@ var ( "TrollRepeatedReward": 3305, "HoroscopeNotTurnedOn": 3401, "HoroscopeRestCDNoEnd": 3402, + "PrivilegeNotFound": 3501, + "PrivilegeRenewTime": 3502, } ) @@ -693,7 +700,7 @@ var File_errorcode_proto protoreflect.FileDescriptor var file_errorcode_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2a, 0xd8, 0x23, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0x89, 0x24, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12, 0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, @@ -978,8 +985,11 @@ var file_errorcode_proto_rawDesc = []byte{ 0x61, 0x72, 0x64, 0x10, 0xe9, 0x19, 0x12, 0x19, 0x0a, 0x14, 0x48, 0x6f, 0x72, 0x6f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x4e, 0x6f, 0x74, 0x54, 0x75, 0x72, 0x6e, 0x65, 0x64, 0x4f, 0x6e, 0x10, 0xc9, 0x1a, 0x12, 0x19, 0x0a, 0x14, 0x48, 0x6f, 0x72, 0x6f, 0x73, 0x63, 0x6f, 0x70, 0x65, 0x52, 0x65, - 0x73, 0x74, 0x43, 0x44, 0x4e, 0x6f, 0x45, 0x6e, 0x64, 0x10, 0xca, 0x1a, 0x42, 0x06, 0x5a, 0x04, - 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x74, 0x43, 0x44, 0x4e, 0x6f, 0x45, 0x6e, 0x64, 0x10, 0xca, 0x1a, 0x12, 0x16, 0x0a, 0x11, + 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x4e, 0x6f, 0x74, 0x46, 0x6f, 0x75, 0x6e, + 0x64, 0x10, 0xad, 0x1b, 0x12, 0x17, 0x0a, 0x12, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, + 0x65, 0x52, 0x65, 0x6e, 0x65, 0x77, 0x54, 0x69, 0x6d, 0x65, 0x10, 0xae, 0x1b, 0x42, 0x06, 0x5a, + 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/privilege_db.pb.go b/pb/privilege_db.pb.go new file mode 100644 index 000000000..5cd3064ea --- /dev/null +++ b/pb/privilege_db.pb.go @@ -0,0 +1,199 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.0 +// source: privilege/privilege_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) +) + +// vip 月卡特权 +type DBPrivilege struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id" bson:"_id"` //ID + Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID + Cid int32 `protobuf:"varint,3,opt,name=cid,proto3" json:"cid" bson:"privilegeID"` //特权id + PrivilegeID []int32 `protobuf:"varint,4,rep,packed,name=privilegeID,proto3" json:"privilegeID" bson:"privilegeID"` + CTime int64 `protobuf:"varint,5,opt,name=cTime,proto3" json:"cTime" bson:"cTime"` ////购买时间 + ETime int64 `protobuf:"varint,6,opt,name=eTime,proto3" json:"eTime" bson:"eTime"` ////到期时间 + RewardTime int64 `protobuf:"varint,7,opt,name=rewardTime,proto3" json:"rewardTime" bson:"rewardTime"` //每日奖励时间 +} + +func (x *DBPrivilege) Reset() { + *x = DBPrivilege{} + if protoimpl.UnsafeEnabled { + mi := &file_privilege_privilege_db_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DBPrivilege) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DBPrivilege) ProtoMessage() {} + +func (x *DBPrivilege) ProtoReflect() protoreflect.Message { + mi := &file_privilege_privilege_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 DBPrivilege.ProtoReflect.Descriptor instead. +func (*DBPrivilege) Descriptor() ([]byte, []int) { + return file_privilege_privilege_db_proto_rawDescGZIP(), []int{0} +} + +func (x *DBPrivilege) GetId() string { + if x != nil { + return x.Id + } + return "" +} + +func (x *DBPrivilege) GetUid() string { + if x != nil { + return x.Uid + } + return "" +} + +func (x *DBPrivilege) GetCid() int32 { + if x != nil { + return x.Cid + } + return 0 +} + +func (x *DBPrivilege) GetPrivilegeID() []int32 { + if x != nil { + return x.PrivilegeID + } + return nil +} + +func (x *DBPrivilege) GetCTime() int64 { + if x != nil { + return x.CTime + } + return 0 +} + +func (x *DBPrivilege) GetETime() int64 { + if x != nil { + return x.ETime + } + return 0 +} + +func (x *DBPrivilege) GetRewardTime() int64 { + if x != nil { + return x.RewardTime + } + return 0 +} + +var File_privilege_privilege_db_proto protoreflect.FileDescriptor + +var file_privilege_privilege_db_proto_rawDesc = []byte{ + 0x0a, 0x1c, 0x70, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x2f, 0x70, 0x72, 0x69, 0x76, + 0x69, 0x6c, 0x65, 0x67, 0x65, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xaf, + 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 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, 0x10, 0x0a, 0x03, 0x63, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x63, + 0x69, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x70, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x49, + 0x44, 0x18, 0x04, 0x20, 0x03, 0x28, 0x05, 0x52, 0x0b, 0x70, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, + 0x67, 0x65, 0x49, 0x44, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x03, 0x52, 0x05, 0x63, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x65, 0x54, + 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05, 0x65, 0x54, 0x69, 0x6d, 0x65, + 0x12, 0x1e, 0x0a, 0x0a, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x07, + 0x20, 0x01, 0x28, 0x03, 0x52, 0x0a, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x54, 0x69, 0x6d, 0x65, + 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_privilege_privilege_db_proto_rawDescOnce sync.Once + file_privilege_privilege_db_proto_rawDescData = file_privilege_privilege_db_proto_rawDesc +) + +func file_privilege_privilege_db_proto_rawDescGZIP() []byte { + file_privilege_privilege_db_proto_rawDescOnce.Do(func() { + file_privilege_privilege_db_proto_rawDescData = protoimpl.X.CompressGZIP(file_privilege_privilege_db_proto_rawDescData) + }) + return file_privilege_privilege_db_proto_rawDescData +} + +var file_privilege_privilege_db_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_privilege_privilege_db_proto_goTypes = []interface{}{ + (*DBPrivilege)(nil), // 0: DBPrivilege +} +var file_privilege_privilege_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_privilege_privilege_db_proto_init() } +func file_privilege_privilege_db_proto_init() { + if File_privilege_privilege_db_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_privilege_privilege_db_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DBPrivilege); 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_privilege_privilege_db_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_privilege_privilege_db_proto_goTypes, + DependencyIndexes: file_privilege_privilege_db_proto_depIdxs, + MessageInfos: file_privilege_privilege_db_proto_msgTypes, + }.Build() + File_privilege_privilege_db_proto = out.File + file_privilege_privilege_db_proto_rawDesc = nil + file_privilege_privilege_db_proto_goTypes = nil + file_privilege_privilege_db_proto_depIdxs = nil +} diff --git a/pb/privilege_msg.pb.go b/pb/privilege_msg.pb.go new file mode 100644 index 000000000..399f464ba --- /dev/null +++ b/pb/privilege_msg.pb.go @@ -0,0 +1,202 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.0 +// source: privilege/privilege_msg.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 PrivilegeGetListReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *PrivilegeGetListReq) Reset() { + *x = PrivilegeGetListReq{} + if protoimpl.UnsafeEnabled { + mi := &file_privilege_privilege_msg_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PrivilegeGetListReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PrivilegeGetListReq) ProtoMessage() {} + +func (x *PrivilegeGetListReq) ProtoReflect() protoreflect.Message { + mi := &file_privilege_privilege_msg_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 PrivilegeGetListReq.ProtoReflect.Descriptor instead. +func (*PrivilegeGetListReq) Descriptor() ([]byte, []int) { + return file_privilege_privilege_msg_proto_rawDescGZIP(), []int{0} +} + +// 返回特权列表数据 +type PrivilegeGetListResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Data []*DBPrivilege `protobuf:"bytes,1,rep,name=data,proto3" json:"data"` +} + +func (x *PrivilegeGetListResp) Reset() { + *x = PrivilegeGetListResp{} + if protoimpl.UnsafeEnabled { + mi := &file_privilege_privilege_msg_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *PrivilegeGetListResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*PrivilegeGetListResp) ProtoMessage() {} + +func (x *PrivilegeGetListResp) ProtoReflect() protoreflect.Message { + mi := &file_privilege_privilege_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 PrivilegeGetListResp.ProtoReflect.Descriptor instead. +func (*PrivilegeGetListResp) Descriptor() ([]byte, []int) { + return file_privilege_privilege_msg_proto_rawDescGZIP(), []int{1} +} + +func (x *PrivilegeGetListResp) GetData() []*DBPrivilege { + if x != nil { + return x.Data + } + return nil +} + +var File_privilege_privilege_msg_proto protoreflect.FileDescriptor + +var file_privilege_privilege_msg_proto_rawDesc = []byte{ + 0x0a, 0x1d, 0x70, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x2f, 0x70, 0x72, 0x69, 0x76, + 0x69, 0x6c, 0x65, 0x67, 0x65, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, + 0x1c, 0x70, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x2f, 0x70, 0x72, 0x69, 0x76, 0x69, + 0x6c, 0x65, 0x67, 0x65, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x15, 0x0a, + 0x13, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x65, 0x71, 0x22, 0x38, 0x0a, 0x14, 0x50, 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, + 0x65, 0x47, 0x65, 0x74, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x20, 0x0a, 0x04, + 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x50, + 0x72, 0x69, 0x76, 0x69, 0x6c, 0x65, 0x67, 0x65, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x42, 0x06, + 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_privilege_privilege_msg_proto_rawDescOnce sync.Once + file_privilege_privilege_msg_proto_rawDescData = file_privilege_privilege_msg_proto_rawDesc +) + +func file_privilege_privilege_msg_proto_rawDescGZIP() []byte { + file_privilege_privilege_msg_proto_rawDescOnce.Do(func() { + file_privilege_privilege_msg_proto_rawDescData = protoimpl.X.CompressGZIP(file_privilege_privilege_msg_proto_rawDescData) + }) + return file_privilege_privilege_msg_proto_rawDescData +} + +var file_privilege_privilege_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_privilege_privilege_msg_proto_goTypes = []interface{}{ + (*PrivilegeGetListReq)(nil), // 0: PrivilegeGetListReq + (*PrivilegeGetListResp)(nil), // 1: PrivilegeGetListResp + (*DBPrivilege)(nil), // 2: DBPrivilege +} +var file_privilege_privilege_msg_proto_depIdxs = []int32{ + 2, // 0: PrivilegeGetListResp.data:type_name -> DBPrivilege + 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 +} + +func init() { file_privilege_privilege_msg_proto_init() } +func file_privilege_privilege_msg_proto_init() { + if File_privilege_privilege_msg_proto != nil { + return + } + file_privilege_privilege_db_proto_init() + if !protoimpl.UnsafeEnabled { + file_privilege_privilege_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PrivilegeGetListReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_privilege_privilege_msg_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*PrivilegeGetListResp); 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_privilege_privilege_msg_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_privilege_privilege_msg_proto_goTypes, + DependencyIndexes: file_privilege_privilege_msg_proto_depIdxs, + MessageInfos: file_privilege_privilege_msg_proto_msgTypes, + }.Build() + File_privilege_privilege_msg_proto = out.File + file_privilege_privilege_msg_proto_rawDesc = nil + file_privilege_privilege_msg_proto_goTypes = nil + file_privilege_privilege_msg_proto_depIdxs = nil +} diff --git a/services/worker/main.go b/services/worker/main.go index 3b03123c8..0fd68a0b8 100644 --- a/services/worker/main.go +++ b/services/worker/main.go @@ -25,6 +25,7 @@ import ( "go_dreamfactory/modules/notify" "go_dreamfactory/modules/pagoda" "go_dreamfactory/modules/pay" + "go_dreamfactory/modules/privilege" "go_dreamfactory/modules/rtask" "go_dreamfactory/modules/shop" "go_dreamfactory/modules/smithy" @@ -98,6 +99,7 @@ func main() { sociaty.NewModule(), horoscope.NewModule(), pay.NewModule(), + privilege.NewModule(), ) }