bootstrap/template/template_apiservices.go

71 lines
1.7 KiB
Go

package template
const templateApiservicesProto = `syntax = "proto3";
package proto.v1;
option go_package = "{{.Name}}/gen;genv1";
// @route_group: true
// @base_url: /v1/file
// @gen_to: ./services/controller/v1/file_controller.go
// @rpc_to: ./services/rpc/v1/file_impl.go
service FileService {
// @desc: 列表
// @author: Young Xu
// @method: GET
// @api: /list
rpc List (FileServiceListRequest) returns (FileServiceListResponse);
// @desc: 上传
// @author: Young Xu
// @method: POST
// @api: /upload
rpc Upload (FileServiceUploadRequest) returns (FileServiceUploadResponse);
// @desc: 删除
// @author: Young Xu
// @method: DELETE
// @api: /delete
rpc Delete (FileServiceDeleteRequest) returns (FileServiceDeleteResponse);
// @desc: 下载
// @author: Young Xu
// @method: GET
// @api: /download
rpc Download (FileServiceDownloadRequest) returns (FileServiceDownloadResponse);
}
message FileServiceListRequest {
string dirname = 1; // 目录
}
message FileServiceListResponse {
message Item {
int64 file_id = 1; // 文件ID
string filename = 2; // 文件名
string file_size = 3; // 文件大小
string created_at = 4; // 上传时间
string dirname = 5; // 文件路径
bool is_directory = 6; // 是否是目录
}
repeated Item items = 1; // 列表
}
message FileServiceUploadRequest {}
message FileServiceUploadResponse {}
message FileServiceDeleteRequest {
int64 file_id = 1; // 文件名
}
message FileServiceDeleteResponse {}
message FileServiceDownloadRequest {
// @v: required
string file_id = 1; // 文件ID
}
message FileServiceDownloadResponse {}
`