131 lines
3.1 KiB
Protocol Buffer
131 lines
3.1 KiB
Protocol Buffer
syntax = "proto3";
|
|
|
|
package gallery;
|
|
|
|
option go_package = "./gallery";
|
|
|
|
service Gallery {
|
|
// 健康检查
|
|
rpc Ping(PingRequest) returns (PingResponse);
|
|
|
|
// 图片元数据操作
|
|
rpc GetImageList(ImageListRequest) returns (ImageListResponse);
|
|
rpc GetImageDetail(ImageDetailRequest) returns (ImageDetailResponse);
|
|
rpc UpdateImage(UpdateImageRequest) returns (UpdateImageResponse);
|
|
rpc DeleteImage(DeleteImageRequest) returns (DeleteImageResponse);
|
|
|
|
// 图片上传
|
|
rpc UploadImage(UploadImageRequest) returns (UploadImageResponse);
|
|
|
|
// 分类管理
|
|
rpc GetCategoryTree(CategoryTreeRequest) returns (CategoryTreeResponse);
|
|
rpc CreateCategory(CreateCategoryRequest) returns (CreateCategoryResponse);
|
|
|
|
// 访问控制
|
|
rpc GenerateUrl(GenerateUrlRequest) returns (GenerateUrlResponse);
|
|
}
|
|
|
|
// 健康检查
|
|
message PingRequest { string ping = 1; }
|
|
message PingResponse { string pong = 1; }
|
|
|
|
// 图片元数据
|
|
message ImageMeta {
|
|
string image_id = 1;
|
|
string title = 2;
|
|
string description = 3;
|
|
string category_id = 4;
|
|
repeated string tags = 5;
|
|
int64 file_size = 6;
|
|
int32 width = 7;
|
|
int32 height = 8;
|
|
string storage_key = 9;
|
|
string file_name = 10;
|
|
string mime_type = 11;
|
|
int64 created_at = 12;
|
|
int64 updated_at = 13;
|
|
}
|
|
|
|
// 图片列表
|
|
message ImageListRequest {
|
|
int32 page = 1;
|
|
int32 page_size = 2;
|
|
string category_id = 3;
|
|
repeated string tags = 4;
|
|
string order_by = 5; // created_at_desc | updated_at_asc
|
|
}
|
|
|
|
message ImageListResponse {
|
|
repeated ImageMeta images = 1;
|
|
int32 total = 2;
|
|
}
|
|
|
|
// 图片详情
|
|
message ImageDetailRequest { string image_id = 1; }
|
|
message ImageDetailResponse { ImageMeta meta = 1; }
|
|
|
|
// 更新图片
|
|
message UpdateImageRequest {
|
|
string image_id = 1;
|
|
optional string title = 2;
|
|
optional string description = 3;
|
|
optional string category_id = 4;
|
|
repeated string tags = 5; // 全量替换
|
|
}
|
|
|
|
message UpdateImageResponse { bool success = 1; }
|
|
|
|
// 删除图片
|
|
message DeleteImageRequest {
|
|
string image_id = 1;
|
|
bool permanent = 2;
|
|
}
|
|
|
|
message DeleteImageResponse { bool success = 1; }
|
|
|
|
// 图片上传
|
|
message UploadImageRequest {
|
|
bytes file_content = 1;
|
|
string file_name = 2;
|
|
optional string title = 3;
|
|
optional string description = 4;
|
|
optional string category_id = 5;
|
|
repeated string tags = 6;
|
|
}
|
|
|
|
message UploadImageResponse {
|
|
ImageMeta image_meta = 1;
|
|
string preview_url = 2;
|
|
}
|
|
|
|
// 分类管理
|
|
message CategoryNode {
|
|
string category_id = 1;
|
|
string name = 2;
|
|
repeated CategoryNode children = 3;
|
|
}
|
|
|
|
message CategoryTreeRequest { bool include_count = 1; }
|
|
message CategoryTreeResponse { repeated CategoryNode categories = 1; }
|
|
|
|
message CreateCategoryRequest {
|
|
string name = 1;
|
|
string parent_id = 2;
|
|
}
|
|
|
|
message CreateCategoryResponse { string category_id = 1; }
|
|
|
|
// URL生成
|
|
message GenerateUrlRequest {
|
|
string image_id = 1;
|
|
optional int32 width = 2;
|
|
optional int32 height = 3;
|
|
optional string format = 4; // webp/jpg/png
|
|
optional int32 quality = 5; // 1-100
|
|
int32 expires = 6; // 有效期(秒)
|
|
}
|
|
|
|
message GenerateUrlResponse {
|
|
string signed_url = 1;
|
|
int64 expires_at = 2; // Unix时间戳
|
|
} |