add check
This commit is contained in:
parent
d9a5fbe5ba
commit
3879ccf652
@ -3,6 +3,7 @@ package robot
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@ -38,7 +39,7 @@ func (r *Robot) Run() {
|
|||||||
log.Printf("websocket %s \n", r.opts.WsUrl)
|
log.Printf("websocket %s \n", r.opts.WsUrl)
|
||||||
|
|
||||||
if r.opts.Create { //创建新用户
|
if r.opts.Create { //创建新用户
|
||||||
r.AccountRegister()
|
r.AccountRegister(r.opts.Account)
|
||||||
} else {
|
} else {
|
||||||
r.AccountLogin()
|
r.AccountLogin()
|
||||||
}
|
}
|
||||||
@ -90,7 +91,7 @@ func (r *Robot) onUserLoaded() {
|
|||||||
// r.FriendBlacklist()
|
// r.FriendBlacklist()
|
||||||
// r.FriendAddBlack()
|
// r.FriendAddBlack()
|
||||||
// r.FriendDelBlack("")
|
// r.FriendDelBlack("")
|
||||||
r.FriendSearch("乐谷5")
|
// r.FriendSearch("乐谷5")
|
||||||
|
|
||||||
//pack
|
//pack
|
||||||
// r.QueryUserPack()
|
// r.QueryUserPack()
|
||||||
@ -106,9 +107,12 @@ func (r *Robot) SendToClient(msg *pb.UserMessage, rsp proto.Message) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//注册账号
|
//注册账号
|
||||||
func (r *Robot) AccountRegister() {
|
func (r *Robot) AccountRegister(account string) {
|
||||||
|
if account == "" {
|
||||||
|
log.Fatal("account value is empty")
|
||||||
|
}
|
||||||
//http
|
//http
|
||||||
regReq := &pb.UserRegisterReq{}
|
regReq := &pb.UserRegisterReq{Account: account}
|
||||||
jsonByte, _ := json.Marshal(regReq)
|
jsonByte, _ := json.Marshal(regReq)
|
||||||
req, err := http.NewRequest("POST", r.opts.RegUrl, bytes.NewReader(jsonByte))
|
req, err := http.NewRequest("POST", r.opts.RegUrl, bytes.NewReader(jsonByte))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -128,6 +132,7 @@ func (r *Robot) AccountRegister() {
|
|||||||
|
|
||||||
if regRsp.Code == pb.ErrorCode_Success { //注册成功
|
if regRsp.Code == pb.ErrorCode_Success { //注册成功
|
||||||
|
|
||||||
|
fmt.Printf("account:%s 注册成功", regRsp.Account)
|
||||||
//登录
|
//登录
|
||||||
loginReg := &pb.UserLoginReq{
|
loginReg := &pb.UserLoginReq{
|
||||||
Sec: r.BuildSecStr(),
|
Sec: r.BuildSecStr(),
|
||||||
|
@ -30,7 +30,7 @@ func (r *Robot) handleLogin(msg *pb.UserMessage) {
|
|||||||
r.user = rsp.Data
|
r.user = rsp.Data
|
||||||
r.onUserLoaded()
|
r.onUserLoaded()
|
||||||
} else {
|
} else {
|
||||||
r.AccountRegister() //请求Http接口,模拟创建新账号
|
r.AccountRegister(r.opts.Account) //请求Http接口,模拟创建新账号
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/event"
|
"go_dreamfactory/lego/sys/event"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/utils"
|
"go_dreamfactory/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (this *Api_Comp) Create_Check(session comm.IUserSession, req *pb.UserCreateReq) (result map[string]interface{}, code pb.ErrorCode) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//创角
|
//创角
|
||||||
func (this *Api_Comp) Create(ctx context.Context, session comm.IUserSession, req *pb.UserCreateReq) (err error) {
|
func (this *Api_Comp) Create(session comm.IUserSession, result map[string]interface{}, req *pb.UserCreateReq) (err error) {
|
||||||
defer utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), User_SubType_Create, req, nil)
|
defer utils.TraceFunc(session.GetUserId(), string(this.module.GetType()), User_SubType_Create, req, nil)
|
||||||
|
|
||||||
var code pb.ErrorCode
|
var code pb.ErrorCode
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/base64"
|
"encoding/base64"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/event"
|
"go_dreamfactory/lego/sys/event"
|
||||||
@ -36,13 +35,13 @@ func decodeUserData(base64Str string) *pb.DB_UserData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//参数校验
|
//参数校验
|
||||||
func (this *Api_Comp) Login_Check(session comm.IUserSession, req *pb.GetlistReq) (result map[string]interface{}, code pb.ErrorCode) {
|
func (this *Api_Comp) Login_Check(session comm.IUserSession, req *pb.UserLoginReq) (result map[string]interface{}, code pb.ErrorCode) {
|
||||||
result = map[string]interface{}{}
|
result = map[string]interface{}{}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
//登录
|
//登录
|
||||||
func (this *Api_Comp) Login(ctx context.Context, session comm.IUserSession, req *pb.UserLoginReq) (err error) {
|
func (this *Api_Comp) Login(session comm.IUserSession, result map[string]interface{}, req *pb.UserLoginReq) (err error) {
|
||||||
var (
|
var (
|
||||||
code pb.ErrorCode
|
code pb.ErrorCode
|
||||||
db_user *pb.DB_UserData
|
db_user *pb.DB_UserData
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
"go_dreamfactory/lego/sys/log"
|
"go_dreamfactory/lego/sys/log"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (this *Api_Comp) Logout_Check(session comm.IUserSession, req *pb.UserLoginReq) (result map[string]interface{}, code pb.ErrorCode) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//注销
|
//注销
|
||||||
func (this *Api_Comp) Logout(ctx context.Context, session comm.IUserSession, rsp *pb.UserLoginReq) error {
|
func (this *Api_Comp) Logout(session comm.IUserSession, result map[string]interface{}, rsp *pb.UserLoginReq) error {
|
||||||
log.Debugf("User - Logout: session:%v rsp:%v", session.ToString(), rsp)
|
log.Debugf("User - Logout: session:%v rsp:%v", session.ToString(), rsp)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
@ -5,31 +5,23 @@ import "user/user_db.proto";
|
|||||||
|
|
||||||
//用户登录
|
//用户登录
|
||||||
message UserLoginReq {
|
message UserLoginReq {
|
||||||
string sec= 1;//密文
|
string sec = 1; //密文
|
||||||
}
|
}
|
||||||
|
|
||||||
message UserLoginResp {
|
message UserLoginResp { Cache_UserData data = 1; }
|
||||||
Cache_UserData data = 1;
|
|
||||||
|
message UserRegisterReq { string account = 1; }
|
||||||
|
|
||||||
|
message UserRegisterRsp {
|
||||||
|
ErrorCode Code = 1;
|
||||||
|
string account = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message UserLoadRsp { Cache_UserData data = 1; }
|
||||||
message UserRegisterReq{
|
|
||||||
string account = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message UserRegisterRsp{
|
|
||||||
ErrorCode Code = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
message UserLoadRsp {
|
|
||||||
Cache_UserData data = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
//创角
|
//创角
|
||||||
message UserCreateReq{
|
message UserCreateReq {
|
||||||
string NickName = 1;//昵称
|
string NickName = 1; //昵称
|
||||||
}
|
}
|
||||||
|
|
||||||
message UserCreateRsp{
|
message UserCreateRsp {}
|
||||||
|
|
||||||
}
|
|
@ -167,7 +167,8 @@ type UserRegisterRsp struct {
|
|||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
unknownFields protoimpl.UnknownFields
|
unknownFields protoimpl.UnknownFields
|
||||||
|
|
||||||
Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code"`
|
Code ErrorCode `protobuf:"varint,1,opt,name=Code,proto3,enum=ErrorCode" json:"Code"`
|
||||||
|
Account string `protobuf:"bytes,2,opt,name=account,proto3" json:"account"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (x *UserRegisterRsp) Reset() {
|
func (x *UserRegisterRsp) Reset() {
|
||||||
@ -209,6 +210,13 @@ func (x *UserRegisterRsp) GetCode() ErrorCode {
|
|||||||
return ErrorCode_Success
|
return ErrorCode_Success
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (x *UserRegisterRsp) GetAccount() string {
|
||||||
|
if x != nil {
|
||||||
|
return x.Account
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
type UserLoadRsp struct {
|
type UserLoadRsp struct {
|
||||||
state protoimpl.MessageState
|
state protoimpl.MessageState
|
||||||
sizeCache protoimpl.SizeCache
|
sizeCache protoimpl.SizeCache
|
||||||
@ -357,18 +365,19 @@ var file_user_user_msg_proto_rawDesc = []byte{
|
|||||||
0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0f, 0x55, 0x73, 0x65, 0x72, 0x52, 0x65, 0x67, 0x69, 0x73, 0x74,
|
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,
|
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,
|
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,
|
0x4b, 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,
|
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,
|
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,
|
0x64, 0x65, 0x12, 0x18, 0x0a, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x18, 0x02, 0x20,
|
||||||
0x70, 0x12, 0x23, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
|
0x01, 0x28, 0x09, 0x52, 0x07, 0x61, 0x63, 0x63, 0x6f, 0x75, 0x6e, 0x74, 0x22, 0x32, 0x0a, 0x0b,
|
||||||
0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68, 0x65, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61,
|
0x55, 0x73, 0x65, 0x72, 0x4c, 0x6f, 0x61, 0x64, 0x52, 0x73, 0x70, 0x12, 0x23, 0x0a, 0x04, 0x64,
|
||||||
0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x2b, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72,
|
0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x43, 0x61, 0x63, 0x68,
|
||||||
0x65, 0x61, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e,
|
0x65, 0x5f, 0x55, 0x73, 0x65, 0x72, 0x44, 0x61, 0x74, 0x61, 0x52, 0x04, 0x64, 0x61, 0x74, 0x61,
|
||||||
0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e,
|
0x22, 0x2b, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74, 0x65, 0x52, 0x65,
|
||||||
0x61, 0x6d, 0x65, 0x22, 0x0f, 0x0a, 0x0d, 0x55, 0x73, 0x65, 0x72, 0x43, 0x72, 0x65, 0x61, 0x74,
|
0x71, 0x12, 0x1a, 0x0a, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20,
|
||||||
0x65, 0x52, 0x73, 0x70, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72,
|
0x01, 0x28, 0x09, 0x52, 0x08, 0x4e, 0x69, 0x63, 0x6b, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x0f, 0x0a,
|
||||||
0x6f, 0x74, 0x6f, 0x33,
|
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 (
|
var (
|
||||||
|
Loading…
Reference in New Issue
Block a user