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

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/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";
// 文档
message Document {
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; // 转换错误信息
}
// 删除文档,放入回收站
message DeleteDocumentRequest { repeated int64 id = 1; }
// 恢复文档
message RecoverRecycleDocumentRequest { repeated int64 id = 1; }
// 查询文档
message GetDocumentRequest {
int64 id = 1; // 文档ID
bool with_author = 2; // 是否查询作者信息
}
// 文档列表
message ListDocumentRequest {
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无效
}
// 文档列表
message ListDocumentReply {
int64 total = 1; // 文档总数
repeated Document document = 2; // 文档列表
}
// 创建文档
message CreateDocumentItem {
string title = 1; // 文档标题
int64 attachment_id = 2; // 文档附件ID
int32 price = 3; // 文档价格
}
// 创建文档
message CreateDocumentRequest {
bool overwrite = 1; // 是否覆盖。暂时用不到
repeated int64 category_id = 2; // 文档分类ID
repeated CreateDocumentItem document = 3; // 文档列表
}
// 设置文档推荐
message SetDocumentRecommendRequest {
repeated int64 id = 1; // 文档ID
int32 type = 2; // 0, 取消推荐1:推荐 2:重新推荐
}
// 查询文档(针对首页的查询)
message ListDocumentForHomeRequest { int64 limit = 1; }
// 首页文档查询返回项
message ListDocumentForHomeItem {
int64 category_id = 1; // 分类ID
string category_cover = 2; // 分类封面
string category_name = 3; // 分类名称
repeated Document document = 4; // 文档列表
}
// 查询文档(针对首页的查询)
message ListDocumentForHomeResponse {
repeated ListDocumentForHomeItem document = 1; // 文档列表
}
// 文档搜索
message SearchDocumentRequest {
int32 page = 1; // 页码
int32 size = 2; // 每页数量
string wd = 3; // 搜索关键字
repeated int64 category_id = 4; // 分类
string sort = 5; // 排序
string ext = 7; // 类型
}
// 文档评分
message DocumentScore {
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 ]; // 更新时间
}
// 文档搜索响应
message SearchDocumentReply {
int64 total = 1; // 文档总数
string spend = 2; // 搜索耗时
repeated Document document = 3; // 文档列表
}
// 文档下载
message DownloadDocumentReply { string url = 1; }
// 文档服务
service DocumentAPI {
// 针对首页的文档查询
rpc ListDocumentForHome(ListDocumentForHomeRequest)
returns (ListDocumentForHomeResponse) {
option (google.api.http) = {
get : '/api/v1/document/home',
};
}
// 设置文档推荐
rpc SetDocumentRecommend(SetDocumentRecommendRequest)
returns (google.protobuf.Empty) {
option (google.api.http) = {
put : '/api/v1/document/recommend',
body : '*',
};
}
// 创建文档
rpc CreateDocument(CreateDocumentRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
post : '/api/v1/document',
body : '*',
};
}
// 更新文档
rpc UpdateDocument(Document) returns (google.protobuf.Empty) {
option (google.api.http) = {
put : '/api/v1/document',
body : '*',
};
}
// 删除文档
rpc DeleteDocument(DeleteDocumentRequest) returns (google.protobuf.Empty) {
option (google.api.http) = {
delete : '/api/v1/document',
};
}
// 查询文档
rpc GetDocument(GetDocumentRequest) returns (Document) {
option (google.api.http) = {
get : '/api/v1/document',
};
}
// 根据文档ID查询当前文档的相关文档
rpc GetRelatedDocuments(Document) returns (ListDocumentReply) {
option (google.api.http) = {
get : '/api/v1/document/related',
};
}
// 根据文档ID获取文档下载链接
rpc DownloadDocument(Document) returns (DownloadDocumentReply) {
option (google.api.http) = {
get : '/api/v1/document/download',
};
}
// 文档列表查询
rpc ListDocument(ListDocumentRequest) returns (ListDocumentReply) {
option (google.api.http) = {
get : '/api/v1/document/list',
};
}
// 文档搜索
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 {
// 文档回收站列表
rpc ListRecycleDocument(ListDocumentRequest) returns (ListDocumentReply) {
option (google.api.http) = {
get : '/api/v1/document/recycle',
};
}
// 恢复回收站文档,支持恢复单个文档或者是批量恢复
rpc RecoverRecycleDocument(RecoverRecycleDocumentRequest)
returns (google.protobuf.Empty) {
option (google.api.http) = {
put : '/api/v1/document/recycle',
body : '*',
};
}
// 删除回收站文档
rpc DeleteRecycleDocument(DeleteDocumentRequest)
returns (google.protobuf.Empty) {
option (google.api.http) = {
delete : '/api/v1/document/recycle',
};
}
// 清空回收站文档
rpc ClearRecycleDocument(google.protobuf.Empty)
returns (google.protobuf.Empty) {
option (google.api.http) = {
delete : '/api/v1/document/recycle/all',
};
}
}