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.

292 lines
8.8 KiB

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/attachment.proto";
import "api/v1/user.proto";
package api.v1;
option go_package = "moredoc/api/v1;v1";
option java_multiple_files = true;
option java_package = "api.v1";
1 year ago
// 文档
message Document {
1 year ago
int64 id = 1; // 文档ID
string title = 2; // 文档标题
string keywords = 3; // 文档关键字
string description = 4; // 文档描述
int64 user_id = 5; // 文档作者
string cover = 6; // 文档封面
int32 width = 7; // 文档宽度
int32 height = 8; // 文档高度
int32 preview = 9; // 文档可预览页数0表示不限制
int32 pages = 10; // 文档页数
string uuid = 11; // 文档UUID
int32 download_count = 12; // 文档下载次数
int32 view_count = 13; // 文档浏览次数
int32 favorite_count = 14; // 文档收藏次数
int32 comment_count = 15; // 文档评论次数
int32 score = 16; // 文档评分
int32 score_count = 17; // 文档评分次数
int32 price = 18; // 文档价格
int64 size = 19; // 文档大小
int32 status = 20; // 文档状态,见 web/utils/enum.js
google.protobuf.Timestamp created_at = 21
[ (gogoproto.stdtime) = true ]; // 文档创建时间
google.protobuf.Timestamp updated_at = 22
[ (gogoproto.stdtime) = true ]; // 文档更新时间
google.protobuf.Timestamp deleted_at = 23
[ (gogoproto.stdtime) = true ]; // 文档删除时间
google.protobuf.Timestamp recommend_at = 29
[ (gogoproto.stdtime) = true ]; // 文档推荐时间
int64 deleted_user_id = 24; // 删除文档的用户
string username = 25; // 文档作者用户名
repeated int64 category_id = 26; // 文档分类ID
string deleted_username = 27; // 删除文档的用户名
string ext = 28; // 文档扩展名
Attachment attachment = 30; // 文档附件
User user = 31; // 文档作者
bool enable_gzip = 32; // 是否启用gzip压缩
string convert_error = 33; // 转换错误信息
}
1 year ago
// 删除文档,放入回收站
message DeleteDocumentRequest { repeated int64 id = 1; }
1 year ago
// 恢复文档
2 years ago
message RecoverRecycleDocumentRequest { repeated int64 id = 1; }
1 year ago
// 查询文档
1 year ago
message GetDocumentRequest {
1 year ago
int64 id = 1; // 文档ID
bool with_author = 2; // 是否查询作者信息
1 year ago
}
1 year ago
// 文档列表
message ListDocumentRequest {
1 year ago
int64 page = 1; // 页码
int64 size = 2; // 每页数量
string wd = 3; // 搜索关键字
repeated string field = 4; // 查询字段
string order = 5; // 排序
repeated int64 category_id = 6; // 分类ID
repeated int64 user_id = 7; // 用户ID
repeated int32 status = 8; // 文档状态
repeated bool is_recommend = 9; // 是否推荐
int64 limit = 10; // 查询数量显示。当该值大于0时page和size无效
}
1 year ago
// 文档列表
message ListDocumentReply {
1 year ago
int64 total = 1; // 文档总数
repeated Document document = 2; // 文档列表
}
1 year ago
// 创建文档
1 year ago
message CreateDocumentItem {
1 year ago
string title = 1; // 文档标题
int64 attachment_id = 2; // 文档附件ID
int32 price = 3; // 文档价格
}
1 year ago
// 创建文档
message CreateDocumentRequest {
1 year ago
bool overwrite = 1; // 是否覆盖。暂时用不到
repeated int64 category_id = 2; // 文档分类ID
repeated CreateDocumentItem document = 3; // 文档列表
}
1 year ago
// 设置文档推荐
1 year ago
message SetDocumentRecommendRequest {
1 year ago
repeated int64 id = 1; // 文档ID
int32 type = 2; // 0, 取消推荐1:推荐 2:重新推荐
1 year ago
}
1 year ago
// 查询文档(针对首页的查询)
1 year ago
message ListDocumentForHomeRequest { int64 limit = 1; }
1 year ago
1 year ago
// 首页文档查询返回项
1 year ago
message ListDocumentForHomeItem {
1 year ago
int64 category_id = 1; // 分类ID
string category_cover = 2; // 分类封面
string category_name = 3; // 分类名称
repeated Document document = 4; // 文档列表
1 year ago
}
1 year ago
// 查询文档(针对首页的查询)
1 year ago
message ListDocumentForHomeResponse {
1 year ago
repeated ListDocumentForHomeItem document = 1; // 文档列表
1 year ago
}
1 year ago
1 year ago
// 文档搜索
1 year ago
message SearchDocumentRequest {
1 year ago
int32 page = 1; // 页码
int32 size = 2; // 每页数量
string wd = 3; // 搜索关键字
1 year ago
repeated int64 category_id = 4; // 分类
1 year ago
string sort = 5; // 排序
string ext = 7; // 类型
1 year ago
}
1 year ago
// 文档评分
message DocumentScore {
1 year ago
int64 id = 1; // 评分ID
int64 document_id = 2; // 文档ID
int64 user_id = 3; // 用户ID
int32 score = 4; // 评分100~500100为1分500为5分
google.protobuf.Timestamp created_at = 5
[ (gogoproto.stdtime) = true ]; // 评分时间
google.protobuf.Timestamp updated_at = 6
[ (gogoproto.stdtime) = true ]; // 更新时间
}
1 year ago
// 文档搜索响应
1 year ago
message SearchDocumentReply {
1 year ago
int64 total = 1; // 文档总数
string spend = 2; // 搜索耗时
repeated Document document = 3; // 文档列表
1 year ago
}
1 year ago
// 文档下载
1 year ago
message DownloadDocumentReply { string url = 1; }
1 year ago
// 文档服务
service DocumentAPI {
1 year ago
// 针对首页的文档查询
1 year ago
rpc ListDocumentForHome(ListDocumentForHomeRequest)
returns (ListDocumentForHomeResponse) {
1 year ago
option (google.api.http) = {
get : '/api/v1/document/home',
};
}
1 year ago
// 设置文档推荐
1 year ago
rpc SetDocumentRecommend(SetDocumentRecommendRequest)
returns (google.protobuf.Empty) {
1 year ago
option (google.api.http) = {
put : '/api/v1/document/recommend',
body : '*',
};
}
1 year ago
1 year ago
// 创建文档
rpc CreateDocument(CreateDocumentRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
post : '/api/v1/document',
body : '*',
};
}
1 year ago
// 更新文档
rpc UpdateDocument(Document) returns (google.protobuf.Empty) {
option (google.api.http) = {
put : '/api/v1/document',
body : '*',
};
}
1 year ago
// 删除文档
rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete : '/api/v1/document',
};
}
1 year ago
// 查询文档
rpc GetDocument(GetDocumentRequest) returns (Document) {
option (google.api.http) = {
get : '/api/v1/document',
};
}
1 year ago
// 根据文档ID查询当前文档的相关文档
1 year ago
rpc GetRelatedDocuments(Document) returns (ListDocumentReply) {
option (google.api.http) = {
get : '/api/v1/document/related',
};
}
1 year ago
// 根据文档ID获取文档下载链接
rpc DownloadDocument(Document) returns (DownloadDocumentReply) {
option (google.api.http) = {
get : '/api/v1/document/download',
};
}
1 year ago
// 文档列表查询
rpc ListDocument(ListDocumentRequest) returns (ListDocumentReply) {
option (google.api.http) = {
get : '/api/v1/document/list',
};
}
1 year ago
1 year ago
// 文档搜索
1 year ago
rpc SearchDocument(SearchDocumentRequest) returns (SearchDocumentReply) {
option (google.api.http) = {
get : '/api/v1/document/search',
};
}
// 设置文档评分
rpc SetDocumentScore(DocumentScore) returns (google.protobuf.Empty) {
option (google.api.http) = {
post : '/api/v1/document/score',
body : '*',
};
}
// 获取当前登录用户的文档评分
rpc GetDocumentScore(DocumentScore) returns (DocumentScore) {
option (google.api.http) = {
get : '/api/v1/document/score',
};
}
// 将文档一键设置为重转
rpc SetDocumentReconvert(google.protobuf.Empty)
returns (google.protobuf.Empty) {
option (google.api.http) = {
put : '/api/v1/document/reconvert',
};
}
}
service RecycleAPI {
2 years ago
// 文档回收站列表
rpc ListRecycleDocument(ListDocumentRequest) returns (ListDocumentReply) {
option (google.api.http) = {
get : '/api/v1/document/recycle',
};
}
// 恢复回收站文档,支持恢复单个文档或者是批量恢复
rpc RecoverRecycleDocument(RecoverRecycleDocumentRequest)
returns (google.protobuf.Empty) {
2 years ago
option (google.api.http) = {
put : '/api/v1/document/recycle',
body : '*',
2 years ago
};
}
// 删除回收站文档
rpc DeleteRecycleDocument(DeleteDocumentRequest)
returns (google.protobuf.Empty) {
2 years ago
option (google.api.http) = {
delete : '/api/v1/document/recycle',
};
}
// 清空回收站文档
rpc ClearRecycleDocument(google.protobuf.Empty)
returns (google.protobuf.Empty) {
2 years ago
option (google.api.http) = {
delete : '/api/v1/document/recycle/all',
};
}
}