From 4d72246e666327fefbb4204e744aa49c889b090b Mon Sep 17 00:00:00 2001 From: zqj <582132116@qq.com> Date: Mon, 28 Feb 2022 17:25:29 +0800 Subject: [PATCH] reactor: account, game. add models, protocode --- account.proto | 29 ++++++----------------------- doc/login.md | 52 ++++++++++++++++++++++++++++++++++++++++++---------- game.proto | 75 ++++++++++++++------------------------------------------------------------- models.proto | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ protocode.proto | 13 +++++++++++++ 5 files changed, 129 insertions(+), 94 deletions(-) create mode 100644 models.proto create mode 100644 protocode.proto diff --git a/account.proto b/account.proto index 8e89f03..d97a9a2 100644 --- a/account.proto +++ b/account.proto @@ -9,30 +9,13 @@ message ServiceInfo { string address = 3; } -message Account{ - string phone = 1; // @inject_tag: index:"unique" pri:"1" - string password = 2; - string uid = 3; -} - -message CreateTokenRsp { - int64 code = 1; - string uid = 2; - string token = 3; - repeated ServiceInfo game_service = 4; +message LoginRsp { + string uid = 1; + repeated ServiceInfo game_service = 2; } message Register { - string phone = 1; - string password = 2; - int32 code = 3; -} - -message RegisterRsp{ - int64 code = 1; -} - -service Login{ - rpc RegisterHandler(Register) returns (RegisterRsp) {} - rpc CreateTokenHandler(Account) returns (CreateTokenRsp) {} + string phone = 1; // @inject_tag: binding:"required" + string password = 2; // @inject_tag: binding:"required" + int32 code = 3; // @inject_tag: binding:"required" } \ No newline at end of file diff --git a/doc/login.md b/doc/login.md index 409a5ee..abe075b 100644 --- a/doc/login.md +++ b/doc/login.md @@ -1,14 +1,46 @@ -## 注册 & 登录流程 +## 登录服管理用户账号 +### 账号登录 & 注册流程 +1. 调用注册接口注册账号 +2. 使用注册接口返回的uid和游戏服地址,登录游戏服务 + +### 注册接口 +1. 说明:研发提供的接口必须遵循以下协议 +2. 请求方式:POST(JSON) + * 请求参数需要拼接为json,请求体是data-raw, 详情参考【请求参数】 +3. 请求参数:(以参数有就传) + +| 参数 | 类型 | 是否必须 | 备注 | +| --- | --- | --- | --- | +| phone | string | Y |手机号 | +| password | string | Y | 密码 | +| code | string | Y | 短信验证码(暂无) | + +最后参数组合示例为: +```json +{ + "phone":"17683852936", + "password":"123456" +} ``` -accountServer -rpc RegisterHandler -rpc CreateTokenHandler -gameServer -rpc LoginHandler -rpc CreateRoleHandler +请求示例: +```shell +$ curl --request POST 'http://192.168.0.206:8080/v1/register' \ +--header 'Content-Type: application/json' \ +--data '{ + "phone":"17683852936", + "password":"123456" +}' ``` -1. Account服务注册账号 -2. Account服务createToken -3. Game服务登录,判断角色是否创建, 未创建角色则创建,返回角色信息 \ No newline at end of file +返回结果: +```shell +{"code":0 ,"data":{"phone":"", "uid":"","password":""}} +``` + +### 创建token接口 + + + + +## 游戏服处理业务逻辑 \ No newline at end of file diff --git a/game.proto b/game.proto index aefd244..18cb1fb 100644 --- a/game.proto +++ b/game.proto @@ -2,73 +2,26 @@ syntax = "proto3"; option go_package = "./pb;pb"; package game; -import "google/protobuf/empty.proto"; +//import "google/protobuf/empty.proto"; +import "models.proto"; -message Hero { - int64 id = 1; // @inject_tag: index:"unique" pri:"1" - int64 role_id = 2; - int32 type = 3; - int32 level = 4; - int32 rein_count = 5; - int32 rein_point = 6; - string equipments = 7; -} - -message Equipment { - int64 id = 1; // @inject_tag: index:"unique" pri:"1" - int64 role_id = 2; - int64 type = 3; - bool equip = 4; - bool enhance_level = 5; -} - -message Prop { - int64 id = 1; // @inject_tag: index:"unique" pri:"1" - int64 count = 2; -} - -message Team { - int64 id = 1; // @inject_tag: index:"unique" pri:"1" - string hero_ids = 2; -} - -message Role{ - int64 id = 1; // @inject_tag: index:"unique" pri:"1" - string uid = 2;// @inject_tag: index:"unique" - string device = 3; - string nick = 4; - - int32 level = 5; - int64 exp = 6; - int64 hp = 7; - int64 hp_max = 8; - string buy_r = 11; - string pay_r = 12; - bool del = 13; -} - -message Token { - string token = 1; -} - -message HeartRsp { +message HeartReq { int64 code = 1; } -message RoleRsp { - int64 code = 1; - Role role = 2; - map hero = 3; - Team team = 4; - repeated Equipment equips = 5; +message LoginReq { + string uid = 1; + string device = 2; } -message LoginReq { - string device = 1; +message CreateReq { + string uid = 1; + string device = 2; } -service Game{ - rpc HeartBeatHandler(google.protobuf.Empty) returns (HeartRsp) {} - rpc LoginHandler(LoginReq) returns (RoleRsp) {} - rpc CreateRoleHandler(LoginReq) returns (RoleRsp) {} +message RoleRsp { + models.Role role = 2; + map hero = 3; + models.Team team = 4; + repeated models.Equipment equips = 5; } \ No newline at end of file diff --git a/models.proto b/models.proto new file mode 100644 index 0000000..0502026 --- /dev/null +++ b/models.proto @@ -0,0 +1,54 @@ +syntax = "proto3"; +option go_package = "./pb;pb"; + +package models; +//import "google/protobuf/empty.proto"; + +message Account{ + string phone = 1; // @inject_tag: index:"unique" pri:"1" + string password = 2; + string uid = 3; +} + +message Hero { + int64 id = 1; // @inject_tag: index:"unique" pri:"1" + int64 role_id = 2; + int32 type = 3; + int32 level = 4; + int32 rein_count = 5; + int32 rein_point = 6; + string equipments = 7; +} + +message Equipment { + int64 id = 1; // @inject_tag: index:"unique" pri:"1" + int64 role_id = 2; + int64 type = 3; + bool equip = 4; + bool enhance_level = 5; +} + +message Prop { + int64 id = 1; // @inject_tag: index:"unique" pri:"1" + int64 count = 2; +} + +message Team { + int64 id = 1; // @inject_tag: index:"unique" pri:"1" + string hero_ids = 2; +} + +message Role{ + int64 id = 1; // @inject_tag: index:"unique" pri:"1" + string uid = 2;// @inject_tag: index:"unique" + string device = 3; + string nick = 4; + + int32 level = 5; + int64 exp = 6; + int64 hp = 7; + int64 hp_max = 8; + string buy_r = 11; + string pay_r = 12; + bool del = 13; +} diff --git a/protocode.proto b/protocode.proto new file mode 100644 index 0000000..826f661 --- /dev/null +++ b/protocode.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +option go_package = "./pb;pb"; + +package protocode; + +enum ProtoCode +{ + UNKNOWN = 0x000; + HeartRpc = 01; + LoginRpc = 02; + CreateRpc = 03; + +} \ No newline at end of file -- libgit2 0.21.2