上传工会排名数据
This commit is contained in:
parent
5b1085cd04
commit
15a10c074d
@ -1,6 +1,7 @@
|
|||||||
package guildgve
|
package guildgve
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
)
|
)
|
||||||
@ -17,6 +18,7 @@ func (this *apiComp) Rank(session comm.IUserSession, req *pb.GuildGveRankReq) (e
|
|||||||
err error
|
err error
|
||||||
ids []string
|
ids []string
|
||||||
sociatys []*pb.DBSociaty
|
sociatys []*pb.DBSociaty
|
||||||
|
guilids []*pb.DBGuildGve
|
||||||
ranks []*pb.GuildGveRankItem
|
ranks []*pb.GuildGveRankItem
|
||||||
)
|
)
|
||||||
if errdata = this.RankCheck(session, req); errdata != nil {
|
if errdata = this.RankCheck(session, req); errdata != nil {
|
||||||
@ -35,12 +37,32 @@ func (this *apiComp) Rank(session comm.IUserSession, req *pb.GuildGveRankReq) (e
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if guilids, err = this.module.modelGuildGve.querySociatys(ids); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_DBError,
|
||||||
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(guilids) != len(sociatys) {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_DBError,
|
||||||
|
Title: pb.ErrorCode_DBError.ToString(),
|
||||||
|
Message: fmt.Sprintf("数据不对称 guilids:%d sociatys:%d", len(guilids), len(sociatys)),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
for i, v := range sociatys {
|
for i, v := range sociatys {
|
||||||
ranks = append(ranks, &pb.GuildGveRankItem{
|
ranks = append(ranks, &pb.GuildGveRankItem{
|
||||||
Guildid: v.Id,
|
Guildid: v.Id,
|
||||||
Name: v.Name,
|
Name: v.Name,
|
||||||
Icon: v.Icon,
|
Icon: v.Icon,
|
||||||
Rank: int32(i),
|
Rank: int32(i),
|
||||||
|
KillCount: guilids[i].Kills,
|
||||||
|
LastKillTime: guilids[i].Lastkilltime,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
session.SendMsg(string(this.module.GetType()), "rank", &pb.GuildGveRankResp{List: ranks})
|
session.SendMsg(string(this.module.GetType()), "rank", &pb.GuildGveRankResp{List: ranks})
|
||||||
|
@ -40,6 +40,17 @@ func (this *ModelUniongve) Start() (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 批量查询工会信息
|
||||||
|
func (this *ModelUniongve) querySociatys(guildids []string) (result []*pb.DBGuildGve, err error) {
|
||||||
|
result = make([]*pb.DBGuildGve, 0)
|
||||||
|
if _, err = this.Gets(guildids, &result); err != nil && err != mgo.MongodbNil {
|
||||||
|
this.module.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = nil
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// 获取用户全部的埋点数据
|
// 获取用户全部的埋点数据
|
||||||
func (this *ModelUniongve) getGuildGve(guildid string) (results *pb.DBGuildGve, err error) {
|
func (this *ModelUniongve) getGuildGve(guildid string) (results *pb.DBGuildGve, err error) {
|
||||||
var (
|
var (
|
||||||
|
77
modules/guildgve/module_test.go
Normal file
77
modules/guildgve/module_test.go
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
package guildgve_test
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"go_dreamfactory/comm"
|
||||||
|
"go_dreamfactory/lego"
|
||||||
|
"go_dreamfactory/lego/base/rpcx"
|
||||||
|
"go_dreamfactory/lego/core"
|
||||||
|
"go_dreamfactory/lego/sys/log"
|
||||||
|
"go_dreamfactory/modules/chat"
|
||||||
|
"go_dreamfactory/services"
|
||||||
|
"go_dreamfactory/sys/db"
|
||||||
|
"os"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
|
)
|
||||||
|
|
||||||
|
func newService(ops ...rpcx.Option) core.IService {
|
||||||
|
s := new(TestService)
|
||||||
|
s.Configure(ops...)
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
|
// 梦工厂基础服务对象
|
||||||
|
type TestService struct {
|
||||||
|
services.ServiceBase
|
||||||
|
}
|
||||||
|
|
||||||
|
// 初始化相关系统
|
||||||
|
func (this *TestService) InitSys() {
|
||||||
|
this.ServiceBase.InitSys()
|
||||||
|
if err := db.OnInit(this.GetSettings().Sys["db"], db.SetServiceId(this.GetTag())); err != nil {
|
||||||
|
panic(fmt.Sprintf("init sys.db err: %s", err.Error()))
|
||||||
|
} else {
|
||||||
|
log.Infof("init sys.db success!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var service core.IService
|
||||||
|
var s_gateComp comm.ISC_GateRouteComp = services.NewGateRouteComp()
|
||||||
|
var module = new(chat.Chat)
|
||||||
|
|
||||||
|
// 测试环境下初始化db和cache 系统
|
||||||
|
func TestMain(m *testing.M) {
|
||||||
|
service = newService(
|
||||||
|
rpcx.SetConfPath("../../bin/conf/dfli_worker0.yaml"),
|
||||||
|
rpcx.SetVersion("1.0.0.0"),
|
||||||
|
)
|
||||||
|
service.OnInstallComp( //装备组件
|
||||||
|
s_gateComp, //此服务需要接受用户的消息 需要装备网关组件
|
||||||
|
)
|
||||||
|
go func() {
|
||||||
|
lego.Run(service) //运行模块
|
||||||
|
|
||||||
|
}()
|
||||||
|
time.Sleep(time.Second * 3)
|
||||||
|
defer os.Exit(m.Run())
|
||||||
|
}
|
||||||
|
|
||||||
|
func Test_Module(t *testing.T) {
|
||||||
|
var (
|
||||||
|
key string
|
||||||
|
score float64
|
||||||
|
menbers *redis.Z
|
||||||
|
conn *db.DBConn
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
key = "guildgvebattlerank:3"
|
||||||
|
score = 1
|
||||||
|
menbers = &redis.Z{Score: (score), Member: "member"}
|
||||||
|
conn, err = db.Local()
|
||||||
|
if err = conn.Redis.ZAdd(key, menbers); err != nil {
|
||||||
|
log.Errorln(err)
|
||||||
|
}
|
||||||
|
}
|
@ -90,7 +90,7 @@ type DBGuildGve struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Guildid string `protobuf:"bytes,1,opt,name=Guildid,proto3" json:"Guildid" bson:"_id"`
|
Guildid string `protobuf:"bytes,1,opt,name=guildid,proto3" json:"guildid" bson:"_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"` //当前第几阶段
|
||||||
@ -716,8 +716,8 @@ var file_guildgve_guildgve_db_proto_rawDesc = []byte{
|
|||||||
0x12, 0x14, 0x0a, 0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
|
0x12, 0x14, 0x0a, 0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x03, 0x52,
|
||||||
0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x6f, 0x73, 0x18, 0x03,
|
0x05, 0x72, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x62, 0x6f, 0x6f, 0x73, 0x18, 0x03,
|
||||||
0x20, 0x03, 0x28, 0x05, 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x73, 0x22, 0xf9, 0x01, 0x0a, 0x0a, 0x44,
|
0x20, 0x03, 0x28, 0x05, 0x52, 0x04, 0x62, 0x6f, 0x6f, 0x73, 0x22, 0xf9, 0x01, 0x0a, 0x0a, 0x44,
|
||||||
0x42, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x47, 0x76, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x47, 0x75, 0x69,
|
0x42, 0x47, 0x75, 0x69, 0x6c, 0x64, 0x47, 0x76, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x67, 0x75, 0x69,
|
||||||
0x6c, 0x64, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x47, 0x75, 0x69, 0x6c,
|
0x6c, 0x64, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x67, 0x75, 0x69, 0x6c,
|
||||||
0x64, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20,
|
0x64, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x18, 0x02, 0x20,
|
||||||
0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66,
|
0x01, 0x28, 0x09, 0x52, 0x06, 0x6e, 0x6f, 0x74, 0x69, 0x63, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x66,
|
||||||
0x69, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x69, 0x72, 0x65, 0x12,
|
0x69, 0x72, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x04, 0x66, 0x69, 0x72, 0x65, 0x12,
|
||||||
|
Loading…
Reference in New Issue
Block a user