Protobuf 的简单使用例子


点击我, 到底部

应用层协议设计

  • 通信双方交换数据的格式与顺序
  • 通信双方应该采取的动作

用户登陆模块

  • 短信获取
    获取短信请求 mobile_request
字段名 类型 属性 字段描述
mobile string required 手机号码, 必须为大陆手机取 11 位数字

获取短信响应 mobile_response

字段名 类型 属性 字段描述
code int32 required 响应代号: 200-成功 400-失败
icode int32 required 成功保存验证码, 失败保存0
desc string optional 可选, 失败时描述失败原因

登陆验证

  • 短信验证请求 login_request
字段名 类型 属性 字段描述
mobile string required 手机号码, 必须为大陆手机取 11 位数字
icode int32 required 验证码
  • 短信验证响应 login_response
字段名 类型 属性 字段描述
code int32 required 响应代号: 200-成功 400-失败
desc string optional 可选, 失败时描述失败原因

充值

  • 充值请求 recharge_request
字段名 类型 属性 字段描述
mobile string required 手机号码, 必须为大陆手机取 11 位数字
amount int32 required 充值数量
  • 充值响应 recharge_response
字段名 类型 属性 字段描述
code int32 required 响应代号: 200-成功 400-失败
desc string optional 可选, 失败时描述失败原因
balance int32 required 最新余额
  • 余额查询 account_balance_request
字段名 类型 属性 字段描述
mobile string required 手机号码, 必须为大陆手机取 11 位数字
  • 余额查询响应 account_balance_response
字段名 类型 属性 字段描述
code int32 required 响应代号: 200-成功 400-失败
desc string optional 可选, 失败时描述失败原因
balance int32 required 失败置为 -1

查询充值记录

  • 充值记录请求 list_account_records_request
字段名 类型 属性 字段描述
mobile string required 手机号码, 必须为大陆手机取 11 位数字
  • 充值记录响应 list_account_records_response
字段名 类型 属性 字段描述
code int32 required 响应代号: 200-成功 400-失败
desc string optional 可选, 失败时描述失败原因
records account_record required ==>>

==>>

message account_record {
    
	required int32  type = 1; // 0 : 骑行消费,  1 : 充值, 2 : 退款
	required int32  limit  = 2; // 消费或者充值金额
	required uint64 timestamp = 3; 
  • 3
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值