sponge/api/userExample/v1/userExample.proto

98 lines
2.9 KiB
Protocol Buffer
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// todo generate the protobuf code here
// delete the templates code start
syntax = "proto3";
package api.userExample.v1;
import "validate/validate.proto";
import "api/types/types.proto";
option go_package = "github.com/zhufuyi/sponge/api/userExample/v1;v1";
service userExampleService {
rpc Create(CreateUserExampleRequest) returns (CreateUserExampleReply) {}
rpc DeleteByID(DeleteUserExampleByIDRequest) returns (DeleteUserExampleByIDReply) {}
rpc UpdateByID(UpdateUserExampleByIDRequest) returns (UpdateUserExampleByIDReply) {}
rpc GetByID(GetUserExampleByIDRequest) returns (GetUserExampleByIDReply) {}
rpc List(ListUserExampleRequest) returns (ListUserExampleReply) {}
}
enum GenderType {
UNKNOWN = 0;
MALE = 1;
FEMALE = 2;
};
message CreateUserExampleRequest {
string name = 1 [(validate.rules).string.min_len = 2]; // 名称
string email = 2 [(validate.rules).string.email = true]; // 邮件
string password = 3 [(validate.rules).string.min_len = 10]; // 密码
string phone=4 [(validate.rules).string = {pattern: "^1[3456789]\\d{9}$"}]; // 手机号码
string avatar=5 [(validate.rules).string.uri = true]; // 头像
int32 age=6 [(validate.rules).int32 = {gte:0, lte: 120}]; // 年龄
GenderType gender=7 [(validate.rules).enum.defined_only = true]; // 性别1:男2:女
}
message CreateUserExampleReply {
uint64 id = 1 [(validate.rules).uint64.gte = 1];
}
message DeleteUserExampleByIDRequest {
uint64 id = 1 [(validate.rules).uint64.gte = 1];
}
message DeleteUserExampleByIDReply {
}
message UpdateUserExampleByIDRequest {
uint64 id = 1 [(validate.rules).uint64.gte = 1];
string name = 2; // 名称
string email = 3; // 邮件
string password = 4; // 密码
string phone=5; // 手机号码,必须在前加'+86'
string avatar=6; // 头像
int32 age=7; // 年龄
GenderType gender=8; // 性别1:男2:女
int32 status=9; // 账号状态
int64 login_at=10; // 登录时间戳
}
message UpdateUserExampleByIDReply {
}
message UserExample {
uint64 id = 1;
string name = 2; // 名称
string email = 3; // 邮件
string phone=4; // 手机号码,必须在前加'+86'
string avatar=5; // 头像
int32 age=6; // 年龄
GenderType gender=7; // 性别1:男2:女
int32 status=8; // 账号状态
int64 login_at=9; // 登录时间戳
int64 created_at=10; // 创建时间
int64 updated_at=11; // 更新时间
}
message GetUserExampleByIDRequest {
uint64 id = 1 [(validate.rules).uint64.gte = 1];
}
message GetUserExampleByIDReply {
UserExample userExample = 1;
}
message ListUserExampleRequest {
types.Params params = 1 [(validate.rules).message.required = true];
}
message ListUserExampleReply {
int64 total =1;
repeated UserExample userExamples = 2;
}
// delete the templates code end