You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
5.5 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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";
import "api/v1/permission.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;
repeated int64 group_id = 18;
}
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 DeleteUserRequest { repeated int64 id = 1; }
message GetUserRequest { int64 id = 1; }
message ListUserRequest {
int64 page = 1;
int64 size = 2;
string wd = 3;
string sort = 4;
repeated int64 id = 5;
repeated int64 group_id = 6;
repeated int32 status = 7;
}
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 [ (gogoproto.moretags) = "validate:\"min=6\"" ];
}
message GetUserPermissionsReply{
repeated Permission permission = 1;
}
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 : '*',
};
}
// 退出登录
rpc Logout(google.protobuf.Empty) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete : '/api/v1/user/logout',
};
}
// 查询用户信息。如果传递了Id参数则表示查询用户的公开信息否则查询当前用户的私有信息
rpc GetUser(GetUserRequest) returns (User) {
option (google.api.http) = {
get : '/api/v1/user',
};
}
// 更新用户密码。如果不传用户ID则表示更新当前用户的密码
// 如果穿了用户ID则表示更新指定用户的密码这时需要验证当前用户的权限
rpc UpdateUserPassword(UpdateUserPasswordRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
put : '/api/v1/user/password',
body : '*',
};
}
// 更新用户密码。如果不传用户ID则表示更新当前用户的密码
// 如果穿了用户ID则表示更新指定用户的密码这时需要验证当前用户的权限
rpc UpdateUser(User) returns (google.protobuf.Empty) {
option (google.api.http) = {
put : '/api/v1/user',
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',
};
}
// GetUserCaptcha 获取用户验证码
rpc GetUserPermissions(google.protobuf.Empty) returns (GetUserPermissionsReply) {
option (google.api.http) = {
get : '/api/v1/user/permission',
};
}
// 获取用户粉丝列表
// 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',
// };
// }
}