Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into liwei
This commit is contained in:
commit
20ef5c5280
@ -32,7 +32,7 @@ func (r *Robot) handleFriendMsg(msg *pb.UserMessage) {
|
|||||||
func (r *Robot) FriendList() {
|
func (r *Robot) FriendList() {
|
||||||
req := &pb.FriendListReq{}
|
req := &pb.FriendListReq{}
|
||||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_List}
|
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_List}
|
||||||
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUid(), req)
|
||||||
err := r.SendToClient(head, req)
|
err := r.SendToClient(head, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -53,7 +53,7 @@ func (r *Robot) FriendSearch(nickName string) {
|
|||||||
NickName: nickName,
|
NickName: nickName,
|
||||||
}
|
}
|
||||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Search}
|
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Search}
|
||||||
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUid(), req)
|
||||||
err := r.SendToClient(head, req)
|
err := r.SendToClient(head, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -74,7 +74,7 @@ func (r *Robot) FriendApply(friendId string) {
|
|||||||
FriendId: friendId,
|
FriendId: friendId,
|
||||||
}
|
}
|
||||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Apply}
|
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Apply}
|
||||||
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUid(), req)
|
||||||
err := r.SendToClient(head, req)
|
err := r.SendToClient(head, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -93,7 +93,7 @@ func (r *Robot) handleFriendApply(msg *pb.UserMessage) {
|
|||||||
func (r *Robot) FriendApplyList() {
|
func (r *Robot) FriendApplyList() {
|
||||||
req := &pb.FriendApplyListReq{}
|
req := &pb.FriendApplyListReq{}
|
||||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_ApplyList}
|
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_ApplyList}
|
||||||
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUid(), req)
|
||||||
err := r.SendToClient(head, req)
|
err := r.SendToClient(head, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -114,7 +114,7 @@ func (r *Robot) FriendAgree(friendIds []string) {
|
|||||||
FriendIds: friendIds,
|
FriendIds: friendIds,
|
||||||
}
|
}
|
||||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Apply}
|
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Apply}
|
||||||
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUid(), req)
|
||||||
err := r.SendToClient(head, req)
|
err := r.SendToClient(head, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -135,7 +135,7 @@ func (r *Robot) FriendRefuse(friendIds []string) {
|
|||||||
FriendIds: friendIds,
|
FriendIds: friendIds,
|
||||||
}
|
}
|
||||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Refuse}
|
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Refuse}
|
||||||
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUid(), req)
|
||||||
err := r.SendToClient(head, req)
|
err := r.SendToClient(head, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -154,7 +154,7 @@ func (r *Robot) handleFriendRefuse(msg *pb.UserMessage) {
|
|||||||
func (r *Robot) FriendBlacklist() {
|
func (r *Robot) FriendBlacklist() {
|
||||||
req := &pb.FriendBlackListReq{}
|
req := &pb.FriendBlackListReq{}
|
||||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Blacklist}
|
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_Blacklist}
|
||||||
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUid(), req)
|
||||||
err := r.SendToClient(head, req)
|
err := r.SendToClient(head, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -173,7 +173,7 @@ func (r *Robot) handleFriendBlacklist(msg *pb.UserMessage) {
|
|||||||
func (r *Robot) FriendAddBlack() {
|
func (r *Robot) FriendAddBlack() {
|
||||||
req := &pb.FriendBlackAddReq{}
|
req := &pb.FriendBlackAddReq{}
|
||||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_AddBlack}
|
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_AddBlack}
|
||||||
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUid(), req)
|
||||||
err := r.SendToClient(head, req)
|
err := r.SendToClient(head, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
@ -194,7 +194,7 @@ func (r *Robot) FriendDelBlack(friendId string) {
|
|||||||
FriendId: friendId,
|
FriendId: friendId,
|
||||||
}
|
}
|
||||||
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_DelBlack}
|
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_DelBlack}
|
||||||
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUid(), req)
|
||||||
err := r.SendToClient(head, req)
|
err := r.SendToClient(head, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -17,7 +17,7 @@ func (r *Robot) handlePackMsg(msg *pb.UserMessage) {
|
|||||||
func (r *Robot) QueryUserPack() {
|
func (r *Robot) QueryUserPack() {
|
||||||
req := &pb.GetlistReq{IType: 1}
|
req := &pb.GetlistReq{IType: 1}
|
||||||
head := &pb.UserMessage{MainType: "pack", SubType: "queryuserpackreq"}
|
head := &pb.UserMessage{MainType: "pack", SubType: "queryuserpackreq"}
|
||||||
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUid(), req)
|
||||||
err := r.SendToClient(head, req)
|
err := r.SendToClient(head, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -45,7 +45,7 @@ func (r *Robot) CreateUser(NickName string) {
|
|||||||
SubType: user.User_SubType_Create,
|
SubType: user.User_SubType_Create,
|
||||||
}
|
}
|
||||||
|
|
||||||
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUserId(), req)
|
defer traceFunc(head.MainType, head.SubType, r.user.UserData.GetUid(), req)
|
||||||
err := r.SendToClient(head, req)
|
err := r.SendToClient(head, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
@ -54,8 +54,8 @@ func (this *FriendComp) Search(ctx context.Context, session comm.IUserSession, r
|
|||||||
user := db.Defsys.Frined_FindCond(req.NickName)
|
user := db.Defsys.Frined_FindCond(req.NickName)
|
||||||
if user != nil {
|
if user != nil {
|
||||||
friend = &pb.FriendBase{
|
friend = &pb.FriendBase{
|
||||||
UserId: user.UserId,
|
UserId: user.Uid,
|
||||||
NickName: user.NiceName,
|
NickName: user.Name,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
|
@ -40,7 +40,7 @@ func (this *ModuleBase) SendMsgToUser(mainType, subType string, msg proto.Messag
|
|||||||
SubType: subType,
|
SubType: subType,
|
||||||
Data: data,
|
Data: data,
|
||||||
}, reply); err != nil {
|
}, reply); err != nil {
|
||||||
log.Errorf("SendMsgToUser%d:%s [%s.%s] err:%v", user.UserData.UserId, user.SessionId, mainType, subType, err)
|
log.Errorf("SendMsgToUser%d:%s [%s.%s] err:%v", user.UserData.Uid, user.SessionId, mainType, subType, err)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -38,8 +38,8 @@ func decodeUserData(base64Str string) *pb.DB_UserData {
|
|||||||
}
|
}
|
||||||
account := jsonRet.Get("account").String()
|
account := jsonRet.Get("account").String()
|
||||||
return &pb.DB_UserData{
|
return &pb.DB_UserData{
|
||||||
ServerId: int32(serverId),
|
Sid: int32(serverId),
|
||||||
Account: account,
|
Binduid: account,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
event.TriggerEvent(comm.Event_UserLogin, db_user.UserId)
|
event.TriggerEvent(comm.Event_UserLogin, db_user.Uid)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if !utils.ValidSecretKey(req.Sec) {
|
if !utils.ValidSecretKey(req.Sec) {
|
||||||
@ -81,9 +81,9 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req
|
|||||||
log.Errorf("User_CreateUser err %v", err)
|
log.Errorf("User_CreateUser err %v", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
session.Bind(user.UserId, this.S.GetId())
|
session.Bind(user.Uid, this.S.GetId())
|
||||||
} else {
|
} else {
|
||||||
session.Bind(db_user.UserId, this.S.GetId())
|
session.Bind(db_user.Uid, this.S.GetId())
|
||||||
}
|
}
|
||||||
|
|
||||||
cache_user := &pb.Cache_UserData{
|
cache_user := &pb.Cache_UserData{
|
||||||
|
@ -42,7 +42,7 @@ func (this *UserComp) Create(ctx context.Context, session comm.IUserSession, req
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
user.UserData.NiceName = req.NickName
|
user.UserData.Name = req.NickName
|
||||||
err = cache.Defsys.Update(user)
|
err = cache.Defsys.Update(user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("cache update err")
|
log.Errorf("cache update err")
|
||||||
|
@ -38,7 +38,7 @@ func (this *Api_Comp) Register(c *engine.Context) {
|
|||||||
err := c.BindJSON(&req)
|
err := c.BindJSON(&req)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err := db.Defsys.User_Create(&pb.DB_UserData{
|
err := db.Defsys.User_Create(&pb.DB_UserData{
|
||||||
Account: req.Account,
|
Binduid: req.Account,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("create user err: %v", err)
|
log.Errorf("create user err: %v", err)
|
||||||
|
1
pb.bat
1
pb.bat
@ -8,6 +8,7 @@ set SRC=%PROJECT_ROOT%\pb\proto
|
|||||||
set TAR=%PROJECT_ROOT%\pb
|
set TAR=%PROJECT_ROOT%\pb
|
||||||
|
|
||||||
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import %SRC%\*.proto
|
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import %SRC%\*.proto
|
||||||
|
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import %SRC%\user\*.proto
|
||||||
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import %SRC%\friend\*.proto
|
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import %SRC%\friend\*.proto
|
||||||
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import %SRC%\pack\*.proto
|
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import %SRC%\pack\*.proto
|
||||||
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import %SRC%\mail\*.proto
|
protoc --proto_path=%SRC% --go_out=%TAR% --go_opt=paths=import %SRC%\mail\*.proto
|
||||||
|
158
pb/proto/google/protobuf/any.proto
Normal file
158
pb/proto/google/protobuf/any.proto
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
// Protocol Buffers - Google's data interchange format
|
||||||
|
// Copyright 2008 Google Inc. All rights reserved.
|
||||||
|
// https://developers.google.com/protocol-buffers/
|
||||||
|
//
|
||||||
|
// Redistribution and use in source and binary forms, with or without
|
||||||
|
// modification, are permitted provided that the following conditions are
|
||||||
|
// met:
|
||||||
|
//
|
||||||
|
// * Redistributions of source code must retain the above copyright
|
||||||
|
// notice, this list of conditions and the following disclaimer.
|
||||||
|
// * Redistributions in binary form must reproduce the above
|
||||||
|
// copyright notice, this list of conditions and the following disclaimer
|
||||||
|
// in the documentation and/or other materials provided with the
|
||||||
|
// distribution.
|
||||||
|
// * Neither the name of Google Inc. nor the names of its
|
||||||
|
// contributors may be used to endorse or promote products derived from
|
||||||
|
// this software without specific prior written permission.
|
||||||
|
//
|
||||||
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||||
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||||
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||||
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||||
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
||||||
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
||||||
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
|
syntax = "proto3";
|
||||||
|
|
||||||
|
package google.protobuf;
|
||||||
|
|
||||||
|
option csharp_namespace = "Google.Protobuf.WellKnownTypes";
|
||||||
|
option go_package = "google.golang.org/protobuf/types/known/anypb";
|
||||||
|
option java_package = "com.google.protobuf";
|
||||||
|
option java_outer_classname = "AnyProto";
|
||||||
|
option java_multiple_files = true;
|
||||||
|
option objc_class_prefix = "GPB";
|
||||||
|
|
||||||
|
// `Any` contains an arbitrary serialized protocol buffer message along with a
|
||||||
|
// URL that describes the type of the serialized message.
|
||||||
|
//
|
||||||
|
// Protobuf library provides support to pack/unpack Any values in the form
|
||||||
|
// of utility functions or additional generated methods of the Any type.
|
||||||
|
//
|
||||||
|
// Example 1: Pack and unpack a message in C++.
|
||||||
|
//
|
||||||
|
// Foo foo = ...;
|
||||||
|
// Any any;
|
||||||
|
// any.PackFrom(foo);
|
||||||
|
// ...
|
||||||
|
// if (any.UnpackTo(&foo)) {
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Example 2: Pack and unpack a message in Java.
|
||||||
|
//
|
||||||
|
// Foo foo = ...;
|
||||||
|
// Any any = Any.pack(foo);
|
||||||
|
// ...
|
||||||
|
// if (any.is(Foo.class)) {
|
||||||
|
// foo = any.unpack(Foo.class);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// Example 3: Pack and unpack a message in Python.
|
||||||
|
//
|
||||||
|
// foo = Foo(...)
|
||||||
|
// any = Any()
|
||||||
|
// any.Pack(foo)
|
||||||
|
// ...
|
||||||
|
// if any.Is(Foo.DESCRIPTOR):
|
||||||
|
// any.Unpack(foo)
|
||||||
|
// ...
|
||||||
|
//
|
||||||
|
// Example 4: Pack and unpack a message in Go
|
||||||
|
//
|
||||||
|
// foo := &pb.Foo{...}
|
||||||
|
// any, err := anypb.New(foo)
|
||||||
|
// if err != nil {
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
// ...
|
||||||
|
// foo := &pb.Foo{}
|
||||||
|
// if err := any.UnmarshalTo(foo); err != nil {
|
||||||
|
// ...
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// The pack methods provided by protobuf library will by default use
|
||||||
|
// 'type.googleapis.com/full.type.name' as the type URL and the unpack
|
||||||
|
// methods only use the fully qualified type name after the last '/'
|
||||||
|
// in the type URL, for example "foo.bar.com/x/y.z" will yield type
|
||||||
|
// name "y.z".
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// JSON
|
||||||
|
//
|
||||||
|
// The JSON representation of an `Any` value uses the regular
|
||||||
|
// representation of the deserialized, embedded message, with an
|
||||||
|
// additional field `@type` which contains the type URL. Example:
|
||||||
|
//
|
||||||
|
// package google.profile;
|
||||||
|
// message Person {
|
||||||
|
// string first_name = 1;
|
||||||
|
// string last_name = 2;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// {
|
||||||
|
// "@type": "type.googleapis.com/google.profile.Person",
|
||||||
|
// "firstName": <string>,
|
||||||
|
// "lastName": <string>
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// If the embedded message type is well-known and has a custom JSON
|
||||||
|
// representation, that representation will be embedded adding a field
|
||||||
|
// `value` which holds the custom JSON in addition to the `@type`
|
||||||
|
// field. Example (for message [google.protobuf.Duration][]):
|
||||||
|
//
|
||||||
|
// {
|
||||||
|
// "@type": "type.googleapis.com/google.protobuf.Duration",
|
||||||
|
// "value": "1.212s"
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
message Any {
|
||||||
|
// A URL/resource name that uniquely identifies the type of the serialized
|
||||||
|
// protocol buffer message. This string must contain at least
|
||||||
|
// one "/" character. The last segment of the URL's path must represent
|
||||||
|
// the fully qualified name of the type (as in
|
||||||
|
// `path/google.protobuf.Duration`). The name should be in a canonical form
|
||||||
|
// (e.g., leading "." is not accepted).
|
||||||
|
//
|
||||||
|
// In practice, teams usually precompile into the binary all types that they
|
||||||
|
// expect it to use in the context of Any. However, for URLs which use the
|
||||||
|
// scheme `http`, `https`, or no scheme, one can optionally set up a type
|
||||||
|
// server that maps type URLs to message definitions as follows:
|
||||||
|
//
|
||||||
|
// * If no scheme is provided, `https` is assumed.
|
||||||
|
// * An HTTP GET on the URL must yield a [google.protobuf.Type][]
|
||||||
|
// value in binary format, or produce an error.
|
||||||
|
// * Applications are allowed to cache lookup results based on the
|
||||||
|
// URL, or have them precompiled into a binary to avoid any
|
||||||
|
// lookup. Therefore, binary compatibility needs to be preserved
|
||||||
|
// on changes to types. (Use versioned type names to manage
|
||||||
|
// breaking changes.)
|
||||||
|
//
|
||||||
|
// Note: this functionality is not currently available in the official
|
||||||
|
// protobuf release, and it is not used for type URLs beginning with
|
||||||
|
// type.googleapis.com.
|
||||||
|
//
|
||||||
|
// Schemes other than `http`, `https` (or the empty scheme) might be
|
||||||
|
// used with implementation specific semantics.
|
||||||
|
//
|
||||||
|
string type_url = 1;
|
||||||
|
|
||||||
|
// Must be a valid serialized protocol buffer of the above specified type.
|
||||||
|
bytes value = 2;
|
||||||
|
}
|
@ -8,10 +8,15 @@ message Cache_UserData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
message DB_UserData {
|
message DB_UserData {
|
||||||
string UserId = 1; // @go_tags(`bson:"_id"`) ID
|
string uid = 1;
|
||||||
string Account = 2;
|
string uuid = 2; //玩家唯一uuid
|
||||||
string NiceName = 3;
|
string binduid = 3; //玩家账号
|
||||||
int32 ServerId = 4;
|
string name = 4; //玩家名
|
||||||
int32 FriendPoint = 5;//友情点
|
int32 sid = 5; //区服id
|
||||||
int32 avatar = 6;//头像
|
string createip = 6; //创建账号时的ip
|
||||||
|
string lastloginip = 7; //最后一次登录时的ip
|
||||||
|
int64 ctime = 8; //玩家创号时间戳
|
||||||
|
int64 logintime = 9; //最后一次登录时间
|
||||||
|
int32 FriendPoint = 10; //友情点
|
||||||
|
int32 avatar = 11; //头像
|
||||||
}
|
}
|
101
pb/user_db.pb.go
101
pb/user_db.pb.go
@ -88,12 +88,17 @@ type DB_UserData struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` // ID
|
Uid string `protobuf:"bytes,1,opt,name=uid,proto3" json:"uid,omitempty"`
|
||||||
Account string `protobuf:"bytes,2,opt,name=Account,proto3" json:"Account,omitempty"`
|
Uuid string `protobuf:"bytes,2,opt,name=uuid,proto3" json:"uuid,omitempty"` //玩家唯一uuid
|
||||||
NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"`
|
Binduid string `protobuf:"bytes,3,opt,name=binduid,proto3" json:"binduid,omitempty"` //玩家账号
|
||||||
ServerId int32 `protobuf:"varint,4,opt,name=ServerId,proto3" json:"ServerId,omitempty"`
|
Name string `protobuf:"bytes,4,opt,name=name,proto3" json:"name,omitempty"` //玩家名
|
||||||
FriendPoint int32 `protobuf:"varint,5,opt,name=FriendPoint,proto3" json:"FriendPoint,omitempty"` //友情点
|
Sid int32 `protobuf:"varint,5,opt,name=sid,proto3" json:"sid,omitempty"` //区服id
|
||||||
Avatar int32 `protobuf:"varint,6,opt,name=avatar,proto3" json:"avatar,omitempty"` //头像
|
Createip string `protobuf:"bytes,6,opt,name=createip,proto3" json:"createip,omitempty"` //创建账号时的ip
|
||||||
|
Lastloginip string `protobuf:"bytes,7,opt,name=lastloginip,proto3" json:"lastloginip,omitempty"` //最后一次登录时的ip
|
||||||
|
Ctime int64 `protobuf:"varint,8,opt,name=ctime,proto3" json:"ctime,omitempty"` //玩家创号时间戳
|
||||||
|
Logintime int64 `protobuf:"varint,9,opt,name=logintime,proto3" json:"logintime,omitempty"` //最后一次登录时间
|
||||||
|
FriendPoint int32 `protobuf:"varint,10,opt,name=FriendPoint,proto3" json:"FriendPoint,omitempty"` //友情点
|
||||||
|
Avatar int32 `protobuf:"varint,11,opt,name=avatar,proto3" json:"avatar,omitempty"` //头像
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DB_UserData) Reset() {
|
func (x *DB_UserData) Reset() {
|
||||||
@ -128,30 +133,65 @@ func (*DB_UserData) Descriptor() ([]byte, []int) {
|
|||||||
return file_user_user_db_proto_rawDescGZIP(), []int{1}
|
return file_user_user_db_proto_rawDescGZIP(), []int{1}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DB_UserData) GetUserId() string {
|
func (x *DB_UserData) GetUid() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.UserId
|
return x.Uid
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DB_UserData) GetAccount() string {
|
func (x *DB_UserData) GetUuid() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.Account
|
return x.Uuid
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DB_UserData) GetNiceName() string {
|
func (x *DB_UserData) GetBinduid() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.NiceName
|
return x.Binduid
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *DB_UserData) GetServerId() int32 {
|
func (x *DB_UserData) GetName() string {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
return x.ServerId
|
return x.Name
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DB_UserData) GetSid() int32 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Sid
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DB_UserData) GetCreateip() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Createip
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DB_UserData) GetLastloginip() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Lastloginip
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DB_UserData) GetCtime() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Ctime
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (x *DB_UserData) GetLogintime() int64 {
|
||||||
|
if x != nil {
|
||||||
|
return x.Logintime
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
@ -182,19 +222,26 @@ var file_user_user_db_proto_rawDesc = []byte{
|
|||||||
0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49,
|
0x10, 0x47, 0x61, 0x74, 0x65, 0x77, 0x61, 0x79, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x49,
|
||||||
0x64, 0x12, 0x28, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20,
|
0x64, 0x12, 0x28, 0x0a, 0x08, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x18, 0x04, 0x20,
|
||||||
0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74,
|
0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74,
|
||||||
0x61, 0x52, 0x08, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x22, 0xb1, 0x01, 0x0a, 0x0b,
|
0x61, 0x52, 0x08, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x22, 0x9f, 0x02, 0x0a, 0x0b,
|
||||||
0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55,
|
0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x10, 0x0a, 0x03, 0x75,
|
||||||
0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65,
|
0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a,
|
||||||
0x72, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02,
|
0x04, 0x75, 0x75, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x75, 0x75, 0x69,
|
||||||
0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a,
|
0x64, 0x12, 0x18, 0x0a, 0x07, 0x62, 0x69, 0x6e, 0x64, 0x75, 0x69, 0x64, 0x18, 0x03, 0x20, 0x01,
|
||||||
0x08, 0x4e, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52,
|
0x28, 0x09, 0x52, 0x07, 0x62, 0x69, 0x6e, 0x64, 0x75, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x6e,
|
||||||
0x08, 0x4e, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x65, 0x72,
|
0x61, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12,
|
||||||
0x76, 0x65, 0x72, 0x49, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x53, 0x65, 0x72,
|
0x10, 0x0a, 0x03, 0x73, 0x69, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x73, 0x69,
|
||||||
0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x50,
|
0x64, 0x12, 0x1a, 0x0a, 0x08, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x69, 0x70, 0x18, 0x06, 0x20,
|
||||||
0x6f, 0x69, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x46, 0x72, 0x69, 0x65,
|
0x01, 0x28, 0x09, 0x52, 0x08, 0x63, 0x72, 0x65, 0x61, 0x74, 0x65, 0x69, 0x70, 0x12, 0x20, 0x0a,
|
||||||
0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61,
|
0x0b, 0x6c, 0x61, 0x73, 0x74, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x69, 0x70, 0x18, 0x07, 0x20, 0x01,
|
||||||
0x72, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x42,
|
0x28, 0x09, 0x52, 0x0b, 0x6c, 0x61, 0x73, 0x74, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x69, 0x70, 0x12,
|
||||||
0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x08, 0x20, 0x01, 0x28, 0x03, 0x52, 0x05,
|
||||||
|
0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x1c, 0x0a, 0x09, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x74, 0x69,
|
||||||
|
0x6d, 0x65, 0x18, 0x09, 0x20, 0x01, 0x28, 0x03, 0x52, 0x09, 0x6c, 0x6f, 0x67, 0x69, 0x6e, 0x74,
|
||||||
|
0x69, 0x6d, 0x65, 0x12, 0x20, 0x0a, 0x0b, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69,
|
||||||
|
0x6e, 0x74, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64,
|
||||||
|
0x50, 0x6f, 0x69, 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18,
|
||||||
|
0x0b, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x42, 0x06, 0x5a,
|
||||||
|
0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
2
sys/cache/user.go
vendored
2
sys/cache/user.go
vendored
@ -20,7 +20,7 @@ type IUser interface {
|
|||||||
func (this *Cache) Update(data *pb.Cache_UserData) (err error) {
|
func (this *Cache) Update(data *pb.Cache_UserData) (err error) {
|
||||||
err = db.Defsys.User_Update(data.UserData)
|
err = db.Defsys.User_Update(data.UserData)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
err = this.redis.Set(fmt.Sprintf(Redis_UserCache, data.UserData.UserId), data, -1)
|
err = this.redis.Set(fmt.Sprintf(Redis_UserCache, data.UserData.Uid), data, -1)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
4
sys/cache/user_test.go
vendored
4
sys/cache/user_test.go
vendored
@ -15,8 +15,8 @@ func TestUpdateUser(t *testing.T) {
|
|||||||
SessionId: "1",
|
SessionId: "1",
|
||||||
GatewayServiceId: "work",
|
GatewayServiceId: "work",
|
||||||
UserData: &pb.DB_UserData{
|
UserData: &pb.DB_UserData{
|
||||||
UserId: primitive.NewObjectID().Hex(),
|
Uid: primitive.NewObjectID().Hex(),
|
||||||
Account: "aaa",
|
Name: "aaa",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
err := cache.Defsys.Update(user)
|
err := cache.Defsys.Update(user)
|
||||||
|
@ -24,8 +24,8 @@ type IUser interface {
|
|||||||
//
|
//
|
||||||
func (this *DB) User_FindByAccount(user *pb.DB_UserData) (*pb.DB_UserData, error) {
|
func (this *DB) User_FindByAccount(user *pb.DB_UserData) (*pb.DB_UserData, error) {
|
||||||
filter := bson.M{
|
filter := bson.M{
|
||||||
"serverid": user.ServerId,
|
"sid": user.Sid,
|
||||||
"account": user.Account,
|
"binduid": user.Binduid,
|
||||||
}
|
}
|
||||||
sr := this.mgo.FindOne(DB_UserTable, filter)
|
sr := this.mgo.FindOne(DB_UserTable, filter)
|
||||||
var nd *pb.DB_UserData
|
var nd *pb.DB_UserData
|
||||||
@ -44,7 +44,7 @@ func (this *DB) User_FindById(id string) (*pb.DB_UserData, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this *DB) User_Create(user *pb.DB_UserData) (err error) {
|
func (this *DB) User_Create(user *pb.DB_UserData) (err error) {
|
||||||
user.UserId = primitive.NewObjectID().Hex()
|
user.Uid = primitive.NewObjectID().Hex()
|
||||||
_, err = this.mgo.InsertOne(DB_UserTable, user)
|
_, err = this.mgo.InsertOne(DB_UserTable, user)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -53,9 +53,9 @@ func (this *DB) User_Create(user *pb.DB_UserData) (err error) {
|
|||||||
func (this *DB) User_Update(data *pb.DB_UserData) (err error) {
|
func (this *DB) User_Update(data *pb.DB_UserData) (err error) {
|
||||||
err = this.mgo.FindOneAndUpdate(
|
err = this.mgo.FindOneAndUpdate(
|
||||||
DB_UserTable,
|
DB_UserTable,
|
||||||
bson.M{"userid": data.UserId},
|
bson.M{"uid": data.Uid},
|
||||||
bson.M{"$set": bson.M{
|
bson.M{"$set": bson.M{
|
||||||
"nicename": data.NiceName,
|
"name": data.Name,
|
||||||
}},
|
}},
|
||||||
options.FindOneAndUpdate().SetUpsert(true),
|
options.FindOneAndUpdate().SetUpsert(true),
|
||||||
).Err()
|
).Err()
|
||||||
|
@ -11,9 +11,9 @@ import (
|
|||||||
|
|
||||||
func TestCreate(t *testing.T) {
|
func TestCreate(t *testing.T) {
|
||||||
user := &pb.DB_UserData{
|
user := &pb.DB_UserData{
|
||||||
Account: "legu3",
|
Binduid: "legu3",
|
||||||
NiceName: "乐谷3",
|
Name: "乐谷3",
|
||||||
ServerId: 1,
|
Sid: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := db.User_Create(user)
|
err := db.User_Create(user)
|
||||||
@ -23,18 +23,18 @@ func TestCreate(t *testing.T) {
|
|||||||
func TestFindOne(t *testing.T) {
|
func TestFindOne(t *testing.T) {
|
||||||
user, err := db.User_FindById("629eb3f4132dc4bb26139659")
|
user, err := db.User_FindById("629eb3f4132dc4bb26139659")
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
assert.Equal(t, "legu3", user.Account)
|
assert.Equal(t, "legu3", user.Binduid)
|
||||||
|
|
||||||
// user.ServerId = 2
|
// user.ServerId = 2
|
||||||
user2, err := db.User_FindByAccount(user)
|
user2, err := db.User_FindByAccount(user)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
assert.Equal(t, "legu3", user2.Account)
|
assert.Equal(t, "legu3", user2.Binduid)
|
||||||
assert.Equal(t, int32(1), user2.ServerId)
|
assert.Equal(t, int32(1), user2.Sid)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestUpdate(t *testing.T) {
|
func TestUpdate(t *testing.T) {
|
||||||
user := &pb.DB_UserData{
|
user := &pb.DB_UserData{
|
||||||
UserId: primitive.NewObjectID().Hex(),
|
Uuid: primitive.NewObjectID().Hex(),
|
||||||
}
|
}
|
||||||
err := db.User_Update(user)
|
err := db.User_Update(user)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
Loading…
Reference in New Issue
Block a user