70 lines
1.4 KiB
Protocol Buffer
70 lines
1.4 KiB
Protocol Buffer
// 使用的是proto3版本
|
|
syntax = "proto3";
|
|
// 定义命名空间,后续生成代码时就会生成对应的命名空间
|
|
option csharp_namespace = "gRPC.ZHiZHUN.AuthServer.protos";
|
|
|
|
/*
|
|
每一句需要用分号结尾
|
|
message 用来定义请求和返回数据格式
|
|
tag message后面的值数字代表是字段的标识(tag),不是赋值,
|
|
*/
|
|
|
|
|
|
// 新增用户时需要传递数据消息, 可理解为一个类
|
|
message GetTokenReuqest{
|
|
string id=1;
|
|
string userName=2;
|
|
string realName=3;
|
|
string reviewerCode=4;
|
|
int32 userTypeEnumInt=5;
|
|
string userTypeShortName=6;
|
|
bool isAdmin=7;
|
|
|
|
}
|
|
|
|
// 新增时返回的消息格式
|
|
message GetTokenResponse {
|
|
int32 code=1;
|
|
string token =2;
|
|
}
|
|
|
|
|
|
// service 用标识定义服务的,里面写对应的方法
|
|
service TokenGrpcService{
|
|
// 获取token
|
|
rpc GetUserToken(GetTokenReuqest) returns (GetTokenResponse);
|
|
|
|
}
|
|
|
|
/*
|
|
// 新增用户时需要传递数据消息, 可理解为一个类
|
|
message AddUserReuqest{
|
|
string name=1;
|
|
int32 age=2;
|
|
bool isBoy=3;
|
|
}
|
|
// 新增时返回的消息格式
|
|
message ResultResponse {
|
|
int32 code=1;
|
|
string msg =2;
|
|
}
|
|
//传递的查询条件信息格式,可理解为平时传入的查询条件对象
|
|
message QueryUserReuqest{
|
|
string name=1;
|
|
}
|
|
//查询返回的用户信息格式,可理解为返回的类
|
|
message UserInfoResponse {
|
|
string name=1;
|
|
int32 age=2;
|
|
string gender=3;
|
|
}
|
|
|
|
// service 用标识定义服务的,里面写对应的方法
|
|
service UserService{
|
|
// 新增用户
|
|
rpc AddUser(AddUserReuqest) returns (ResultResponse);
|
|
// 查询用户
|
|
rpc GetAllUser(QueryUserReuqest) returns (UserInfoResponse);
|
|
}
|
|
*/
|