数据层接口测试

This commit is contained in:
zhaocy 2022-06-17 13:51:43 +08:00
parent c77f36ca3a
commit ce3440d7f9
9 changed files with 37 additions and 30 deletions

View File

@ -89,7 +89,7 @@ func (r *Robot) handleFriendApply(msg *pb.UserMessage) {
printReply(msg, rsp) printReply(msg, rsp)
} }
//申请列表 // 申请列表
func (r *Robot) FriendApplyList() { func (r *Robot) FriendApplyList() {
req := &pb.Friend_ApplyList_Req{} req := &pb.Friend_ApplyList_Req{}
head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_ApplyList} head := &pb.UserMessage{MainType: string(comm.SM_FriendModule), SubType: friend.Friend_SubType_ApplyList}

View File

@ -83,7 +83,7 @@ func (r *Robot) handleMsg(msg *pb.UserMessage) {
//在这里添加玩家成功登录以后的测试方法 //在这里添加玩家成功登录以后的测试方法
func (r *Robot) onUserLoaded() { func (r *Robot) onUserLoaded() {
//user //user
// r.CreateUser("乐谷616") r.CreateUser("乐谷616")
//friend //friend
// r.FriendApply("1_62aa8f30d25fb8c1a7d90b50") // r.FriendApply("1_62aa8f30d25fb8c1a7d90b50")

View File

@ -96,8 +96,7 @@ type IUserSession interface {
//对protobuf格式的数据进行反序列化 //对protobuf格式的数据进行反序列化
func ProtoUnmarshal(msg *pb.UserMessage, req proto.Message) (ok bool) { func ProtoUnmarshal(msg *pb.UserMessage, req proto.Message) (ok bool) {
any := msg.Data err := msg.Data.UnmarshalTo(req)
err := any.UnmarshalTo(req)
if err != nil { if err != nil {
log.Errorf("UnmarshalTo %s.%s %v", msg.MainType, msg.SubType, err) log.Errorf("UnmarshalTo %s.%s %v", msg.MainType, msg.SubType, err)
return return

View File

@ -194,7 +194,6 @@ func (this *Model_Comp) GetHM(uid string, data interface{}) error {
//update cache without mgolog //update cache without mgolog
return this.SetHM(this.ukey(uid), data, cache.WithDisabledMgoLog()) return this.SetHM(this.ukey(uid), data, cache.WithDisabledMgoLog())
} }
return nil
} }

View File

@ -4,7 +4,6 @@ import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/lego/sys/event" "go_dreamfactory/lego/sys/event"
"go_dreamfactory/pb" "go_dreamfactory/pb"
"go_dreamfactory/sys/cache"
"go_dreamfactory/utils" "go_dreamfactory/utils"
) )
@ -32,7 +31,7 @@ func (this *Api_Comp) Create(session comm.IUserSession, result map[string]interf
return return
} }
self.Name = req.NickName self.Name = req.NickName
err = this.module.modelUser.SetObj(session.GetUserId(), self, cache.WithND()) err = this.module.modelUser.SetObj(session.GetUserId(), self)
if err != nil { if err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return

View File

@ -105,7 +105,11 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
return return
} }
} else { } else {
session.Bind(db_user.Uid, this.service.GetId()) err := session.Bind(db_user.Uid, this.service.GetId())
if err != nil {
code = pb.ErrorCode_BindUser
return
}
data := &pb.Cache_UserData{ data := &pb.Cache_UserData{
Uid: db_user.Uid, Uid: db_user.Uid,
SessionId: cache_user.SessionId, SessionId: cache_user.SessionId,
@ -115,7 +119,7 @@ func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interfa
// "sessionId": cache_user.SessionId, // "sessionId": cache_user.SessionId,
// "gatewayServiceId": cache_user.GatewayServiceId, // "gatewayServiceId": cache_user.GatewayServiceId,
// } // }
err = this.module.modelSession.SetObj(db_user.Uid, data) err = this.module.modelSession.SetObj(db_user.Uid, data, cache.WithDisabledMgoLog())
if err != nil { if err != nil {
code = pb.ErrorCode_DBError code = pb.ErrorCode_DBError
return return

View File

@ -41,6 +41,7 @@ const (
// user // user
ErrorCode_SecKeyInvalid ErrorCode = 1000 //秘钥无效 ErrorCode_SecKeyInvalid ErrorCode = 1000 //秘钥无效
ErrorCode_SecKey ErrorCode = 1001 //秘钥格式错误 ErrorCode_SecKey ErrorCode = 1001 //秘钥格式错误
ErrorCode_BindUser ErrorCode = 1002 //用户绑定错误
// friend // friend
ErrorCode_FriendNotSelf ErrorCode = 1100 //不能是自己 ErrorCode_FriendNotSelf ErrorCode = 1100 //不能是自己
ErrorCode_FriendSelfMax ErrorCode = 1101 //超出好友最大数量 ErrorCode_FriendSelfMax ErrorCode = 1101 //超出好友最大数量
@ -76,6 +77,7 @@ var (
100: "Exception", 100: "Exception",
1000: "SecKeyInvalid", 1000: "SecKeyInvalid",
1001: "SecKey", 1001: "SecKey",
1002: "BindUser",
1100: "FriendNotSelf", 1100: "FriendNotSelf",
1101: "FriendSelfMax", 1101: "FriendSelfMax",
1102: "FriendTargetMax", 1102: "FriendTargetMax",
@ -107,6 +109,7 @@ var (
"Exception": 100, "Exception": 100,
"SecKeyInvalid": 1000, "SecKeyInvalid": 1000,
"SecKey": 1001, "SecKey": 1001,
"BindUser": 1002,
"FriendNotSelf": 1100, "FriendNotSelf": 1100,
"FriendSelfMax": 1101, "FriendSelfMax": 1101,
"FriendTargetMax": 1102, "FriendTargetMax": 1102,
@ -153,7 +156,7 @@ var File_errorcode_proto protoreflect.FileDescriptor
var file_errorcode_proto_rawDesc = []byte{ var file_errorcode_proto_rawDesc = []byte{
0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x0a, 0x0f, 0x65, 0x72, 0x72, 0x6f, 0x72, 0x63, 0x6f, 0x64, 0x65, 0x2e, 0x70, 0x72, 0x6f, 0x74,
0x6f, 0x2a, 0xe5, 0x04, 0x0a, 0x09, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x6f, 0x2a, 0xf4, 0x04, 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, 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, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x10, 0x0a, 0x12,
0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x1b, 0x0a, 0x17, 0x4e, 0x6f, 0x46, 0x69, 0x6e, 0x64, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65,
@ -174,25 +177,26 @@ var file_errorcode_proto_rawDesc = []byte{
0x74, 0x65, 0x6d, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x16, 0x12, 0x0d, 0x0a, 0x09, 0x45, 0x78, 0x74, 0x65, 0x6d, 0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0x16, 0x12, 0x0d, 0x0a, 0x09, 0x45, 0x78,
0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x64, 0x12, 0x12, 0x0a, 0x0d, 0x53, 0x65, 0x63, 0x63, 0x65, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x10, 0x64, 0x12, 0x12, 0x0a, 0x0d, 0x53, 0x65, 0x63,
0x4b, 0x65, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0xe8, 0x07, 0x12, 0x0b, 0x0a, 0x4b, 0x65, 0x79, 0x49, 0x6e, 0x76, 0x61, 0x6c, 0x69, 0x64, 0x10, 0xe8, 0x07, 0x12, 0x0b, 0x0a,
0x06, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x10, 0xe9, 0x07, 0x12, 0x12, 0x0a, 0x0d, 0x46, 0x72, 0x06, 0x53, 0x65, 0x63, 0x4b, 0x65, 0x79, 0x10, 0xe9, 0x07, 0x12, 0x0d, 0x0a, 0x08, 0x42, 0x69,
0x69, 0x65, 0x6e, 0x64, 0x4e, 0x6f, 0x74, 0x53, 0x65, 0x6c, 0x66, 0x10, 0xcc, 0x08, 0x12, 0x12, 0x6e, 0x64, 0x55, 0x73, 0x65, 0x72, 0x10, 0xea, 0x07, 0x12, 0x12, 0x0a, 0x0d, 0x46, 0x72, 0x69,
0x0a, 0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x4d, 0x61, 0x78, 0x10, 0x65, 0x6e, 0x64, 0x4e, 0x6f, 0x74, 0x53, 0x65, 0x6c, 0x66, 0x10, 0xcc, 0x08, 0x12, 0x12, 0x0a,
0xcd, 0x08, 0x12, 0x14, 0x0a, 0x0f, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x0d, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x4d, 0x61, 0x78, 0x10, 0xcd,
0x65, 0x74, 0x4d, 0x61, 0x78, 0x10, 0xce, 0x08, 0x12, 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69, 0x65, 0x08, 0x12, 0x14, 0x0a, 0x0f, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65,
0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x4e, 0x6f, 0x44, 0x61, 0x74, 0x61, 0x10, 0xcf, 0x08, 0x12, 0x74, 0x4d, 0x61, 0x78, 0x10, 0xce, 0x08, 0x12, 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69, 0x65, 0x6e,
0x17, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x4e, 0x6f, 0x44, 0x61, 0x74, 0x61, 0x10, 0xcf, 0x08, 0x12, 0x17,
0x6f, 0x44, 0x61, 0x74, 0x61, 0x10, 0xd0, 0x08, 0x12, 0x0e, 0x0a, 0x09, 0x46, 0x72, 0x69, 0x65, 0x0a, 0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x4e, 0x6f,
0x6e, 0x64, 0x59, 0x65, 0x74, 0x10, 0xd1, 0x08, 0x12, 0x13, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x44, 0x61, 0x74, 0x61, 0x10, 0xd0, 0x08, 0x12, 0x0e, 0x0a, 0x09, 0x46, 0x72, 0x69, 0x65, 0x6e,
0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x59, 0x65, 0x74, 0x10, 0xd2, 0x08, 0x12, 0x17, 0x0a, 0x64, 0x59, 0x65, 0x74, 0x10, 0xd1, 0x08, 0x12, 0x13, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e,
0x12, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x59, 0x65, 0x74, 0x10, 0xd2, 0x08, 0x12, 0x17, 0x0a, 0x12,
0x59, 0x65, 0x74, 0x10, 0xd3, 0x08, 0x12, 0x19, 0x0a, 0x14, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x6c, 0x66, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x59,
0x54, 0x61, 0x72, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x59, 0x65, 0x74, 0x10, 0xd4, 0x65, 0x74, 0x10, 0xd3, 0x08, 0x12, 0x19, 0x0a, 0x14, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x54,
0x08, 0x12, 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x61, 0x72, 0x67, 0x65, 0x74, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x59, 0x65, 0x74, 0x10, 0xd4, 0x08,
0x45, 0x72, 0x72, 0x6f, 0x72, 0x10, 0xd5, 0x08, 0x12, 0x13, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x12, 0x15, 0x0a, 0x10, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x41, 0x70, 0x70, 0x6c, 0x79, 0x45,
0x6e, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4d, 0x61, 0x78, 0x10, 0xd6, 0x08, 0x12, 0x1a, 0x0a, 0x72, 0x72, 0x6f, 0x72, 0x10, 0xd5, 0x08, 0x12, 0x13, 0x0a, 0x0e, 0x46, 0x72, 0x69, 0x65, 0x6e,
0x15, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x4e, 0x61, 0x6d, 0x64, 0x42, 0x6c, 0x61, 0x63, 0x6b, 0x4d, 0x61, 0x78, 0x10, 0xd6, 0x08, 0x12, 0x1a, 0x0a, 0x15,
0x65, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x10, 0xd7, 0x08, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x4e, 0x61, 0x6d, 0x65,
0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x10, 0xd7, 0x08, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
} }
var ( var (

View File

@ -21,6 +21,7 @@ enum ErrorCode {
// user // user
SecKeyInvalid = 1000; // SecKeyInvalid = 1000; //
SecKey = 1001; // SecKey = 1001; //
BindUser = 1002; //
// friend // friend
FriendNotSelf = 1100; // FriendNotSelf = 1100; //

View File

@ -3,6 +3,7 @@ package main
import ( import (
"flag" "flag"
"fmt" "fmt"
"go_dreamfactory/modules/dbservice"
"go_dreamfactory/modules/friend" "go_dreamfactory/modules/friend"
"go_dreamfactory/modules/mail" "go_dreamfactory/modules/mail"
"go_dreamfactory/modules/pack" "go_dreamfactory/modules/pack"
@ -40,7 +41,7 @@ func main() {
pack.NewModule(), pack.NewModule(),
mail.NewModule(), mail.NewModule(),
friend.NewModule(), friend.NewModule(),
// dbservice.NewModule(), dbservice.NewModule(),
) )
} }