From e122abaa4be391ef058583f3e669e5fc7015809b Mon Sep 17 00:00:00 2001 From: zhaocy Date: Tue, 7 Jun 2022 10:03:04 +0800 Subject: [PATCH 1/7] update --- modules/gateway/client_test.go | 59 ----------------------- modules/user/login_comp.go | 29 ++++++++++-- pb/errorcode.pb.go | 14 ++++-- pb/proto/errorcode.proto | 2 + pb/proto/user_msg.proto | 7 +-- pb/user_msg.pb.go | 85 +++++++++++++++------------------- utils/md5.go | 17 +++++++ 7 files changed, 97 insertions(+), 116 deletions(-) delete mode 100644 modules/gateway/client_test.go create mode 100644 utils/md5.go diff --git a/modules/gateway/client_test.go b/modules/gateway/client_test.go deleted file mode 100644 index 921e3590b..000000000 --- a/modules/gateway/client_test.go +++ /dev/null @@ -1,59 +0,0 @@ -package gateway_test - -import ( - "fmt" - "go_dreamfactory/pb" - "os" - "os/signal" - "syscall" - "testing" - - "github.com/gorilla/websocket" - "google.golang.org/protobuf/proto" -) - -func Test_WebSocket(t *testing.T) { - url := "ws://localhost:7891/gateway" //服务器地址 - ws, _, err := websocket.DefaultDialer.Dial(url, nil) - if err != nil { - fmt.Printf("err:%v", err) - return - } - - go func() { - var msg *pb.UserMessage = &pb.UserMessage{} - for { - _, data, err := ws.ReadMessage() - if err != nil { - fmt.Printf("err:%v\n", err) - } - if err = proto.Unmarshal(data, msg); err != nil { - fmt.Printf("err:%v\n", err) - } else { - fmt.Printf("ReadMessage msg:%v\n", msg) - } - } - }() - - loginreq := &pb.UserLoginReq{ - Name: "aaa", - } - logindata, _ := proto.Marshal(loginreq) - message := &pb.UserMessage{ - MainType: "login", - SubType: "login", - Data: logindata, - } - data, _ := proto.Marshal(message) - err = ws.WriteMessage(websocket.BinaryMessage, data) - if err != nil { - fmt.Printf("err:%v\n", err) - } - - sigterm := make(chan os.Signal, 1) - signal.Notify(sigterm, syscall.SIGINT, syscall.SIGTERM) - select { - case <-sigterm: - fmt.Printf("terminating: via signal\n") - } -} diff --git a/modules/user/login_comp.go b/modules/user/login_comp.go index 7cad5c595..247c3c62a 100644 --- a/modules/user/login_comp.go +++ b/modules/user/login_comp.go @@ -2,11 +2,14 @@ package user import ( "context" + "fmt" "go_dreamfactory/comm" "go_dreamfactory/modules" "go_dreamfactory/pb" "go_dreamfactory/sys/cache" "go_dreamfactory/sys/db" + "go_dreamfactory/utils" + "strings" "github.com/liwei1dao/lego/sys/log" "go.mongodb.org/mongo-driver/mongo" @@ -20,15 +23,33 @@ type LoginComp struct { func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req *pb.UserLoginReq) error { log.Debugf("User - Login: session:%v rsp:%v", session.ToString(), req) - db_user, err := db.Defsys.User_FindUserByAccount(req.Name) + var code pb.ErrorCode = pb.ErrorCode_Success + rsp := &pb.UserLoginResp{} + secStr := req.Sec + + if !strings.HasPrefix(secStr, "CE:") || len(secStr) < 35 { + session.SendMsg("user", "login", pb.ErrorCode_SecKey, rsp) + return nil + } + + clientMd5Key := strings.TrimPrefix(secStr, "CE:") + rawmsg := secStr[35:] + serverMd5Key := utils.MD5Str(rawmsg) + s := fmt.Sprintf("%x", serverMd5Key) + if !strings.EqualFold(strings.ToLower(s), strings.ToLower(clientMd5Key)) { + session.SendMsg("user", "login", pb.ErrorCode_SecKeyInvalid, rsp) + return nil + } + account := "" + db_user, err := db.Defsys.User_FindUserByAccount(account) if err != nil { if err != mongo.ErrNoDocuments { return err } } - if db_user.UserId == 0 { - db_user.Account = req.Name + if db_user.UserId == "" { + db_user.Account = account err = db.Defsys.User_CreateUser(db_user) if err != nil { return err @@ -47,7 +68,7 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req return err } - session.SendMsg("login", "login", pb.ErrorCode_Success, &pb.UserLoginResp{ + session.SendMsg("user", "login", code, &pb.UserLoginResp{ Data: &pb.Cache_UserData{ UserData: &pb.DB_UserData{ UserId: db_user.UserId, diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index cd54102a5..85cc5aebd 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -33,6 +33,8 @@ const ( ErrorCode_InsufficientPermissions ErrorCode = 16 //权限不足 ErrorCode_NoLogin ErrorCode = 17 //未登录 ErrorCode_UserSessionNobeing ErrorCode = 18 //用户不存在 + ErrorCode_SecKey ErrorCode = 19 //秘钥格式错误 + ErrorCode_SecKeyInvalid ErrorCode = 20 //秘钥无效 ) // Enum value maps for ErrorCode. @@ -48,6 +50,8 @@ var ( 16: "InsufficientPermissions", 17: "NoLogin", 18: "UserSessionNobeing", + 19: "SecKey", + 20: "SecKeyInvalid", } ErrorCode_value = map[string]int32{ "Success": 0, @@ -60,6 +64,8 @@ var ( "InsufficientPermissions": 16, "NoLogin": 17, "UserSessionNobeing": 18, + "SecKey": 19, + "SecKeyInvalid": 20, } ) @@ -94,7 +100,7 @@ var File_errorcode_proto protoreflect.FileDescriptor var file_errorcode_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2a, 0xd9, 0x01, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0xf8, 0x01, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12, 0x19, 0x0a, 0x15, 0x52, 0x70, 0x63, 0x46, 0x75, 0x6e, 0x63, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, @@ -107,8 +113,10 @@ var file_errorcode_proto_rawDesc = []byte{ 0x6e, 0x73, 0x75, 0x66, 0x66, 0x69, 0x63, 0x69, 0x65, 0x6e, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x10, 0x10, 0x12, 0x0b, 0x0a, 0x07, 0x4e, 0x6f, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x10, 0x11, 0x12, 0x16, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, - 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x10, 0x12, 0x42, 0x06, 0x5a, - 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x10, 0x12, 0x12, 0x0a, 0x0a, + 0x06, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x10, 0x13, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x65, 0x63, + 0x4b, 0x65, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x14, 0x42, 0x06, 0x5a, 0x04, + 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/proto/errorcode.proto b/pb/proto/errorcode.proto index c2d283c43..9c3e94476 100644 --- a/pb/proto/errorcode.proto +++ b/pb/proto/errorcode.proto @@ -13,4 +13,6 @@ enum ErrorCode { InsufficientPermissions = 16; //权限不足 NoLogin = 17; //未登录 UserSessionNobeing = 18; //用户不存在 + SecKey = 19; //秘钥格式错误 + SecKeyInvalid = 20; //秘钥无效 } \ No newline at end of file diff --git a/pb/proto/user_msg.proto b/pb/proto/user_msg.proto index 5e21e3a72..061cbd035 100644 --- a/pb/proto/user_msg.proto +++ b/pb/proto/user_msg.proto @@ -3,13 +3,13 @@ option go_package = ".;pb"; import "errorcode.proto"; import "user_db.proto"; +//用户登录 message UserLoginReq { - string Name = 1; + string sec= 1;//密文 } message UserLoginResp { - ErrorCode Code = 1; - Cache_UserData data = 2; + Cache_UserData data = 1; } @@ -25,6 +25,7 @@ message UserLoadRsp { Cache_UserData data = 1; } +//创角 message UserCreateReq{ string NickName = 1;//昵称 int32 gender = 2; //性别 diff --git a/pb/user_msg.pb.go b/pb/user_msg.pb.go index d2e7e851e..47f8d000e 100644 --- a/pb/user_msg.pb.go +++ b/pb/user_msg.pb.go @@ -20,12 +20,13 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) +//用户登录 type UserLoginReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty"` + Sec string `protobuf:"bytes,1,opt,name=sec,proto3" json:"sec,omitempty"` //密文 } func (x *UserLoginReq) Reset() { @@ -60,9 +61,9 @@ func (*UserLoginReq) Descriptor() ([]byte, []int) { return file_user_msg_proto_rawDescGZIP(), []int{0} } -func (x *UserLoginReq) GetName() string { +func (x *UserLoginReq) GetSec() string { if x != nil { - return x.Name + return x.Sec } return "" } @@ -72,8 +73,7 @@ type UserLoginResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code,omitempty"` - Data *Cache_UserData `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` + Data *Cache_UserData `protobuf:"bytes,1,opt,name=data,proto3" json:"data,omitempty"` } func (x *UserLoginResp) Reset() { @@ -108,13 +108,6 @@ func (*UserLoginResp) Descriptor() ([]byte, []int) { return file_user_msg_proto_rawDescGZIP(), []int{1} } -func (x *UserLoginResp) GetCode() ErrorCode { - if x != nil { - return x.Code - } - return ErrorCode_Success -} - func (x *UserLoginResp) GetData() *Cache_UserData { if x != nil { return x.Data @@ -263,6 +256,7 @@ func (x *UserLoadRsp) GetData() *Cache_UserData { return nil } +//创角 type UserCreateReq struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -362,30 +356,28 @@ var file_user_msg_proto_rawDesc = []byte{ 0x0a, 0x0e, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x1a, 0x0d, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x22, 0x22, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, - 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, - 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x54, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, - 0x6e, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x52, - 0x04, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x02, 0x20, - 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72, - 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0f, 0x55, 0x73, - 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, - 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x31, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, - 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, - 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, - 0x43, 0x6f, 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x32, 0x0a, 0x0b, 0x55, 0x73, - 0x65, 0x72, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, - 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, - 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x43, - 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, - 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, - 0x65, 0x6e, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x67, 0x65, 0x6e, - 0x64, 0x65, 0x72, 0x22, 0x0f, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, - 0x65, 0x52, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x33, + 0x22, 0x20, 0x0a, 0x0c, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, 0x65, 0x71, + 0x12, 0x10, 0x0a, 0x03, 0x73, 0x65, 0x63, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, + 0x65, 0x63, 0x22, 0x34, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x67, 0x69, 0x6e, 0x52, + 0x65, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, + 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, + 0x52, 0x65, 0x67, 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x61, + 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, + 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x31, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67, + 0x69, 0x73, 0x74, 0x65, 0x72, 0x52, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x04, 0x43, 0x6f, 0x64, 0x65, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x0a, 0x2e, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, + 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x32, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, + 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, + 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x43, 0x0a, 0x0d, + 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, + 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x65, 0x6e, + 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, + 0x72, 0x22, 0x0f, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, + 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -409,19 +401,18 @@ var file_user_msg_proto_goTypes = []interface{}{ (*UserLoadRsp)(nil), // 4: UserLoadRsp (*UserCreateReq)(nil), // 5: UserCreateReq (*UserCreateRsp)(nil), // 6: UserCreateRsp - (ErrorCode)(0), // 7: ErrorCode - (*Cache_UserData)(nil), // 8: Cache_UserData + (*Cache_UserData)(nil), // 7: Cache_UserData + (ErrorCode)(0), // 8: ErrorCode } var file_user_msg_proto_depIdxs = []int32{ - 7, // 0: UserLoginResp.Code:type_name -> ErrorCode - 8, // 1: UserLoginResp.data:type_name -> Cache_UserData - 7, // 2: UserRegisterRsp.Code:type_name -> ErrorCode - 8, // 3: UserLoadRsp.data:type_name -> Cache_UserData - 4, // [4:4] is the sub-list for method output_type - 4, // [4:4] is the sub-list for method input_type - 4, // [4:4] is the sub-list for extension type_name - 4, // [4:4] is the sub-list for extension extendee - 0, // [0:4] is the sub-list for field type_name + 7, // 0: UserLoginResp.data:type_name -> Cache_UserData + 8, // 1: UserRegisterRsp.Code:type_name -> ErrorCode + 7, // 2: UserLoadRsp.data:type_name -> Cache_UserData + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_user_msg_proto_init() } diff --git a/utils/md5.go b/utils/md5.go new file mode 100644 index 000000000..c5649d59a --- /dev/null +++ b/utils/md5.go @@ -0,0 +1,17 @@ +package utils + +import ( + "crypto/md5" + "encoding/hex" +) + +func MD5Str(s string) string { + return MD5Bytes([]byte(s)) +} + +func MD5Bytes(s []byte) string { + md5Ctx := md5.New() + md5Ctx.Write(s) + cipherStr := md5Ctx.Sum(nil) + return hex.EncodeToString(cipherStr) +} From 54b40517525a3fd05332d146b5fb3e10caddf703 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 7 Jun 2022 11:25:47 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E7=9B=B8=E5=85=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pb/mail.pb.go | 12 +++++------- pb/pack_db.pb.go | 2 +- pb/proto/mail.proto | 5 ++--- pb/user_db.pb.go | 2 +- sys/cache/core.go | 1 + sys/cache/mail.go | 34 +++++++++++++++++++++++++++++++--- sys/db/mail.go | 14 +++++++++----- 7 files changed, 50 insertions(+), 20 deletions(-) diff --git a/pb/mail.pb.go b/pb/mail.pb.go index 103198ff3..e5e2522b9 100644 --- a/pb/mail.pb.go +++ b/pb/mail.pb.go @@ -75,7 +75,6 @@ func (x *MailAttachment) GetItemCount() uint32 { return 0 } -//背包格子 type MailData struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache @@ -163,14 +162,13 @@ func (x *MailData) GetItems() []*MailAttachment { return nil } -//用户背包 type DB_UserMailData struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UserId uint32 `bson:"_id" json:"UserId,omitempty" protobuf:"varint,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}用户Id - Mails []*MailData `protobuf:"bytes,2,rep,name=mails,proto3" json:"mails,omitempty"` // 邮件列表 + UserId string `bson:"_id" json:"UserId,omitempty" protobuf:"bytes,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}用户Id + Mails []*MailData `protobuf:"bytes,2,rep,name=mails,proto3" json:"mails,omitempty"` // 邮件列表 } func (x *DB_UserMailData) Reset() { @@ -205,11 +203,11 @@ func (*DB_UserMailData) Descriptor() ([]byte, []int) { return file_mail_proto_rawDescGZIP(), []int{2} } -func (x *DB_UserMailData) GetUserId() uint32 { +func (x *DB_UserMailData) GetUserId() string { if x != nil { return x.UserId } - return 0 + return "" } func (x *DB_UserMailData) GetMails() []*MailData { @@ -240,7 +238,7 @@ var file_mail_proto_rawDesc = []byte{ 0x2e, 0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x4a, 0x0a, 0x0f, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x61, 0x69, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, - 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, + 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1f, 0x0a, 0x05, 0x6d, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x4d, 0x61, 0x69, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x6d, 0x61, 0x69, 0x6c, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, diff --git a/pb/pack_db.pb.go b/pb/pack_db.pb.go index 6dd9577bf..0dc1074bd 100644 --- a/pb/pack_db.pb.go +++ b/pb/pack_db.pb.go @@ -139,7 +139,7 @@ type DB_UserPackData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}用户Id + UserId string `bson:"_id" json:"UserId,omitempty" protobuf:"bytes,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}用户Id Pack []*GridData `protobuf:"bytes,2,rep,name=Pack,proto3" json:"Pack,omitempty"` //背包列表 } diff --git a/pb/proto/mail.proto b/pb/proto/mail.proto index ebdf9ed65..6c3c4f54c 100644 --- a/pb/proto/mail.proto +++ b/pb/proto/mail.proto @@ -5,7 +5,7 @@ message MailAttachment { // 附件 uint32 Itemid = 1; // 道具iD uint32 ItemCount = 2; // 数量 } -//背包格子 + message MailData { string Title = 1; // 邮件标题 string Contex = 2; // 邮件内容 @@ -15,8 +15,7 @@ message MailData { repeated MailAttachment Items = 6; // 附件 } -//用户背包 message DB_UserMailData { - uint32 UserId = 1; //tags:{bson:"_id"}用户Id + string UserId = 1; //tags:{bson:"_id"}用户Id repeated MailData mails = 2; // 邮件列表 } \ No newline at end of file diff --git a/pb/user_db.pb.go b/pb/user_db.pb.go index 2ce469232..2c4b65c99 100644 --- a/pb/user_db.pb.go +++ b/pb/user_db.pb.go @@ -88,7 +88,7 @@ type DB_UserData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}动态Id + UserId string `bson:"_id" json:"UserId,omitempty" protobuf:"bytes,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}动态Id Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"` NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"` Email string `protobuf:"bytes,4,opt,name=Email,proto3" json:"Email,omitempty"` diff --git a/sys/cache/core.go b/sys/cache/core.go index e8eecaed8..ddda681f7 100644 --- a/sys/cache/core.go +++ b/sys/cache/core.go @@ -4,6 +4,7 @@ type ( ISys interface { IUser IPack + IMail } ) diff --git a/sys/cache/mail.go b/sys/cache/mail.go index fca759d23..d42970c83 100644 --- a/sys/cache/mail.go +++ b/sys/cache/mail.go @@ -1,7 +1,35 @@ package cache -const ( //Redis - Redis_mailCache string = "mail:%d" +import ( + "fmt" + "go_dreamfactory/pb" + "go_dreamfactory/sys/db" + + "github.com/liwei1dao/lego/sys/mgo" + "github.com/liwei1dao/lego/sys/redis" ) -type IMail interface{} +const ( //Redis + Redis_MailCache string = "mail:%s" +) + +type IMail interface { + QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error) +} + +// 查询玩家邮件数据 +func (this *Cache) QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error) { + mail = &pb.DB_UserMailData{ + UserId: uId, + } + if err = this.redis.Get(fmt.Sprintf(Redis_MailCache, uId), mail); err == nil { + return + } else if err == redis.RedisNil { + if mail, err = db.Defsys.QueryUserMail(uId); err == nil { + this.redis.Set(fmt.Sprintf(Redis_MailCache, uId), mail, -1) + } else if err == mgo.MongodbNil { + err = nil + } + } + return +} diff --git a/sys/db/mail.go b/sys/db/mail.go index fa06af9f5..5772e2e42 100644 --- a/sys/db/mail.go +++ b/sys/db/mail.go @@ -4,15 +4,19 @@ import ( "go_dreamfactory/pb" "github.com/liwei1dao/lego/core" + "go.mongodb.org/mongo-driver/bson" ) -type IMail interface { -} - const ( //Redis DB_MailTable core.SqlTable = "mail" ) -type IMain interface { - QueryUserMail(uId uint32) (pack *pb.DB_UserPackData, err error) +type IMail interface { + QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error) +} + +func (this *DB) QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error) { + mail = &pb.DB_UserMailData{} + err = this.mgo.FindOne(DB_MailTable, bson.M{"_id": uId}).Decode(mail) + return } From d4fa18143ab77d9e50273de2817f51da5c7bb919 Mon Sep 17 00:00:00 2001 From: zhaocy Date: Tue, 7 Jun 2022 17:18:34 +0800 Subject: [PATCH 3/7] update login --- bin/json/tbhero.json | 552 +++++++++++++++++++++++++++ cmd/robot/login.go | 42 +- cmd/robot/options.go | 17 +- cmd/robot/robot.go | 10 +- cmd/robot/user.go | 41 +- comm/core.go | 12 +- comm/usersession.go | 8 +- go.mod | 3 + go.sum | 7 +- modules/gateway/agent.go | 14 +- modules/gateway/module.go | 2 +- modules/user/login_comp.go | 71 ++-- modules/user/module.go | 10 +- modules/user/user_comp.go | 12 +- pb/proto/user_db.proto | 3 +- pb/proto/user_msg.proto | 3 +- pb/user_db.pb.go | 36 +- pb/user_msg.pb.go | 29 +- sys/cache/user.go | 17 +- sys/cache/user_test.go | 8 +- sys/configure/structs/MyBean.Hero.go | 79 ++++ sys/configure/structs/Tables.go | 7 + sys/configure/structs/TbHero.go | 42 ++ sys/db/user.go | 14 +- sys/db/user_test.go | 18 +- utils/base64.go | 37 ++ 26 files changed, 939 insertions(+), 155 deletions(-) create mode 100644 bin/json/tbhero.json create mode 100644 sys/configure/structs/MyBean.Hero.go create mode 100644 sys/configure/structs/TbHero.go create mode 100644 utils/base64.go diff --git a/bin/json/tbhero.json b/bin/json/tbhero.json new file mode 100644 index 000000000..177d56de6 --- /dev/null +++ b/bin/json/tbhero.json @@ -0,0 +1,552 @@ +[ + { + "id": "11001", + "name": "阿宝", + "star": 4, + "color": 3, + "chengwei": 3, + "zhongzu": 1, + "job": 1, + "type": 1, + "prefab": "Person/11001.prefab", + "icon": "11001", + "sound": "121323", + "tujing": "[1]", + "hpgrow": "57.4", + "atkgrow": "7.2", + "defgrow": "5.6", + "speedgrow": "2", + "hp": "576", + "atk": "73", + "def": "57", + "speed": "174", + "intr": "", + "events": "EventDataSet/Hero_11001.asset", + "cite": "" + }, + { + "id": "11002", + "name": "原始人", + "star": 5, + "color": 4, + "chengwei": 3, + "zhongzu": 1, + "job": 1, + "type": 1, + "prefab": "Person/11002.prefab", + "icon": "11002", + "sound": "11002", + "tujing": "[1]", + "hpgrow": "82.9", + "atkgrow": "9.4", + "defgrow": "5.8", + "speedgrow": "2", + "hp": "830", + "atk": "95", + "def": "59", + "speed": "193", + "intr": "", + "events": "EventDataSet/Hero_11002.asset", + "cite": "" + }, + { + "id": "11003", + "name": "波比", + "star": 5, + "color": 4, + "chengwei": 3, + "zhongzu": 1, + "job": 1, + "type": 1, + "prefab": "Person/11003.prefab", + "icon": "11003", + "sound": "11003", + "tujing": "[1]", + "hpgrow": "82.9", + "atkgrow": "9.4", + "defgrow": "5.8", + "speedgrow": "2", + "hp": "830", + "atk": "95", + "def": "59", + "speed": "193", + "intr": "", + "events": "EventDataSet/Hero_11003.asset", + "cite": "" + }, + { + "id": "11004", + "name": "布兰", + "star": 5, + "color": 4, + "chengwei": 3, + "zhongzu": 1, + "job": 1, + "type": 1, + "prefab": "11004", + "icon": "11004", + "sound": "11004", + "tujing": "[1]", + "hpgrow": "82.9", + "atkgrow": "9.4", + "defgrow": "5.8", + "speedgrow": "2", + "hp": "830", + "atk": "95", + "def": "59", + "speed": "193", + "intr": "", + "events": "hero_2011", + "cite": "" + }, + { + "id": "11005", + "name": "无牙仔", + "star": 4, + "color": 3, + "chengwei": 3, + "zhongzu": 1, + "job": 1, + "type": 1, + "prefab": "Person/11001.prefab", + "icon": "11005", + "sound": "121323", + "tujing": "[1]", + "hpgrow": "57.4", + "atkgrow": "7.2", + "defgrow": "5.6", + "speedgrow": "2", + "hp": "576", + "atk": "73", + "def": "57", + "speed": "174", + "intr": "", + "events": "EventDataSet/Hero_11001.asset", + "cite": "" + }, + { + "id": "11006", + "name": "亚丝翠", + "star": 5, + "color": 4, + "chengwei": 3, + "zhongzu": 1, + "job": 1, + "type": 1, + "prefab": "11006", + "icon": "11006", + "sound": "11006", + "tujing": "[1]", + "hpgrow": "82.9", + "atkgrow": "9.4", + "defgrow": "5.8", + "speedgrow": "2", + "hp": "830", + "atk": "95", + "def": "59", + "speed": "193", + "intr": "", + "events": "hero_2011", + "cite": "" + }, + { + "id": "11009", + "name": "希卡普", + "star": 4, + "color": 3, + "chengwei": 4, + "zhongzu": 2, + "job": 2, + "type": 1, + "prefab": "11009", + "icon": "11009", + "sound": "11009", + "tujing": "[1]", + "hpgrow": "38.6", + "atkgrow": "10.5", + "defgrow": "5.7", + "speedgrow": "2", + "hp": "389", + "atk": "106", + "def": "58", + "speed": "165", + "intr": "", + "events": "EventDataSet/Hero_11009.asset", + "cite": "" + }, + { + "id": "22002", + "name": "沈王爷青春版", + "star": 5, + "color": 4, + "chengwei": 4, + "zhongzu": 2, + "job": 2, + "type": 1, + "prefab": "22002", + "icon": "22002", + "sound": "22002", + "tujing": "[1]", + "hpgrow": "55.6", + "atkgrow": "13.6", + "defgrow": "5.9", + "speedgrow": "2", + "hp": "561", + "atk": "137", + "def": "60", + "speed": "183", + "intr": "", + "events": "hero_2011", + "cite": "" + }, + { + "id": "90001", + "name": "邪恶阿宝", + "star": 4, + "color": 3, + "chengwei": 3, + "zhongzu": 1, + "job": 1, + "type": 1, + "prefab": "Person/90001.prefab", + "icon": "90001", + "sound": "90001", + "tujing": "[1]", + "hpgrow": "57.4", + "atkgrow": "7.2", + "defgrow": "5.6", + "speedgrow": "2", + "hp": "576", + "atk": "73", + "def": "57", + "speed": "174", + "intr": "", + "events": "hero_90001", + "cite": "11001" + }, + { + "id": "11011", + "name": "浣熊", + "star": 4, + "color": 3, + "chengwei": 4, + "zhongzu": 2, + "job": 2, + "type": 1, + "prefab": "11011", + "icon": "11011", + "sound": "11011", + "tujing": "[1]", + "hpgrow": "38.6", + "atkgrow": "10.5", + "defgrow": "5.7", + "speedgrow": "2", + "hp": "389", + "atk": "106", + "def": "58", + "speed": "165", + "intr": "", + "events": "EventDataSet/Hero_11011.asset", + "cite": "" + }, + { + "id": "11008", + "name": "悍娇虎", + "star": 5, + "color": 4, + "chengwei": 4, + "zhongzu": 2, + "job": 2, + "type": 1, + "prefab": "11008", + "icon": "11008", + "sound": "11008", + "tujing": "[1]", + "hpgrow": "55.6", + "atkgrow": "13.6", + "defgrow": "5.9", + "speedgrow": "2", + "hp": "561", + "atk": "137", + "def": "60", + "speed": "183", + "intr": "", + "events": "hero_2011", + "cite": "" + }, + { + "id": "11017", + "name": "冰霜杰克", + "star": 5, + "color": 4, + "chengwei": 4, + "zhongzu": 2, + "job": 2, + "type": 1, + "prefab": "11017", + "icon": "11017", + "sound": "11017", + "tujing": "[1]", + "hpgrow": "55.6", + "atkgrow": "13.6", + "defgrow": "5.9", + "speedgrow": "2", + "hp": "561", + "atk": "137", + "def": "60", + "speed": "183", + "intr": "", + "events": "EventDataSet/Hero_11017.asset", + "cite": "" + }, + { + "id": "11018", + "name": "睡神", + "star": 5, + "color": 4, + "chengwei": 4, + "zhongzu": 2, + "job": 2, + "type": 1, + "prefab": "11018", + "icon": "11018", + "sound": "11018", + "tujing": "[1]", + "hpgrow": "55.6", + "atkgrow": "13.6", + "defgrow": "5.9", + "speedgrow": "2", + "hp": "561", + "atk": "137", + "def": "60", + "speed": "183", + "intr": "", + "events": "EventDataSet/Hero_11018.asset", + "cite": "" + }, + { + "id": "11019", + "name": "莫甘娜", + "star": 5, + "color": 4, + "chengwei": 4, + "zhongzu": 2, + "job": 2, + "type": 1, + "prefab": "11019", + "icon": "11019", + "sound": "11019", + "tujing": "[1]", + "hpgrow": "55.6", + "atkgrow": "13.6", + "defgrow": "5.9", + "speedgrow": "2", + "hp": "561", + "atk": "137", + "def": "60", + "speed": "183", + "intr": "", + "events": "EventDataSet/Hero_11019.asset", + "cite": "" + }, + { + "id": "11020", + "name": "莫甘娜二阶段", + "star": 5, + "color": 4, + "chengwei": 4, + "zhongzu": 2, + "job": 2, + "type": 1, + "prefab": "11020", + "icon": "11020", + "sound": "11020", + "tujing": "[1]", + "hpgrow": "55.6", + "atkgrow": "13.6", + "defgrow": "5.9", + "speedgrow": "2", + "hp": "561", + "atk": "137", + "def": "60", + "speed": "183", + "intr": "", + "events": "EventDataSet/Hero_11020.asset", + "cite": "" + }, + { + "id": "11021", + "name": "莫甘娜巨怪", + "star": 5, + "color": 4, + "chengwei": 4, + "zhongzu": 2, + "job": 2, + "type": 1, + "prefab": "11021", + "icon": "11021", + "sound": "11021", + "tujing": "[1]", + "hpgrow": "55.6", + "atkgrow": "13.6", + "defgrow": "5.9", + "speedgrow": "2", + "hp": "561", + "atk": "137", + "def": "60", + "speed": "183", + "intr": "", + "events": "EventDataSet/Hero_11021.asset", + "cite": "" + }, + { + "id": "11099", + "name": "触手", + "star": 5, + "color": 4, + "chengwei": 4, + "zhongzu": 2, + "job": 2, + "type": 1, + "prefab": "11099", + "icon": "11099", + "sound": "11099", + "tujing": "[1]", + "hpgrow": "55.6", + "atkgrow": "13.6", + "defgrow": "5.9", + "speedgrow": "2", + "hp": "561", + "atk": "137", + "def": "60", + "speed": "183", + "intr": "", + "events": "EventDataSet/Hero_11099.asset", + "cite": "" + }, + { + "id": "12001", + "name": "黑化阿宝", + "star": 5, + "color": 4, + "chengwei": 4, + "zhongzu": 2, + "job": 2, + "type": 1, + "prefab": "Person/12001.prefab", + "icon": "12001", + "sound": "121323", + "tujing": "[1]", + "hpgrow": "57.4", + "atkgrow": "7.2", + "defgrow": "5.6", + "speedgrow": "2", + "hp": "576", + "atk": "73", + "def": "57", + "speed": "174", + "intr": "", + "events": "EventDataSet/Hero_12001.asset", + "cite": "" + }, + { + "id": "12003", + "name": "黑化包比", + "star": 5, + "color": 4, + "chengwei": 4, + "zhongzu": 2, + "job": 2, + "type": 1, + "prefab": "Person/11003.prefab", + "icon": "12003", + "sound": "12003", + "tujing": "[1]", + "hpgrow": "82.9", + "atkgrow": "9.4", + "defgrow": "5.8", + "speedgrow": "2", + "hp": "830", + "atk": "95", + "def": "59", + "speed": "193", + "intr": "", + "events": "EventDataSet/Hero_11003.asset", + "cite": "11003" + }, + { + "id": "12009", + "name": "黑化希卡普", + "star": 5, + "color": 4, + "chengwei": 4, + "zhongzu": 2, + "job": 2, + "type": 1, + "prefab": "12009", + "icon": "11009", + "sound": "11009", + "tujing": "[1]", + "hpgrow": "38.6", + "atkgrow": "10.5", + "defgrow": "5.7", + "speedgrow": "2", + "hp": "389", + "atk": "106", + "def": "58", + "speed": "165", + "intr": "", + "events": "EventDataSet/Hero_11009.asset", + "cite": "" + }, + { + "id": "12017", + "name": "黑化杰克", + "star": 5, + "color": 4, + "chengwei": 4, + "zhongzu": 2, + "job": 2, + "type": 1, + "prefab": "12017", + "icon": "12017", + "sound": "12017", + "tujing": "[1]", + "hpgrow": "55.6", + "atkgrow": "13.6", + "defgrow": "5.9", + "speedgrow": "2", + "hp": "561", + "atk": "137", + "def": "60", + "speed": "183", + "intr": "", + "events": "EventDataSet/Hero_11017.asset", + "cite": "" + }, + { + "id": "12018", + "name": "黑化睡神", + "star": 5, + "color": 4, + "chengwei": 4, + "zhongzu": 2, + "job": 2, + "type": 1, + "prefab": "12018", + "icon": "12018", + "sound": "12018", + "tujing": "[1]", + "hpgrow": "55.6", + "atkgrow": "13.6", + "defgrow": "5.9", + "speedgrow": "2", + "hp": "561", + "atk": "137", + "def": "60", + "speed": "183", + "intr": "", + "events": "EventDataSet/Hero_11018.asset", + "cite": "11018" + } +] \ No newline at end of file diff --git a/cmd/robot/login.go b/cmd/robot/login.go index 7e0f2d049..e6e6988b6 100644 --- a/cmd/robot/login.go +++ b/cmd/robot/login.go @@ -1,47 +1,55 @@ package robot import ( + "fmt" "go_dreamfactory/comm" "go_dreamfactory/pb" + "go_dreamfactory/utils" "log" + "time" + jsoniter "github.com/json-iterator/go" + "github.com/nacos-group/nacos-sdk-go/util" "google.golang.org/protobuf/proto" ) -func (r *Robot) handleLogin(msg *pb.UserMessage) { - switch msg.SubType { - case "login": - handleLogin(r, msg) - default: - log.Fatal("methodName no exist") - } +type LoginParam struct { + Account string `json:"account"` + ServerId int `json:"serverId"` + TimeStamp int64 `json:"timestamp"` } -//处理接口响应数据 -func handleLogin(r *Robot, msg *pb.UserMessage) { - rsp := &pb.UserLoginResp{} - if !comm.ProtoDecode(msg, rsp) { - return - } - log.Printf("to client: %v", rsp.Data) +func (r *Robot) BuildSecStr() string { + jsonByte, _ := jsoniter.Marshal(&LoginParam{ + Account: r.Opts.Account, + ServerId: r.Opts.ServerId, + TimeStamp: time.Now().Unix(), + }) + jsonBase64 := utils.Base64Encode(jsonByte) + log.Printf("client base64:%s", jsonBase64) + clientMd5key := util.Md5(jsonBase64) + log.Printf("client md5:%s", clientMd5key) + return fmt.Sprintf("CE:%s%s", clientMd5key, jsonBase64) } //处理登录请求 func (r *Robot) AccountLogin() { //登录 + sec := r.BuildSecStr() + log.Printf("client secret key:%s", sec) loginReg := &pb.UserLoginReq{ - Name: r.Opts.Account, + Sec: sec, } head := &pb.UserMessage{ - MainType: "login", + MainType: "user", SubType: "login", } if comm.ProtoEncode(loginReg, head) { data, _ := proto.Marshal(head) err := r.SendToClient(data) if err != nil { - log.Fatal(err) + log.Fatalf("send err:%v", err) } } diff --git a/cmd/robot/options.go b/cmd/robot/options.go index 827bdbc3a..46aeb9aba 100644 --- a/cmd/robot/options.go +++ b/cmd/robot/options.go @@ -1,17 +1,20 @@ package robot type Options struct { - WsUrl string //客户端访问网关的ws接口地址 - RegUrl string //账号注册接口地址 - Account string //玩家账号 - Create bool + WsUrl string //客户端访问网关的ws接口地址 + RegUrl string //账号注册接口地址 + Account string //玩家账号 + Create bool + Secretkey string //秘钥串 + ServerId int } func DefaultOpts() *Options { return &Options{ - WsUrl: "ws://localhost:7891/gateway", - RegUrl: "http://localhost:8000/register", - Create: false, + WsUrl: "ws://localhost:7891/gateway", + RegUrl: "http://localhost:8000/register", + Create: false, + ServerId: 1, } } diff --git a/cmd/robot/robot.go b/cmd/robot/robot.go index bc4ff8de3..785194e23 100644 --- a/cmd/robot/robot.go +++ b/cmd/robot/robot.go @@ -39,7 +39,6 @@ func (r *Robot) Run() { if r.Opts.Create { //创建新用户 r.AccountRegister() } else { - //login user r.AccountLogin() } @@ -62,10 +61,9 @@ func (r *Robot) Run() { select {} } +//模块处理 func (r *Robot) handleMsg(msg *pb.UserMessage) { switch msg.MainType { - case "login": - r.handleLogin(msg) case "user": r.handleUserMsg(msg) default: @@ -73,6 +71,7 @@ func (r *Robot) handleMsg(msg *pb.UserMessage) { } } +//在这里添加玩家成功登录以后的测试方法 func (r *Robot) onUserLoaded() { } @@ -103,13 +102,14 @@ func (r *Robot) AccountRegister() { err = jsoniter.Unmarshal(body, regRsp) if regRsp.Code == pb.ErrorCode_Success { //注册成功 + //登录 loginReg := &pb.UserLoginReq{ - Name: regReq.Account, + Sec: r.BuildSecStr(), } head := &pb.UserMessage{ - MainType: "login", + MainType: "user", SubType: "login", } if comm.ProtoEncode(loginReg, head) { diff --git a/cmd/robot/user.go b/cmd/robot/user.go index cc4dd1b75..b204d9268 100644 --- a/cmd/robot/user.go +++ b/cmd/robot/user.go @@ -3,37 +3,40 @@ package robot import ( "go_dreamfactory/comm" "go_dreamfactory/pb" - - "github.com/liwei1dao/lego/sys/log" + "log" ) func (r *Robot) handleUserMsg(msg *pb.UserMessage) { - switch msg.SubType { - //创建账号 + case "login": + handleLogin(r, msg) case "create": - case "load": - + handleCreateUser(r, msg) } - //加载玩家数据 - if msg.SubType == "load" { - rsp := &pb.UserLoadRsp{} - if !comm.ProtoDecode(msg, rsp) { - log.Fatal("load user err") - } +} - if rsp.Data.UserData.UserId != "" { - r.onUserLoaded() - } else { - log.Debugf("%s不存在", r.Opts.Account) - //创建 - - } +//处理登录响应数据 +func handleLogin(r *Robot, msg *pb.UserMessage) { + rsp := &pb.UserLoginResp{} + if !comm.ProtoDecode(msg, rsp) { + return + } + log.Printf("登录返回: %v", rsp) + //是否有登录数据返回 + if rsp != nil { + r.onUserLoaded() + } else { + r.AccountRegister() //请求Http接口,模拟创建新账号 } } +func handleCreateUser(r *Robot, msg *pb.UserMessage) { + +} + +//创角色 func (r *Robot) CreateUser() { } diff --git a/comm/core.go b/comm/core.go index 88a10e89e..55e0b617b 100644 --- a/comm/core.go +++ b/comm/core.go @@ -14,10 +14,10 @@ const ( ) const ( - SM_GateModule core.M_Modules = "gateway" //gate模块 网关服务模块 - SM_WebModule core.M_Modules = "web" //web模块 - SM_LoginModule core.M_Modules = "user" //用户模块 - SM_PackModule core.M_Modules = "pack" //背包模块 + SM_GateModule core.M_Modules = "gateway" //gate模块 网关服务模块 + SM_WebModule core.M_Modules = "web" //web模块 + SM_UserModule core.M_Modules = "user" //用户模块 + SM_PackModule core.M_Modules = "pack" //背包模块 ) const ( //Rpc @@ -30,6 +30,10 @@ const ( //Rpc Rpc_GatewayAgentClose core.Rpc_Key = "Rpc_GatewayAgentClose" //代理关闭 关闭用户连接 ) +const ( + Event_UserLogin core.Event_Key = "Event_UserLogin" //登录事件 +) + type ISC_GateRouteComp interface { core.IServiceComp RegisterRoute(methodName string, comp reflect.Value, msg reflect.Type, fn reflect.Method) diff --git a/comm/usersession.go b/comm/usersession.go index 44a961e51..425f422df 100644 --- a/comm/usersession.go +++ b/comm/usersession.go @@ -48,7 +48,7 @@ func (this *UserSession) Build(uid string) (err error) { UserSessionId: this.SessionId, UserId: uid, }, reply); err != nil { - log.Errorf("UserSession:%s UserId:%d Build:%s err:%v", this.SessionId, this.UserId, err) + log.Errorf("UserSession:%s UserId:%s Build:%s err:%v", this.SessionId, this.UserId, err) } return } @@ -58,7 +58,7 @@ func (this *UserSession) UnBuild(ServiceMethod string, msg proto.Message) (err e if err := this.service.RpcCallById(this.GatewayServiceId, string(Rpc_GatewayAgentUnBuild), context.Background(), &pb.AgentUnBuildReq{ UserSessionId: this.SessionId, }, reply); err != nil { - log.Errorf("UserSession:%s UserId:%d UnBuild err:%v", this.SessionId, this.UserId, err) + log.Errorf("UserSession:%s UserId:%s UnBuild err:%v", this.SessionId, this.UserId, err) } return } @@ -74,7 +74,7 @@ func (this *UserSession) SendMsg(mainType, subType string, code pb.ErrorCode, ms Code: code, Data: data, }, reply); err != nil { - log.Errorf("UserSession:%s UserId:%d SendMsg:%s err:%v", this.SessionId, this.UserId, mainType, err) + log.Errorf("UserSession:%s UserId:%s SendMsg:%s err:%v", this.SessionId, this.UserId, mainType, err) } return } @@ -89,5 +89,5 @@ func (this *UserSession) Close() (err error) { } func (this *UserSession) ToString() string { - return fmt.Sprintf("SessionId:%s UserId:%d GatewayServiceId:%s", this.SessionId, this.UserId, this.GatewayServiceId) + return fmt.Sprintf("SessionId:%s UserId:%s GatewayServiceId:%s", this.SessionId, this.UserId, this.GatewayServiceId) } diff --git a/go.mod b/go.mod index d3a36b9cb..ffbb3e0ac 100644 --- a/go.mod +++ b/go.mod @@ -10,6 +10,7 @@ require ( 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 go.mongodb.org/mongo-driver v1.5.1 google.golang.org/protobuf v1.28.0 ) @@ -98,6 +99,8 @@ require ( github.com/soheilhy/cmux v0.1.5 // indirect github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 // indirect github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b // indirect + github.com/tidwall/match v1.1.1 // indirect + github.com/tidwall/pretty v1.2.0 // indirect github.com/tinylib/msgp v1.1.6 // indirect github.com/tjfoc/gmsm v1.4.1 // indirect github.com/toolkits/concurrent v0.0.0-20150624120057-a4371d70e3e3 // indirect diff --git a/go.sum b/go.sum index 77febd27a..ee27c71dd 100644 --- a/go.sum +++ b/go.sum @@ -783,8 +783,13 @@ github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161 h1:89CEmDvlq/F7S github.com/templexxx/cpufeat v0.0.0-20180724012125-cef66df7f161/go.mod h1:wM7WEvslTq+iOEAMDLSzhVuOt5BRZ05WirO+b09GHQU= github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b h1:fj5tQ8acgNUr6O8LEplsxDhUIe2573iLkJc+PqnzZTI= github.com/templexxx/xor v0.0.0-20191217153810-f85b25db303b/go.mod h1:5XA7W9S6mni3h5uvOC75dA3m9CCCaS83lltmc0ukdi4= -github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4= +github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo= +github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk= +github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA= +github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM= github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk= +github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs= +github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tinylib/msgp v1.1.6 h1:i+SbKraHhnrf9M5MYmvQhFnbLhAXSDWF8WWsuyRdocw= github.com/tinylib/msgp v1.1.6/go.mod h1:75BAfg2hauQhs3qedfdDZmWAPcFMAvJE5b9rGOMufyw= github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho= diff --git a/modules/gateway/agent.go b/modules/gateway/agent.go index ac7ca93f2..d5ac6a896 100644 --- a/modules/gateway/agent.go +++ b/modules/gateway/agent.go @@ -52,19 +52,19 @@ func (this *Agent) readLoop() { locp: for { if _, data, err = this.wsConn.ReadMessage(); err != nil { - log.Errorf("agent:%s uId:%d ReadMessage err:%v", this.sessionId, this.uId, err) + log.Errorf("agent:%s uId:%s ReadMessage err:%v", this.sessionId, this.uId, err) go this.Close() break locp } if err = proto.Unmarshal(data, msg); err != nil { - log.Errorf("agent:%s uId:%d Unmarshal err:%v", this.sessionId, this.uId, err) + log.Errorf("agent:%s uId:%s Unmarshal err:%v", this.sessionId, this.uId, err) go this.Close() break locp } else { this.messageDistribution(msg) } } - log.Debugf("agent:%s uId:%d readLoop end!", this.sessionId, this.uId) + log.Debugf("agent:%s uId:%s readLoop end!", this.sessionId, this.uId) } func (this *Agent) writeLoop() { @@ -90,7 +90,7 @@ locp: } } } - log.Debugf("agent:%s uId:%d writeLoop end!", this.sessionId, this.uId) + log.Debugf("agent:%s uId:%s writeLoop end!", this.sessionId, this.uId) } func (this *Agent) SessionId() string { @@ -135,7 +135,7 @@ func (this *Agent) Close() { //分发用户消息 func (this *Agent) messageDistribution(msg *pb.UserMessage) { reply := &pb.RPCMessageReply{} - log.Debugf("agent:%s uId:%d MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType) + log.Debugf("agent:%s uId:%s MessageDistribution msg:%s.%s", this.sessionId, this.uId, msg.MainType, msg.SubType) if err := this.gateway.Service().RpcCallByType("worker", string(comm.Rpc_GatewayRoute), context.Background(), &pb.AgentMessage{ Ip: this.IP(), UserSessionId: this.sessionId, @@ -144,8 +144,8 @@ func (this *Agent) messageDistribution(msg *pb.UserMessage) { Method: fmt.Sprintf("%s.%s", msg.MainType, msg.SubType), Message: msg.Data, }, reply); err != nil { - log.Errorf("agent:%s uId:%d MessageDistribution err:%v", this.sessionId, this.uId, err) + log.Errorf("agent:%s uId:%s MessageDistribution err:%v", this.sessionId, this.uId, err) } else { - log.Debugf("agent:%s uId:%d MessageDistribution reply:%v", this.sessionId, this.uId, reply) + log.Debugf("agent:%s uId:%s MessageDistribution reply:%v", this.sessionId, this.uId, reply) } } diff --git a/modules/gateway/module.go b/modules/gateway/module.go index 718758e6c..51d5479a7 100644 --- a/modules/gateway/module.go +++ b/modules/gateway/module.go @@ -64,6 +64,6 @@ func (this *Gateway) Connect(a IAgent) { //有新的连接对象进入 func (this *Gateway) DisConnect(a IAgent) { - log.Debugf("[Module.Gateway] have disConnect:Ip[%s] SessionId:[%s] uid:[%d]", a.IP(), a.SessionId(), a.UserId()) + log.Debugf("[Module.Gateway] have disConnect:Ip[%s] SessionId:[%s] uid:[%s]", a.IP(), a.SessionId(), a.UserId()) this.agentmgr_comp.DisConnect(a) } diff --git a/modules/user/login_comp.go b/modules/user/login_comp.go index 247c3c62a..85106b8ba 100644 --- a/modules/user/login_comp.go +++ b/modules/user/login_comp.go @@ -2,16 +2,18 @@ package user import ( "context" - "fmt" + "encoding/base64" "go_dreamfactory/comm" "go_dreamfactory/modules" "go_dreamfactory/pb" "go_dreamfactory/sys/cache" "go_dreamfactory/sys/db" "go_dreamfactory/utils" - "strings" + "time" + "github.com/liwei1dao/lego/sys/event" "github.com/liwei1dao/lego/sys/log" + "github.com/tidwall/gjson" "go.mongodb.org/mongo-driver/mongo" ) @@ -19,63 +21,76 @@ type LoginComp struct { modules.MComp_GateComp } +func DecodeUserData(base64Str string) *pb.DB_UserData { + //解码 + dec, err := base64.StdEncoding.DecodeString(base64Str[35:]) + if err != nil { + log.Errorf("base64 decode err %v", err) + return nil + } + now := time.Now().Unix() + jsonRet := gjson.Parse(string(dec)) + serverId := jsonRet.Get("serverId").Int() + timestamp := jsonRet.Get("timestamp").Int() + if now-time.Unix(timestamp, 0).Unix() > 100 { + return nil + } + account := jsonRet.Get("account").String() + return &pb.DB_UserData{ + ServerId: int32(serverId), + Account: account, + } +} + //登录 func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req *pb.UserLoginReq) error { log.Debugf("User - Login: session:%v rsp:%v", session.ToString(), req) - var code pb.ErrorCode = pb.ErrorCode_Success - rsp := &pb.UserLoginResp{} - secStr := req.Sec - - if !strings.HasPrefix(secStr, "CE:") || len(secStr) < 35 { - session.SendMsg("user", "login", pb.ErrorCode_SecKey, rsp) + if !utils.ValidSecretKey(req.Sec) { + session.SendMsg("user", "login", pb.ErrorCode_SecKeyInvalid, nil) return nil } - clientMd5Key := strings.TrimPrefix(secStr, "CE:") - rawmsg := secStr[35:] - serverMd5Key := utils.MD5Str(rawmsg) - s := fmt.Sprintf("%x", serverMd5Key) - if !strings.EqualFold(strings.ToLower(s), strings.ToLower(clientMd5Key)) { - session.SendMsg("user", "login", pb.ErrorCode_SecKeyInvalid, rsp) - return nil - } - account := "" - db_user, err := db.Defsys.User_FindUserByAccount(account) + user := DecodeUserData(req.Sec) + + db_user, err := db.Defsys.User_FindUserByAccount(user) if err != nil { if err != mongo.ErrNoDocuments { return err } } - if db_user.UserId == "" { - db_user.Account = account - err = db.Defsys.User_CreateUser(db_user) + //如果是新玩家,创建一条基础的数据,页面会引导进入创角页面 + if db_user == nil { + err = db.Defsys.User_CreateUser(user) if err != nil { + log.Errorf("User_CreateUser err %v", err) return err } } - session.Build(db_user.UserId) + session.Build(user.UserId) cache_user := &pb.Cache_UserData{ SessionId: session.GetSessionId(), GatewayServiceId: session.GetGatewayServiceId(), UserData: db_user, } - err = cache.Defsys.User_UpdateUser(cache_user) + err = cache.Defsys.Update(cache_user) if err != nil { + log.Errorf("update cache err:%v", err) return err } - session.SendMsg("user", "login", code, &pb.UserLoginResp{ + err = session.SendMsg("user", "login", code, &pb.UserLoginResp{ Data: &pb.Cache_UserData{ - UserData: &pb.DB_UserData{ - UserId: db_user.UserId, - }, + UserData: db_user, }, }) - + if err != nil { + return err + } + event.TriggerEvent(comm.Event_UserLogin, db_user.UserId) return nil } diff --git a/modules/user/module.go b/modules/user/module.go index 47afe980f..7387d18ce 100644 --- a/modules/user/module.go +++ b/modules/user/module.go @@ -15,13 +15,21 @@ func NewModule() core.IModule { type User struct { modules.ModuleBase login_comp *LoginComp + user_comp *UserComp } func (this *User) GetType() core.M_Modules { - return comm.SM_LoginModule + return comm.SM_UserModule +} + +func (this *User) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { + err = this.ModuleBase.Init(service, module, options) + + return } func (this *User) OnInstallComp() { this.ModuleBase.OnInstallComp() this.login_comp = this.RegisterComp(new(LoginComp)).(*LoginComp) + this.user_comp = this.RegisterComp(new(UserComp)).(*UserComp) } diff --git a/modules/user/user_comp.go b/modules/user/user_comp.go index 64b51ba9b..8d5c3126c 100644 --- a/modules/user/user_comp.go +++ b/modules/user/user_comp.go @@ -5,13 +5,23 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/modules" "go_dreamfactory/pb" + + "github.com/liwei1dao/lego/core" ) type UserComp struct { modules.MComp_GateComp + module *User +} + +func (this *UserComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { + this.MComp_GateComp.Init(service, module, comp, options) + this.module = module.(*User) + return } //创角 -func (this *UserComp) CreateUser(ctx context.Context, session comm.IUserSession, req *pb.UserLoginReq) error { +func (this *UserComp) Create(ctx context.Context, session comm.IUserSession, req *pb.UserCreateReq) error { + return nil } diff --git a/pb/proto/user_db.proto b/pb/proto/user_db.proto index 7a239c802..a7d8daf65 100644 --- a/pb/proto/user_db.proto +++ b/pb/proto/user_db.proto @@ -11,6 +11,5 @@ message DB_UserData { string UserId = 1; //tags:{bson:"_id"}动态Id string account = 2; string NiceName = 3; - string Email = 4; - string Password = 5; + int32 ServerId = 4; } \ No newline at end of file diff --git a/pb/proto/user_msg.proto b/pb/proto/user_msg.proto index 061cbd035..88f64d141 100644 --- a/pb/proto/user_msg.proto +++ b/pb/proto/user_msg.proto @@ -28,9 +28,8 @@ message UserLoadRsp { //创角 message UserCreateReq{ string NickName = 1;//昵称 - int32 gender = 2; //性别 } message UserCreateRsp{ - + string NickName = 1; } \ No newline at end of file diff --git a/pb/user_db.pb.go b/pb/user_db.pb.go index 2ce469232..8e356e1f7 100644 --- a/pb/user_db.pb.go +++ b/pb/user_db.pb.go @@ -91,8 +91,7 @@ type DB_UserData struct { UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}动态Id Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"` NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"` - Email string `protobuf:"bytes,4,opt,name=Email,proto3" json:"Email,omitempty"` - Password string `protobuf:"bytes,5,opt,name=Password,proto3" json:"Password,omitempty"` + ServerId int32 `protobuf:"varint,4,opt,name=ServerId,proto3" json:"ServerId,omitempty"` } func (x *DB_UserData) Reset() { @@ -148,18 +147,11 @@ func (x *DB_UserData) GetNiceName() string { return "" } -func (x *DB_UserData) GetEmail() string { +func (x *DB_UserData) GetServerId() int32 { if x != nil { - return x.Email + return x.ServerId } - return "" -} - -func (x *DB_UserData) GetPassword() string { - if x != nil { - return x.Password - } - return "" + return 0 } var File_user_db_proto protoreflect.FileDescriptor @@ -174,17 +166,15 @@ var file_user_db_proto_rawDesc = []byte{ 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, 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, 0x8d, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73, - 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18, - 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x65, - 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x65, - 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x61, - 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x61, - 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x22, 0x77, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, + 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18, 0x0a, + 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x65, 0x4e, + 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x65, 0x4e, + 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x42, + 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/user_msg.pb.go b/pb/user_msg.pb.go index 47f8d000e..83f6141cc 100644 --- a/pb/user_msg.pb.go +++ b/pb/user_msg.pb.go @@ -263,7 +263,6 @@ type UserCreateReq struct { unknownFields protoimpl.UnknownFields NickName string `protobuf:"bytes,1,opt,name=NickName,proto3" json:"NickName,omitempty"` //昵称 - Gender int32 `protobuf:"varint,2,opt,name=gender,proto3" json:"gender,omitempty"` //性别 } func (x *UserCreateReq) Reset() { @@ -305,17 +304,12 @@ func (x *UserCreateReq) GetNickName() string { return "" } -func (x *UserCreateReq) GetGender() int32 { - if x != nil { - return x.Gender - } - return 0 -} - type UserCreateRsp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields + + NickName string `protobuf:"bytes,1,opt,name=NickName,proto3" json:"NickName,omitempty"` } func (x *UserCreateRsp) Reset() { @@ -350,6 +344,13 @@ func (*UserCreateRsp) Descriptor() ([]byte, []int) { return file_user_msg_proto_rawDescGZIP(), []int{6} } +func (x *UserCreateRsp) GetNickName() string { + if x != nil { + return x.NickName + } + return "" +} + var File_user_msg_proto protoreflect.FileDescriptor var file_user_msg_proto_rawDesc = []byte{ @@ -370,14 +371,14 @@ var file_user_msg_proto_rawDesc = []byte{ 0x64, 0x65, 0x52, 0x04, 0x43, 0x6f, 0x64, 0x65, 0x22, 0x32, 0x0a, 0x0b, 0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, - 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x43, 0x0a, 0x0d, + 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x67, 0x65, 0x6e, - 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x67, 0x65, 0x6e, 0x64, 0x65, - 0x72, 0x22, 0x0f, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, - 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x2b, 0x0a, 0x0d, 0x55, 0x73, 0x65, + 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, + 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, + 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/sys/cache/user.go b/sys/cache/user.go index f2bae78cd..6f08b151a 100644 --- a/sys/cache/user.go +++ b/sys/cache/user.go @@ -3,6 +3,8 @@ package cache import ( "fmt" "go_dreamfactory/pb" + + "github.com/liwei1dao/lego/sys/log" ) const ( //Redis @@ -10,10 +12,21 @@ const ( //Redis ) type IUser interface { - User_UpdateUser(data *pb.Cache_UserData) (err error) + Update(data *pb.Cache_UserData) (err error) + Get(userId string) *pb.Cache_UserData } -func (this *Cache) User_UpdateUser(data *pb.Cache_UserData) (err error) { +func (this *Cache) Update(data *pb.Cache_UserData) (err error) { err = this.redis.Set(fmt.Sprintf(Redis_UserCache, data.UserData.UserId), data, -1) return } + +func (this *Cache) Get(userId string) *pb.Cache_UserData { + var user *pb.Cache_UserData + err := this.redis.Get(fmt.Sprintf(Redis_UserCache, userId), &user) + if err != nil { + log.Errorf("get user cache err:%v", err) + return nil + } + return user +} diff --git a/sys/cache/user_test.go b/sys/cache/user_test.go index 0f2a97533..09e8b1953 100644 --- a/sys/cache/user_test.go +++ b/sys/cache/user_test.go @@ -1,6 +1,7 @@ package cache import ( + "fmt" "go_dreamfactory/pb" "log" "testing" @@ -33,6 +34,11 @@ func TestUpdateUser(t *testing.T) { Account: "aaa", }, } - err := cache.User_UpdateUser(user) + err := cache.Update(user) require.Nil(t, err) } + +func TestGetUser(t *testing.T) { + c := cache.Get("62157") + fmt.Println(c) +} diff --git a/sys/configure/structs/MyBean.Hero.go b/sys/configure/structs/MyBean.Hero.go new file mode 100644 index 000000000..f82f8f681 --- /dev/null +++ b/sys/configure/structs/MyBean.Hero.go @@ -0,0 +1,79 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +package cfg + +import "errors" + +type MyBeanHero struct { + Id string + Name string + Star int32 + Color int32 + Chengwei int32 + Zhongzu int32 + Job int32 + Type int32 + Prefab string + Icon string + Sound string + Tujing string + Hpgrow string + Atkgrow string + Defgrow string + Speedgrow string + Hp string + Atk string + Def string + Speed string + Intr string + Events string + Cite string +} + +const TypeId_MyBeanHero = 1050121004 + +func (*MyBeanHero) GetTypeId() int32 { + return 1050121004 +} + +func (_v *MyBeanHero)Deserialize(_buf map[string]interface{}) (err error) { + { var _ok_ bool; if _v.Id, _ok_ = _buf["id"].(string); !_ok_ { err = errors.New("id error"); return } } + { var _ok_ bool; if _v.Name, _ok_ = _buf["name"].(string); !_ok_ { err = errors.New("name error"); return } } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["star"].(float64); !_ok_ { err = errors.New("star error"); return }; _v.Star = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["color"].(float64); !_ok_ { err = errors.New("color error"); return }; _v.Color = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["chengwei"].(float64); !_ok_ { err = errors.New("chengwei error"); return }; _v.Chengwei = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["zhongzu"].(float64); !_ok_ { err = errors.New("zhongzu error"); return }; _v.Zhongzu = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["job"].(float64); !_ok_ { err = errors.New("job error"); return }; _v.Job = int32(_tempNum_) } + { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["type"].(float64); !_ok_ { err = errors.New("type error"); return }; _v.Type = int32(_tempNum_) } + { var _ok_ bool; if _v.Prefab, _ok_ = _buf["prefab"].(string); !_ok_ { err = errors.New("prefab error"); return } } + { var _ok_ bool; if _v.Icon, _ok_ = _buf["icon"].(string); !_ok_ { err = errors.New("icon error"); return } } + { var _ok_ bool; if _v.Sound, _ok_ = _buf["sound"].(string); !_ok_ { err = errors.New("sound error"); return } } + { var _ok_ bool; if _v.Tujing, _ok_ = _buf["tujing"].(string); !_ok_ { err = errors.New("tujing error"); return } } + { var _ok_ bool; if _v.Hpgrow, _ok_ = _buf["hpgrow"].(string); !_ok_ { err = errors.New("hpgrow error"); return } } + { var _ok_ bool; if _v.Atkgrow, _ok_ = _buf["atkgrow"].(string); !_ok_ { err = errors.New("atkgrow error"); return } } + { var _ok_ bool; if _v.Defgrow, _ok_ = _buf["defgrow"].(string); !_ok_ { err = errors.New("defgrow error"); return } } + { var _ok_ bool; if _v.Speedgrow, _ok_ = _buf["speedgrow"].(string); !_ok_ { err = errors.New("speedgrow error"); return } } + { var _ok_ bool; if _v.Hp, _ok_ = _buf["hp"].(string); !_ok_ { err = errors.New("hp error"); return } } + { var _ok_ bool; if _v.Atk, _ok_ = _buf["atk"].(string); !_ok_ { err = errors.New("atk error"); return } } + { var _ok_ bool; if _v.Def, _ok_ = _buf["def"].(string); !_ok_ { err = errors.New("def error"); return } } + { var _ok_ bool; if _v.Speed, _ok_ = _buf["speed"].(string); !_ok_ { err = errors.New("speed error"); return } } + { var _ok_ bool; if _v.Intr, _ok_ = _buf["intr"].(string); !_ok_ { err = errors.New("intr error"); return } } + { var _ok_ bool; if _v.Events, _ok_ = _buf["events"].(string); !_ok_ { err = errors.New("events error"); return } } + { var _ok_ bool; if _v.Cite, _ok_ = _buf["cite"].(string); !_ok_ { err = errors.New("cite error"); return } } + return +} + +func DeserializeMyBeanHero(_buf map[string]interface{}) (*MyBeanHero, error) { + v := &MyBeanHero{} + if err := v.Deserialize(_buf); err == nil { + return v, nil + } else { + return nil, err + } +} diff --git a/sys/configure/structs/Tables.go b/sys/configure/structs/Tables.go index d747ebe7e..d02bc6c59 100644 --- a/sys/configure/structs/Tables.go +++ b/sys/configure/structs/Tables.go @@ -13,6 +13,7 @@ type JsonLoader func(string) ([]map[string]interface{}, error) type Tables struct { TbRewards *TbRewards TbItem *TbItem + TbHero *TbHero } func NewTables(loader JsonLoader) (*Tables, error) { @@ -32,5 +33,11 @@ func NewTables(loader JsonLoader) (*Tables, error) { if tables.TbItem, err = NewTbItem(buf) ; err != nil { return nil, err } + if buf, err = loader("tbhero") ; err != nil { + return nil, err + } + if tables.TbHero, err = NewTbHero(buf) ; err != nil { + return nil, err + } return tables, nil } diff --git a/sys/configure/structs/TbHero.go b/sys/configure/structs/TbHero.go new file mode 100644 index 000000000..4de71689b --- /dev/null +++ b/sys/configure/structs/TbHero.go @@ -0,0 +1,42 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +package cfg + +type TbHero struct { + _dataMap map[string]*MyBeanHero + _dataList []*MyBeanHero +} + +func NewTbHero(_buf []map[string]interface{}) (*TbHero, error) { + _dataList := make([]*MyBeanHero, 0, len(_buf)) + dataMap := make(map[string]*MyBeanHero) + for _, _ele_ := range _buf { + if _v, err2 := DeserializeMyBeanHero(_ele_); err2 != nil { + return nil, err2 + } else { + _dataList = append(_dataList, _v) + dataMap[_v.Id] = _v + } + } + return &TbHero{_dataList:_dataList, _dataMap:dataMap}, nil +} + +func (table *TbHero) GetDataMap() map[string]*MyBeanHero { + return table._dataMap +} + +func (table *TbHero) GetDataList() []*MyBeanHero { + return table._dataList +} + +func (table *TbHero) Get(key string) *MyBeanHero { + return table._dataMap[key] +} + + diff --git a/sys/db/user.go b/sys/db/user.go index 12b4688d5..3a57799e0 100644 --- a/sys/db/user.go +++ b/sys/db/user.go @@ -14,20 +14,21 @@ const ( //Redis ) type IUser interface { - User_FindUserByAccount(account string) (*pb.DB_UserData, error) + User_FindUserByAccount(user *pb.DB_UserData) (*pb.DB_UserData, error) User_FindUserById(id string) (*pb.DB_UserData, error) User_CreateUser(user *pb.DB_UserData) error User_UpdateUser(data *pb.DB_UserData) (err error) } -func (this *DB) User_FindUserByAccount(account string) (*pb.DB_UserData, error) { +func (this *DB) User_FindUserByAccount(user *pb.DB_UserData) (*pb.DB_UserData, error) { filter := bson.D{ - {"account", account}, + {"serverid", user.ServerId}, + {"account", user.Account}, } sr := this.mgo.FindOne(DB_UserTable, filter) - user := &pb.DB_UserData{} - err := sr.Decode(user) - return user, err + var nd *pb.DB_UserData + err := sr.Decode(&nd) + return nd, err } func (this *DB) User_FindUserById(id string) (*pb.DB_UserData, error) { @@ -53,7 +54,6 @@ func (this *DB) User_UpdateUser(data *pb.DB_UserData) (err error) { bson.M{"_id": data.UserId}, bson.M{"$set": bson.M{ "niceName": data.NiceName, - "email": data.Email, }}, options.FindOneAndUpdate().SetUpsert(false).SetReturnDocument(options.After), ).Decode(data) diff --git a/sys/db/user_test.go b/sys/db/user_test.go index b0128ad23..7c914b811 100644 --- a/sys/db/user_test.go +++ b/sys/db/user_test.go @@ -30,7 +30,7 @@ func TestCreate(t *testing.T) { user := &pb.DB_UserData{ Account: "legu3", NiceName: "乐谷3", - Email: "1111@legu.com", + ServerId: 1, } err := db.User_CreateUser(user) @@ -38,23 +38,23 @@ func TestCreate(t *testing.T) { } func TestFindOne(t *testing.T) { - user, err := db.User_FindUserById("") + user, err := db.User_FindUserById("629eb3f4132dc4bb26139659") require.Nil(t, err) - assert.Equal(t, "legu1", user.Account) + assert.Equal(t, "legu3", user.Account) - user2, err := db.User_FindUserByAccount("legu1") + // user.ServerId = 2 + user2, err := db.User_FindUserByAccount(user) require.Nil(t, err) - assert.Equal(t, "legu1", user2.Account) - + assert.Equal(t, "legu3", user2.Account) + assert.Equal(t, int32(1), user2.ServerId) } func TestUpdate(t *testing.T) { user := &pb.DB_UserData{ - UserId: primitive.NewObjectID().String(), - Email: "new@qq.com", + UserId: primitive.NewObjectID().Hex(), } err := db.User_UpdateUser(user) require.Nil(t, err) - assert.Equal(t, "new@qq.com", user.Email) + assert.Equal(t, "NiceName", "") } diff --git a/utils/base64.go b/utils/base64.go new file mode 100644 index 000000000..74176f126 --- /dev/null +++ b/utils/base64.go @@ -0,0 +1,37 @@ +package utils + +import ( + "encoding/base64" + "strings" + + "github.com/liwei1dao/lego/sys/log" +) + +func Base64Encode(data []byte) string { + return base64.StdEncoding.EncodeToString(data) +} + +func Base64Decode(data string) string { + b, err := base64.StdEncoding.DecodeString(data) + if err != nil { + log.Errorf("base64 decode", err) + return "" + } + return string(b) +} + +func ValidSecretKey(secStr string) bool { + if !strings.HasPrefix(secStr, "CE:") || len(secStr) < 35 { + return false + } + + clientMd5Key := secStr[3:35] + rawmsg := secStr[35:] + log.Debugf("data base: %s", rawmsg) + serverMd5Key := MD5Str(rawmsg) + // s := fmt.Sprintf("%x", serverMd5Key) + if !strings.EqualFold(strings.ToLower(serverMd5Key), strings.ToLower(clientMd5Key)) { + return false + } + return true +} From f85141f6f8f6aecf26679bfa92940be0839e4b72 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 7 Jun 2022 17:28:00 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/mail/api_comp.go | 55 +++- pb/mail.pb.go | 337 ---------------------- pb/mail_db.pb.go | 282 +++++++++++++++++++ pb/mail_msg.pb.go | 584 +++++++++++++++++++++++++++++++++++++++ pb/proto/mail.proto | 21 -- pb/proto/mail_db.proto | 23 ++ pb/proto/mail_msg.proto | 39 +++ pb/user_db.pb.go | 6 +- pb_2.7.py | 3 +- sys/cache/mail.go | 52 ++-- sys/db/mail.go | 26 +- 11 files changed, 1041 insertions(+), 387 deletions(-) delete mode 100644 pb/mail.pb.go create mode 100644 pb/mail_db.pb.go create mode 100644 pb/mail_msg.pb.go delete mode 100644 pb/proto/mail.proto create mode 100644 pb/proto/mail_db.proto create mode 100644 pb/proto/mail_msg.proto diff --git a/modules/mail/api_comp.go b/modules/mail/api_comp.go index 4c938fc40..5221d3806 100644 --- a/modules/mail/api_comp.go +++ b/modules/mail/api_comp.go @@ -1,14 +1,25 @@ package mail import ( + "context" + "go_dreamfactory/comm" "go_dreamfactory/modules" + "go_dreamfactory/pb" + "go_dreamfactory/sys/cache" "github.com/liwei1dao/lego/core" + "github.com/liwei1dao/lego/sys/log" ) const ( - QueryUserMailReq = "mail.queryusermailreq" - QueryUserMailResp = "mail.queryusermailresp" + QueryUserMailReq = "mail.queryusermailreq" + QueryUserMailResp = "mail.queryusermailresp" + ReadUserMailReq = "mail.readusermailreq" + ReadUserMailResp = "mail.readusermailresp" + GetUserMailAttachmentReq = "mail.getusermailattachmentreq" + GetUserMailAttachmentResp = "mail.getusermailattachmentresp" + DelUserMailReq = "mail.delusermailreq" + DelUserMailResp = "mail.delusermailresp" ) type Api_Comp struct { @@ -21,3 +32,43 @@ func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core this.module = module.(*Mail) return } + +func (this *Api_Comp) QueryUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.QueryUserMailResp) (err error) { + + code := pb.ErrorCode_Success + mailinfo := make([]*pb.DB_MailData, 0) + defer func() { + session.SendMsg("mail", "queryusermailresp", code, &pb.QueryUserMailResp{Mails: mailinfo}) + }() + if session.GetUserId() == "" { + code = pb.ErrorCode_NoLogin + return + } + if mailinfo, err = cache.Defsys.QueryUserMail(session.GetUserId()); err != nil { + log.Errorf("QueryUserMailResp err:%v", err) + code = pb.ErrorCode_CacheReadError + return + } + + return +} + +func (this *Api_Comp) ReadUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.ReadUserMailResp) (err error) { + var ( + code pb.ErrorCode + mail *pb.DB_MailData + ) + defer func() { + session.SendMsg(string(this.module.GetType()), "readusermailresp", code, &pb.ReadUserMailResp{Mail: mail}) + }() + + return +} + +func (this *Api_Comp) GetUserMailAttachmentReq(ctx context.Context, session comm.IUserSession, req *pb.GetUserMailAttachmentResp) (err error) { + return +} + +func (this *Api_Comp) DelUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.DelUserMailResp) (err error) { + return +} diff --git a/pb/mail.pb.go b/pb/mail.pb.go deleted file mode 100644 index e5e2522b9..000000000 --- a/pb/mail.pb.go +++ /dev/null @@ -1,337 +0,0 @@ -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.0 -// protoc v3.20.0 -// source: mail.proto - -package pb - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type MailAttachment struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Itemid uint32 `protobuf:"varint,1,opt,name=Itemid,proto3" json:"Itemid,omitempty"` // 道具iD - ItemCount uint32 `protobuf:"varint,2,opt,name=ItemCount,proto3" json:"ItemCount,omitempty"` // 数量 -} - -func (x *MailAttachment) Reset() { - *x = MailAttachment{} - if protoimpl.UnsafeEnabled { - mi := &file_mail_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MailAttachment) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MailAttachment) ProtoMessage() {} - -func (x *MailAttachment) ProtoReflect() protoreflect.Message { - mi := &file_mail_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use MailAttachment.ProtoReflect.Descriptor instead. -func (*MailAttachment) Descriptor() ([]byte, []int) { - return file_mail_proto_rawDescGZIP(), []int{0} -} - -func (x *MailAttachment) GetItemid() uint32 { - if x != nil { - return x.Itemid - } - return 0 -} - -func (x *MailAttachment) GetItemCount() uint32 { - if x != nil { - return x.ItemCount - } - return 0 -} - -type MailData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Title string `protobuf:"bytes,1,opt,name=Title,proto3" json:"Title,omitempty"` // 邮件标题 - Contex string `protobuf:"bytes,2,opt,name=Contex,proto3" json:"Contex,omitempty"` // 邮件内容 - CreateTime uint64 `protobuf:"varint,3,opt,name=CreateTime,proto3" json:"CreateTime,omitempty"` // 发送时间 - DueTime uint64 `protobuf:"varint,4,opt,name=DueTime,proto3" json:"DueTime,omitempty"` // 过期时间 - Check bool `protobuf:"varint,5,opt,name=Check,proto3" json:"Check,omitempty"` // 是否查看 - Items []*MailAttachment `protobuf:"bytes,6,rep,name=Items,proto3" json:"Items,omitempty"` // 附件 -} - -func (x *MailData) Reset() { - *x = MailData{} - if protoimpl.UnsafeEnabled { - mi := &file_mail_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *MailData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*MailData) ProtoMessage() {} - -func (x *MailData) ProtoReflect() protoreflect.Message { - mi := &file_mail_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use MailData.ProtoReflect.Descriptor instead. -func (*MailData) Descriptor() ([]byte, []int) { - return file_mail_proto_rawDescGZIP(), []int{1} -} - -func (x *MailData) GetTitle() string { - if x != nil { - return x.Title - } - return "" -} - -func (x *MailData) GetContex() string { - if x != nil { - return x.Contex - } - return "" -} - -func (x *MailData) GetCreateTime() uint64 { - if x != nil { - return x.CreateTime - } - return 0 -} - -func (x *MailData) GetDueTime() uint64 { - if x != nil { - return x.DueTime - } - return 0 -} - -func (x *MailData) GetCheck() bool { - if x != nil { - return x.Check - } - return false -} - -func (x *MailData) GetItems() []*MailAttachment { - if x != nil { - return x.Items - } - return nil -} - -type DB_UserMailData struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - UserId string `bson:"_id" json:"UserId,omitempty" protobuf:"bytes,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}用户Id - Mails []*MailData `protobuf:"bytes,2,rep,name=mails,proto3" json:"mails,omitempty"` // 邮件列表 -} - -func (x *DB_UserMailData) Reset() { - *x = DB_UserMailData{} - if protoimpl.UnsafeEnabled { - mi := &file_mail_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DB_UserMailData) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DB_UserMailData) ProtoMessage() {} - -func (x *DB_UserMailData) ProtoReflect() protoreflect.Message { - mi := &file_mail_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DB_UserMailData.ProtoReflect.Descriptor instead. -func (*DB_UserMailData) Descriptor() ([]byte, []int) { - return file_mail_proto_rawDescGZIP(), []int{2} -} - -func (x *DB_UserMailData) GetUserId() string { - if x != nil { - return x.UserId - } - return "" -} - -func (x *DB_UserMailData) GetMails() []*MailData { - if x != nil { - return x.Mails - } - return nil -} - -var File_mail_proto protoreflect.FileDescriptor - -var file_mail_proto_rawDesc = []byte{ - 0x0a, 0x0a, 0x6d, 0x61, 0x69, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x46, 0x0a, 0x0e, - 0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x16, - 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, - 0x49, 0x74, 0x65, 0x6d, 0x69, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x49, 0x74, 0x65, 0x6d, 0x43, 0x6f, - 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x49, 0x74, 0x65, 0x6d, 0x43, - 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xaf, 0x01, 0x0a, 0x08, 0x4d, 0x61, 0x69, 0x6c, 0x44, 0x61, 0x74, - 0x61, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x43, 0x6f, 0x6e, 0x74, 0x65, - 0x78, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x12, - 0x1e, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x03, 0x20, - 0x01, 0x28, 0x04, 0x52, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, - 0x18, 0x0a, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x04, - 0x52, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x43, 0x68, 0x65, - 0x63, 0x6b, 0x18, 0x05, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x12, - 0x25, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x06, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, - 0x2e, 0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, - 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x22, 0x4a, 0x0a, 0x0f, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, - 0x72, 0x4d, 0x61, 0x69, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, - 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, - 0x64, 0x12, 0x1f, 0x0a, 0x05, 0x6d, 0x61, 0x69, 0x6c, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, - 0x32, 0x09, 0x2e, 0x4d, 0x61, 0x69, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x6d, 0x61, 0x69, - 0x6c, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, -} - -var ( - file_mail_proto_rawDescOnce sync.Once - file_mail_proto_rawDescData = file_mail_proto_rawDesc -) - -func file_mail_proto_rawDescGZIP() []byte { - file_mail_proto_rawDescOnce.Do(func() { - file_mail_proto_rawDescData = protoimpl.X.CompressGZIP(file_mail_proto_rawDescData) - }) - return file_mail_proto_rawDescData -} - -var file_mail_proto_msgTypes = make([]protoimpl.MessageInfo, 3) -var file_mail_proto_goTypes = []interface{}{ - (*MailAttachment)(nil), // 0: MailAttachment - (*MailData)(nil), // 1: MailData - (*DB_UserMailData)(nil), // 2: DB_UserMailData -} -var file_mail_proto_depIdxs = []int32{ - 0, // 0: MailData.Items:type_name -> MailAttachment - 1, // 1: DB_UserMailData.mails:type_name -> MailData - 2, // [2:2] is the sub-list for method output_type - 2, // [2:2] is the sub-list for method input_type - 2, // [2:2] is the sub-list for extension type_name - 2, // [2:2] is the sub-list for extension extendee - 0, // [0:2] is the sub-list for field type_name -} - -func init() { file_mail_proto_init() } -func file_mail_proto_init() { - if File_mail_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_mail_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MailAttachment); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_mail_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*MailData); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_mail_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DB_UserMailData); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_mail_proto_rawDesc, - NumEnums: 0, - NumMessages: 3, - NumExtensions: 0, - NumServices: 0, - }, - GoTypes: file_mail_proto_goTypes, - DependencyIndexes: file_mail_proto_depIdxs, - MessageInfos: file_mail_proto_msgTypes, - }.Build() - File_mail_proto = out.File - file_mail_proto_rawDesc = nil - file_mail_proto_goTypes = nil - file_mail_proto_depIdxs = nil -} diff --git a/pb/mail_db.pb.go b/pb/mail_db.pb.go new file mode 100644 index 000000000..629a68696 --- /dev/null +++ b/pb/mail_db.pb.go @@ -0,0 +1,282 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.0 +// source: mail_db.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type MailAttachment struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ItemId uint32 `protobuf:"varint,1,opt,name=ItemId,proto3" json:"ItemId,omitempty"` // 道具iD + ItemCount uint32 `protobuf:"varint,2,opt,name=ItemCount,proto3" json:"ItemCount,omitempty"` // 数量 +} + +func (x *MailAttachment) Reset() { + *x = MailAttachment{} + if protoimpl.UnsafeEnabled { + mi := &file_mail_db_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *MailAttachment) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*MailAttachment) ProtoMessage() {} + +func (x *MailAttachment) ProtoReflect() protoreflect.Message { + mi := &file_mail_db_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use MailAttachment.ProtoReflect.Descriptor instead. +func (*MailAttachment) Descriptor() ([]byte, []int) { + return file_mail_db_proto_rawDescGZIP(), []int{0} +} + +func (x *MailAttachment) GetItemId() uint32 { + if x != nil { + return x.ItemId + } + return 0 +} + +func (x *MailAttachment) GetItemCount() uint32 { + if x != nil { + return x.ItemCount + } + return 0 +} + +type DB_MailData struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ObjId string `bson:"_id" json:"ObjId,omitempty" protobuf:"bytes,1,opt,name=ObjId,proto3"` // tags:{bson:"_id"} + UserId string `protobuf:"bytes,2,opt,name=UserId,proto3" json:"UserId,omitempty"` + Title string `protobuf:"bytes,3,opt,name=Title,proto3" json:"Title,omitempty"` // 邮件标题 + Contex string `protobuf:"bytes,4,opt,name=Contex,proto3" json:"Contex,omitempty"` // 邮件内容 + CreateTime uint64 `protobuf:"varint,5,opt,name=CreateTime,proto3" json:"CreateTime,omitempty"` // 发送时间 + DueTime uint64 `protobuf:"varint,6,opt,name=DueTime,proto3" json:"DueTime,omitempty"` // 过期时间 + Check bool `protobuf:"varint,7,opt,name=Check,proto3" json:"Check,omitempty"` // 是否查看 + Items []*MailAttachment `protobuf:"bytes,8,rep,name=Items,proto3" json:"Items,omitempty"` // 附件 +} + +func (x *DB_MailData) Reset() { + *x = DB_MailData{} + if protoimpl.UnsafeEnabled { + mi := &file_mail_db_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DB_MailData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DB_MailData) ProtoMessage() {} + +func (x *DB_MailData) ProtoReflect() protoreflect.Message { + mi := &file_mail_db_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DB_MailData.ProtoReflect.Descriptor instead. +func (*DB_MailData) Descriptor() ([]byte, []int) { + return file_mail_db_proto_rawDescGZIP(), []int{1} +} + +func (x *DB_MailData) GetObjId() string { + if x != nil { + return x.ObjId + } + return "" +} + +func (x *DB_MailData) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +func (x *DB_MailData) GetTitle() string { + if x != nil { + return x.Title + } + return "" +} + +func (x *DB_MailData) GetContex() string { + if x != nil { + return x.Contex + } + return "" +} + +func (x *DB_MailData) GetCreateTime() uint64 { + if x != nil { + return x.CreateTime + } + return 0 +} + +func (x *DB_MailData) GetDueTime() uint64 { + if x != nil { + return x.DueTime + } + return 0 +} + +func (x *DB_MailData) GetCheck() bool { + if x != nil { + return x.Check + } + return false +} + +func (x *DB_MailData) GetItems() []*MailAttachment { + if x != nil { + return x.Items + } + return nil +} + +var File_mail_db_proto protoreflect.FileDescriptor + +var file_mail_db_proto_rawDesc = []byte{ + 0x0a, 0x0d, 0x6d, 0x61, 0x69, 0x6c, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x46, 0x0a, 0x0e, 0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, + 0x74, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x49, 0x74, 0x65, + 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x49, 0x74, + 0x65, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xe0, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x4d, + 0x61, 0x69, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x12, 0x16, 0x0a, + 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, + 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x54, 0x69, 0x74, 0x6c, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x43, + 0x6f, 0x6e, 0x74, 0x65, 0x78, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x43, 0x6f, 0x6e, + 0x74, 0x65, 0x78, 0x12, 0x1e, 0x0a, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, 0x69, 0x6d, + 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x54, + 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x06, + 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, + 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x43, 0x68, + 0x65, 0x63, 0x6b, 0x12, 0x25, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x08, 0x20, 0x03, + 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, + 0x65, 0x6e, 0x74, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, + 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_mail_db_proto_rawDescOnce sync.Once + file_mail_db_proto_rawDescData = file_mail_db_proto_rawDesc +) + +func file_mail_db_proto_rawDescGZIP() []byte { + file_mail_db_proto_rawDescOnce.Do(func() { + file_mail_db_proto_rawDescData = protoimpl.X.CompressGZIP(file_mail_db_proto_rawDescData) + }) + return file_mail_db_proto_rawDescData +} + +var file_mail_db_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_mail_db_proto_goTypes = []interface{}{ + (*MailAttachment)(nil), // 0: MailAttachment + (*DB_MailData)(nil), // 1: DB_MailData +} +var file_mail_db_proto_depIdxs = []int32{ + 0, // 0: DB_MailData.Items:type_name -> MailAttachment + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_mail_db_proto_init() } +func file_mail_db_proto_init() { + if File_mail_db_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_mail_db_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*MailAttachment); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mail_db_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DB_MailData); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_mail_db_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_mail_db_proto_goTypes, + DependencyIndexes: file_mail_db_proto_depIdxs, + MessageInfos: file_mail_db_proto_msgTypes, + }.Build() + File_mail_db_proto = out.File + file_mail_db_proto_rawDesc = nil + file_mail_db_proto_goTypes = nil + file_mail_db_proto_depIdxs = nil +} diff --git a/pb/mail_msg.pb.go b/pb/mail_msg.pb.go new file mode 100644 index 000000000..6034a2005 --- /dev/null +++ b/pb/mail_msg.pb.go @@ -0,0 +1,584 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.0 +// source: mail_msg.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type QueryUserMailReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *QueryUserMailReq) Reset() { + *x = QueryUserMailReq{} + if protoimpl.UnsafeEnabled { + mi := &file_mail_msg_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryUserMailReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryUserMailReq) ProtoMessage() {} + +func (x *QueryUserMailReq) ProtoReflect() protoreflect.Message { + mi := &file_mail_msg_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use QueryUserMailReq.ProtoReflect.Descriptor instead. +func (*QueryUserMailReq) Descriptor() ([]byte, []int) { + return file_mail_msg_proto_rawDescGZIP(), []int{0} +} + +// 查询邮件信息 +type QueryUserMailResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Mails []*DB_MailData `protobuf:"bytes,1,rep,name=Mails,proto3" json:"Mails,omitempty"` +} + +func (x *QueryUserMailResp) Reset() { + *x = QueryUserMailResp{} + if protoimpl.UnsafeEnabled { + mi := &file_mail_msg_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *QueryUserMailResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*QueryUserMailResp) ProtoMessage() {} + +func (x *QueryUserMailResp) ProtoReflect() protoreflect.Message { + mi := &file_mail_msg_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use QueryUserMailResp.ProtoReflect.Descriptor instead. +func (*QueryUserMailResp) Descriptor() ([]byte, []int) { + return file_mail_msg_proto_rawDescGZIP(), []int{1} +} + +func (x *QueryUserMailResp) GetMails() []*DB_MailData { + if x != nil { + return x.Mails + } + return nil +} + +// 查看邮件 +type ReadUserMailReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ObjID string `protobuf:"bytes,1,opt,name=ObjID,proto3" json:"ObjID,omitempty"` +} + +func (x *ReadUserMailReq) Reset() { + *x = ReadUserMailReq{} + if protoimpl.UnsafeEnabled { + mi := &file_mail_msg_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReadUserMailReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadUserMailReq) ProtoMessage() {} + +func (x *ReadUserMailReq) ProtoReflect() protoreflect.Message { + mi := &file_mail_msg_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadUserMailReq.ProtoReflect.Descriptor instead. +func (*ReadUserMailReq) Descriptor() ([]byte, []int) { + return file_mail_msg_proto_rawDescGZIP(), []int{2} +} + +func (x *ReadUserMailReq) GetObjID() string { + if x != nil { + return x.ObjID + } + return "" +} + +type ReadUserMailResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Mail *DB_MailData `protobuf:"bytes,1,opt,name=Mail,proto3" json:"Mail,omitempty"` +} + +func (x *ReadUserMailResp) Reset() { + *x = ReadUserMailResp{} + if protoimpl.UnsafeEnabled { + mi := &file_mail_msg_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *ReadUserMailResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ReadUserMailResp) ProtoMessage() {} + +func (x *ReadUserMailResp) ProtoReflect() protoreflect.Message { + mi := &file_mail_msg_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use ReadUserMailResp.ProtoReflect.Descriptor instead. +func (*ReadUserMailResp) Descriptor() ([]byte, []int) { + return file_mail_msg_proto_rawDescGZIP(), []int{3} +} + +func (x *ReadUserMailResp) GetMail() *DB_MailData { + if x != nil { + return x.Mail + } + return nil +} + +// 领取附件 +type GetUserMailAttachmentReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ObjID string `protobuf:"bytes,1,opt,name=ObjID,proto3" json:"ObjID,omitempty"` +} + +func (x *GetUserMailAttachmentReq) Reset() { + *x = GetUserMailAttachmentReq{} + if protoimpl.UnsafeEnabled { + mi := &file_mail_msg_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetUserMailAttachmentReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserMailAttachmentReq) ProtoMessage() {} + +func (x *GetUserMailAttachmentReq) ProtoReflect() protoreflect.Message { + mi := &file_mail_msg_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetUserMailAttachmentReq.ProtoReflect.Descriptor instead. +func (*GetUserMailAttachmentReq) Descriptor() ([]byte, []int) { + return file_mail_msg_proto_rawDescGZIP(), []int{4} +} + +func (x *GetUserMailAttachmentReq) GetObjID() string { + if x != nil { + return x.ObjID + } + return "" +} + +type GetUserMailAttachmentResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Mail *DB_MailData `protobuf:"bytes,1,opt,name=Mail,proto3" json:"Mail,omitempty"` +} + +func (x *GetUserMailAttachmentResp) Reset() { + *x = GetUserMailAttachmentResp{} + if protoimpl.UnsafeEnabled { + mi := &file_mail_msg_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *GetUserMailAttachmentResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GetUserMailAttachmentResp) ProtoMessage() {} + +func (x *GetUserMailAttachmentResp) ProtoReflect() protoreflect.Message { + mi := &file_mail_msg_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GetUserMailAttachmentResp.ProtoReflect.Descriptor instead. +func (*GetUserMailAttachmentResp) Descriptor() ([]byte, []int) { + return file_mail_msg_proto_rawDescGZIP(), []int{5} +} + +func (x *GetUserMailAttachmentResp) GetMail() *DB_MailData { + if x != nil { + return x.Mail + } + return nil +} + +// 删除某个邮件 +type DelUserMailReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + ObjID string `protobuf:"bytes,1,opt,name=ObjID,proto3" json:"ObjID,omitempty"` +} + +func (x *DelUserMailReq) Reset() { + *x = DelUserMailReq{} + if protoimpl.UnsafeEnabled { + mi := &file_mail_msg_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DelUserMailReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DelUserMailReq) ProtoMessage() {} + +func (x *DelUserMailReq) ProtoReflect() protoreflect.Message { + mi := &file_mail_msg_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DelUserMailReq.ProtoReflect.Descriptor instead. +func (*DelUserMailReq) Descriptor() ([]byte, []int) { + return file_mail_msg_proto_rawDescGZIP(), []int{6} +} + +func (x *DelUserMailReq) GetObjID() string { + if x != nil { + return x.ObjID + } + return "" +} + +type DelUserMailResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Mail []*DB_MailData `protobuf:"bytes,1,rep,name=Mail,proto3" json:"Mail,omitempty"` +} + +func (x *DelUserMailResp) Reset() { + *x = DelUserMailResp{} + if protoimpl.UnsafeEnabled { + mi := &file_mail_msg_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *DelUserMailResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*DelUserMailResp) ProtoMessage() {} + +func (x *DelUserMailResp) ProtoReflect() protoreflect.Message { + mi := &file_mail_msg_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use DelUserMailResp.ProtoReflect.Descriptor instead. +func (*DelUserMailResp) Descriptor() ([]byte, []int) { + return file_mail_msg_proto_rawDescGZIP(), []int{7} +} + +func (x *DelUserMailResp) GetMail() []*DB_MailData { + if x != nil { + return x.Mail + } + return nil +} + +var File_mail_msg_proto protoreflect.FileDescriptor + +var file_mail_msg_proto_rawDesc = []byte{ + 0x0a, 0x0e, 0x6d, 0x61, 0x69, 0x6c, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x1a, 0x0d, 0x6d, 0x61, 0x69, 0x6c, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, + 0x12, 0x0a, 0x10, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x61, 0x69, 0x6c, + 0x52, 0x65, 0x71, 0x22, 0x37, 0x0a, 0x11, 0x51, 0x75, 0x65, 0x72, 0x79, 0x55, 0x73, 0x65, 0x72, + 0x4d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x22, 0x0a, 0x05, 0x4d, 0x61, 0x69, 0x6c, + 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x5f, 0x4d, 0x61, 0x69, + 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x05, 0x4d, 0x61, 0x69, 0x6c, 0x73, 0x22, 0x27, 0x0a, 0x0f, + 0x52, 0x65, 0x61, 0x64, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x12, + 0x14, 0x0a, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, + 0x4f, 0x62, 0x6a, 0x49, 0x44, 0x22, 0x34, 0x0a, 0x10, 0x52, 0x65, 0x61, 0x64, 0x55, 0x73, 0x65, + 0x72, 0x4d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x20, 0x0a, 0x04, 0x4d, 0x61, 0x69, + 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x5f, 0x4d, 0x61, 0x69, + 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x4d, 0x61, 0x69, 0x6c, 0x22, 0x30, 0x0a, 0x18, 0x47, + 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, + 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x71, 0x12, 0x14, 0x0a, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x44, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x44, 0x22, 0x3d, 0x0a, + 0x19, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61, + 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x20, 0x0a, 0x04, 0x4d, 0x61, + 0x69, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x5f, 0x4d, 0x61, + 0x69, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x4d, 0x61, 0x69, 0x6c, 0x22, 0x26, 0x0a, 0x0e, + 0x44, 0x65, 0x6c, 0x55, 0x73, 0x65, 0x72, 0x4d, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x14, + 0x0a, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x44, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4f, + 0x62, 0x6a, 0x49, 0x44, 0x22, 0x33, 0x0a, 0x0f, 0x44, 0x65, 0x6c, 0x55, 0x73, 0x65, 0x72, 0x4d, + 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x20, 0x0a, 0x04, 0x4d, 0x61, 0x69, 0x6c, 0x18, + 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42, 0x5f, 0x4d, 0x61, 0x69, 0x6c, 0x44, + 0x61, 0x74, 0x61, 0x52, 0x04, 0x4d, 0x61, 0x69, 0x6c, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, + 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_mail_msg_proto_rawDescOnce sync.Once + file_mail_msg_proto_rawDescData = file_mail_msg_proto_rawDesc +) + +func file_mail_msg_proto_rawDescGZIP() []byte { + file_mail_msg_proto_rawDescOnce.Do(func() { + file_mail_msg_proto_rawDescData = protoimpl.X.CompressGZIP(file_mail_msg_proto_rawDescData) + }) + return file_mail_msg_proto_rawDescData +} + +var file_mail_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 8) +var file_mail_msg_proto_goTypes = []interface{}{ + (*QueryUserMailReq)(nil), // 0: QueryUserMailReq + (*QueryUserMailResp)(nil), // 1: QueryUserMailResp + (*ReadUserMailReq)(nil), // 2: ReadUserMailReq + (*ReadUserMailResp)(nil), // 3: ReadUserMailResp + (*GetUserMailAttachmentReq)(nil), // 4: GetUserMailAttachmentReq + (*GetUserMailAttachmentResp)(nil), // 5: GetUserMailAttachmentResp + (*DelUserMailReq)(nil), // 6: DelUserMailReq + (*DelUserMailResp)(nil), // 7: DelUserMailResp + (*DB_MailData)(nil), // 8: DB_MailData +} +var file_mail_msg_proto_depIdxs = []int32{ + 8, // 0: QueryUserMailResp.Mails:type_name -> DB_MailData + 8, // 1: ReadUserMailResp.Mail:type_name -> DB_MailData + 8, // 2: GetUserMailAttachmentResp.Mail:type_name -> DB_MailData + 8, // 3: DelUserMailResp.Mail:type_name -> DB_MailData + 4, // [4:4] is the sub-list for method output_type + 4, // [4:4] is the sub-list for method input_type + 4, // [4:4] is the sub-list for extension type_name + 4, // [4:4] is the sub-list for extension extendee + 0, // [0:4] is the sub-list for field type_name +} + +func init() { file_mail_msg_proto_init() } +func file_mail_msg_proto_init() { + if File_mail_msg_proto != nil { + return + } + file_mail_db_proto_init() + if !protoimpl.UnsafeEnabled { + file_mail_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryUserMailReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mail_msg_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*QueryUserMailResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mail_msg_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReadUserMailReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mail_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*ReadUserMailResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mail_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetUserMailAttachmentReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mail_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*GetUserMailAttachmentResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mail_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DelUserMailReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_mail_msg_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*DelUserMailResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_mail_msg_proto_rawDesc, + NumEnums: 0, + NumMessages: 8, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_mail_msg_proto_goTypes, + DependencyIndexes: file_mail_msg_proto_depIdxs, + MessageInfos: file_mail_msg_proto_msgTypes, + }.Build() + File_mail_msg_proto = out.File + file_mail_msg_proto_rawDesc = nil + file_mail_msg_proto_goTypes = nil + file_mail_msg_proto_depIdxs = nil +} diff --git a/pb/proto/mail.proto b/pb/proto/mail.proto deleted file mode 100644 index 6c3c4f54c..000000000 --- a/pb/proto/mail.proto +++ /dev/null @@ -1,21 +0,0 @@ -syntax = "proto3"; -option go_package = ".;pb"; - -message MailAttachment { // 附件 - uint32 Itemid = 1; // 道具iD - uint32 ItemCount = 2; // 数量 -} - -message MailData { - string Title = 1; // 邮件标题 - string Contex = 2; // 邮件内容 - uint64 CreateTime = 3; // 发送时间 - uint64 DueTime = 4; // 过期时间 - bool Check = 5; // 是否查看 - repeated MailAttachment Items = 6; // 附件 -} - -message DB_UserMailData { - string UserId = 1; //tags:{bson:"_id"}用户Id - repeated MailData mails = 2; // 邮件列表 -} \ No newline at end of file diff --git a/pb/proto/mail_db.proto b/pb/proto/mail_db.proto new file mode 100644 index 000000000..532b97a72 --- /dev/null +++ b/pb/proto/mail_db.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; +option go_package = ".;pb"; + +// message Cache_mailData { +// string UserID = 1; +// repeated DB_MailData MailData = 2; +// } + +message MailAttachment { // 附件 + uint32 ItemId = 1; // 道具iD + uint32 ItemCount = 2; // 数量 +} + +message DB_MailData { + string ObjId = 1; // tags:{bson:"_id"} + string UserId = 2; + string Title = 3; // 邮件标题 + string Contex = 4; // 邮件内容 + uint64 CreateTime = 5; // 发送时间 + uint64 DueTime = 6; // 过期时间 + bool Check = 7; // 是否查看 + repeated MailAttachment Items = 8; // 附件 +} diff --git a/pb/proto/mail_msg.proto b/pb/proto/mail_msg.proto new file mode 100644 index 000000000..024ed1a70 --- /dev/null +++ b/pb/proto/mail_msg.proto @@ -0,0 +1,39 @@ +syntax = "proto3"; +option go_package = ".;pb"; +import "mail_db.proto"; + +message QueryUserMailReq { + +} + +// 查询邮件信息 +message QueryUserMailResp { + repeated DB_MailData Mails = 1; +} + +// 查看邮件 +message ReadUserMailReq { + string ObjID = 1; +} + +message ReadUserMailResp { + DB_MailData Mail = 1; +} + +// 领取附件 +message GetUserMailAttachmentReq { + string ObjID = 1; +} + +message GetUserMailAttachmentResp { + DB_MailData Mail = 1; +} + +// 删除某个邮件 +message DelUserMailReq { + string ObjID = 1; +} + +message DelUserMailResp { + repeated DB_MailData Mail = 1; +} diff --git a/pb/user_db.pb.go b/pb/user_db.pb.go index 2c4b65c99..b4c44f448 100644 --- a/pb/user_db.pb.go +++ b/pb/user_db.pb.go @@ -89,7 +89,7 @@ type DB_UserData struct { unknownFields protoimpl.UnknownFields UserId string `bson:"_id" json:"UserId,omitempty" protobuf:"bytes,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}动态Id - Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"` + Account string `protobuf:"bytes,2,opt,name=Account,proto3" json:"Account,omitempty"` NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"` Email string `protobuf:"bytes,4,opt,name=Email,proto3" json:"Email,omitempty"` Password string `protobuf:"bytes,5,opt,name=Password,proto3" json:"Password,omitempty"` @@ -177,8 +177,8 @@ var file_user_db_proto_rawDesc = []byte{ 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x22, 0x8d, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18, - 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x65, + 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x61, diff --git a/pb_2.7.py b/pb_2.7.py index e5e9d74fb..8d377aab1 100644 --- a/pb_2.7.py +++ b/pb_2.7.py @@ -31,4 +31,5 @@ buildProto('./pb/proto','./pb','user_db') buildProto('./pb/proto','./pb','user_msg') buildProto('./pb/proto','./pb','pack_db') buildProto('./pb/proto','./pb','pack_msg') -buildProto('./pb/proto','./pb','mail') \ No newline at end of file +buildProto('./pb/proto','./pb','mail_db') +buildProto('./pb/proto','./pb','mail_msg') \ No newline at end of file diff --git a/sys/cache/mail.go b/sys/cache/mail.go index d42970c83..1dfb8c1b8 100644 --- a/sys/cache/mail.go +++ b/sys/cache/mail.go @@ -1,12 +1,8 @@ package cache import ( - "fmt" "go_dreamfactory/pb" "go_dreamfactory/sys/db" - - "github.com/liwei1dao/lego/sys/mgo" - "github.com/liwei1dao/lego/sys/redis" ) const ( //Redis @@ -14,22 +10,42 @@ const ( //Redis ) type IMail interface { - QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error) + QueryUserMail(uId string) (mail []*pb.DB_MailData, err error) + InsertUserMail(uId string) (mail []*pb.DB_MailData, err error) + ReadOneMail(uId string, ObjId string) (mail *pb.DB_MailData, err error) } // 查询玩家邮件数据 -func (this *Cache) QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error) { - mail = &pb.DB_UserMailData{ - UserId: uId, - } - if err = this.redis.Get(fmt.Sprintf(Redis_MailCache, uId), mail); err == nil { - return - } else if err == redis.RedisNil { - if mail, err = db.Defsys.QueryUserMail(uId); err == nil { - this.redis.Set(fmt.Sprintf(Redis_MailCache, uId), mail, -1) - } else if err == mgo.MongodbNil { - err = nil - } - } +func (this *Cache) QueryUserMail(uId string) (mail []*pb.DB_MailData, err error) { + // var result []interface{} + // if result, err = this.redis.HGetAll(fmt.Sprintf(Redis_MailCache, uId), reflect.TypeOf(&pb.DB_MailData{})); err != nil { + // return + // } else { + // mail = make([]*pb.DB_MailData, len(result)) + // for i, v := range result { + // mail[i] = v.(*pb.DB_MailData) + // } + // } + // 邮件暂时不写redis + mail, _ = db.Defsys.QueryUserMail(uId) + + // } else if err == redis.RedisNil { + // if mail, err = db.Defsys.QueryUserMail(uId); err == nil { + // this.redis.Set(fmt.Sprintf(Redis_MailCache, uId), mail, -1) + // } else if err == mgo.MongodbNil { + // err = nil + // } + // } + return +} + +// 创建新的邮件 +func (this *Cache) ReadOneMail(uId string, ObjId string) (mail *pb.DB_MailData, err error) { + + return +} + +func (this *Cache) InsertUserMail(uId string) (mail []*pb.DB_MailData, err error) { + return } diff --git a/sys/db/mail.go b/sys/db/mail.go index 5772e2e42..2d2434eed 100644 --- a/sys/db/mail.go +++ b/sys/db/mail.go @@ -1,22 +1,38 @@ package db import ( + "context" "go_dreamfactory/pb" "github.com/liwei1dao/lego/core" "go.mongodb.org/mongo-driver/bson" + "go.mongodb.org/mongo-driver/bson/primitive" ) -const ( //Redis +const ( DB_MailTable core.SqlTable = "mail" ) type IMail interface { - QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error) + QueryUserMail(uId string) (mail []*pb.DB_MailData, err error) + InsertUserMail(mail *pb.DB_MailData) (err error) } -func (this *DB) QueryUserMail(uId string) (mail *pb.DB_UserMailData, err error) { - mail = &pb.DB_UserMailData{} - err = this.mgo.FindOne(DB_MailTable, bson.M{"_id": uId}).Decode(mail) +func (this *DB) QueryUserMail(uId string) (mail []*pb.DB_MailData, err error) { + + if _data, err := this.mgo.Find(DB_MailTable, bson.M{"userid": uId}); err == nil { + for _data.Next(context.TODO()) { + temp := &pb.DB_MailData{} + if err = _data.Decode(temp); err == nil { + mail = append(mail, temp) + } + } + } return } + +func (this *DB) InsertUserMail(mail *pb.DB_MailData) (err error) { + mail.ObjId = primitive.NewObjectID().Hex() + _, err = this.mgo.InsertOne(DB_MailTable, mail) + return err +} From 804880162059ac3ff438079c5f2e2acc1dc11d82 Mon Sep 17 00:00:00 2001 From: zhaocy Date: Tue, 7 Jun 2022 18:14:49 +0800 Subject: [PATCH 5/7] =?UTF-8?q?=E5=88=9B=E8=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/robot/robot.go | 3 +++ cmd/robot/user.go | 26 +++++++++++++++++++-- modules/user/login_comp.go | 5 ++-- modules/user/user_comp.go | 16 +++++++++++++ pb/mail.pb.go | 2 +- pb/pack_db.pb.go | 2 +- pb/proto/user_db.proto | 1 + pb/proto/user_msg.proto | 2 +- pb/user_db.pb.go | 37 +++++++++++++++++++----------- pb/user_msg.pb.go | 17 +++----------- utils/trace.go | 47 ++++++++++++++++++++++++++++++++++++++ 11 files changed, 124 insertions(+), 34 deletions(-) create mode 100644 utils/trace.go diff --git a/cmd/robot/robot.go b/cmd/robot/robot.go index 785194e23..a1977c903 100644 --- a/cmd/robot/robot.go +++ b/cmd/robot/robot.go @@ -63,6 +63,7 @@ func (r *Robot) Run() { //模块处理 func (r *Robot) handleMsg(msg *pb.UserMessage) { + log.Printf("route: %s.%s", msg.MainType, msg.SubType) switch msg.MainType { case "user": r.handleUserMsg(msg) @@ -73,6 +74,8 @@ func (r *Robot) handleMsg(msg *pb.UserMessage) { //在这里添加玩家成功登录以后的测试方法 func (r *Robot) onUserLoaded() { + //user + r.CreateUser("user671") } diff --git a/cmd/robot/user.go b/cmd/robot/user.go index b204d9268..0d9da8e52 100644 --- a/cmd/robot/user.go +++ b/cmd/robot/user.go @@ -4,6 +4,8 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/pb" "log" + + "google.golang.org/protobuf/proto" ) func (r *Robot) handleUserMsg(msg *pb.UserMessage) { @@ -33,10 +35,30 @@ func handleLogin(r *Robot, msg *pb.UserMessage) { } func handleCreateUser(r *Robot, msg *pb.UserMessage) { - + rsp := &pb.UserCreateRsp{} + if !comm.ProtoDecode(msg, rsp) { + return + } + log.Printf("创角返回: %v", rsp) } //创角色 -func (r *Robot) CreateUser() { +func (r *Robot) CreateUser(NickName string) { + req := &pb.UserCreateReq{ + NickName: NickName, + } + + head := &pb.UserMessage{ + MainType: "user", + SubType: "create", + } + + if comm.ProtoEncode(req, head) { + data, _ := proto.Marshal(head) + err := r.SendToClient(data) + if err != nil { + log.Fatal(err) + } + } } diff --git a/modules/user/login_comp.go b/modules/user/login_comp.go index 85106b8ba..c0d74080a 100644 --- a/modules/user/login_comp.go +++ b/modules/user/login_comp.go @@ -67,10 +67,11 @@ func (this *LoginComp) Login(ctx context.Context, session comm.IUserSession, req log.Errorf("User_CreateUser err %v", err) return err } + session.Build(user.UserId) + } else { + session.Build(db_user.UserId) } - session.Build(user.UserId) - cache_user := &pb.Cache_UserData{ SessionId: session.GetSessionId(), GatewayServiceId: session.GetGatewayServiceId(), diff --git a/modules/user/user_comp.go b/modules/user/user_comp.go index 8d5c3126c..90b9c9d2a 100644 --- a/modules/user/user_comp.go +++ b/modules/user/user_comp.go @@ -5,8 +5,11 @@ import ( "go_dreamfactory/comm" "go_dreamfactory/modules" "go_dreamfactory/pb" + "go_dreamfactory/sys/cache" + "go_dreamfactory/utils" "github.com/liwei1dao/lego/core" + "github.com/liwei1dao/lego/sys/log" ) type UserComp struct { @@ -22,6 +25,19 @@ func (this *UserComp) Init(service core.IService, module core.IModule, comp core //创角 func (this *UserComp) Create(ctx context.Context, session comm.IUserSession, req *pb.UserCreateReq) error { + defer utils.TraceFunc(session.GetUserId(), "user", "create", req, nil) + user := cache.Defsys.Get(session.GetUserId()) + if user == nil { + log.Errorf("user no exist") + session.SendMsg("user", "create", pb.ErrorCode_UserSessionNobeing, nil) + return nil + } + user.UserData.NiceName = req.NickName + err := cache.Defsys.Update(user) + if err != nil { + log.Errorf("cache update err") + } + session.SendMsg("user", "create", pb.ErrorCode_Success, &pb.UserCreateRsp{}) return nil } diff --git a/pb/mail.pb.go b/pb/mail.pb.go index e5e2522b9..5f8e0a3a3 100644 --- a/pb/mail.pb.go +++ b/pb/mail.pb.go @@ -167,7 +167,7 @@ type DB_UserMailData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UserId string `bson:"_id" json:"UserId,omitempty" protobuf:"bytes,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}用户Id + UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}用户Id Mails []*MailData `protobuf:"bytes,2,rep,name=mails,proto3" json:"mails,omitempty"` // 邮件列表 } diff --git a/pb/pack_db.pb.go b/pb/pack_db.pb.go index 0dc1074bd..6dd9577bf 100644 --- a/pb/pack_db.pb.go +++ b/pb/pack_db.pb.go @@ -139,7 +139,7 @@ type DB_UserPackData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UserId string `bson:"_id" json:"UserId,omitempty" protobuf:"bytes,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}用户Id + UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}用户Id Pack []*GridData `protobuf:"bytes,2,rep,name=Pack,proto3" json:"Pack,omitempty"` //背包列表 } diff --git a/pb/proto/user_db.proto b/pb/proto/user_db.proto index 46a2b4fb0..95ce91c15 100644 --- a/pb/proto/user_db.proto +++ b/pb/proto/user_db.proto @@ -12,4 +12,5 @@ message DB_UserData { string Account = 2; string NiceName = 3; int32 ServerId = 4; + int32 FriendPoint = 5;//友情点 } \ No newline at end of file diff --git a/pb/proto/user_msg.proto b/pb/proto/user_msg.proto index 88f64d141..3458babd1 100644 --- a/pb/proto/user_msg.proto +++ b/pb/proto/user_msg.proto @@ -31,5 +31,5 @@ message UserCreateReq{ } message UserCreateRsp{ - string NickName = 1; + } \ No newline at end of file diff --git a/pb/user_db.pb.go b/pb/user_db.pb.go index 06bb4caf5..44e8928d7 100644 --- a/pb/user_db.pb.go +++ b/pb/user_db.pb.go @@ -88,10 +88,11 @@ type DB_UserData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - UserId string `bson:"_id" json:"UserId,omitempty" protobuf:"bytes,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}动态Id - Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account,omitempty"` - NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"` - ServerId int32 `protobuf:"varint,4,opt,name=ServerId,proto3" json:"ServerId,omitempty"` + UserId string `protobuf:"bytes,1,opt,name=UserId,proto3" json:"UserId,omitempty" bson:"_id"` //tags:{bson:"_id"}动态Id + Account string `protobuf:"bytes,2,opt,name=Account,proto3" json:"Account,omitempty"` + NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"` + ServerId int32 `protobuf:"varint,4,opt,name=ServerId,proto3" json:"ServerId,omitempty"` + FriendPoint int32 `protobuf:"varint,5,opt,name=FriendPoint,proto3" json:"FriendPoint,omitempty"` //友情点 } func (x *DB_UserData) Reset() { @@ -154,6 +155,13 @@ func (x *DB_UserData) GetServerId() int32 { return 0 } +func (x *DB_UserData) GetFriendPoint() int32 { + if x != nil { + return x.FriendPoint + } + return 0 +} + var File_user_db_proto protoreflect.FileDescriptor var file_user_db_proto_rawDesc = []byte{ @@ -166,15 +174,18 @@ var file_user_db_proto_rawDesc = []byte{ 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, 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, 0x77, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, - 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18, 0x0a, - 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, - 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x65, 0x4e, - 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x65, 0x4e, - 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, - 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x42, - 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x22, 0x99, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73, + 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18, + 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x65, + 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x65, + 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, + 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, + 0x12, 0x20, 0x0a, 0x0b, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x18, + 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, + 0x6e, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/pb/user_msg.pb.go b/pb/user_msg.pb.go index 83f6141cc..58f347003 100644 --- a/pb/user_msg.pb.go +++ b/pb/user_msg.pb.go @@ -308,8 +308,6 @@ type UserCreateRsp struct { state protoimpl.MessageState sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - - NickName string `protobuf:"bytes,1,opt,name=NickName,proto3" json:"NickName,omitempty"` } func (x *UserCreateRsp) Reset() { @@ -344,13 +342,6 @@ func (*UserCreateRsp) Descriptor() ([]byte, []int) { return file_user_msg_proto_rawDescGZIP(), []int{6} } -func (x *UserCreateRsp) GetNickName() string { - if x != nil { - return x.NickName - } - return "" -} - var File_user_msg_proto protoreflect.FileDescriptor var file_user_msg_proto_rawDesc = []byte{ @@ -374,11 +365,9 @@ var file_user_msg_proto_rawDesc = []byte{ 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x2b, 0x0a, 0x0d, 0x55, 0x73, 0x65, - 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, - 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, - 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x0f, 0x0a, 0x0d, 0x55, 0x73, 0x65, + 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, + 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/utils/trace.go b/utils/trace.go new file mode 100644 index 000000000..ccea0c2af --- /dev/null +++ b/utils/trace.go @@ -0,0 +1,47 @@ +package utils + +import ( + "fmt" + "runtime" + "time" + + "github.com/liwei1dao/lego/sys/log" +) + +const ( + UID = "uid" + Module = "module" + FuncName = "funcName" + FuncArgs = "funcArgs" + FuncRsp = "response" + TimeCost = "timeCost" +) + +//打印函数处理信息 +func TraceFunc(uid string, module string, funcName string, funcArgs interface{}, rsp interface{}) { + log.Debugf("traceFunc uid:%s module:%s funcName:%s funcArgs:%v", uid, module, funcName, funcArgs) +} + +//打印函数处理时间 +func TraceTimeCost(funcName string, invocation time.Time) { + elapsed := time.Since(invocation) + cost := elapsed.Milliseconds() + lg := fmt.Sprintf("funcName:%s timeCost:%v", funcName, cost) + + if cost < 20 { + log.Debugf(lg) + return + } + log.Warnf(lg) +} + +//打印异常 +func TraceError(err error) (b bool) { + if err != nil { + pc, fn, line, _ := runtime.Caller(1) + + log.Errorf("[error] in %s[%s:%d] %v", runtime.FuncForPC(pc).Name(), fn, line, err) + b = true + } + return +} From c5e99c66045aa75b42374e3ab3ce54ee5bdd2d47 Mon Sep 17 00:00:00 2001 From: zhaocy Date: Tue, 7 Jun 2022 19:45:52 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E5=A5=BD=E5=8F=8B=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- comm/core.go | 11 +- modules/friend/friend_comp.go | 67 ++ modules/friend/module.go | 33 + pb/friend_db.pb.go | 146 ++++ pb/friend_msg.pb.go | 1520 +++++++++++++++++++++++++++++++++ pb/mail_db.pb.go | 2 +- pb/proto/friend_db.proto | 8 + pb/proto/friend_msg.proto | 111 +++ pb/proto/user_db.proto | 1 + pb/user_db.pb.go | 15 +- pb_2.7.py | 4 +- 11 files changed, 1908 insertions(+), 10 deletions(-) create mode 100644 modules/friend/friend_comp.go create mode 100644 modules/friend/module.go create mode 100644 pb/friend_db.pb.go create mode 100644 pb/friend_msg.pb.go create mode 100644 pb/proto/friend_db.proto create mode 100644 pb/proto/friend_msg.proto diff --git a/comm/core.go b/comm/core.go index 48650a254..f2357dc7b 100644 --- a/comm/core.go +++ b/comm/core.go @@ -14,11 +14,12 @@ const ( ) const ( - SM_GateModule core.M_Modules = "gateway" //gate模块 网关服务模块 - SM_WebModule core.M_Modules = "web" //web模块 - SM_UserModule core.M_Modules = "user" //用户模块 - SM_PackModule core.M_Modules = "pack" //背包模块 - SM_MailModule core.M_Modules = "mail" //邮件模块 + SM_GateModule core.M_Modules = "gateway" //gate模块 网关服务模块 + SM_WebModule core.M_Modules = "web" //web模块 + SM_UserModule core.M_Modules = "user" //用户模块 + SM_PackModule core.M_Modules = "pack" //背包模块 + SM_MailModule core.M_Modules = "mail" //邮件模块 + SM_FriendModule core.M_Modules = "friend" //好友模块 ) const ( //Rpc diff --git a/modules/friend/friend_comp.go b/modules/friend/friend_comp.go new file mode 100644 index 000000000..b7b51d720 --- /dev/null +++ b/modules/friend/friend_comp.go @@ -0,0 +1,67 @@ +package friend + +import ( + "context" + "go_dreamfactory/comm" + "go_dreamfactory/modules" + "go_dreamfactory/pb" +) + +type FriendComp struct { + modules.MComp_GateComp +} + +//搜索 +func (this *FriendComp) Search(ctx context.Context, session comm.IUserSession, req *pb.FriendSearchReq) error { + return nil +} + +//添加好友 +func (this *FriendComp) Add(ctx context.Context, session comm.IUserSession, req *pb.FriendAddReq) error { + return nil +} + +//删除好友 +func (this *FriendComp) Del(ctx context.Context, session comm.IUserSession, req *pb.FriendDelReq) error { + return nil +} + +//好友列表 +func (this *FriendComp) List(ctx context.Context, session comm.IUserSession, req *pb.FriendListReq) error { + return nil +} + +//同意或拒绝 +func (this *FriendComp) Check(ctx context.Context, session comm.IUserSession, req *pb.FriendAgreeOrRefuseReq) error { + return nil +} + +//批量同意或拒绝 +func (this *FriendComp) CheckAll(ctx context.Context, session comm.IUserSession, req *pb.FriendAgreeOrRefuseReq) error { + return nil +} + +//赠送或接收 +func (this *FriendComp) ReceSend(ctx context.Context, session comm.IUserSession, req *pb.FriendReceiveOrSendReq) error { + return nil +} + +//好友数量 +func (this *FriendComp) Total(ctx context.Context, session comm.IUserSession, req *pb.FriendTotalReq) error { + return nil +} + +//好友详情 +func (this *FriendComp) Detail(ctx context.Context, session comm.IUserSession, req *pb.FriendTotalReq) error { + return nil +} + +//黑名单 +func (this *FriendComp) Blacklist(ctx context.Context, session comm.IUserSession, req *pb.FriendBlackListReq) error { + return nil +} + +//加入黑名单 +func (this *FriendComp) Addblack(ctx context.Context, session comm.IUserSession, req *pb.FriendBlackAddReq) error { + return nil +} diff --git a/modules/friend/module.go b/modules/friend/module.go new file mode 100644 index 000000000..8ff8b3e6a --- /dev/null +++ b/modules/friend/module.go @@ -0,0 +1,33 @@ +package friend + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/modules" + + "github.com/liwei1dao/lego/core" +) + +func NewModule() core.IModule { + m := new(Friend) + return m +} + +type Friend struct { + modules.ModuleBase + +} + +func (this *Friend) GetType() core.M_Modules { + return comm.SM_UserModule +} + +func (this *Friend) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) { + err = this.ModuleBase.Init(service, module, options) + + return +} + +func (this *Friend) OnInstallComp() { + this.ModuleBase.OnInstallComp() + +} diff --git a/pb/friend_db.pb.go b/pb/friend_db.pb.go new file mode 100644 index 000000000..6112889fe --- /dev/null +++ b/pb/friend_db.pb.go @@ -0,0 +1,146 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.0 +// source: friend_db.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Friend struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserData *DB_UserData `protobuf:"bytes,1,opt,name=UserData,proto3" json:"UserData,omitempty"` //用户 +} + +func (x *Friend) Reset() { + *x = Friend{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_db_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Friend) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Friend) ProtoMessage() {} + +func (x *Friend) ProtoReflect() protoreflect.Message { + mi := &file_friend_db_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Friend.ProtoReflect.Descriptor instead. +func (*Friend) Descriptor() ([]byte, []int) { + return file_friend_db_proto_rawDescGZIP(), []int{0} +} + +func (x *Friend) GetUserData() *DB_UserData { + if x != nil { + return x.UserData + } + return nil +} + +var File_friend_db_proto protoreflect.FileDescriptor + +var file_friend_db_proto_rawDesc = []byte{ + 0x0a, 0x0f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x1a, 0x0d, 0x75, 0x73, 0x65, 0x72, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x22, 0x32, 0x0a, 0x06, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x12, 0x28, 0x0a, 0x08, 0x55, 0x73, + 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 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, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_friend_db_proto_rawDescOnce sync.Once + file_friend_db_proto_rawDescData = file_friend_db_proto_rawDesc +) + +func file_friend_db_proto_rawDescGZIP() []byte { + file_friend_db_proto_rawDescOnce.Do(func() { + file_friend_db_proto_rawDescData = protoimpl.X.CompressGZIP(file_friend_db_proto_rawDescData) + }) + return file_friend_db_proto_rawDescData +} + +var file_friend_db_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_friend_db_proto_goTypes = []interface{}{ + (*Friend)(nil), // 0: Friend + (*DB_UserData)(nil), // 1: DB_UserData +} +var file_friend_db_proto_depIdxs = []int32{ + 1, // 0: Friend.UserData:type_name -> DB_UserData + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_friend_db_proto_init() } +func file_friend_db_proto_init() { + if File_friend_db_proto != nil { + return + } + file_user_db_proto_init() + if !protoimpl.UnsafeEnabled { + file_friend_db_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Friend); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_friend_db_proto_rawDesc, + NumEnums: 0, + NumMessages: 1, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_friend_db_proto_goTypes, + DependencyIndexes: file_friend_db_proto_depIdxs, + MessageInfos: file_friend_db_proto_msgTypes, + }.Build() + File_friend_db_proto = out.File + file_friend_db_proto_rawDesc = nil + file_friend_db_proto_goTypes = nil + file_friend_db_proto_depIdxs = nil +} diff --git a/pb/friend_msg.pb.go b/pb/friend_msg.pb.go new file mode 100644 index 000000000..da58871e6 --- /dev/null +++ b/pb/friend_msg.pb.go @@ -0,0 +1,1520 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.0 +// protoc v3.20.0 +// source: friend_msg.proto + +package pb + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type FriendBase struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserId string `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` //ID + NickName string `protobuf:"bytes,2,opt,name=NickName,proto3" json:"NickName,omitempty"` //昵称 + Level int32 `protobuf:"varint,3,opt,name=level,proto3" json:"level,omitempty"` //等级 + Avatar int32 `protobuf:"varint,4,opt,name=avatar,proto3" json:"avatar,omitempty"` //头像 + Strength int64 `protobuf:"varint,5,opt,name=strength,proto3" json:"strength,omitempty"` //战力 + ServerId int32 `protobuf:"varint,6,opt,name=serverId,proto3" json:"serverId,omitempty"` //服务编号 + OfflineTime int64 `protobuf:"varint,7,opt,name=offlineTime,proto3" json:"offlineTime,omitempty"` //最近一次下线时间 0在线 +} + +func (x *FriendBase) Reset() { + *x = FriendBase{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendBase) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendBase) ProtoMessage() {} + +func (x *FriendBase) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendBase.ProtoReflect.Descriptor instead. +func (*FriendBase) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{0} +} + +func (x *FriendBase) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +func (x *FriendBase) GetNickName() string { + if x != nil { + return x.NickName + } + return "" +} + +func (x *FriendBase) GetLevel() int32 { + if x != nil { + return x.Level + } + return 0 +} + +func (x *FriendBase) GetAvatar() int32 { + if x != nil { + return x.Avatar + } + return 0 +} + +func (x *FriendBase) GetStrength() int64 { + if x != nil { + return x.Strength + } + return 0 +} + +func (x *FriendBase) GetServerId() int32 { + if x != nil { + return x.ServerId + } + return 0 +} + +func (x *FriendBase) GetOfflineTime() int64 { + if x != nil { + return x.OfflineTime + } + return 0 +} + +//好友列表 +type FriendListReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *FriendListReq) Reset() { + *x = FriendListReq{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendListReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendListReq) ProtoMessage() {} + +func (x *FriendListReq) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendListReq.ProtoReflect.Descriptor instead. +func (*FriendListReq) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{1} +} + +type FriendListRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + List []*Friend `protobuf:"bytes,1,rep,name=list,proto3" json:"list,omitempty"` +} + +func (x *FriendListRsp) Reset() { + *x = FriendListRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendListRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendListRsp) ProtoMessage() {} + +func (x *FriendListRsp) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendListRsp.ProtoReflect.Descriptor instead. +func (*FriendListRsp) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{2} +} + +func (x *FriendListRsp) GetList() []*Friend { + if x != nil { + return x.List + } + return nil +} + +//添加好友 +type FriendAddReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FriendId string `protobuf:"bytes,1,opt,name=friendId,proto3" json:"friendId,omitempty"` //好友ID +} + +func (x *FriendAddReq) Reset() { + *x = FriendAddReq{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendAddReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendAddReq) ProtoMessage() {} + +func (x *FriendAddReq) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendAddReq.ProtoReflect.Descriptor instead. +func (*FriendAddReq) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{3} +} + +func (x *FriendAddReq) GetFriendId() string { + if x != nil { + return x.FriendId + } + return "" +} + +type FriendAddRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + UserId string `protobuf:"bytes,1,opt,name=userId,proto3" json:"userId,omitempty"` //用户ID +} + +func (x *FriendAddRsp) Reset() { + *x = FriendAddRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[4] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendAddRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendAddRsp) ProtoMessage() {} + +func (x *FriendAddRsp) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[4] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendAddRsp.ProtoReflect.Descriptor instead. +func (*FriendAddRsp) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{4} +} + +func (x *FriendAddRsp) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +//删除好友 +type FriendDelReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FriendId string `protobuf:"bytes,1,opt,name=friendId,proto3" json:"friendId,omitempty"` //好友ID +} + +func (x *FriendDelReq) Reset() { + *x = FriendDelReq{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[5] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendDelReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendDelReq) ProtoMessage() {} + +func (x *FriendDelReq) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[5] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendDelReq.ProtoReflect.Descriptor instead. +func (*FriendDelReq) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{5} +} + +func (x *FriendDelReq) GetFriendId() string { + if x != nil { + return x.FriendId + } + return "" +} + +type FriendDelRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FriendId string `protobuf:"bytes,1,opt,name=friendId,proto3" json:"friendId,omitempty"` //好友ID + UserId string `protobuf:"bytes,2,opt,name=userId,proto3" json:"userId,omitempty"` //用户ID +} + +func (x *FriendDelRsp) Reset() { + *x = FriendDelRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[6] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendDelRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendDelRsp) ProtoMessage() {} + +func (x *FriendDelRsp) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[6] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendDelRsp.ProtoReflect.Descriptor instead. +func (*FriendDelRsp) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{6} +} + +func (x *FriendDelRsp) GetFriendId() string { + if x != nil { + return x.FriendId + } + return "" +} + +func (x *FriendDelRsp) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +//同意或拒绝 +type FriendAgreeOrRefuseReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FriendId string `protobuf:"bytes,1,opt,name=friendId,proto3" json:"friendId,omitempty"` //被同意或拒绝的用户 + IsAgree bool `protobuf:"varint,2,opt,name=isAgree,proto3" json:"isAgree,omitempty"` +} + +func (x *FriendAgreeOrRefuseReq) Reset() { + *x = FriendAgreeOrRefuseReq{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[7] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendAgreeOrRefuseReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendAgreeOrRefuseReq) ProtoMessage() {} + +func (x *FriendAgreeOrRefuseReq) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[7] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendAgreeOrRefuseReq.ProtoReflect.Descriptor instead. +func (*FriendAgreeOrRefuseReq) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{7} +} + +func (x *FriendAgreeOrRefuseReq) GetFriendId() string { + if x != nil { + return x.FriendId + } + return "" +} + +func (x *FriendAgreeOrRefuseReq) GetIsAgree() bool { + if x != nil { + return x.IsAgree + } + return false +} + +type FriendAgressOrRefuseRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Num int32 `protobuf:"varint,1,opt,name=Num,proto3" json:"Num,omitempty"` //操作的数量 + IsAgree bool `protobuf:"varint,2,opt,name=isAgree,proto3" json:"isAgree,omitempty"` +} + +func (x *FriendAgressOrRefuseRsp) Reset() { + *x = FriendAgressOrRefuseRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendAgressOrRefuseRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendAgressOrRefuseRsp) ProtoMessage() {} + +func (x *FriendAgressOrRefuseRsp) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[8] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendAgressOrRefuseRsp.ProtoReflect.Descriptor instead. +func (*FriendAgressOrRefuseRsp) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{8} +} + +func (x *FriendAgressOrRefuseRsp) GetNum() int32 { + if x != nil { + return x.Num + } + return 0 +} + +func (x *FriendAgressOrRefuseRsp) GetIsAgree() bool { + if x != nil { + return x.IsAgree + } + return false +} + +//好友申请列表 +type FriendApplyListReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *FriendApplyListReq) Reset() { + *x = FriendApplyListReq{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[9] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendApplyListReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendApplyListReq) ProtoMessage() {} + +func (x *FriendApplyListReq) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[9] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendApplyListReq.ProtoReflect.Descriptor instead. +func (*FriendApplyListReq) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{9} +} + +type FriendApplyListRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *FriendApplyListRsp) Reset() { + *x = FriendApplyListRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendApplyListRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendApplyListRsp) ProtoMessage() {} + +func (x *FriendApplyListRsp) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[10] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendApplyListRsp.ProtoReflect.Descriptor instead. +func (*FriendApplyListRsp) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{10} +} + +//好友搜索 +type FriendSearchReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FriendId string `protobuf:"bytes,1,opt,name=friendId,proto3" json:"friendId,omitempty"` + NickName string `protobuf:"bytes,2,opt,name=nickName,proto3" json:"nickName,omitempty"` //好友昵称 +} + +func (x *FriendSearchReq) Reset() { + *x = FriendSearchReq{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendSearchReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendSearchReq) ProtoMessage() {} + +func (x *FriendSearchReq) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[11] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendSearchReq.ProtoReflect.Descriptor instead. +func (*FriendSearchReq) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{11} +} + +func (x *FriendSearchReq) GetFriendId() string { + if x != nil { + return x.FriendId + } + return "" +} + +func (x *FriendSearchReq) GetNickName() string { + if x != nil { + return x.NickName + } + return "" +} + +type FriendSearchRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Friends []*FriendBase `protobuf:"bytes,1,rep,name=friends,proto3" json:"friends,omitempty"` +} + +func (x *FriendSearchRsp) Reset() { + *x = FriendSearchRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendSearchRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendSearchRsp) ProtoMessage() {} + +func (x *FriendSearchRsp) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[12] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendSearchRsp.ProtoReflect.Descriptor instead. +func (*FriendSearchRsp) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{12} +} + +func (x *FriendSearchRsp) GetFriends() []*FriendBase { + if x != nil { + return x.Friends + } + return nil +} + +//黑名单 +type FriendBlackListReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *FriendBlackListReq) Reset() { + *x = FriendBlackListReq{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[13] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendBlackListReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendBlackListReq) ProtoMessage() {} + +func (x *FriendBlackListReq) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[13] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendBlackListReq.ProtoReflect.Descriptor instead. +func (*FriendBlackListReq) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{13} +} + +type FriendBlackListRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Friends []*FriendBase `protobuf:"bytes,1,rep,name=friends,proto3" json:"friends,omitempty"` +} + +func (x *FriendBlackListRsp) Reset() { + *x = FriendBlackListRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[14] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendBlackListRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendBlackListRsp) ProtoMessage() {} + +func (x *FriendBlackListRsp) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[14] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendBlackListRsp.ProtoReflect.Descriptor instead. +func (*FriendBlackListRsp) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{14} +} + +func (x *FriendBlackListRsp) GetFriends() []*FriendBase { + if x != nil { + return x.Friends + } + return nil +} + +//添加黑名单 +type FriendBlackAddReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FriendId string `protobuf:"bytes,1,opt,name=friendId,proto3" json:"friendId,omitempty"` +} + +func (x *FriendBlackAddReq) Reset() { + *x = FriendBlackAddReq{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[15] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendBlackAddReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendBlackAddReq) ProtoMessage() {} + +func (x *FriendBlackAddReq) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[15] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendBlackAddReq.ProtoReflect.Descriptor instead. +func (*FriendBlackAddReq) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{15} +} + +func (x *FriendBlackAddReq) GetFriendId() string { + if x != nil { + return x.FriendId + } + return "" +} + +type FriendBlackAddRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FriendId string `protobuf:"bytes,1,opt,name=friendId,proto3" json:"friendId,omitempty"` + UserId string `protobuf:"bytes,2,opt,name=userId,proto3" json:"userId,omitempty"` +} + +func (x *FriendBlackAddRsp) Reset() { + *x = FriendBlackAddRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[16] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendBlackAddRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendBlackAddRsp) ProtoMessage() {} + +func (x *FriendBlackAddRsp) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[16] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendBlackAddRsp.ProtoReflect.Descriptor instead. +func (*FriendBlackAddRsp) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{16} +} + +func (x *FriendBlackAddRsp) GetFriendId() string { + if x != nil { + return x.FriendId + } + return "" +} + +func (x *FriendBlackAddRsp) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +//赠送或接收 +type FriendReceiveOrSendReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FriendId string `protobuf:"bytes,1,opt,name=friendId,proto3" json:"friendId,omitempty"` + IsReceive bool `protobuf:"varint,2,opt,name=isReceive,proto3" json:"isReceive,omitempty"` +} + +func (x *FriendReceiveOrSendReq) Reset() { + *x = FriendReceiveOrSendReq{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[17] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendReceiveOrSendReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendReceiveOrSendReq) ProtoMessage() {} + +func (x *FriendReceiveOrSendReq) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[17] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendReceiveOrSendReq.ProtoReflect.Descriptor instead. +func (*FriendReceiveOrSendReq) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{17} +} + +func (x *FriendReceiveOrSendReq) GetFriendId() string { + if x != nil { + return x.FriendId + } + return "" +} + +func (x *FriendReceiveOrSendReq) GetIsReceive() bool { + if x != nil { + return x.IsReceive + } + return false +} + +type FriendReceiveOrSendRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FriendId string `protobuf:"bytes,1,opt,name=friendId,proto3" json:"friendId,omitempty"` + UserId string `protobuf:"bytes,2,opt,name=userId,proto3" json:"userId,omitempty"` + IsReceive bool `protobuf:"varint,3,opt,name=isReceive,proto3" json:"isReceive,omitempty"` +} + +func (x *FriendReceiveOrSendRsp) Reset() { + *x = FriendReceiveOrSendRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[18] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendReceiveOrSendRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendReceiveOrSendRsp) ProtoMessage() {} + +func (x *FriendReceiveOrSendRsp) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[18] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendReceiveOrSendRsp.ProtoReflect.Descriptor instead. +func (*FriendReceiveOrSendRsp) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{18} +} + +func (x *FriendReceiveOrSendRsp) GetFriendId() string { + if x != nil { + return x.FriendId + } + return "" +} + +func (x *FriendReceiveOrSendRsp) GetUserId() string { + if x != nil { + return x.UserId + } + return "" +} + +func (x *FriendReceiveOrSendRsp) GetIsReceive() bool { + if x != nil { + return x.IsReceive + } + return false +} + +//好友数量 +type FriendTotalReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FriendId string `protobuf:"bytes,1,opt,name=friendId,proto3" json:"friendId,omitempty"` +} + +func (x *FriendTotalReq) Reset() { + *x = FriendTotalReq{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[19] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendTotalReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendTotalReq) ProtoMessage() {} + +func (x *FriendTotalReq) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[19] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendTotalReq.ProtoReflect.Descriptor instead. +func (*FriendTotalReq) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{19} +} + +func (x *FriendTotalReq) GetFriendId() string { + if x != nil { + return x.FriendId + } + return "" +} + +type FriendTotalRsp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + FriendId string `protobuf:"bytes,1,opt,name=friendId,proto3" json:"friendId,omitempty"` + Total int32 `protobuf:"varint,2,opt,name=total,proto3" json:"total,omitempty"` //好友数量 +} + +func (x *FriendTotalRsp) Reset() { + *x = FriendTotalRsp{} + if protoimpl.UnsafeEnabled { + mi := &file_friend_msg_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *FriendTotalRsp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*FriendTotalRsp) ProtoMessage() {} + +func (x *FriendTotalRsp) ProtoReflect() protoreflect.Message { + mi := &file_friend_msg_proto_msgTypes[20] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use FriendTotalRsp.ProtoReflect.Descriptor instead. +func (*FriendTotalRsp) Descriptor() ([]byte, []int) { + return file_friend_msg_proto_rawDescGZIP(), []int{20} +} + +func (x *FriendTotalRsp) GetFriendId() string { + if x != nil { + return x.FriendId + } + return "" +} + +func (x *FriendTotalRsp) GetTotal() int32 { + if x != nil { + return x.Total + } + return 0 +} + +var File_friend_msg_proto protoreflect.FileDescriptor + +var file_friend_msg_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x6d, 0x73, 0x67, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x1a, 0x0f, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x5f, 0x64, 0x62, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x22, 0xc8, 0x01, 0x0a, 0x0a, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, + 0x73, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, + 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, + 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x12, 0x16, 0x0a, 0x06, + 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x61, 0x76, + 0x61, 0x74, 0x61, 0x72, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x74, 0x72, 0x65, 0x6e, 0x67, 0x74, 0x68, + 0x18, 0x05, 0x20, 0x01, 0x28, 0x03, 0x52, 0x08, 0x73, 0x74, 0x72, 0x65, 0x6e, 0x67, 0x74, 0x68, + 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, 0x06, 0x20, 0x01, + 0x28, 0x05, 0x52, 0x08, 0x73, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, + 0x6f, 0x66, 0x66, 0x6c, 0x69, 0x6e, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x03, 0x52, 0x0b, 0x6f, 0x66, 0x66, 0x6c, 0x69, 0x6e, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x22, 0x0f, + 0x0a, 0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, + 0x2c, 0x0a, 0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x73, 0x70, + 0x12, 0x1b, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, + 0x2e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x2a, 0x0a, + 0x0c, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, + 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x22, 0x26, 0x0a, 0x0c, 0x46, 0x72, 0x69, + 0x65, 0x6e, 0x64, 0x41, 0x64, 0x64, 0x52, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, + 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, + 0x64, 0x22, 0x2a, 0x0a, 0x0c, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x44, 0x65, 0x6c, 0x52, 0x65, + 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x22, 0x42, 0x0a, + 0x0c, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x44, 0x65, 0x6c, 0x52, 0x73, 0x70, 0x12, 0x1a, 0x0a, + 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, + 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, + 0x64, 0x22, 0x4e, 0x0a, 0x16, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x67, 0x72, 0x65, 0x65, + 0x4f, 0x72, 0x52, 0x65, 0x66, 0x75, 0x73, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, + 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, + 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x69, 0x73, 0x41, 0x67, 0x72, + 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, 0x07, 0x69, 0x73, 0x41, 0x67, 0x72, 0x65, + 0x65, 0x22, 0x45, 0x0a, 0x17, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x67, 0x72, 0x65, 0x73, + 0x73, 0x4f, 0x72, 0x52, 0x65, 0x66, 0x75, 0x73, 0x65, 0x52, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, + 0x4e, 0x75, 0x6d, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x4e, 0x75, 0x6d, 0x12, 0x18, + 0x0a, 0x07, 0x69, 0x73, 0x41, 0x67, 0x72, 0x65, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x07, 0x69, 0x73, 0x41, 0x67, 0x72, 0x65, 0x65, 0x22, 0x14, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, + 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, 0x14, + 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x4c, 0x69, 0x73, + 0x74, 0x52, 0x73, 0x70, 0x22, 0x49, 0x0a, 0x0f, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, + 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, + 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, + 0x64, 0x49, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, + 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x6e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x22, + 0x38, 0x0a, 0x0f, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, + 0x73, 0x70, 0x12, 0x25, 0x0a, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, + 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, + 0x52, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x22, 0x14, 0x0a, 0x12, 0x46, 0x72, 0x69, + 0x65, 0x6e, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x22, + 0x3b, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4c, 0x69, + 0x73, 0x74, 0x52, 0x73, 0x70, 0x12, 0x25, 0x0a, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, + 0x61, 0x73, 0x65, 0x52, 0x07, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x22, 0x2f, 0x0a, 0x11, + 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x41, 0x64, 0x64, 0x52, 0x65, + 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x22, 0x47, 0x0a, + 0x11, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x41, 0x64, 0x64, 0x52, + 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x16, + 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x22, 0x52, 0x0a, 0x16, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, + 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x4f, 0x72, 0x53, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x71, + 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, + 0x69, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08, 0x52, + 0x09, 0x69, 0x73, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x22, 0x6a, 0x0a, 0x16, 0x46, 0x72, + 0x69, 0x65, 0x6e, 0x64, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x4f, 0x72, 0x53, 0x65, 0x6e, + 0x64, 0x52, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x49, 0x64, + 0x12, 0x16, 0x0a, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x06, 0x75, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73, 0x52, 0x65, + 0x63, 0x65, 0x69, 0x76, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x52, + 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x22, 0x2c, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, + 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, + 0x6e, 0x64, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, + 0x6e, 0x64, 0x49, 0x64, 0x22, 0x42, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x6f, + 0x74, 0x61, 0x6c, 0x52, 0x73, 0x70, 0x12, 0x1a, 0x0a, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, + 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, + 0x49, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x18, 0x02, 0x20, 0x01, 0x28, + 0x05, 0x52, 0x05, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, + 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_friend_msg_proto_rawDescOnce sync.Once + file_friend_msg_proto_rawDescData = file_friend_msg_proto_rawDesc +) + +func file_friend_msg_proto_rawDescGZIP() []byte { + file_friend_msg_proto_rawDescOnce.Do(func() { + file_friend_msg_proto_rawDescData = protoimpl.X.CompressGZIP(file_friend_msg_proto_rawDescData) + }) + return file_friend_msg_proto_rawDescData +} + +var file_friend_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 21) +var file_friend_msg_proto_goTypes = []interface{}{ + (*FriendBase)(nil), // 0: FriendBase + (*FriendListReq)(nil), // 1: FriendListReq + (*FriendListRsp)(nil), // 2: FriendListRsp + (*FriendAddReq)(nil), // 3: FriendAddReq + (*FriendAddRsp)(nil), // 4: FriendAddRsp + (*FriendDelReq)(nil), // 5: FriendDelReq + (*FriendDelRsp)(nil), // 6: FriendDelRsp + (*FriendAgreeOrRefuseReq)(nil), // 7: FriendAgreeOrRefuseReq + (*FriendAgressOrRefuseRsp)(nil), // 8: FriendAgressOrRefuseRsp + (*FriendApplyListReq)(nil), // 9: FriendApplyListReq + (*FriendApplyListRsp)(nil), // 10: FriendApplyListRsp + (*FriendSearchReq)(nil), // 11: FriendSearchReq + (*FriendSearchRsp)(nil), // 12: FriendSearchRsp + (*FriendBlackListReq)(nil), // 13: FriendBlackListReq + (*FriendBlackListRsp)(nil), // 14: FriendBlackListRsp + (*FriendBlackAddReq)(nil), // 15: FriendBlackAddReq + (*FriendBlackAddRsp)(nil), // 16: FriendBlackAddRsp + (*FriendReceiveOrSendReq)(nil), // 17: FriendReceiveOrSendReq + (*FriendReceiveOrSendRsp)(nil), // 18: FriendReceiveOrSendRsp + (*FriendTotalReq)(nil), // 19: FriendTotalReq + (*FriendTotalRsp)(nil), // 20: FriendTotalRsp + (*Friend)(nil), // 21: Friend +} +var file_friend_msg_proto_depIdxs = []int32{ + 21, // 0: FriendListRsp.list:type_name -> Friend + 0, // 1: FriendSearchRsp.friends:type_name -> FriendBase + 0, // 2: FriendBlackListRsp.friends:type_name -> FriendBase + 3, // [3:3] is the sub-list for method output_type + 3, // [3:3] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name +} + +func init() { file_friend_msg_proto_init() } +func file_friend_msg_proto_init() { + if File_friend_msg_proto != nil { + return + } + file_friend_db_proto_init() + if !protoimpl.UnsafeEnabled { + file_friend_msg_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendBase); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendListReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendListRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendAddReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendAddRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendDelReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[6].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendDelRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[7].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendAgreeOrRefuseReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[8].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendAgressOrRefuseRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[9].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendApplyListReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendApplyListRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[11].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendSearchReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendSearchRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[13].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendBlackListReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[14].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendBlackListRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[15].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendBlackAddReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[16].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendBlackAddRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[17].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendReceiveOrSendReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[18].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendReceiveOrSendRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[19].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendTotalReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_friend_msg_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*FriendTotalRsp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_friend_msg_proto_rawDesc, + NumEnums: 0, + NumMessages: 21, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_friend_msg_proto_goTypes, + DependencyIndexes: file_friend_msg_proto_depIdxs, + MessageInfos: file_friend_msg_proto_msgTypes, + }.Build() + File_friend_msg_proto = out.File + file_friend_msg_proto_rawDesc = nil + file_friend_msg_proto_goTypes = nil + file_friend_msg_proto_depIdxs = nil +} diff --git a/pb/mail_db.pb.go b/pb/mail_db.pb.go index 629a68696..e46beba84 100644 --- a/pb/mail_db.pb.go +++ b/pb/mail_db.pb.go @@ -80,7 +80,7 @@ type DB_MailData struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - ObjId string `bson:"_id" json:"ObjId,omitempty" protobuf:"bytes,1,opt,name=ObjId,proto3"` // tags:{bson:"_id"} + ObjId string `protobuf:"bytes,1,opt,name=ObjId,proto3" json:"ObjId,omitempty" bson:"_id"` // tags:{bson:"_id"} UserId string `protobuf:"bytes,2,opt,name=UserId,proto3" json:"UserId,omitempty"` Title string `protobuf:"bytes,3,opt,name=Title,proto3" json:"Title,omitempty"` // 邮件标题 Contex string `protobuf:"bytes,4,opt,name=Contex,proto3" json:"Contex,omitempty"` // 邮件内容 diff --git a/pb/proto/friend_db.proto b/pb/proto/friend_db.proto new file mode 100644 index 000000000..c9c3d38d5 --- /dev/null +++ b/pb/proto/friend_db.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +option go_package = ".;pb"; +import "user_db.proto"; + +message Friend { + DB_UserData UserData = 1;//用户 + //工会 +} \ No newline at end of file diff --git a/pb/proto/friend_msg.proto b/pb/proto/friend_msg.proto new file mode 100644 index 000000000..52e90fc43 --- /dev/null +++ b/pb/proto/friend_msg.proto @@ -0,0 +1,111 @@ +syntax = "proto3"; +option go_package = ".;pb"; +import "friend_db.proto"; + +message FriendBase { + string userId = 1; //ID + string NickName = 2; //昵称 + int32 level = 3; //等级 + int32 avatar = 4; //头像 + int64 strength = 5; //战力 + int32 serverId = 6;//服务编号 + int64 offlineTime =7;//最近一次下线时间 0在线 +} + +//好友列表 +message FriendListReq{ + +} +message FriendListRsp{ + repeated Friend list = 1; +} + +//添加好友 +message FriendAddReq{ + string friendId = 1; //好友ID +} +message FriendAddRsp{ + string userId = 1; //用户ID +} + +//删除好友 +message FriendDelReq{ + string friendId = 1;//好友ID + +} + +message FriendDelRsp{ + string friendId = 1;//好友ID + string userId = 2; //用户ID +} + +//同意或拒绝 +message FriendAgreeOrRefuseReq{ + string friendId = 1; //被同意或拒绝的用户 + bool isAgree = 2; + +} +message FriendAgressOrRefuseRsp{ + int32 Num = 1;//操作的数量 + bool isAgree = 2; +} + + +//好友申请列表 +message FriendApplyListReq{ + +} +message FriendApplyListRsp{ + +} + +//好友搜索 +message FriendSearchReq{ + string friendId = 1; + string nickName = 2; //好友昵称 +} + +message FriendSearchRsp{ + repeated FriendBase friends = 1; +} + +//黑名单 +message FriendBlackListReq{ + +} + +message FriendBlackListRsp{ + repeated FriendBase friends = 1; +} + +//添加黑名单 +message FriendBlackAddReq{ + string friendId = 1; +} + +message FriendBlackAddRsp{ + string friendId = 1; + string userId = 2; +} + +//赠送或接收 +message FriendReceiveOrSendReq{ + string friendId = 1; + bool isReceive = 2; +} + +message FriendReceiveOrSendRsp{ + string friendId = 1; + string userId = 2; + bool isReceive = 3; +} + +//好友数量 +message FriendTotalReq{ + string friendId = 1; +} + +message FriendTotalRsp{ + string friendId = 1; + int32 total = 2; //好友数量 +} \ No newline at end of file diff --git a/pb/proto/user_db.proto b/pb/proto/user_db.proto index 95ce91c15..8af1ddedd 100644 --- a/pb/proto/user_db.proto +++ b/pb/proto/user_db.proto @@ -13,4 +13,5 @@ message DB_UserData { string NiceName = 3; int32 ServerId = 4; int32 FriendPoint = 5;//友情点 + int32 avatar = 6;//头像 } \ No newline at end of file diff --git a/pb/user_db.pb.go b/pb/user_db.pb.go index 44e8928d7..f7897e40a 100644 --- a/pb/user_db.pb.go +++ b/pb/user_db.pb.go @@ -93,6 +93,7 @@ type DB_UserData struct { NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"` ServerId int32 `protobuf:"varint,4,opt,name=ServerId,proto3" json:"ServerId,omitempty"` FriendPoint int32 `protobuf:"varint,5,opt,name=FriendPoint,proto3" json:"FriendPoint,omitempty"` //友情点 + Avatar int32 `protobuf:"varint,6,opt,name=avatar,proto3" json:"avatar,omitempty"` //头像 } func (x *DB_UserData) Reset() { @@ -162,6 +163,13 @@ func (x *DB_UserData) GetFriendPoint() int32 { return 0 } +func (x *DB_UserData) GetAvatar() int32 { + if x != nil { + return x.Avatar + } + return 0 +} + var File_user_db_proto protoreflect.FileDescriptor var file_user_db_proto_rawDesc = []byte{ @@ -174,7 +182,7 @@ var file_user_db_proto_rawDesc = []byte{ 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, 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, 0x99, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73, + 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x22, 0xb1, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18, 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, @@ -184,8 +192,9 @@ var file_user_db_proto_rawDesc = []byte{ 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x12, 0x20, 0x0a, 0x0b, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x05, 0x52, 0x0b, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x50, 0x6f, 0x69, - 0x6e, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x33, + 0x6e, 0x74, 0x12, 0x16, 0x0a, 0x06, 0x61, 0x76, 0x61, 0x74, 0x61, 0x72, 0x18, 0x06, 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 ( diff --git a/pb_2.7.py b/pb_2.7.py index 8d377aab1..9f19bee65 100644 --- a/pb_2.7.py +++ b/pb_2.7.py @@ -32,4 +32,6 @@ buildProto('./pb/proto','./pb','user_msg') buildProto('./pb/proto','./pb','pack_db') buildProto('./pb/proto','./pb','pack_msg') buildProto('./pb/proto','./pb','mail_db') -buildProto('./pb/proto','./pb','mail_msg') \ No newline at end of file +buildProto('./pb/proto','./pb','mail_msg') +buildProto('./pb/proto','./pb','friend_db') +buildProto('./pb/proto','./pb','friend_msg') \ No newline at end of file From 35a1353df50feacd2341fe911edee4dfecab5451 Mon Sep 17 00:00:00 2001 From: meixiongfeng <766881921@qq.com> Date: Tue, 7 Jun 2022 20:05:07 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E9=82=AE=E4=BB=B6=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/mail/api_comp.go | 67 +++++++++++++++++++++++++++++++++++--- pb/errorcode.pb.go | 14 ++++++-- pb/mail_db.pb.go | 22 +++++++++---- pb/proto/errorcode.proto | 2 ++ pb/proto/mail_db.proto | 3 +- pb/user_db.pb.go | 36 ++++++++------------- sys/db/mail.go | 69 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 176 insertions(+), 37 deletions(-) diff --git a/modules/mail/api_comp.go b/modules/mail/api_comp.go index 5221d3806..fc7b07173 100644 --- a/modules/mail/api_comp.go +++ b/modules/mail/api_comp.go @@ -6,6 +6,7 @@ import ( "go_dreamfactory/modules" "go_dreamfactory/pb" "go_dreamfactory/sys/cache" + "go_dreamfactory/sys/db" "github.com/liwei1dao/lego/core" "github.com/liwei1dao/lego/sys/log" @@ -33,7 +34,7 @@ func (this *Api_Comp) Init(service core.IService, module core.IModule, comp core return } -func (this *Api_Comp) QueryUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.QueryUserMailResp) (err error) { +func (this *Api_Comp) QueryUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.QueryUserMailReq) (err error) { code := pb.ErrorCode_Success mailinfo := make([]*pb.DB_MailData, 0) @@ -53,7 +54,7 @@ func (this *Api_Comp) QueryUserMailReq(ctx context.Context, session comm.IUserSe return } -func (this *Api_Comp) ReadUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.ReadUserMailResp) (err error) { +func (this *Api_Comp) ReadUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.ReadUserMailReq) (err error) { var ( code pb.ErrorCode mail *pb.DB_MailData @@ -61,14 +62,72 @@ func (this *Api_Comp) ReadUserMailReq(ctx context.Context, session comm.IUserSes defer func() { session.SendMsg(string(this.module.GetType()), "readusermailresp", code, &pb.ReadUserMailResp{Mail: mail}) }() + if session.GetUserId() == "" { + code = pb.ErrorCode_NoLogin + return + } + + mail, err = db.Defsys.ReadOneMail(req.ObjID) + if err != nil { + code = pb.ErrorCode_ReqParameterError + } return } -func (this *Api_Comp) GetUserMailAttachmentReq(ctx context.Context, session comm.IUserSession, req *pb.GetUserMailAttachmentResp) (err error) { +func (this *Api_Comp) GetUserMailAttachmentReq(ctx context.Context, session comm.IUserSession, req *pb.GetUserMailAttachmentReq) (err error) { + + var ( + code pb.ErrorCode + mail *pb.DB_MailData + ) + defer func() { + session.SendMsg(string(this.module.GetType()), "getusermailattachmentresp", code, &pb.GetUserMailAttachmentResp{Mail: mail}) + }() + if session.GetUserId() == "" { + code = pb.ErrorCode_NoLogin + return + } + _bGet := db.Defsys.GetMailAttachmentState(req.ObjID) + if !_bGet { + code = pb.ErrorCode_StateInvalid + return + } + _data, err := db.Defsys.GetMailAttachment(req.ObjID) + if err != nil { + if len(_data) > 0 { + // todo 领取附件 + } else { + return + } + } + // 修改状态 + db.Defsys.UpdateMailAttachmentState(req.ObjID) + mail.Reward = true + return } -func (this *Api_Comp) DelUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.DelUserMailResp) (err error) { +func (this *Api_Comp) DelUserMailReq(ctx context.Context, session comm.IUserSession, req *pb.DelUserMailReq) (err error) { + + code := pb.ErrorCode_Success + mailinfo := make([]*pb.DB_MailData, 0) + defer func() { + session.SendMsg(string(this.module.GetType()), "delusermailresp", code, &pb.DelUserMailResp{Mail: mailinfo}) + }() + if session.GetUserId() == "" { + code = pb.ErrorCode_NoLogin + return + } + bRet := db.Defsys.DelUserMail(req.ObjID) + if !bRet { + code = pb.ErrorCode_DBError + return + } + if mailinfo, err = cache.Defsys.QueryUserMail(session.GetUserId()); err != nil { + log.Errorf("QueryUserMailResp err:%v", err) + code = pb.ErrorCode_CacheReadError + return + } return } diff --git a/pb/errorcode.pb.go b/pb/errorcode.pb.go index 85cc5aebd..b51373e4a 100644 --- a/pb/errorcode.pb.go +++ b/pb/errorcode.pb.go @@ -35,6 +35,8 @@ const ( ErrorCode_UserSessionNobeing ErrorCode = 18 //用户不存在 ErrorCode_SecKey ErrorCode = 19 //秘钥格式错误 ErrorCode_SecKeyInvalid ErrorCode = 20 //秘钥无效 + ErrorCode_StateInvalid ErrorCode = 21 //无效状态 + ErrorCode_DBError ErrorCode = 22 // 数据库操作失败 ) // Enum value maps for ErrorCode. @@ -52,6 +54,8 @@ var ( 18: "UserSessionNobeing", 19: "SecKey", 20: "SecKeyInvalid", + 21: "StateInvalid", + 22: "DBError", } ErrorCode_value = map[string]int32{ "Success": 0, @@ -66,6 +70,8 @@ var ( "UserSessionNobeing": 18, "SecKey": 19, "SecKeyInvalid": 20, + "StateInvalid": 21, + "DBError": 22, } ) @@ -100,7 +106,7 @@ var File_errorcode_proto protoreflect.FileDescriptor var file_errorcode_proto_rawDesc = []byte{ 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2a, 0xf8, 0x01, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, + 0x6f, 0x2a, 0x97, 0x02, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x0b, 0x0a, 0x07, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x10, 0x00, 0x12, 0x11, 0x0a, 0x0d, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12, 0x19, 0x0a, 0x15, 0x52, 0x70, 0x63, 0x46, 0x75, 0x6e, 0x63, 0x45, 0x78, 0x65, 0x63, 0x75, 0x74, @@ -115,8 +121,10 @@ var file_errorcode_proto_rawDesc = []byte{ 0x67, 0x69, 0x6e, 0x10, 0x11, 0x12, 0x16, 0x0a, 0x12, 0x55, 0x73, 0x65, 0x72, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x4e, 0x6f, 0x62, 0x65, 0x69, 0x6e, 0x67, 0x10, 0x12, 0x12, 0x0a, 0x0a, 0x06, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x10, 0x13, 0x12, 0x11, 0x0a, 0x0d, 0x53, 0x65, 0x63, - 0x4b, 0x65, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x14, 0x42, 0x06, 0x5a, 0x04, - 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x4b, 0x65, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x14, 0x12, 0x10, 0x0a, 0x0c, + 0x53, 0x74, 0x61, 0x74, 0x65, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0x15, 0x12, 0x0b, + 0x0a, 0x07, 0x44, 0x42, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x16, 0x42, 0x06, 0x5a, 0x04, 0x2e, + 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/pb/mail_db.pb.go b/pb/mail_db.pb.go index 629a68696..1d4460e9a 100644 --- a/pb/mail_db.pb.go +++ b/pb/mail_db.pb.go @@ -87,7 +87,8 @@ type DB_MailData struct { CreateTime uint64 `protobuf:"varint,5,opt,name=CreateTime,proto3" json:"CreateTime,omitempty"` // 发送时间 DueTime uint64 `protobuf:"varint,6,opt,name=DueTime,proto3" json:"DueTime,omitempty"` // 过期时间 Check bool `protobuf:"varint,7,opt,name=Check,proto3" json:"Check,omitempty"` // 是否查看 - Items []*MailAttachment `protobuf:"bytes,8,rep,name=Items,proto3" json:"Items,omitempty"` // 附件 + Reward bool `protobuf:"varint,8,opt,name=Reward,proto3" json:"Reward,omitempty"` // 附件领取状态 + Items []*MailAttachment `protobuf:"bytes,9,rep,name=Items,proto3" json:"Items,omitempty"` // 附件 } func (x *DB_MailData) Reset() { @@ -171,6 +172,13 @@ func (x *DB_MailData) GetCheck() bool { return false } +func (x *DB_MailData) GetReward() bool { + if x != nil { + return x.Reward + } + return false +} + func (x *DB_MailData) GetItems() []*MailAttachment { if x != nil { return x.Items @@ -186,7 +194,7 @@ var file_mail_db_proto_rawDesc = []byte{ 0x74, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x06, 0x49, 0x74, 0x65, 0x6d, 0x49, 0x64, 0x12, 0x1c, 0x0a, 0x09, 0x49, 0x74, 0x65, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0d, 0x52, 0x09, 0x49, 0x74, - 0x65, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xe0, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x4d, + 0x65, 0x6d, 0x43, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0xf8, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x4d, 0x61, 0x69, 0x6c, 0x44, 0x61, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x4f, 0x62, 0x6a, 0x49, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, @@ -198,10 +206,12 @@ var file_mail_db_proto_rawDesc = []byte{ 0x69, 0x6d, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x07, 0x44, 0x75, 0x65, 0x54, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x43, 0x68, 0x65, 0x63, 0x6b, 0x18, 0x07, 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x43, 0x68, - 0x65, 0x63, 0x6b, 0x12, 0x25, 0x0a, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x18, 0x08, 0x20, 0x03, - 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x4d, 0x61, 0x69, 0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, - 0x65, 0x6e, 0x74, 0x52, 0x05, 0x49, 0x74, 0x65, 0x6d, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x63, 0x6b, 0x12, 0x16, 0x0a, 0x06, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x18, 0x08, 0x20, + 0x01, 0x28, 0x08, 0x52, 0x06, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x12, 0x25, 0x0a, 0x05, 0x49, + 0x74, 0x65, 0x6d, 0x73, 0x18, 0x09, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x4d, 0x61, 0x69, + 0x6c, 0x41, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x52, 0x05, 0x49, 0x74, 0x65, + 0x6d, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( diff --git a/pb/proto/errorcode.proto b/pb/proto/errorcode.proto index 9c3e94476..e2def10e4 100644 --- a/pb/proto/errorcode.proto +++ b/pb/proto/errorcode.proto @@ -15,4 +15,6 @@ enum ErrorCode { UserSessionNobeing = 18; //用户不存在 SecKey = 19; //秘钥格式错误 SecKeyInvalid = 20; //秘钥无效 + StateInvalid = 21; //无效状态 + DBError = 22; // 数据库操作失败 } \ No newline at end of file diff --git a/pb/proto/mail_db.proto b/pb/proto/mail_db.proto index 532b97a72..aab8a6960 100644 --- a/pb/proto/mail_db.proto +++ b/pb/proto/mail_db.proto @@ -19,5 +19,6 @@ message DB_MailData { uint64 CreateTime = 5; // 发送时间 uint64 DueTime = 6; // 过期时间 bool Check = 7; // 是否查看 - repeated MailAttachment Items = 8; // 附件 + bool Reward = 8; // 附件领取状态 + repeated MailAttachment Items = 9; // 附件 } diff --git a/pb/user_db.pb.go b/pb/user_db.pb.go index b4c44f448..79fdf224d 100644 --- a/pb/user_db.pb.go +++ b/pb/user_db.pb.go @@ -91,8 +91,7 @@ type DB_UserData struct { UserId string `bson:"_id" json:"UserId,omitempty" protobuf:"bytes,1,opt,name=UserId,proto3"` //tags:{bson:"_id"}动态Id Account string `protobuf:"bytes,2,opt,name=Account,proto3" json:"Account,omitempty"` NiceName string `protobuf:"bytes,3,opt,name=NiceName,proto3" json:"NiceName,omitempty"` - Email string `protobuf:"bytes,4,opt,name=Email,proto3" json:"Email,omitempty"` - Password string `protobuf:"bytes,5,opt,name=Password,proto3" json:"Password,omitempty"` + ServerId int32 `protobuf:"varint,4,opt,name=ServerId,proto3" json:"ServerId,omitempty"` } func (x *DB_UserData) Reset() { @@ -148,18 +147,11 @@ func (x *DB_UserData) GetNiceName() string { return "" } -func (x *DB_UserData) GetEmail() string { +func (x *DB_UserData) GetServerId() int32 { if x != nil { - return x.Email + return x.ServerId } - return "" -} - -func (x *DB_UserData) GetPassword() string { - if x != nil { - return x.Password - } - return "" + return 0 } var File_user_db_proto protoreflect.FileDescriptor @@ -174,17 +166,15 @@ var file_user_db_proto_rawDesc = []byte{ 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, 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, 0x8d, 0x01, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73, - 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18, - 0x0a, 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x65, - 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x65, - 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x18, 0x04, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x05, 0x45, 0x6d, 0x61, 0x69, 0x6c, 0x12, 0x1a, 0x0a, 0x08, 0x50, 0x61, - 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x50, 0x61, - 0x73, 0x73, 0x77, 0x6f, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x22, 0x77, 0x0a, 0x0b, 0x44, 0x42, 0x5f, 0x55, 0x73, 0x65, + 0x72, 0x44, 0x61, 0x74, 0x61, 0x12, 0x16, 0x0a, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x18, + 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x18, 0x0a, + 0x07, 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, + 0x41, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x65, 0x4e, + 0x61, 0x6d, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x65, 0x4e, + 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x18, + 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x08, 0x53, 0x65, 0x72, 0x76, 0x65, 0x72, 0x49, 0x64, 0x42, + 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/sys/db/mail.go b/sys/db/mail.go index 2d2434eed..50fc60824 100644 --- a/sys/db/mail.go +++ b/sys/db/mail.go @@ -7,6 +7,7 @@ import ( "github.com/liwei1dao/lego/core" "go.mongodb.org/mongo-driver/bson" "go.mongodb.org/mongo-driver/bson/primitive" + "go.mongodb.org/mongo-driver/mongo/options" ) const ( @@ -16,6 +17,11 @@ const ( type IMail interface { QueryUserMail(uId string) (mail []*pb.DB_MailData, err error) InsertUserMail(mail *pb.DB_MailData) (err error) + ReadOneMail(objId string) (mail *pb.DB_MailData, err error) + GetMailAttachment(objId string) (itmes []*pb.MailAttachment, err error) + GetMailAttachmentState(objId string) bool + UpdateMailAttachmentState(objId string) bool + DelUserMail(objId string) bool } func (this *DB) QueryUserMail(uId string) (mail []*pb.DB_MailData, err error) { @@ -32,7 +38,70 @@ func (this *DB) QueryUserMail(uId string) (mail []*pb.DB_MailData, err error) { } func (this *DB) InsertUserMail(mail *pb.DB_MailData) (err error) { + mail.ObjId = primitive.NewObjectID().Hex() + mail.Check = false _, err = this.mgo.InsertOne(DB_MailTable, mail) + return err } + +func (this *DB) ReadOneMail(objId string) (mail *pb.DB_MailData, err error) { + + err = this.mgo.FindOneAndUpdate( + DB_MailTable, + bson.M{"_id": objId}, + bson.M{"$set": bson.M{ + "check": false, + }}, + options.FindOneAndUpdate().SetUpsert(false).SetReturnDocument(options.After), + ).Decode(mail) + + return mail, err +} + +// 查询附件信息 +func (this *DB) GetMailAttachment(objId string) (itmes []*pb.MailAttachment, err error) { + + obj := this.mgo.FindOne(DB_MailTable, bson.M{"_id": objId}) + var nd *pb.DB_MailData + err = obj.Decode(&nd) + itmes = nd.GetItems() + + return itmes, err +} + +// 查看领取附件状态 +func (this *DB) GetMailAttachmentState(objId string) bool { + var nd *pb.DB_MailData + err := this.mgo.FindOne(DB_MailTable, bson.M{"_id": objId}).Decode(nd) + if err != nil { + return false + } + return nd.Reward && len(nd.GetItems()) > 0 +} + +// 更新领取附件状态 +func (this *DB) UpdateMailAttachmentState(objId string) bool { + this.mgo.FindOneAndUpdate( + DB_MailTable, + bson.M{"_id": objId}, + bson.M{"$set": bson.M{ + "reward": true, + }}, + options.FindOneAndUpdate().SetUpsert(false).SetReturnDocument(options.After), + ) + + return true +} + +func (this *DB) DelUserMail(objId string) bool { + var obj *pb.DB_MailData + err := this.mgo.FindOne(DB_MailTable, bson.M{"_id": objId}).Decode(obj) + if err != nil { + return false + } + this.mgo.DeleteOne(DB_MailTable, bson.M{"_id": objId}) + + return true +}