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) { ok, account := models.AccountExistByPhone(in.Phone) 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 } 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 }