This commit is contained in:
meixiongfeng 2023-07-19 18:38:03 +08:00
commit a2cfc059d3
23 changed files with 249 additions and 109 deletions

View File

@ -295,6 +295,8 @@ const (
TableUniongve = "uniongve" TableUniongve = "uniongve"
///工会轮盘 ///工会轮盘
TableUnionroulette = "unionroulette" TableUnionroulette = "unionroulette"
///工会排行榜
TableUnionrank = "unionrank"
//全局表 //全局表
TableGlobal = "global" TableGlobal = "global"
) )

View File

@ -370,7 +370,7 @@ type (
// 获取我的公会成员 // 获取我的公会成员
MembersByUid(uid string) (list []*pb.SociatyMemberInfo) MembersByUid(uid string) (list []*pb.SociatyMemberInfo)
// 获取公会成员 // 获取公会成员
MembersBySociatyId(sociatyId string) (list []*pb.SociatyMemberInfo) MembersBySociatyId(sociatyId string) (list []*pb.SociatyMemberInfo, errdata *pb.ErrorData)
// 设置工会经验 // 设置工会经验
BingoSetExp(session IUserSession, exp int32) error BingoSetExp(session IUserSession, exp int32) error
// 设置工会活跃度 // 设置工会活跃度

View File

@ -20,13 +20,13 @@ var unionchatkey = "chat:union"
var crosschatkey = "chat:cross" var crosschatkey = "chat:cross"
var systemchatkey = "chat:system" var systemchatkey = "chat:system"
///论坛 数据组件 // /论坛 数据组件
type modelChatComp struct { type modelChatComp struct {
modules.MCompModel modules.MCompModel
module *Chat module *Chat
} }
//组件初始化接口 // 组件初始化接口
func (this *modelChatComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) { func (this *modelChatComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, opt core.IModuleOptions) (err error) {
this.TableName = comm.TableChat this.TableName = comm.TableChat
this.MCompModel.Init(service, module, comp, opt) this.MCompModel.Init(service, module, comp, opt)
@ -38,7 +38,7 @@ func (this *modelChatComp) Init(service core.IService, module core.IModule, comp
return return
} }
//查询用户未读消息 // 查询用户未读消息
func (this *modelChatComp) queryUserMsg(uid string) (result []*pb.DBChat, err error) { func (this *modelChatComp) queryUserMsg(uid string) (result []*pb.DBChat, err error) {
var ( var (
c *mongo.Cursor c *mongo.Cursor
@ -62,7 +62,7 @@ func (this *modelChatComp) queryUserMsg(uid string) (result []*pb.DBChat, err er
return return
} }
//查询用户未读消息 // 查询用户未读消息
func (this *modelChatComp) getChatQueue(channel pb.ChatChannel, stag, union string, area int32) (result []*pb.DBChat, err error) { func (this *modelChatComp) getChatQueue(channel pb.ChatChannel, stag, union string, area int32) (result []*pb.DBChat, err error) {
var ( var (
key string key string
@ -123,7 +123,7 @@ func (this *modelChatComp) getChatQueue(channel pb.ChatChannel, stag, union stri
return return
} }
//添加跨服频道成员 // 添加跨服频道成员
func (this *modelChatComp) addCrossChannelMember(session comm.IUserSession) (channel int32, err error) { func (this *modelChatComp) addCrossChannelMember(session comm.IUserSession) (channel int32, err error) {
udata := &pb.CacheUser{ udata := &pb.CacheUser{
Uid: session.GetUserId(), Uid: session.GetUserId(),
@ -159,7 +159,7 @@ func (this *modelChatComp) addCrossChannelMember(session comm.IUserSession) (cha
return return
} }
//切换跨服频道 // 切换跨服频道
func (this *modelChatComp) chanageChannel(session comm.IUserSession, channel int32) (err error, ok bool) { func (this *modelChatComp) chanageChannel(session comm.IUserSession, channel int32) (err error, ok bool) {
udata := &pb.CacheUser{ udata := &pb.CacheUser{
Uid: session.GetUserId(), Uid: session.GetUserId(),
@ -190,7 +190,7 @@ func (this *modelChatComp) chanageChannel(session comm.IUserSession, channel int
return return
} }
//读取跨服聊天频道下成员 // 读取跨服聊天频道下成员
func (this *modelChatComp) getCrossChannelMember(channel int32) (result []*pb.CacheUser, err error) { func (this *modelChatComp) getCrossChannelMember(channel int32) (result []*pb.CacheUser, err error) {
key := fmt.Sprintf("%s-%d-member", crosschatkey, channel) key := fmt.Sprintf("%s-%d-member", crosschatkey, channel)
temp := make(map[string]*pb.CacheUser, 0) temp := make(map[string]*pb.CacheUser, 0)
@ -207,7 +207,7 @@ func (this *modelChatComp) getCrossChannelMember(channel int32) (result []*pb.Ca
return return
} }
//移除频道成员 // 移除频道成员
func (this *modelChatComp) removeCrossChannelMember(uid string) (err error) { func (this *modelChatComp) removeCrossChannelMember(uid string) (err error) {
var ( var (
result *pb.DBUserExpand result *pb.DBUserExpand
@ -225,7 +225,7 @@ func (this *modelChatComp) removeCrossChannelMember(uid string) (err error) {
return return
} }
//保存用户聊天消息 // 保存用户聊天消息
func (this *modelChatComp) saveUserMsg(msg *pb.DBChat) (err error) { func (this *modelChatComp) saveUserMsg(msg *pb.DBChat) (err error) {
if _, err = this.DB.InsertOne(core.SqlTable(this.TableName), msg); err != nil { if _, err = this.DB.InsertOne(core.SqlTable(this.TableName), msg); err != nil {
this.module.Errorf("err:%v", err) this.module.Errorf("err:%v", err)
@ -320,7 +320,7 @@ func (this *modelChatComp) addChatMsg(key string, count int64, msgs ...*pb.DBCha
return return
} }
//发送聊天消息到世界频道 // 发送聊天消息到世界频道
func (this *modelChatComp) sendChatToWorld(chat *pb.DBChat, queuecount int32) (err error) { func (this *modelChatComp) sendChatToWorld(chat *pb.DBChat, queuecount int32) (err error) {
if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%s", worldchatkey, chat.Stag), int64(queuecount), chat); err != nil { if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%s", worldchatkey, chat.Stag), int64(queuecount), chat); err != nil {
this.module.Errorln(err) this.module.Errorln(err)
@ -333,20 +333,28 @@ func (this *modelChatComp) sendChatToWorld(chat *pb.DBChat, queuecount int32) (e
return return
} }
//发送聊天消息到工会频道 // 发送聊天消息到工会频道
func (this *modelChatComp) sendChatToUnion(chat *pb.DBChat, queuecount int32) (err error) { func (this *modelChatComp) sendChatToUnion(chat *pb.DBChat, queuecount int32) (errdata *pb.ErrorData) {
var (
err error
)
if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%s", unionchatkey, chat.UnionId), int64(queuecount), chat); err != nil { if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%s", unionchatkey, chat.UnionId), int64(queuecount), chat); err != nil {
this.module.Errorln(err) this.module.Errorln(err)
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return return
} }
if err = this.module.pushChatToUnion(chat); err != nil { if errdata = this.module.pushChatToUnion(chat); errdata != nil {
this.module.Errorln(err) this.module.Errorln(errdata)
return return
} }
return return
} }
//发送聊天消息到工会频道 // 发送聊天消息到工会频道
func (this *modelChatComp) sendChatToCrossServer(chat *pb.DBChat, queuecount int32) (err error) { func (this *modelChatComp) sendChatToCrossServer(chat *pb.DBChat, queuecount int32) (err error) {
if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%d", crosschatkey, chat.ChannelId), int64(queuecount), chat); err != nil { if err = this.module.modelChat.addChatMsg(fmt.Sprintf("%s-%d", crosschatkey, chat.ChannelId), int64(queuecount), chat); err != nil {
this.module.Errorln(err) this.module.Errorln(err)
@ -358,7 +366,7 @@ func (this *modelChatComp) sendChatToCrossServer(chat *pb.DBChat, queuecount int
return return
} }
//发送聊天消息到私聊频道 // 发送聊天消息到私聊频道
func (this *modelChatComp) sendChatToSystem(chat *pb.DBChat) (err error) { func (this *modelChatComp) sendChatToSystem(chat *pb.DBChat) (err error) {
if err = this.module.pushChatToSystem(chat); err != nil { if err = this.module.pushChatToSystem(chat); err != nil {
this.module.Errorln(err) this.module.Errorln(err)
@ -367,7 +375,7 @@ func (this *modelChatComp) sendChatToSystem(chat *pb.DBChat) (err error) {
return return
} }
//发送聊天消息到私聊频道 // 发送聊天消息到私聊频道
func (this *modelChatComp) sendChatToPrivate(chat *pb.DBChat) (err error) { func (this *modelChatComp) sendChatToPrivate(chat *pb.DBChat) (err error) {
if err = this.module.pushChatToPrivate(chat); err != nil { if err = this.module.pushChatToPrivate(chat); err != nil {
this.module.Errorln(err) this.module.Errorln(err)

View File

@ -2,6 +2,7 @@ package chat
import ( import (
"context" "context"
"errors"
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/base" "go_dreamfactory/lego/base"
"go_dreamfactory/lego/core" "go_dreamfactory/lego/core"
@ -93,6 +94,7 @@ func (this *Chat) EventUserOffline(uid, sessionid string) {
func (this *Chat) Rpc_ModuleChatPushChat(ctx context.Context, args *pb.DBChat, reply *pb.EmptyResp) (err error) { func (this *Chat) Rpc_ModuleChatPushChat(ctx context.Context, args *pb.DBChat, reply *pb.EmptyResp) (err error) {
var ( var (
max_chat int32 max_chat int32
errdata *pb.ErrorData
) )
if max_chat, err = this.configure.GetChannelRecordMax(); err != nil { if max_chat, err = this.configure.GetChannelRecordMax(); err != nil {
this.Errorln(err) this.Errorln(err)
@ -106,7 +108,8 @@ func (this *Chat) Rpc_ModuleChatPushChat(ctx context.Context, args *pb.DBChat, r
} }
break break
case pb.ChatChannel_Union: case pb.ChatChannel_Union:
if err = this.modelChat.sendChatToUnion(args, max_chat); err != nil { if errdata = this.modelChat.sendChatToUnion(args, max_chat); errdata != nil {
err = errors.New(errdata.Message)
this.Errorln(err) this.Errorln(err)
return return
} }
@ -189,8 +192,8 @@ func (this *Chat) SendUnionChat(msg *pb.DBChat) (errdata *pb.ErrorData) {
return return
} }
if this.IsCross() { if this.IsCross() {
if err = this.modelChat.sendChatToUnion(msg, max_chat); err != nil { if errdata = this.modelChat.sendChatToUnion(msg, max_chat); errdata != nil {
this.Errorln(err) this.Errorln(errdata)
return return
} }
} else { } else {
@ -353,8 +356,11 @@ func (this *Chat) pushChatToWorld(msg *pb.DBChat) (err error) {
} }
// 推送消息到工会 // 推送消息到工会
func (this *Chat) pushChatToUnion(msg *pb.DBChat) (err error) { func (this *Chat) pushChatToUnion(msg *pb.DBChat) (errdata *pb.ErrorData) {
if members := this.sociaty.MembersBySociatyId(msg.UnionId); members != nil { var (
members []*pb.SociatyMemberInfo
)
if members, errdata = this.sociaty.MembersBySociatyId(msg.UnionId); members != nil {
users := make([]string, 0, len(members)) users := make([]string, 0, len(members))
for _, v := range members { for _, v := range members {
if v.OfflineTime == 0 { //离线时间为0 表示在线 if v.OfflineTime == 0 { //离线时间为0 表示在线

View File

@ -113,6 +113,11 @@ func (this *MCompModel) Get(id string, data interface{}, opt ...db.DBOption) (er
return this.DBModel.Get(id, data, opt...) return this.DBModel.Get(id, data, opt...)
} }
// 读取全部数据
func (this *MCompModel) GetByID(id string, data interface{}, opt ...db.DBOption) (err error) {
return this.DBModel.GetByID(id, data, opt...)
}
// 读取多个数据对象 // 读取多个数据对象
func (this *MCompModel) Gets(ids []string, data interface{}, opt ...db.DBOption) (onfound []string, err error) { func (this *MCompModel) Gets(ids []string, data interface{}, opt ...db.DBOption) (onfound []string, err error) {
return this.DBModel.Gets(ids, data, opt...) return this.DBModel.Gets(ids, data, opt...)

View File

@ -83,7 +83,7 @@ func (this *Passon) HeroUpLv(session comm.IUserSession, heroid string, lv int32)
return heros[i].Lv > heros[j].Lv return heros[i].Lv > heros[j].Lv
} else { } else {
conf_i, _ := this.ModuleTools.GetHeroConfig(heros[i].HeroID) conf_i, _ := this.ModuleTools.GetHeroConfig(heros[i].HeroID)
conf_j, _ := this.ModuleTools.GetHeroConfig(heros[i].HeroID) conf_j, _ := this.ModuleTools.GetHeroConfig(heros[j].HeroID)
return conf_i.Color > conf_j.Color return conf_i.Color > conf_j.Color
} }
}) })

View File

@ -23,17 +23,22 @@ func (this *apiComp) ApplyCheck(session comm.IUserSession, req *pb.SociatyApplyR
} }
func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (errdata *pb.ErrorData) { func (this *apiComp) Apply(session comm.IUserSession, req *pb.SociatyApplyReq) (errdata *pb.ErrorData) {
var (
sociaty *pb.DBSociaty
err error
)
if errdata = this.ApplyCheck(session, req); errdata != nil { if errdata = this.ApplyCheck(session, req); errdata != nil {
return return
} }
uid := session.GetUserId() uid := session.GetUserId()
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId) if sociaty, err = this.module.modelSociaty.getSociaty(req.SociatyId); err != nil {
if sociaty == nil {
errdata = &pb.ErrorData{ errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound, Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(), Title: pb.ErrorCode_SociatyNoFound.ToString(),
Message: err.Error(),
} }
return return
} }

View File

@ -20,17 +20,22 @@ func (this *apiComp) ApplyCancelCheck(session comm.IUserSession, req *pb.Sociaty
} }
func (this *apiComp) ApplyCancel(session comm.IUserSession, req *pb.SociatyApplyCancelReq) (errdata *pb.ErrorData) { func (this *apiComp) ApplyCancel(session comm.IUserSession, req *pb.SociatyApplyCancelReq) (errdata *pb.ErrorData) {
var (
uid string
sociaty *pb.DBSociaty
err error
)
if errdata = this.ApplyCancelCheck(session, req); errdata != nil { if errdata = this.ApplyCancelCheck(session, req); errdata != nil {
return return
} }
uid = session.GetUserId()
uid := session.GetUserId() if sociaty, err = this.module.modelSociaty.getSociaty(req.SociatyId); err != nil {
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
if sociaty != nil && sociaty.Id == "" {
errdata = &pb.ErrorData{ errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound, Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(), Title: pb.ErrorCode_SociatyNoFound.ToString(),
Message: err.Error(),
} }
return return
} }

View File

@ -20,16 +20,22 @@ func (this *apiComp) ApplyListCheck(session comm.IUserSession, req *pb.SociatyAp
} }
func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.SociatyApplyListReq) (errdata *pb.ErrorData) { func (this *apiComp) ApplyList(session comm.IUserSession, req *pb.SociatyApplyListReq) (errdata *pb.ErrorData) {
var (
uid string
sociaty *pb.DBSociaty
err error
)
if errdata = this.ApplyListCheck(session, req); errdata != nil { if errdata = this.ApplyListCheck(session, req); errdata != nil {
return return
} }
uid = session.GetUserId()
uid := session.GetUserId() if sociaty, err = this.module.modelSociaty.getSociaty(req.SociatyId); err != nil {
sociaty := this.module.modelSociaty.getSociaty(req.SociatyId)
if sociaty == nil {
errdata = &pb.ErrorData{ errdata = &pb.ErrorData{
Code: pb.ErrorCode_SociatyNoFound, Code: pb.ErrorCode_SociatyNoFound,
Title: pb.ErrorCode_SociatyNoFound.ToString(), Title: pb.ErrorCode_SociatyNoFound.ToString(),
Message: err.Error(),
} }
return return
} }

View File

@ -62,9 +62,13 @@ func (this *apiComp) Create(session comm.IUserSession, req *pb.SociatyCreateReq)
user := this.module.ModuleUser.GetUser(uid) user := this.module.ModuleUser.GetUser(uid)
if user == nil { if user == nil {
this.module.Error("GetRmoteUser not found", log.Field{Key: "uid", Value: uid}) this.module.Error("GetRmoteUser not found", log.Field{Key: "uid", Value: uid})
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: fmt.Sprintf("not found user: %s", uid),
}
return return
} }
userExpand, err := this.module.ModuleUser.GetUserExpand(uid) userExpand, err := this.module.ModuleUser.GetUserExpand(uid)
if err != nil { if err != nil {
errdata = &pb.ErrorData{ errdata = &pb.ErrorData{

View File

@ -167,14 +167,11 @@ func (this *ModelSociaty) findByName(name string) *pb.DBSociaty {
} }
// 获取公会 // 获取公会
func (this *ModelSociaty) getSociaty(sociatyId string) (sociaty *pb.DBSociaty) { func (this *ModelSociaty) getSociaty(sociatyId string) (sociaty *pb.DBSociaty, err error) {
sociaty = &pb.DBSociaty{} sociaty = &pb.DBSociaty{}
if err := this.GetListObj(comm.RDS_EMPTY, sociatyId, sociaty); err != nil { if err = this.GetListObj(comm.RDS_EMPTY, sociatyId, sociaty); err != nil {
log.Error("GetListObj", log.Field{Key: "sociatyId", Value: sociatyId}) this.module.Error("获取工会信息 失败", log.Field{Key: "sociatyId", Value: sociatyId}, log.Field{Key: "err", Value: err.Error()})
return nil return
}
if sociaty.Id == "" {
return nil
} }
return return
} }
@ -217,7 +214,7 @@ func (this *ModelSociaty) getUserSociaty(uid string) (sociaty *pb.DBSociaty) {
return return
} }
if userEx.SociatyId != "" { if userEx.SociatyId != "" {
sociaty = this.getSociaty(userEx.SociatyId) sociaty, _ = this.getSociaty(userEx.SociatyId)
if sociaty != nil { if sociaty != nil {
//验证是否解散 //验证是否解散
if this.isDismiss(sociaty) { if this.isDismiss(sociaty) {

View File

@ -115,7 +115,7 @@ func (this *Sociaty) ProcessAccuse(uid, sociatyId string) {
if t == 0 { if t == 0 {
return return
} }
sociaty := this.modelSociaty.getSociaty(sociatyId) sociaty, _ := this.modelSociaty.getSociaty(sociatyId)
if sociaty != nil { if sociaty != nil {
if sociaty.AccuseTime > 0 { if sociaty.AccuseTime > 0 {
now := configure.Now().Unix() now := configure.Now().Unix()
@ -142,9 +142,20 @@ func (this *Sociaty) MembersByUid(uid string) (list []*pb.SociatyMemberInfo) {
} }
// 获取公会成员 // 获取公会成员
func (this *Sociaty) MembersBySociatyId(sociatyId string) (list []*pb.SociatyMemberInfo) { func (this *Sociaty) MembersBySociatyId(sociatyId string) (list []*pb.SociatyMemberInfo, errdata *pb.ErrorData) {
sociaty := this.modelSociaty.getSociaty(sociatyId) var (
return this.modelSociaty.members(sociaty) sociaty *pb.DBSociaty
err error
)
if sociaty, err = this.modelSociaty.getSociaty(sociatyId); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
return this.modelSociaty.members(sociaty), nil
} }
// 批量获取公户信息 // 批量获取公户信息
@ -212,7 +223,11 @@ func (this *Sociaty) Reddot(session comm.IUserSession, rid ...comm.ReddotType) (
// 跨服获取公会 // 跨服获取公会
func (this *Sociaty) RpcGetSociaty(ctx context.Context, req *pb.RPCGeneralReqA1, reply *pb.DBSociaty) error { func (this *Sociaty) RpcGetSociaty(ctx context.Context, req *pb.RPCGeneralReqA1, reply *pb.DBSociaty) error {
this.Debug("Rpc_ModuleSociaty", log.Field{Key: "req", Value: req.String()}) this.Debug("Rpc_ModuleSociaty", log.Field{Key: "req", Value: req.String()})
sociaty := this.modelSociaty.getSociaty(req.Param1) var (
sociaty *pb.DBSociaty
err error
)
sociaty, err = this.modelSociaty.getSociaty(req.Param1)
reply.Id = sociaty.Id reply.Id = sociaty.Id
reply.Lv = sociaty.Lv reply.Lv = sociaty.Lv
reply.Exp = sociaty.Exp reply.Exp = sociaty.Exp
@ -229,7 +244,7 @@ func (this *Sociaty) RpcGetSociaty(ctx context.Context, req *pb.RPCGeneralReqA1,
reply.Activity = sociaty.Activity reply.Activity = sociaty.Activity
reply.AccuseTime = sociaty.AccuseTime reply.AccuseTime = sociaty.AccuseTime
reply.ApplyRecord = sociaty.ApplyRecord reply.ApplyRecord = sociaty.ApplyRecord
return nil return err
} }
type SociatyUpdateParam struct { type SociatyUpdateParam struct {

View File

@ -29,11 +29,12 @@ type Timer struct {
//season *SeasonPagoda //season *SeasonPagoda
forum *ForumComp forum *ForumComp
arena *ArenaComp arena *ArenaComp
sociaty *SociatyComp
parkour *ParkourComp parkour *ParkourComp
caravan *CaravanRank caravan *CaravanRank
} }
//模块名 // 模块名
func (this *Timer) GetType() core.M_Modules { func (this *Timer) GetType() core.M_Modules {
return comm.ModuleTimer return comm.ModuleTimer
} }
@ -43,7 +44,7 @@ func (this *Timer) NewOptions() (options core.IModuleOptions) {
return new(Options) return new(Options)
} }
//模块初始化接口 注册用户创建角色事件 // 模块初始化接口 注册用户创建角色事件
func (this *Timer) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { func (this *Timer) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options) err = this.ModuleBase.Init(service, module, options)
this.service = service.(base.IRPCXService) this.service = service.(base.IRPCXService)
@ -62,11 +63,12 @@ func (this *Timer) OnInstallComp() {
this.chat = this.RegisterComp(new(ChatComp)).(*ChatComp) this.chat = this.RegisterComp(new(ChatComp)).(*ChatComp)
//this.season = this.RegisterComp(new(SeasonPagoda)).(*SeasonPagoda) //this.season = this.RegisterComp(new(SeasonPagoda)).(*SeasonPagoda)
this.arena = this.RegisterComp(new(ArenaComp)).(*ArenaComp) this.arena = this.RegisterComp(new(ArenaComp)).(*ArenaComp)
this.sociaty = this.RegisterComp(new(SociatyComp)).(*SociatyComp)
this.parkour = this.RegisterComp(new(ParkourComp)).(*ParkourComp) this.parkour = this.RegisterComp(new(ParkourComp)).(*ParkourComp)
this.caravan = this.RegisterComp(new(CaravanRank)).(*CaravanRank) this.caravan = this.RegisterComp(new(CaravanRank)).(*CaravanRank)
} }
//跨服对象获取数据操作对象 // 跨服对象获取数据操作对象
func (this *Timer) getDBModelByUid(uid, tableName string) (model *db.DBModel, err error) { func (this *Timer) getDBModelByUid(uid, tableName string) (model *db.DBModel, err error) {
var ( var (
stag string stag string
@ -88,7 +90,7 @@ func (this *Timer) getDBModelByUid(uid, tableName string) (model *db.DBModel, er
return return
} }
//日志 // 日志
func (this *Timer) Enabled(lvl log.Loglevel) bool { func (this *Timer) Enabled(lvl log.Loglevel) bool {
return this.options.GetLog().Enabled(lvl) return this.options.GetLog().Enabled(lvl)
} }
@ -96,7 +98,7 @@ func (this *Timer) SetName(name string) {
this.options.GetLog().SetName(name) this.options.GetLog().SetName(name)
} }
//日志接口 // 日志接口
func (this *Timer) Debug(msg string, args ...log.Field) { func (this *Timer) Debug(msg string, args ...log.Field) {
this.options.GetLog().Debug(msg, args...) this.options.GetLog().Debug(msg, args...)
} }

54
modules/timer/sociaty.go Normal file
View File

@ -0,0 +1,54 @@
package timer
import (
"context"
"go_dreamfactory/comm"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/db"
"go_dreamfactory/lego/base"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/cron"
)
/*
工会结算计时器
*/
type SociatyComp struct {
modules.MCompConfigure
service base.IRPCXService
module *Timer
takes []cron.EntryID
}
// 组件初始化接口
func (this *SociatyComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
this.MCompConfigure.Init(service, module, comp, options)
this.service = service.(base.IRPCXService)
this.module = module.(*Timer)
this.takes = make([]cron.EntryID, 0)
return
}
// 自由跨服环境下开启此功能
func (this *SociatyComp) Start() (err error) {
err = this.MCompConfigure.Start()
if db.IsCross() {
if _, err = cron.AddFunc("0 0 1 ? * 1", this.timer); err != nil {
this.module.Errorf("cron.AddFunc err:%v", err)
}
}
return
}
func (this *SociatyComp) timer() {
if _, err := this.service.RpcGo(context.Background(),
comm.Service_Worker,
string(comm.Rpc_ModuleGuildBossSettlement),
pb.EmptyReq{},
nil,
); err != nil {
this.module.Errorln(err)
}
}

View File

@ -33,7 +33,7 @@ func (this *modelGlobal) GetGlobalData(key string, v interface{}) (err error) {
// 更新全局配置 // 更新全局配置
func (this *modelGlobal) UpdateGlobalData(key string, v interface{}) (err error) { func (this *modelGlobal) UpdateGlobalData(key string, v interface{}) (err error) {
if _, err = this.DBModel.DB.UpdateOne(core.SqlTable(this.TableName), bson.M{"_id": key}, v, options.Update().SetUpsert(true)); err != nil { if _, err = this.DBModel.DB.UpdateOne(core.SqlTable(this.TableName), bson.M{"_id": key}, bson.M{"$set": v}, options.Update().SetUpsert(true)); err != nil {
this.module.Error("GetGlobalData err", log.Field{Key: "key", Value: key}, log.Field{Key: "err", Value: err.Error()}) this.module.Error("GetGlobalData err", log.Field{Key: "key", Value: key}, log.Field{Key: "err", Value: err.Error()})
} }
return return

View File

@ -10,13 +10,13 @@ import (
) )
// 参数校验 // 参数校验
func (this *apiComp) ChallengeFinishCheck(session comm.IUserSession, req *pb.UniongveChallengeFinishRep) (errdata *pb.ErrorData) { func (this *apiComp) ChallengeFinishCheck(session comm.IUserSession, req *pb.UniongveChallengeFinishReq) (errdata *pb.ErrorData) {
return return
} }
// 获取工会boos战信息 // 获取工会boos战信息
func (this *apiComp) ChallengeFinish(session comm.IUserSession, req *pb.UniongveChallengeFinishRep) (errdata *pb.ErrorData) { func (this *apiComp) ChallengeFinish(session comm.IUserSession, req *pb.UniongveChallengeFinishReq) (errdata *pb.ErrorData) {
var ( var (
conf *cfg.GameGuildBossData conf *cfg.GameGuildBossData
score *cfg.GameGuildBossScoreData score *cfg.GameGuildBossScoreData

View File

@ -58,7 +58,7 @@ func (this *apiComp) Roulette(session comm.IUserSession, req *pb.UniongveRoulett
} }
if confs[index].Push == 1 { //推送通知 if confs[index].Push == 1 { //推送通知
go this.module.modelUnionroulette.roulettechangePush(session.GetUserId(), req.Unionid, award) go this.module.modelUnionroulette.roulettechangePush(req.Unionid, session.GetUserId(), award)
} }
session.SendMsg(string(this.module.GetType()), "roulette", &pb.UniongveRouletteResp{Cid: confs[index].Id, Award: award}) session.SendMsg(string(this.module.GetType()), "roulette", &pb.UniongveRouletteResp{Cid: confs[index].Id, Award: award})

View File

@ -60,7 +60,7 @@ func (this *ModelUnionroulette) updateUnionRoulette(data *pb.DBUnionRouletteReco
// 分布式锁 // 分布式锁
func (this *ModelUnionroulette) userlock(id string) (result *redis.RedisMutex, err error) { func (this *ModelUnionroulette) userlock(id string) (result *redis.RedisMutex, err error) {
return this.DBModel.Redis.NewRedisMutex(fmt.Sprintf("unionroulette:%s", id)) return this.DBModel.Redis.NewRedisMutex(fmt.Sprintf("lockunionroulette:%s", id))
} }
// boos 信息变化推送 // boos 信息变化推送
@ -69,11 +69,11 @@ func (this *ModelUnionroulette) roulettechangePush(unionid string, uid string, a
info *pb.DBUnionRouletteRecord info *pb.DBUnionRouletteRecord
members []*pb.SociatyMemberInfo members []*pb.SociatyMemberInfo
users []string = make([]string, 0) users []string = make([]string, 0)
errdata *pb.ErrorData
err error err error
) )
members = this.module.sociaty.MembersBySociatyId(unionid) if members, errdata = this.module.sociaty.MembersBySociatyId(unionid); errdata != nil {
if members == nil || len(members) == 0 { this.module.Debug("获取工会成员列表!", log.Field{Key: "errdata", Value: errdata})
this.module.Error("MembersBySociatyId is nil !")
return return
} }
for _, v := range members { for _, v := range members {
@ -98,5 +98,5 @@ func (this *ModelUnionroulette) roulettechangePush(unionid string, uid string, a
this.module.SendMsgToUsers(string(this.module.GetType()), "roulettechange", &pb.UniongveRouletteChangePush{ this.module.SendMsgToUsers(string(this.module.GetType()), "roulettechange", &pb.UniongveRouletteChangePush{
Record: info, Record: info,
}) }, users...)
} }

View File

@ -46,8 +46,10 @@ func (this *ModelUniongve) getUnionGve(unionid string) (results *pb.DBUnionGve,
confs *pb.DBUnionGveBossConf confs *pb.DBUnionGveBossConf
conf *cfg.GameGuildBossData conf *cfg.GameGuildBossData
) )
results = &pb.DBUnionGve{} results = &pb.DBUnionGve{
if err = this.Get(unionid, results); err != nil && err != mgo.MongodbNil { Boos: make([]*pb.DBUnionGveBoss, 0),
}
if err = this.GetByID(unionid, results); err != nil && err != mgo.MongodbNil {
this.module.Errorln(err) this.module.Errorln(err)
return return
} }
@ -120,12 +122,16 @@ func (this *ModelUniongve) getGlobalBoos() (conf *pb.DBUnionGveBossConf, err err
) )
this.conflock.RLock() this.conflock.RLock()
bossconf = this.bossconf bossconf = this.bossconf
this.conflock.Unlock() this.conflock.RUnlock()
if bossconf == nil || !utils.IsSameWeek(bossconf.Rtime) { if bossconf == nil || !utils.IsSameWeek(bossconf.Rtime) {
if bossconf, err = this.refreshGlobalBoos(); err != nil { if bossconf, err = this.refreshGlobalBoos(); err != nil {
return return
} }
this.conflock.Lock()
this.bossconf = bossconf
this.conflock.Unlock()
} }
conf = bossconf
return return
} }
@ -154,13 +160,16 @@ func (this *ModelUniongve) refreshGlobalBoos() (conf *pb.DBUnionGveBossConf, err
this.conflock.Lock() this.conflock.Lock()
this.bossconf = conf this.bossconf = conf
this.conflock.Unlock() this.conflock.Unlock()
this.module.ModuleTools.UpdateGlobalData(UnionGveBoosCoonfKey, conf) this.module.ModuleTools.UpdateGlobalData(UnionGveBoosCoonfKey, map[string]interface{}{
"rtime": conf.Rtime,
"boos": conf.Boos,
})
return return
} }
// 分布式锁 // 分布式锁
func (this *ModelUniongve) userlock(id string) (result *redis.RedisMutex, err error) { func (this *ModelUniongve) userlock(id string) (result *redis.RedisMutex, err error) {
return this.DBModel.Redis.NewRedisMutex(fmt.Sprintf("uniongve:%s", id)) return this.DBModel.Redis.NewRedisMutex(fmt.Sprintf("lockuniongve:%s", id))
} }
// boos 血量变化推送 // boos 血量变化推送
@ -168,10 +177,10 @@ func (this *ModelUniongve) booshpchangepush(unionid string, info *pb.DBUnionGve)
var ( var (
members []*pb.SociatyMemberInfo members []*pb.SociatyMemberInfo
users []string = make([]string, 0) users []string = make([]string, 0)
errdata *pb.ErrorData
) )
members = this.module.sociaty.MembersBySociatyId(unionid) if members, errdata = this.module.sociaty.MembersBySociatyId(unionid); errdata != nil {
if members == nil || len(members) == 0 { this.module.Debug("获取工会成员列表!", log.Field{Key: "errdata", Value: errdata})
this.module.Error("MembersBySociatyId is nil !")
return return
} }
for _, v := range members { for _, v := range members {
@ -180,7 +189,7 @@ func (this *ModelUniongve) booshpchangepush(unionid string, info *pb.DBUnionGve)
} }
this.module.SendMsgToUsers(string(this.module.GetType()), "booschange", &pb.UniongveBoosChangePush{ this.module.SendMsgToUsers(string(this.module.GetType()), "booschange", &pb.UniongveBoosChangePush{
Info: info, Info: info,
}) }, users...)
} }
// 击杀boos // 击杀boos
@ -189,15 +198,15 @@ func (this *ModelUniongve) booskill(unionid string, boosid int32, info *pb.DBUni
conf *cfg.GameGuildBossData conf *cfg.GameGuildBossData
members []*pb.SociatyMemberInfo members []*pb.SociatyMemberInfo
users []string = make([]string, 0) users []string = make([]string, 0)
errdata *pb.ErrorData
err error err error
) )
if conf, err = this.module.configure.getguildbossByid(boosid); err != nil { if conf, err = this.module.configure.getguildbossByid(boosid); err != nil {
this.module.Errorln(err) this.module.Errorln(err)
return return
} }
members = this.module.sociaty.MembersBySociatyId(unionid) if members, errdata = this.module.sociaty.MembersBySociatyId(unionid); errdata != nil {
if members == nil || len(members) == 0 { this.module.Debug("获取工会成员列表!", log.Field{Key: "errdata", Value: errdata})
this.module.Error("MembersBySociatyId is nil !")
return return
} }
for _, v := range members { for _, v := range members {
@ -238,7 +247,7 @@ func (this *ModelUniongve) booskill(unionid string, boosid int32, info *pb.DBUni
} }
this.module.SendMsgToUsers(string(this.module.GetType()), "stagechange", &pb.UniongveStageChangePush{ this.module.SendMsgToUsers(string(this.module.GetType()), "stagechange", &pb.UniongveStageChangePush{
Info: info, Info: info,
}) }, users...)
} }
// boos 信息变化推送 // boos 信息变化推送
@ -246,10 +255,10 @@ func (this *ModelUniongve) infochangepush(unionid string, info *pb.DBUnionGve) {
var ( var (
members []*pb.SociatyMemberInfo members []*pb.SociatyMemberInfo
users []string = make([]string, 0) users []string = make([]string, 0)
errdata *pb.ErrorData
) )
members = this.module.sociaty.MembersBySociatyId(unionid) if members, errdata = this.module.sociaty.MembersBySociatyId(unionid); errdata != nil {
if members == nil || len(members) == 0 { this.module.Debug("获取工会成员列表!", log.Field{Key: "errdata", Value: errdata})
this.module.Error("MembersBySociatyId is nil !")
return return
} }
for _, v := range members { for _, v := range members {
@ -258,5 +267,5 @@ func (this *ModelUniongve) infochangepush(unionid string, info *pb.DBUnionGve) {
} }
this.module.SendMsgToUsers(string(this.module.GetType()), "infochange", &pb.UniongveInfoChangePush{ this.module.SendMsgToUsers(string(this.module.GetType()), "infochange", &pb.UniongveInfoChangePush{
Info: info, Info: info,
}) }, users...)
} }

View File

@ -25,7 +25,7 @@ type modelRank struct {
func (this *modelRank) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { func (this *modelRank) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompModel.Init(service, module, comp, options) err = this.MCompModel.Init(service, module, comp, options)
this.TableName = comm.TableUnionroulette this.TableName = comm.TableUnionrank
this.module = module.(*UnionGve) this.module = module.(*UnionGve)
return return
} }
@ -116,17 +116,18 @@ func (this *modelRank) raceSettlement() {
} }
// boos 血量变化推送 // boos 奖励推送
func (this *modelRank) rankRewardPush(unionid string, reward []*cfg.Gameatn) { func (this *modelRank) rankRewardPush(unionid string, reward []*cfg.Gameatn) {
var ( var (
members []*pb.SociatyMemberInfo members []*pb.SociatyMemberInfo
users []string = make([]string, 0) users []string = make([]string, 0)
errdata *pb.ErrorData
) )
members = this.module.sociaty.MembersBySociatyId(unionid) if members, errdata = this.module.sociaty.MembersBySociatyId(unionid); errdata != nil {
if members == nil || len(members) == 0 { this.module.Debug("获取工会成员列表!", log.Field{Key: "errdata", Value: errdata})
this.module.Error("MembersBySociatyId is nil !")
return return
} }
for _, v := range members { for _, v := range members {
users = append(users, v.Uid) users = append(users, v.Uid)
} }

View File

@ -26,7 +26,7 @@ type DBUnionGveBossConf struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key" bson:"_id"` //刷新时间 //唯一ID Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key" bson:"_id"` //唯一ID
Rtime int64 `protobuf:"varint,2,opt,name=rtime,proto3" json:"rtime"` //刷新时间 Rtime int64 `protobuf:"varint,2,opt,name=rtime,proto3" json:"rtime"` //刷新时间
Boos []int32 `protobuf:"varint,3,rep,packed,name=boos,proto3" json:"boos"` //boosid Boos []int32 `protobuf:"varint,3,rep,packed,name=boos,proto3" json:"boos"` //boosid
} }
@ -90,7 +90,7 @@ type DBUnionGve struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
Unionid string `protobuf:"bytes,1,opt,name=unionid,proto3" json:"unionid"` //工会id Unionid string `protobuf:"bytes,1,opt,name=unionid,proto3" json:"unionid" bson:"_id"` // 背包格子Id
Notice string `protobuf:"bytes,2,opt,name=notice,proto3" json:"notice"` //公告 Notice string `protobuf:"bytes,2,opt,name=notice,proto3" json:"notice"` //公告
Fire int32 `protobuf:"varint,3,opt,name=fire,proto3" json:"fire"` //火力 Fire int32 `protobuf:"varint,3,opt,name=fire,proto3" json:"fire"` //火力
Currstage int32 `protobuf:"varint,4,opt,name=currstage,proto3" json:"currstage"` //当前第几阶段 Currstage int32 `protobuf:"varint,4,opt,name=currstage,proto3" json:"currstage"` //当前第几阶段

View File

@ -611,7 +611,7 @@ func (x *UniongveChallengeResp) GetInfo() *BattleInfo {
} }
//战斗 完成请求 //战斗 完成请求
type UniongveChallengeFinishRep struct { type UniongveChallengeFinishReq struct {
state protoimpl.MessageState state protoimpl.MessageState
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields unknownFields protoimpl.UnknownFields
@ -621,8 +621,8 @@ type UniongveChallengeFinishRep struct {
Report *BattleReport `protobuf:"bytes,3,opt,name=report,proto3" json:"report"` //战报 Report *BattleReport `protobuf:"bytes,3,opt,name=report,proto3" json:"report"` //战报
} }
func (x *UniongveChallengeFinishRep) Reset() { func (x *UniongveChallengeFinishReq) Reset() {
*x = UniongveChallengeFinishRep{} *x = UniongveChallengeFinishReq{}
if protoimpl.UnsafeEnabled { if protoimpl.UnsafeEnabled {
mi := &file_uniongve_uniongve_msg_proto_msgTypes[11] mi := &file_uniongve_uniongve_msg_proto_msgTypes[11]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -630,13 +630,13 @@ func (x *UniongveChallengeFinishRep) Reset() {
} }
} }
func (x *UniongveChallengeFinishRep) String() string { func (x *UniongveChallengeFinishReq) String() string {
return protoimpl.X.MessageStringOf(x) return protoimpl.X.MessageStringOf(x)
} }
func (*UniongveChallengeFinishRep) ProtoMessage() {} func (*UniongveChallengeFinishReq) ProtoMessage() {}
func (x *UniongveChallengeFinishRep) ProtoReflect() protoreflect.Message { func (x *UniongveChallengeFinishReq) ProtoReflect() protoreflect.Message {
mi := &file_uniongve_uniongve_msg_proto_msgTypes[11] mi := &file_uniongve_uniongve_msg_proto_msgTypes[11]
if protoimpl.UnsafeEnabled && x != nil { if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
@ -648,26 +648,26 @@ func (x *UniongveChallengeFinishRep) ProtoReflect() protoreflect.Message {
return mi.MessageOf(x) return mi.MessageOf(x)
} }
// Deprecated: Use UniongveChallengeFinishRep.ProtoReflect.Descriptor instead. // Deprecated: Use UniongveChallengeFinishReq.ProtoReflect.Descriptor instead.
func (*UniongveChallengeFinishRep) Descriptor() ([]byte, []int) { func (*UniongveChallengeFinishReq) Descriptor() ([]byte, []int) {
return file_uniongve_uniongve_msg_proto_rawDescGZIP(), []int{11} return file_uniongve_uniongve_msg_proto_rawDescGZIP(), []int{11}
} }
func (x *UniongveChallengeFinishRep) GetUnionid() string { func (x *UniongveChallengeFinishReq) GetUnionid() string {
if x != nil { if x != nil {
return x.Unionid return x.Unionid
} }
return "" return ""
} }
func (x *UniongveChallengeFinishRep) GetBoosid() int32 { func (x *UniongveChallengeFinishReq) GetBoosid() int32 {
if x != nil { if x != nil {
return x.Boosid return x.Boosid
} }
return 0 return 0
} }
func (x *UniongveChallengeFinishRep) GetReport() *BattleReport { func (x *UniongveChallengeFinishReq) GetReport() *BattleReport {
if x != nil { if x != nil {
return x.Report return x.Report
} }
@ -996,7 +996,7 @@ var file_uniongve_uniongve_msg_proto_rawDesc = []byte{
0x32, 0x0b, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69, 0x32, 0x0b, 0x2e, 0x42, 0x61, 0x74, 0x74, 0x6c, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x04, 0x69,
0x6e, 0x66, 0x6f, 0x22, 0x75, 0x0a, 0x1a, 0x55, 0x6e, 0x69, 0x6f, 0x6e, 0x67, 0x76, 0x65, 0x43, 0x6e, 0x66, 0x6f, 0x22, 0x75, 0x0a, 0x1a, 0x55, 0x6e, 0x69, 0x6f, 0x6e, 0x67, 0x76, 0x65, 0x43,
0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65, 0x68, 0x61, 0x6c, 0x6c, 0x65, 0x6e, 0x67, 0x65, 0x46, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x52, 0x65,
0x70, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01,
0x28, 0x09, 0x52, 0x07, 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x62, 0x28, 0x09, 0x52, 0x07, 0x75, 0x6e, 0x69, 0x6f, 0x6e, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x62,
0x6f, 0x6f, 0x73, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x6f, 0x6f, 0x6f, 0x6f, 0x73, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x62, 0x6f, 0x6f,
0x73, 0x69, 0x64, 0x12, 0x25, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20, 0x73, 0x69, 0x64, 0x12, 0x25, 0x0a, 0x06, 0x72, 0x65, 0x70, 0x6f, 0x72, 0x74, 0x18, 0x03, 0x20,
@ -1055,7 +1055,7 @@ var file_uniongve_uniongve_msg_proto_goTypes = []interface{}{
(*UniongveRouletteResp)(nil), // 8: UniongveRouletteResp (*UniongveRouletteResp)(nil), // 8: UniongveRouletteResp
(*UniongveChallengeReq)(nil), // 9: UniongveChallengeReq (*UniongveChallengeReq)(nil), // 9: UniongveChallengeReq
(*UniongveChallengeResp)(nil), // 10: UniongveChallengeResp (*UniongveChallengeResp)(nil), // 10: UniongveChallengeResp
(*UniongveChallengeFinishRep)(nil), // 11: UniongveChallengeFinishRep (*UniongveChallengeFinishReq)(nil), // 11: UniongveChallengeFinishReq
(*UniongveChallengeFinishResp)(nil), // 12: UniongveChallengeFinishResp (*UniongveChallengeFinishResp)(nil), // 12: UniongveChallengeFinishResp
(*UniongveInfoChangePush)(nil), // 13: UniongveInfoChangePush (*UniongveInfoChangePush)(nil), // 13: UniongveInfoChangePush
(*UniongveStageChangePush)(nil), // 14: UniongveStageChangePush (*UniongveStageChangePush)(nil), // 14: UniongveStageChangePush
@ -1074,7 +1074,7 @@ var file_uniongve_uniongve_msg_proto_depIdxs = []int32{
18, // 2: UniongveRouletteResp.award:type_name -> UserAssets 18, // 2: UniongveRouletteResp.award:type_name -> UserAssets
19, // 3: UniongveChallengeReq.battle:type_name -> BattleFormation 19, // 3: UniongveChallengeReq.battle:type_name -> BattleFormation
20, // 4: UniongveChallengeResp.info:type_name -> BattleInfo 20, // 4: UniongveChallengeResp.info:type_name -> BattleInfo
21, // 5: UniongveChallengeFinishRep.report:type_name -> BattleReport 21, // 5: UniongveChallengeFinishReq.report:type_name -> BattleReport
18, // 6: UniongveChallengeFinishResp.award:type_name -> UserAssets 18, // 6: UniongveChallengeFinishResp.award:type_name -> UserAssets
17, // 7: UniongveInfoChangePush.info:type_name -> DBUnionGve 17, // 7: UniongveInfoChangePush.info:type_name -> DBUnionGve
17, // 8: UniongveStageChangePush.info:type_name -> DBUnionGve 17, // 8: UniongveStageChangePush.info:type_name -> DBUnionGve
@ -1229,7 +1229,7 @@ func file_uniongve_uniongve_msg_proto_init() {
} }
} }
file_uniongve_uniongve_msg_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { file_uniongve_uniongve_msg_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*UniongveChallengeFinishRep); i { switch v := v.(*UniongveChallengeFinishReq); i {
case 0: case 0:
return &v.state return &v.state
case 1: case 1:

View File

@ -386,6 +386,27 @@ func (this *DBModel) Get(uid string, data interface{}, opt ...DBOption) (err err
return return
} }
// 读取全部数据
func (this *DBModel) GetByID(id string, data interface{}, opt ...DBOption) (err error) {
//defer log.Debug("DBModel Get", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "data", Value: data})
if err = this.Redis.HGetAll(this.ukey(id), data); err != nil && err != lgredis.RedisNil {
log.Error("HGetAll 错误!", log.Field{Key: "ukey", Value: this.ukey(id)}, log.Field{Key: "err", Value: err.Error()})
return
}
if err == lgredis.RedisNil {
if err = this.DB.FindOne(core.SqlTable(this.TableName), bson.M{"_id": id}).Decode(data); err != nil {
return
}
err = this.Redis.HMSet(this.ukey(id), data)
}
// option := newDBOption(opt...)
if this.Expired > 0 {
// this.Redis.Expire(this.ukey(uid), option.Expire)
this.conn.UpDateModelExpired(this.ukey(id), nil, this.Expired)
}
return
}
// 读取多个数据对象 // 读取多个数据对象
func (this *DBModel) Gets(ids []string, data interface{}, opt ...DBOption) (onfound []string, err error) { func (this *DBModel) Gets(ids []string, data interface{}, opt ...DBOption) (onfound []string, err error) {
//defer log.Debug("DBModel GetListObjs", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "ids", Value: ids}, log.Field{Key: "data", Value: data}) //defer log.Debug("DBModel GetListObjs", log.Field{Key: "TableName", Value: this.TableName}, log.Field{Key: "uid", Value: uid}, log.Field{Key: "ids", Value: ids}, log.Field{Key: "data", Value: data})