Commit 4d72246e666327fefbb4204e744aa49c889b090b

Authored by zhangqijia
1 parent f39667f5

reactor: account, game. add models, protocode

account.proto
... ... @@ -9,30 +9,13 @@ message ServiceInfo {
9 9 string address = 3;
10 10 }
11 11  
12   -message Account{
13   - string phone = 1; // @inject_tag: index:"unique" pri:"1"
14   - string password = 2;
15   - string uid = 3;
16   -}
17   -
18   -message CreateTokenRsp {
19   - int64 code = 1;
20   - string uid = 2;
21   - string token = 3;
22   - repeated ServiceInfo game_service = 4;
  12 +message LoginRsp {
  13 + string uid = 1;
  14 + repeated ServiceInfo game_service = 2;
23 15 }
24 16  
25 17 message Register {
26   - string phone = 1;
27   - string password = 2;
28   - int32 code = 3;
29   -}
30   -
31   -message RegisterRsp{
32   - int64 code = 1;
33   -}
34   -
35   -service Login{
36   - rpc RegisterHandler(Register) returns (RegisterRsp) {}
37   - rpc CreateTokenHandler(Account) returns (CreateTokenRsp) {}
  18 + string phone = 1; // @inject_tag: binding:"required"
  19 + string password = 2; // @inject_tag: binding:"required"
  20 + int32 code = 3; // @inject_tag: binding:"required"
38 21 }
39 22 \ No newline at end of file
... ...
doc/login.md
1 1  
2   -## 注册 & 登录流程
  2 +## 登录服管理用户账号
  3 +### 账号登录 & 注册流程
  4 +1. 调用注册接口注册账号
  5 +2. 使用注册接口返回的uid和游戏服地址,登录游戏服务
  6 +
  7 +### 注册接口
  8 +1. 说明:研发提供的接口必须遵循以下协议
  9 +2. 请求方式:POST(JSON)
  10 + * 请求参数需要拼接为json,请求体是data-raw, 详情参考【请求参数】
  11 +3. 请求参数:(以参数有就传)
  12 +
  13 +| 参数 | 类型 | 是否必须 | 备注 |
  14 +| --- | --- | --- | --- |
  15 +| phone | string | Y |手机号 |
  16 +| password | string | Y | 密码 |
  17 +| code | string | Y | 短信验证码(暂无) |
  18 +
  19 +最后参数组合示例为:
  20 +```json
  21 +{
  22 + "phone":"17683852936",
  23 + "password":"123456"
  24 +}
3 25 ```
4   -accountServer
5   -rpc RegisterHandler
6   -rpc CreateTokenHandler
7 26  
8   -gameServer
9   -rpc LoginHandler
10   -rpc CreateRoleHandler
  27 +请求示例:
  28 +```shell
  29 +$ curl --request POST 'http://192.168.0.206:8080/v1/register' \
  30 +--header 'Content-Type: application/json' \
  31 +--data '{
  32 + "phone":"17683852936",
  33 + "password":"123456"
  34 +}'
11 35 ```
12   -1. Account服务注册账号
13   -2. Account服务createToken
14   -3. Game服务登录,判断角色是否创建, 未创建角色则创建,返回角色信息
15 36 \ No newline at end of file
  37 +返回结果:
  38 +```shell
  39 +{"code":0 ,"data":{"phone":"", "uid":"","password":""}}
  40 +```
  41 +
  42 +### 创建token接口
  43 +
  44 +
  45 +
  46 +
  47 +## 游戏服处理业务逻辑
16 48 \ No newline at end of file
... ...
game.proto
... ... @@ -2,73 +2,26 @@ syntax = "proto3";
2 2 option go_package = "./pb;pb";
3 3  
4 4 package game;
5   -import "google/protobuf/empty.proto";
  5 +//import "google/protobuf/empty.proto";
  6 +import "models.proto";
6 7  
7   -message Hero {
8   - int64 id = 1; // @inject_tag: index:"unique" pri:"1"
9   - int64 role_id = 2;
10   - int32 type = 3;
11   - int32 level = 4;
12   - int32 rein_count = 5;
13   - int32 rein_point = 6;
14   - string equipments = 7;
15   -}
16   -
17   -message Equipment {
18   - int64 id = 1; // @inject_tag: index:"unique" pri:"1"
19   - int64 role_id = 2;
20   - int64 type = 3;
21   - bool equip = 4;
22   - bool enhance_level = 5;
23   -}
24   -
25   -message Prop {
26   - int64 id = 1; // @inject_tag: index:"unique" pri:"1"
27   - int64 count = 2;
28   -}
29   -
30   -message Team {
31   - int64 id = 1; // @inject_tag: index:"unique" pri:"1"
32   - string hero_ids = 2;
33   -}
34   -
35   -message Role{
36   - int64 id = 1; // @inject_tag: index:"unique" pri:"1"
37   - string uid = 2;// @inject_tag: index:"unique"
38   - string device = 3;
39   - string nick = 4;
40   -
41   - int32 level = 5;
42   - int64 exp = 6;
43   - int64 hp = 7;
44   - int64 hp_max = 8;
45   - string buy_r = 11;
46   - string pay_r = 12;
47   - bool del = 13;
48   -}
49   -
50   -message Token {
51   - string token = 1;
52   -}
53   -
54   -message HeartRsp {
  8 +message HeartReq {
55 9 int64 code = 1;
56 10 }
57 11  
58   -message RoleRsp {
59   - int64 code = 1;
60   - Role role = 2;
61   - map<string, Hero> hero = 3;
62   - Team team = 4;
63   - repeated Equipment equips = 5;
  12 +message LoginReq {
  13 + string uid = 1;
  14 + string device = 2;
64 15 }
65 16  
66   -message LoginReq {
67   - string device = 1;
  17 +message CreateReq {
  18 + string uid = 1;
  19 + string device = 2;
68 20 }
69 21  
70   -service Game{
71   - rpc HeartBeatHandler(google.protobuf.Empty) returns (HeartRsp) {}
72   - rpc LoginHandler(LoginReq) returns (RoleRsp) {}
73   - rpc CreateRoleHandler(LoginReq) returns (RoleRsp) {}
  22 +message RoleRsp {
  23 + models.Role role = 2;
  24 + map<string, models.Hero> hero = 3;
  25 + models.Team team = 4;
  26 + repeated models.Equipment equips = 5;
74 27 }
75 28 \ No newline at end of file
... ...
models.proto 0 → 100644
... ... @@ -0,0 +1,54 @@
  1 +syntax = "proto3";
  2 +option go_package = "./pb;pb";
  3 +
  4 +package models;
  5 +//import "google/protobuf/empty.proto";
  6 +
  7 +message Account{
  8 + string phone = 1; // @inject_tag: index:"unique" pri:"1"
  9 + string password = 2;
  10 + string uid = 3;
  11 +}
  12 +
  13 +message Hero {
  14 + int64 id = 1; // @inject_tag: index:"unique" pri:"1"
  15 + int64 role_id = 2;
  16 + int32 type = 3;
  17 + int32 level = 4;
  18 + int32 rein_count = 5;
  19 + int32 rein_point = 6;
  20 + string equipments = 7;
  21 +}
  22 +
  23 +message Equipment {
  24 + int64 id = 1; // @inject_tag: index:"unique" pri:"1"
  25 + int64 role_id = 2;
  26 + int64 type = 3;
  27 + bool equip = 4;
  28 + bool enhance_level = 5;
  29 +}
  30 +
  31 +message Prop {
  32 + int64 id = 1; // @inject_tag: index:"unique" pri:"1"
  33 + int64 count = 2;
  34 +}
  35 +
  36 +message Team {
  37 + int64 id = 1; // @inject_tag: index:"unique" pri:"1"
  38 + string hero_ids = 2;
  39 +}
  40 +
  41 +message Role{
  42 + int64 id = 1; // @inject_tag: index:"unique" pri:"1"
  43 + string uid = 2;// @inject_tag: index:"unique"
  44 + string device = 3;
  45 + string nick = 4;
  46 +
  47 + int32 level = 5;
  48 + int64 exp = 6;
  49 + int64 hp = 7;
  50 + int64 hp_max = 8;
  51 + string buy_r = 11;
  52 + string pay_r = 12;
  53 + bool del = 13;
  54 +}
... ...
protocode.proto 0 → 100644
... ... @@ -0,0 +1,13 @@
  1 +syntax = "proto3";
  2 +option go_package = "./pb;pb";
  3 +
  4 +package protocode;
  5 +
  6 +enum ProtoCode
  7 +{
  8 + UNKNOWN = 0x000;
  9 + HeartRpc = 01;
  10 + LoginRpc = 02;
  11 + CreateRpc = 03;
  12 +
  13 +}
0 14 \ No newline at end of file
... ...