重名uid
This commit is contained in:
parent
14710e9893
commit
c864dd5432
@ -34,7 +34,7 @@ func (r *Robot) handleFriendMsg(msg *pb.UserMessage) {
|
||||
func (r *Robot) FriendList() {
|
||||
req := &pb.Friend_List_Req{}
|
||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_List}
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req)
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req)
|
||||
err := r.SendToClient(head, req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@ -55,7 +55,7 @@ func (r *Robot) FriendSearch(nickName string) {
|
||||
NickName: nickName,
|
||||
}
|
||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Search}
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req)
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req)
|
||||
err := r.SendToClient(head, req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@ -76,7 +76,7 @@ func (r *Robot) FriendApply(friendId string) {
|
||||
FriendId: friendId,
|
||||
}
|
||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Apply}
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req)
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req)
|
||||
err := r.SendToClient(head, req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@ -95,7 +95,7 @@ func (r *Robot) handleFriendApply(msg *pb.UserMessage) {
|
||||
func (r *Robot) FriendApplyList() {
|
||||
req := &pb.Friend_ApplyList_Req{}
|
||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_ApplyList}
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req)
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req)
|
||||
err := r.SendToClient(head, req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@ -116,7 +116,7 @@ func (r *Robot) FriendAgree(friendIds []string) {
|
||||
FriendIds: friendIds,
|
||||
}
|
||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Agree}
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req)
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req)
|
||||
err := r.SendToClient(head, req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@ -137,7 +137,7 @@ func (r *Robot) FriendRefuse(friendIds []string) {
|
||||
FriendIds: friendIds,
|
||||
}
|
||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Refuse}
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req)
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req)
|
||||
err := r.SendToClient(head, req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@ -156,7 +156,7 @@ func (r *Robot) handleFriendRefuse(msg *pb.UserMessage) {
|
||||
func (r *Robot) FriendBlacklist() {
|
||||
req := &pb.Friend_BlackList_Req{}
|
||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Blacklist}
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req)
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req)
|
||||
err := r.SendToClient(head, req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@ -175,7 +175,7 @@ func (r *Robot) handleFriendBlacklist(msg *pb.UserMessage) {
|
||||
func (r *Robot) FriendAddBlack(friendId string) {
|
||||
req := &pb.Friend_BlackAdd_Req{FriendId: friendId}
|
||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_AddBlack}
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req)
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req)
|
||||
err := r.SendToClient(head, req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
@ -196,7 +196,7 @@ func (r *Robot) FriendDelBlack(friendId string) {
|
||||
FriendId: friendId,
|
||||
}
|
||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_DelBlack}
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req)
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req)
|
||||
err := r.SendToClient(head, req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
@ -17,7 +17,7 @@ func (r *Robot) handlePackMsg(msg *pb.UserMessage) {
|
||||
func (r *Robot) QueryUserPack() {
|
||||
req := &pb.Pack_Getlist_Req{IType: 1}
|
||||
head := &pb.UserMessage{MainType: "pack", SubType: "queryuserpackreq"}
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req)
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req)
|
||||
err := r.SendToClient(head, req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
@ -45,7 +45,7 @@ func (r *Robot) CreateUser(NickName string) {
|
||||
SubType: user.User_SubType_Create,
|
||||
}
|
||||
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUId(), req)
|
||||
defer traceFunc(head.MainType, head.SubType, r.user.GetUid(), req)
|
||||
err := r.SendToClient(head, req)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
|
6
go.mod
6
go.mod
@ -21,9 +21,9 @@ require (
|
||||
github.com/smallnest/rpcx v1.7.4
|
||||
github.com/spf13/cobra v1.2.1
|
||||
github.com/spf13/pflag v1.0.5
|
||||
github.com/stretchr/testify v1.7.1
|
||||
github.com/tidwall/gjson v1.14.1
|
||||
github.com/ugorji/go/codec v1.2.7
|
||||
github.com/valyala/fastrand v1.1.0
|
||||
go.mongodb.org/mongo-driver v1.5.1
|
||||
go.uber.org/zap v1.21.0
|
||||
golang.org/x/net v0.0.0-20220407224826-aac1ed45d8e3
|
||||
@ -42,7 +42,6 @@ require (
|
||||
github.com/cenkalti/backoff v2.2.1+incompatible // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/cheekybits/genny v1.0.0 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dgryski/go-jump v0.0.0-20211018200510-ba001c3ffce0 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/edwingeng/doublejump v0.0.0-20210724020454-c82f1bcb3280 // indirect
|
||||
@ -97,7 +96,6 @@ require (
|
||||
github.com/onsi/ginkgo v1.16.5 // indirect
|
||||
github.com/philhofer/fwd v1.1.1 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/rpcxio/libkv v0.5.1-0.20210420120011-1fceaedca8a5 // indirect
|
||||
github.com/rs/cors v1.8.2 // indirect
|
||||
github.com/rubyist/circuitbreaker v2.2.1+incompatible // indirect
|
||||
@ -112,7 +110,6 @@ require (
|
||||
github.com/tjfoc/gmsm v1.4.1 // indirect
|
||||
github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fastrand v1.1.0 // indirect
|
||||
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
|
||||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||
github.com/xdg-go/pbkdf2 v1.0.0 // indirect
|
||||
@ -134,5 +131,4 @@ require (
|
||||
gopkg.in/ini.v1 v1.62.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
|
||||
)
|
||||
|
@ -31,7 +31,7 @@ func (this *ApiComp) Search(session comm.IUserSession, chk map[string]interface{
|
||||
user := this.module.model_friend.Frined_FindCond(req.NickName)
|
||||
if user != nil {
|
||||
friend = &pb.FriendBase{
|
||||
UserId: user.UId,
|
||||
UserId: user.Uid,
|
||||
NickName: user.Name,
|
||||
}
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
|
||||
code = pb.ErrorCode_SystemError
|
||||
return
|
||||
}
|
||||
event.TriggerEvent(comm.Event_UserLogin, user.UId)
|
||||
event.TriggerEvent(comm.Event_UserLogin, user.Uid)
|
||||
}
|
||||
}()
|
||||
|
||||
@ -57,7 +57,7 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
|
||||
}
|
||||
|
||||
//bind user
|
||||
err = session.Bind(user.UId, this.service.GetId())
|
||||
err = session.Bind(user.Uid, this.service.GetId())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_BindUser
|
||||
return
|
||||
@ -69,8 +69,8 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
|
||||
user.Createip = session.GetIP()
|
||||
|
||||
//缓存user session
|
||||
err = this.module.modelSession.Change(user.UId, map[string]interface{}{
|
||||
"uid": user.UId,
|
||||
err = this.module.modelSession.Change(user.Uid, map[string]interface{}{
|
||||
"uid": user.Uid,
|
||||
"sessionId": session.GetSessionId(),
|
||||
"gatewayServiceId": session.GetGatewayServiceId(),
|
||||
},
|
||||
@ -82,7 +82,7 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
|
||||
}
|
||||
|
||||
//缓存user
|
||||
err = this.module.modelUser.Add(user.UId, user, cache.WithDisabledMgoLog())
|
||||
err = this.module.modelUser.Add(user.Uid, user, cache.WithDisabledMgoLog())
|
||||
if err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
|
@ -51,7 +51,7 @@ func (this *ModelUser) User_FindById(id string) (*pb.DB_UserData, error) {
|
||||
func (this *ModelUser) User_Create(user *pb.DB_UserData) (err error) {
|
||||
_id := primitive.NewObjectID().Hex()
|
||||
user.Id = _id
|
||||
user.UId = fmt.Sprintf("%d_%s", user.Sid, _id)
|
||||
user.Uid = fmt.Sprintf("%d_%s", user.Sid, _id)
|
||||
user.Uuid = uuid.NewV4().String()
|
||||
user.Ctime = time.Now().Unix()
|
||||
_, err = this.DB.InsertOne(DB_UserTable, user)
|
||||
@ -62,7 +62,7 @@ func (this *ModelUser) User_Create(user *pb.DB_UserData) (err error) {
|
||||
func (this *ModelUser) User_Update(data *pb.DB_UserData) (err error) {
|
||||
err = this.DB.FindOneAndUpdate(
|
||||
DB_UserTable,
|
||||
bson.M{"uid": data.UId},
|
||||
bson.M{"uid": data.Uid},
|
||||
bson.M{"$set": bson.M{
|
||||
"name": data.Name,
|
||||
}},
|
||||
|
@ -38,7 +38,7 @@ func (this *Api_Comp) Register(c *engine.Context) {
|
||||
err := c.BindJSON(&req)
|
||||
if err == nil {
|
||||
err := this.module.modelUser.User_Create(&pb.DB_UserData{
|
||||
BinduId: req.Account,
|
||||
Binduid: req.Account,
|
||||
Sid: req.Sid,
|
||||
})
|
||||
if err != nil {
|
||||
|
@ -10,9 +10,9 @@ message Cache_UserData {
|
||||
|
||||
message DB_UserData {
|
||||
string id = 1; //@go_tags(`bson:"_id"`) ID
|
||||
string uId = 2; //@go_tags(`bson:"uId"`) 用户ID
|
||||
string uid = 2; //@go_tags(`bson:"uid"`) 用户ID
|
||||
string uuid = 3; //@go_tags(`bson:"uuid"`) 玩家唯一uuid
|
||||
string binduId = 4; //@go_tags(`bson:"binduId"`) 玩家账号
|
||||
string binduid = 4; //@go_tags(`bson:"binduid"`) 玩家账号
|
||||
string name = 5; //@go_tags(`bson:"name"`) 玩家名
|
||||
int32 sid = 6; //@go_tags(`bson:"sid"`) 区服id
|
||||
string createip = 7; //@go_tags(`bson:"createip"`) 创建账号时的ip
|
||||
|
@ -89,9 +89,9 @@ type DB_UserData struct {
|
||||
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
|
||||
Uid string `protobuf:"bytes,2,opt,name=uid,proto3" json:"uid" bson:"uid"` //用户ID
|
||||
Uuid string `protobuf:"bytes,3,opt,name=uuid,proto3" json:"uuid" bson:"uuid"` //玩家唯一uuid
|
||||
BinduId string `protobuf:"bytes,4,opt,name=binduId,proto3" json:"binduId" bson:"binduId"` //玩家账号
|
||||
Binduid string `protobuf:"bytes,4,opt,name=binduid,proto3" json:"binduid" bson:"binduid"` //玩家账号
|
||||
Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name" bson:"name"` //玩家名
|
||||
Sid int32 `protobuf:"varint,6,opt,name=sid,proto3" json:"sid" bson:"sid"` //区服id
|
||||
Createip string `protobuf:"bytes,7,opt,name=createip,proto3" json:"createip" bson:"createip"` //创建账号时的ip
|
||||
@ -141,9 +141,9 @@ func (x *DB_UserData) GetId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DB_UserData) GetUId() string {
|
||||
func (x *DB_UserData) GetUid() string {
|
||||
if x != nil {
|
||||
return x.UId
|
||||
return x.Uid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -155,9 +155,9 @@ func (x *DB_UserData) GetUuid() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (x *DB_UserData) GetBinduId() string {
|
||||
func (x *DB_UserData) GetBinduid() string {
|
||||
if x != nil {
|
||||
return x.BinduId
|
||||
return x.Binduid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
@ -231,11 +231,11 @@ var file_user_user_db_proto_rawDesc = []byte{
|
||||
0x52, 0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
|
||||
0x49, 0x64, 0x22, 0xaf, 0x02, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61,
|
||||
0x74, 0x61, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02,
|
||||
0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x03, 0x75, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01,
|
||||
0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x03, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x69, 0x6e, 0x64,
|
||||
0x75, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x69, 0x6e, 0x64, 0x75,
|
||||
0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
|
||||
0x75, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x62, 0x69, 0x6e, 0x64, 0x75,
|
||||
0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x06, 0x20,
|
||||
0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x69, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x72, 0x65, 0x61,
|
||||
0x74, 0x65, 0x69, 0x70, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x72, 0x65, 0x61,
|
||||
|
Loading…
Reference in New Issue
Block a user