|
|
syntax = "proto3";
|
|
|
|
|
|
import "google/protobuf/timestamp.proto";
|
|
|
import "gogoproto/gogo.proto";
|
|
|
// import "validate/validate.proto";
|
|
|
import "google/api/annotations.proto";
|
|
|
import "google/protobuf/empty.proto";
|
|
|
|
|
|
package api.v1;
|
|
|
|
|
|
option go_package = "moredoc/api/v1;v1";
|
|
|
option java_multiple_files = true;
|
|
|
option java_package = "api.v1";
|
|
|
|
|
|
message User {
|
|
|
google.protobuf.Timestamp login_at = 19 [ (gogoproto.stdtime) = true ];
|
|
|
google.protobuf.Timestamp created_at = 20 [ (gogoproto.stdtime) = true ];
|
|
|
google.protobuf.Timestamp updated_at = 21 [ (gogoproto.stdtime) = true ];
|
|
|
int64 id = 1;
|
|
|
string username = 2;
|
|
|
string mobile = 3;
|
|
|
string email = 4;
|
|
|
string address = 5;
|
|
|
string signature = 6;
|
|
|
string last_login_ip = 7;
|
|
|
string register_ip = 8;
|
|
|
int32 doc_count = 9;
|
|
|
int32 follow_count = 10;
|
|
|
int32 fans_count = 11;
|
|
|
int32 favorite_count = 12;
|
|
|
int32 comment_count = 13;
|
|
|
int32 status = 14;
|
|
|
string avatar = 15;
|
|
|
string identity = 16;
|
|
|
string realname = 17;
|
|
|
}
|
|
|
|
|
|
message RegisterAndLoginRequest {
|
|
|
string username = 1 [ (gogoproto.moretags) = "validate:\"min=4,max=32\"" ];
|
|
|
string password = 2 [ (gogoproto.moretags) = "validate:\"min=6\"" ];
|
|
|
string captcha = 3;
|
|
|
string captcha_id = 4;
|
|
|
}
|
|
|
|
|
|
message GetUserCaptchaRequest {
|
|
|
string type = 1; // 验证码类型:register、login、comment、find_password、upload
|
|
|
}
|
|
|
|
|
|
message LoginReply {
|
|
|
string token = 1;
|
|
|
User user = 2;
|
|
|
}
|
|
|
|
|
|
message UpdateUserRequest {
|
|
|
int64 id = 1;
|
|
|
string name = 2;
|
|
|
}
|
|
|
|
|
|
message DeleteUserRequest { repeated int64 id = 1; }
|
|
|
|
|
|
message GetUserRequest { int64 id = 1; }
|
|
|
|
|
|
message ListUserRequest {
|
|
|
int64 page = 1;
|
|
|
int64 size = 2;
|
|
|
repeated int64 ids = 3;
|
|
|
}
|
|
|
|
|
|
message ListUserReply {
|
|
|
int64 total = 1;
|
|
|
repeated User user = 2;
|
|
|
}
|
|
|
|
|
|
message GetUserCaptchaReply {
|
|
|
bool enable = 1;
|
|
|
string id = 2;
|
|
|
string captcha = 3;
|
|
|
string type = 4;
|
|
|
}
|
|
|
|
|
|
// 修改用户密码
|
|
|
message UpdateUserPasswordRequest {
|
|
|
int64 id = 1;
|
|
|
string old_password = 2;
|
|
|
string new_password = 3;
|
|
|
}
|
|
|
|
|
|
service UserAPI {
|
|
|
// 用户注册
|
|
|
rpc Register(RegisterAndLoginRequest) returns (google.protobuf.Empty) {
|
|
|
option (google.api.http) = {
|
|
|
post : '/api/v1/user/register',
|
|
|
body : '*',
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// 用户登录
|
|
|
rpc Login(RegisterAndLoginRequest) returns (LoginReply) {
|
|
|
option (google.api.http) = {
|
|
|
post : '/api/v1/user/login',
|
|
|
body : '*',
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// 查询用户信息。如果传递了Id参数,则表示查询用户的公开信息,否则查询当前用户的私有信息
|
|
|
rpc GetUser(GetUserRequest) returns (User) {
|
|
|
option (google.api.http) = {
|
|
|
get : '/api/v1/user',
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// 更新用户密码。如果不传用户ID,则表示更新当前用户的密码;
|
|
|
// 如果穿了用户ID,则表示更新指定用户的密码,这时需要验证当前用户的权限
|
|
|
rpc UpdateUserPassword(UpdateUserRequest) returns (User) {
|
|
|
option (google.api.http) = {
|
|
|
put : '/api/v1/user/password',
|
|
|
body : '*',
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// 更新用户密码。如果不传用户ID,则表示更新当前用户的密码;
|
|
|
// 如果穿了用户ID,则表示更新指定用户的密码,这时需要验证当前用户的权限
|
|
|
rpc UpdateUser(User) returns (User) {
|
|
|
option (google.api.http) = {
|
|
|
put : '/api/v1/user/password',
|
|
|
body : '*',
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// 删除用户。需要验证用户权限
|
|
|
rpc DeleteUser(DeleteUserRequest) returns (google.protobuf.Empty) {
|
|
|
option (google.api.http) = {
|
|
|
delete : '/api/v1/user',
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// 查询用户列表。对于非管理员,返回相应用户的公开信息;
|
|
|
// 对于管理员,返回相应用户的绝大部分信息
|
|
|
rpc ListUser(ListUserRequest) returns (ListUserReply) {
|
|
|
option (google.api.http) = {
|
|
|
get : '/api/v1/user/list',
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// GetUserCaptcha 获取用户验证码
|
|
|
rpc GetUserCaptcha(GetUserCaptchaRequest) returns (GetUserCaptchaReply) {
|
|
|
option (google.api.http) = {
|
|
|
get : '/api/v1/user/captcha',
|
|
|
};
|
|
|
}
|
|
|
|
|
|
// 获取用户粉丝列表
|
|
|
// rpc ListUserFans(ListUserFansRequest) returns (ListUserReply) {
|
|
|
// option (google.api.http) = {
|
|
|
// get : '/api/v1/user/fans',
|
|
|
// };
|
|
|
// }
|
|
|
|
|
|
// // 获取用户关注列表
|
|
|
// rpc ListUserFollow(ListUserFollowRequest) returns (ListUserReply) {
|
|
|
// option (google.api.http) = {
|
|
|
// get : '/api/v1/user/follow',
|
|
|
// };
|
|
|
// }
|
|
|
|
|
|
// // 获取用户收藏列表
|
|
|
// rpc ListUserFavorite(ListUserFavoriteRequest) returns (ListUserReply) {
|
|
|
// option (google.api.http) = {
|
|
|
// get : '/api/v1/user/favorite',
|
|
|
// };
|
|
|
// }
|
|
|
|
|
|
// // 获取用户文档列表
|
|
|
// rpc ListUserDocument(ListUserDocumentRequest) returns (ListUserReply) {
|
|
|
// option (google.api.http) = {
|
|
|
// get : '/api/v1/user/document',
|
|
|
// };
|
|
|
// }
|
|
|
|
|
|
// // 获取用户评论列表
|
|
|
// rpc ListUserComment(ListUserCommentRequest) returns (ListUserReply) {
|
|
|
// option (google.api.http) = {
|
|
|
// get : '/api/v1/user/comment',
|
|
|
// };
|
|
|
// }
|
|
|
} |