ee23102d
zhangqijia
支持mongo, grpc接服务器
|
1
2
3
4
5
6
7
8
9
10
11
12
|
package actions
import (
"context"
"fmt"
"pro2d/conf"
"pro2d/models"
"pro2d/protos/pb"
"pro2d/utils"
)
func (s *AccountServer) RegisterHandler(ctx context.Context, in *pb.Register) (*pb.PubRsp, error) {
|
ee23102d
zhangqijia
支持mongo, grpc接服务器
|
14
15
16
17
18
19
20
21
22
23
24
25
26
|
if !ok {
account.Phone = in.Phone
account.Password = utils.Md5V(in.Password)
account.Uid = conf.SnowFlack.NextVal()
account.Device = "123123"
account.Create()
}else {
return nil, fmt.Errorf("1")
}
return &pb.PubRsp{
Code: 0,
}, nil
|
ee23102d
zhangqijia
支持mongo, grpc接服务器
|
27
28
29
30
31
32
33
34
35
36
37
38
|
}
func (s *AccountServer) CreateTokenHandler(ctx context.Context, in *pb.AccountInfo) (*pb.CreateTokenRsp, error) {
return &pb.CreateTokenRsp{
Token: utils.CreateToken(in),
GameService: &pb.ServiceInfo{
Id: "1",
Name: conf.GlobalConf.GameConf.Name,
Address: fmt.Sprintf("%s:%d",conf.GlobalConf.GameConf.IP, conf.GlobalConf.GameConf.Port),
},
}, nil
}
|