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.

306 lines
9.0 KiB

2 years ago
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";
2 years ago
import "api/v1/permission.proto";
2 years ago
package api.v1;
option go_package = "moredoc/api/v1;v1";
option java_multiple_files = true;
option java_package = "api.v1";
1 year ago
// 用户信息
2 years ago
message User {
1 year ago
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; // 用户ID
string username = 2; // 用户名
string mobile = 3; // 手机号
string email = 4; // 邮箱,唯一
string address = 5; // 地址
string signature = 6; // 个性签名
string last_login_ip = 7; // 最后登录IP
string register_ip = 8; // 注册IP
int32 doc_count = 9; // 文档数量
int32 follow_count = 10; // 关注数量
int32 fans_count = 11; // 粉丝数量
int32 favorite_count = 12; // 收藏数量
int32 comment_count = 13; // 评论数量
int32 status = 14; // 用户状态,见 web/utils/enum.js当前没有使用
string avatar = 15; // 头像
string identity = 16; // 身份证
string realname = 17; // 真实姓名
repeated int64 group_id = 18; // 用户组ID
int32 credit_count = 22; // 积分
2 years ago
}
1 year ago
// 用户注册登录请求
2 years ago
message RegisterAndLoginRequest {
1 year ago
string username = 1
[ (gogoproto.moretags) = "validate:\"min=3,max=32\"" ]; // 用户名
string password = 2 [ (gogoproto.moretags) = "validate:\"min=6\"" ]; // 密码
string captcha = 3; // 验证码
string captcha_id = 4; // 验证码ID
string email = 5; // 邮箱
}
1 year ago
// 查询验证码请求
message GetUserCaptchaRequest {
2 years ago
string type =
1; // 验证码类型register、login、comment、find_password、upload
2 years ago
}
1 year ago
// 用户登录响应
2 years ago
message LoginReply {
string token = 1;
User user = 2;
}
2 years ago
1 year ago
// 删除用户
2 years ago
message DeleteUserRequest { repeated int64 id = 1; }
1 year ago
// 获取用户信息
2 years ago
message GetUserRequest { int64 id = 1; }
1 year ago
// 找回密码
message FindPasswordRequest {
1 year ago
string email = 1; // 邮箱
string token = 2; // 签名token
string password = 3 [ (gogoproto.moretags) = "validate:\"min=6\"" ]; // 新密码
string captcha = 4; // 验证码
string captcha_id = 5; // 验证码ID
}
1 year ago
// 用户列表请求
2 years ago
message ListUserRequest {
1 year ago
int64 page = 1; // 页码
int64 size = 2; // 每页数量
string wd = 3; // 搜索关键词
string sort = 4; // 排序字段
repeated int64 id = 5; // 用户ID
repeated int64 group_id = 6; // 用户组ID
repeated int32 status = 7; // 用户状态
int64 limit = 8; // 请求数量限制大于0时page和size无效
2 years ago
}
1 year ago
// 用户列表响应
2 years ago
message ListUserReply {
1 year ago
int64 total = 1; // 总数
repeated User user = 2; // 用户列表
2 years ago
}
1 year ago
// 验证码响应
message GetUserCaptchaReply {
1 year ago
bool enable = 1; // 是否启用验证码
string id = 2; // 验证码ID
string captcha = 3; // 验证码
string type = 4; // 验证码类型
}
2 years ago
// 修改用户密码
message UpdateUserPasswordRequest {
1 year ago
int64 id = 1; // 用户ID
string old_password = 2; // 旧密码
string new_password = 3
[ (gogoproto.moretags) = "validate:\"min=6\"" ]; // 新密码
2 years ago
}
1 year ago
// 用户权限信息查询
2 years ago
message GetUserPermissionsReply { repeated Permission permission = 1; }
1 year ago
// 管理后台设置用户信息
2 years ago
message SetUserRequest {
1 year ago
int64 id = 1; // 用户ID
string username = 2
[ (gogoproto.moretags) = "validate:\"min=3,max=32\"" ]; // 用户名
string password = 3 [ (gogoproto.moretags) = "validate:\"min=6\"" ]; // 密码
repeated int64 group_id = 4; // 用户组ID
string email = 5; // 邮箱
2 years ago
}
1 year ago
// 用户动态
message Dynamic {
1 year ago
int64 id = 1; // 动态ID
int64 user_id = 2; // 用户ID
string content = 3; // 内容
int32 type = 4; // 类型
string username = 7; // 用户名
google.protobuf.Timestamp created_at = 5
[ (gogoproto.stdtime) = true ]; // 创建时间
google.protobuf.Timestamp updated_at = 6
[ (gogoproto.stdtime) = true ]; // 更新时间
}
1 year ago
// 用户动态列表请求
message ListUserDynamicRequest {
1 year ago
int64 page = 1; // 页码
int64 size = 2; // 每页数量
int64 id = 3; // 用户ID
}
1 year ago
// 用户动态列表响应
message ListUserDynamicReply {
1 year ago
int64 total = 1; // 总数
repeated Dynamic dynamic = 2; // 动态列表
}
1 year ago
// 用户签到
message Sign {
1 year ago
int64 id = 1; // 签到ID
int64 user_id = 2; // 用户ID
int32 sign_at = 3; // 签到日期
string ip = 4; // 签到IP
google.protobuf.Timestamp created_at = 5
[ (gogoproto.stdtime) = true ]; // 创建时间
int32 award = 6; // 签到积分奖励
}
2 years ago
service UserAPI {
// 用户注册
rpc Register(RegisterAndLoginRequest) returns (LoginReply) {
2 years ago
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',
};
}
2 years ago
// 查询用户信息。如果传递了Id参数则表示查询用户的公开信息否则查询当前用户的私有信息
rpc GetUser(GetUserRequest) returns (User) {
option (google.api.http) = {
get : '/api/v1/user',
};
}
// 更新用户密码。如果不传用户ID则表示更新当前用户的密码
// 如果穿了用户ID则表示更新指定用户的密码这时需要验证当前用户的权限
2 years ago
rpc UpdateUserPassword(UpdateUserPasswordRequest)
returns (google.protobuf.Empty) {
2 years ago
option (google.api.http) = {
put : '/api/v1/user/password',
body : '*',
};
}
2 years ago
// 更新用户密码。如果不传用户ID则表示更新当前用户的密码
// 如果穿了用户ID则表示更新指定用户的密码这时需要验证当前用户的权限
2 years ago
rpc UpdateUserProfile(User) returns (google.protobuf.Empty) {
2 years ago
option (google.api.http) = {
2 years ago
put : '/api/v1/user/profile',
2 years ago
body : '*',
};
}
2 years ago
// 删除用户。需要验证用户权限
rpc DeleteUser(DeleteUserRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete : '/api/v1/user',
};
}
2 years ago
// 新增用户
rpc AddUser(SetUserRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
post : '/api/v1/user',
body : '*',
};
}
// 设置用户
rpc SetUser(SetUserRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
put : '/api/v1/user',
body : '*',
};
}
2 years ago
// 查询用户列表。对于非管理员,返回相应用户的公开信息;
// 对于管理员,返回相应用户的绝大部分信息
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',
};
}
2 years ago
// GetUserCaptcha 获取用户验证码
2 years ago
rpc GetUserPermissions(google.protobuf.Empty)
returns (GetUserPermissionsReply) {
2 years ago
option (google.api.http) = {
get : '/api/v1/user/permission',
};
}
// 用户是否可以上传文档
rpc CanIUploadDocument(google.protobuf.Empty)
returns (google.protobuf.Empty) {
option (google.api.http) = {
get : '/api/v1/user/caniuploaddocument',
};
}
// 获取用户动态,包括获取关注的用户的动态
rpc ListUserDynamic(ListUserDynamicRequest) returns (ListUserDynamicReply) {
option (google.api.http) = {
get : '/api/v1/user/dynamic',
};
}
// 每日签到
rpc SignToday(google.protobuf.Empty) returns (Sign) {
option (google.api.http) = {
put : '/api/v1/user/sign',
};
}
// 获取今日已签到记录
rpc GetSignedToday(google.protobuf.Empty) returns (Sign) {
option (google.api.http) = {
get : '/api/v1/user/sign',
};
}
1 year ago
// 找回密码:第一步,发送验证码
rpc FindPasswordStepOne(FindPasswordRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
post : '/api/v1/user/findpassword/stepone',
body : '*',
};
}
1 year ago
// 找回密码:第二步,修改密码
rpc FindPasswordStepTwo(FindPasswordRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
put : '/api/v1/user/findpassword/steptwo',
body : '*',
};
}
2 years ago
}