Files
sponge/api/serverNameExample/v1/userExample.proto
2022-11-28 23:11:46 +08:00

190 lines
5.8 KiB
Protocol Buffer

// todo generate the protobuf code here
// delete the templates code start
syntax = "proto3";
package api.serverNameExample.v1;
import "validate/validate.proto";
import "api/types/types.proto";
import "google/api/annotations.proto";
import "protoc-gen-openapiv2/options/annotations.proto";
import "tagger/tagger.proto";
option go_package = "github.com/zhufuyi/sponge/api/serverNameExample/v1;v1";
// default settings for generating *.swagger.json documents
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_swagger) = {
host: "localhost:8080"
base_path: ""
info: {
title: "serverNameExample api docs";
version: "v0.0.0";
};
schemes: HTTP;
schemes: HTTPS;
consumes: "application/json";
produces: "application/json";
};
service userExampleService {
rpc Create(CreateUserExampleRequest) returns (CreateUserExampleReply) {
option (google.api.http) = {
post: "/api/v1/userExample"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "create userExample",
description: "submit information to create a userExample",
tags: "userExample",
};
}
rpc DeleteByID(DeleteUserExampleByIDRequest) returns (DeleteUserExampleByIDReply) {
option (google.api.http) = {
delete: "/api/v1/userExample/{id}"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "delete userExample",
description: "delete userExample by id",
tags: "userExample",
};
}
rpc UpdateByID(UpdateUserExampleByIDRequest) returns (UpdateUserExampleByIDReply) {
option (google.api.http) = {
put: "/api/v1/userExample/{id}"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "update userExample",
description: "update userExample information based on id",
tags: "userExample",
};
}
rpc GetByID(GetUserExampleByIDRequest) returns (GetUserExampleByIDReply) {
option (google.api.http) = {
get: "/api/v1/userExample/{id}"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "get userExample details",
description: "get userExample details by id",
tags: "userExample",
};
}
rpc ListByIDs(ListUserExampleByIDsRequest) returns (ListUserExampleByIDsReply) {
option (google.api.http) = {
post: "/api/v1/userExamples/ids"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "get a list of userExample based on multiple ids",
description: "get a list of userExample based on multiple ids using a post request",
tags: "userExample",
};
}
rpc List(ListUserExampleRequest) returns (ListUserExampleReply) {
option (google.api.http) = {
post: "/api/v1/userExamples"
body: "*"
};
option (grpc.gateway.protoc_gen_openapiv2.options.openapiv2_operation) = {
summary: "get a list of userExamples",
description: "get a list of userExamples using a post request",
tags: "userExample",
};
}
}
enum GenderType {
UNKNOWN = 0;
MALE = 1;
FEMALE = 2;
};
// if using a grpc gateway, it is recommended to add target, which can be automatically verified on request.
// example: string email = 2 [(tagger.tags) = "binding:\"email\"" ];
message CreateUserExampleRequest {
string name = 1 [(validate.rules).string.min_len = 2]; // name
string email = 2 [(validate.rules).string.email = true]; // email
string password = 3 [(validate.rules).string.min_len = 10]; // password
string phone = 4 [(validate.rules).string = {pattern: "^1[3456789]\\d{9}$"}]; // phone number
string avatar = 5 [(validate.rules).string.uri = true]; // avatar
int32 age = 6 [(validate.rules).int32 = {gte:0, lte: 120}]; // age
GenderType gender = 7 [(validate.rules).enum.defined_only = true]; // gender, 1:Male, 2:Female, other values:unknown
}
message CreateUserExampleReply {
uint64 id = 1;
}
message DeleteUserExampleByIDRequest {
uint64 id = 1 [(validate.rules).uint64.gte = 1, (tagger.tags) = "uri:\"id\"" ];
}
message DeleteUserExampleByIDReply {
}
message UpdateUserExampleByIDRequest {
uint64 id = 1 [(validate.rules).uint64.gte = 1 , (tagger.tags) = "uri:\"id\"" ];
string name = 2; // name
string email = 3; // email
string password = 4; // password
string phone = 5; // phone number
string avatar = 6; // avatar
int32 age = 7; // age
GenderType gender = 8; // gender, 1:Male, 2:Female, other values:unknown
int32 status = 9; // account status
int64 login_at = 10; // login timestamp
}
message UpdateUserExampleByIDReply {
}
message UserExample {
uint64 id = 1;
string name = 2; // name
string email = 3; // email
string phone = 4; // phone number
string avatar = 5; // avatar
int32 age = 6; // age
GenderType gender = 7; // gender, 1:Male, 2:Female, other values:unknown
int32 status = 8; // account status
int64 login_at = 9; // login timestamp
int64 created_at = 10; // creation time
int64 updated_at = 11; // update time
}
message GetUserExampleByIDRequest {
uint64 id = 1 [(validate.rules).uint64.gte = 1, (tagger.tags) = "uri:\"id\"" ];
}
message GetUserExampleByIDReply {
UserExample userExample = 1;
}
message ListUserExampleByIDsRequest {
repeated uint64 ids = 1;
}
message ListUserExampleByIDsReply {
repeated UserExample userExamples = 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