initial commit
This commit is contained in:
178
rpc/category.proto
Normal file
178
rpc/category.proto
Normal file
@ -0,0 +1,178 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package category;
|
||||
|
||||
option go_package = "./category";
|
||||
|
||||
// 分类服务 - 分类管理、树形结构操作、批量处理
|
||||
service Category {
|
||||
// 健康检查
|
||||
rpc Ping(PingRequest) returns (PingResponse);
|
||||
|
||||
// 分类基础操作
|
||||
rpc CreateCategory(CreateCategoryRequest) returns (CategoryInfoResponse);
|
||||
rpc UpdateCategory(UpdateCategoryRequest) returns (CategoryInfoResponse);
|
||||
rpc DeleteCategory(DeleteCategoryRequest) returns (DeleteResponse);
|
||||
rpc GetCategory(GetCategoryRequest) returns (CategoryInfoResponse);
|
||||
|
||||
// 层级结构操作
|
||||
rpc GetChildren(GetChildrenRequest) returns (CategoryListResponse);
|
||||
rpc GetTree(GetTreeRequest) returns (CategoryTreeResponse);
|
||||
rpc MoveCategory(MoveCategoryRequest) returns (CategoryInfoResponse);
|
||||
rpc GetAncestorPath(GetAncestorPathRequest) returns (CategoryPathResponse);
|
||||
|
||||
// 批量操作
|
||||
rpc BatchCreateCategories(BatchCreateRequest) returns (BatchCreateResponse);
|
||||
rpc BatchUpdateCategories(BatchUpdateRequest) returns (BatchUpdateResponse);
|
||||
|
||||
// 查询过滤
|
||||
rpc ListCategories(ListCategoryRequest) returns (CategoryListResponse);
|
||||
rpc CheckAlias(CheckAliasRequest) returns (CheckAliasResponse);
|
||||
}
|
||||
|
||||
// 健康检查请求
|
||||
message PingRequest {
|
||||
string ping = 1;
|
||||
}
|
||||
|
||||
// 健康检查响应
|
||||
message PingResponse {
|
||||
string pong = 1;
|
||||
}
|
||||
|
||||
// 分类基础信息
|
||||
message CategoryInfo {
|
||||
string id = 1; // UUID
|
||||
string system_id = 2; // 所属系统标识
|
||||
string name = 3; // 分类名称
|
||||
string alias = 4; // URL别名
|
||||
string parent_id = 5; // 父分类ID
|
||||
string description = 6; // 描述
|
||||
int64 created_at = 7; // 创建时间戳
|
||||
int64 updated_at = 8; // 更新时间戳
|
||||
}
|
||||
|
||||
// 创建分类请求
|
||||
message CreateCategoryRequest {
|
||||
string system_id = 1;
|
||||
string name = 2;
|
||||
string alias = 3;
|
||||
string parent_id = 4; // 空字符串表示根分类
|
||||
string description = 5;
|
||||
}
|
||||
|
||||
// 更新分类请求
|
||||
message UpdateCategoryRequest {
|
||||
string id = 1;
|
||||
string name = 2;
|
||||
string alias = 3;
|
||||
string parent_id = 4; // 修改父分类时使用
|
||||
string description = 5;
|
||||
}
|
||||
|
||||
// 删除分类请求
|
||||
message DeleteCategoryRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
// 删除响应
|
||||
message DeleteResponse {
|
||||
bool success = 1;
|
||||
}
|
||||
|
||||
// 分类查询请求
|
||||
message GetCategoryRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
// 分类信息响应
|
||||
message CategoryInfoResponse {
|
||||
CategoryInfo category = 1;
|
||||
}
|
||||
|
||||
// 层级结构操作请求
|
||||
message GetChildrenRequest {
|
||||
string parent_id = 1; // 为空时查询根分类
|
||||
bool recursive = 2; // 是否递归获取所有子节点
|
||||
}
|
||||
|
||||
// 树形结构请求
|
||||
message GetTreeRequest {
|
||||
string system_id = 1; // 必须指定系统
|
||||
string root_id = 2; // 空字符串表示从根开始
|
||||
}
|
||||
|
||||
// 移动分类请求
|
||||
message MoveCategoryRequest {
|
||||
string id = 1;
|
||||
string new_parent_id = 2; // 空字符串表示移动到根
|
||||
}
|
||||
|
||||
// 祖先路径请求
|
||||
message GetAncestorPathRequest {
|
||||
string id = 1;
|
||||
}
|
||||
|
||||
// 分类路径响应
|
||||
message CategoryPathResponse {
|
||||
repeated CategoryInfo path = 1; // 从根到当前分类的路径
|
||||
}
|
||||
|
||||
// 批量操作请求
|
||||
message BatchCreateRequest {
|
||||
repeated CreateCategoryRequest categories = 1;
|
||||
}
|
||||
|
||||
message BatchCreateResponse {
|
||||
repeated CategoryInfo created_categories = 1;
|
||||
int32 success_count = 2;
|
||||
int32 fail_count = 3;
|
||||
}
|
||||
|
||||
message BatchUpdateRequest {
|
||||
repeated UpdateCategoryRequest categories = 1;
|
||||
}
|
||||
|
||||
message BatchUpdateResponse {
|
||||
repeated CategoryInfo updated_categories = 1;
|
||||
int32 success_count = 2;
|
||||
int32 fail_count = 3;
|
||||
}
|
||||
|
||||
// 列表查询请求
|
||||
message ListCategoryRequest {
|
||||
string system_id = 1;
|
||||
string parent_id = 2; // 空字符串表示根分类
|
||||
string name = 3; // 模糊匹配
|
||||
string alias = 4; // 精确匹配
|
||||
int32 page = 5; // 分页参数
|
||||
int32 page_size = 6;
|
||||
}
|
||||
|
||||
// 列表响应
|
||||
message CategoryListResponse {
|
||||
repeated CategoryInfo categories = 1;
|
||||
int32 total = 2;
|
||||
}
|
||||
|
||||
// 树形结构响应
|
||||
message CategoryTreeResponse {
|
||||
message TreeNode {
|
||||
CategoryInfo category = 1;
|
||||
repeated TreeNode children = 2;
|
||||
}
|
||||
TreeNode root = 1;
|
||||
}
|
||||
|
||||
// 别名检查请求
|
||||
message CheckAliasRequest {
|
||||
string system_id = 1;
|
||||
string parent_id = 2; // 空字符串表示根父级
|
||||
string alias = 3;
|
||||
}
|
||||
|
||||
// 别名检查响应
|
||||
message CheckAliasResponse {
|
||||
bool is_available = 1;
|
||||
string existing_id = 2; // 冲突时返回已存在的分类ID
|
||||
}
|
||||
51
rpc/file.proto
Normal file
51
rpc/file.proto
Normal file
@ -0,0 +1,51 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package file;
|
||||
|
||||
option go_package = "./file";
|
||||
|
||||
// 文件服务 - 上传图片、获取地址、删除文件等
|
||||
service File {
|
||||
// 上传文件(图片/头像/壁纸等)
|
||||
rpc Upload (UploadRequest) returns (UploadResponse);
|
||||
|
||||
// 获取文件访问链接(带签名,防盗链)
|
||||
rpc GetFileUrl (GetFileUrlRequest) returns (GetFileUrlResponse);
|
||||
|
||||
// 删除文件
|
||||
rpc Delete (DeleteRequest) returns (DeleteResponse);
|
||||
}
|
||||
|
||||
// 上传文件请求
|
||||
message UploadRequest {
|
||||
string filename = 1; // 文件名(建议客户端传原始名,服务端会生成唯一名)
|
||||
string content_type = 2; // 文件类型(如 image/jpeg)
|
||||
bytes content = 3; // 文件二进制内容(base64 编码由客户端完成)
|
||||
string folder = 4; // 可选,文件夹或分类路径,如 "avatars"、"wallpapers"
|
||||
}
|
||||
|
||||
// 上传响应
|
||||
message UploadResponse {
|
||||
string file_id = 1; // 文件唯一 ID(或路径)
|
||||
string url = 2; // 可访问 URL(带 CDN 或签名)
|
||||
}
|
||||
|
||||
// 获取访问链接请求
|
||||
message GetFileUrlRequest {
|
||||
string file_id = 1; // 文件唯一 ID 或路径
|
||||
}
|
||||
|
||||
// 获取访问链接响应
|
||||
message GetFileUrlResponse {
|
||||
string url = 1; // 可访问链接
|
||||
}
|
||||
|
||||
// 删除文件请求
|
||||
message DeleteRequest {
|
||||
string file_id = 1; // 要删除的文件 ID
|
||||
}
|
||||
|
||||
// 删除文件响应
|
||||
message DeleteResponse {
|
||||
bool success = 1; // 是否删除成功
|
||||
}
|
||||
131
rpc/gallery.proto
Normal file
131
rpc/gallery.proto
Normal file
@ -0,0 +1,131 @@
|
||||
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时间戳
|
||||
}
|
||||
81
rpc/user.proto
Normal file
81
rpc/user.proto
Normal file
@ -0,0 +1,81 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package user;
|
||||
|
||||
option go_package = "./user";
|
||||
|
||||
// 用户服务 - 注册、登录、登出、获取用户信息、健康检查
|
||||
service User {
|
||||
// 健康检查
|
||||
rpc Ping (PingRequest) returns (PingResponse);
|
||||
|
||||
// 用户注册
|
||||
rpc Register (RegisterRequest) returns (RegisterResponse);
|
||||
|
||||
// 用户登录,返回 JWT Token
|
||||
rpc Login (LoginRequest) returns (LoginResponse);
|
||||
|
||||
// 用户登出,可选实现
|
||||
rpc Logout (LogoutRequest) returns (LogoutResponse);
|
||||
|
||||
// 获取用户信息
|
||||
rpc GetUserInfo (GetUserInfoRequest) returns (GetUserInfoResponse);
|
||||
}
|
||||
|
||||
// 健康检查请求
|
||||
message PingRequest {
|
||||
string ping = 1;
|
||||
}
|
||||
|
||||
// 健康检查响应
|
||||
message PingResponse {
|
||||
string pong = 1;
|
||||
}
|
||||
|
||||
// 注册请求
|
||||
message RegisterRequest {
|
||||
string username = 1; // 用户名
|
||||
string password = 2; // 密码(明文或哈希后)
|
||||
string email = 3; // 邮箱,可选
|
||||
}
|
||||
|
||||
// 注册响应
|
||||
message RegisterResponse {
|
||||
string user_id = 1; // 新注册用户的唯一 ID
|
||||
}
|
||||
|
||||
// 登录请求
|
||||
message LoginRequest {
|
||||
string username = 1; // 用户名
|
||||
string password = 2; // 密码
|
||||
}
|
||||
|
||||
// 登录响应
|
||||
message LoginResponse {
|
||||
string token = 1; // JWT 访问令牌
|
||||
int64 expires_at = 2; // 过期时间(Unix 时间戳)
|
||||
}
|
||||
|
||||
// 登出请求
|
||||
message LogoutRequest {
|
||||
string token = 1; // 要废弃的 JWT
|
||||
}
|
||||
|
||||
// 登出响应
|
||||
message LogoutResponse {
|
||||
bool success = 1; // 是否登出成功
|
||||
}
|
||||
|
||||
// 获取用户信息请求
|
||||
message GetUserInfoRequest {
|
||||
string user_id = 1; // 目标用户 ID
|
||||
}
|
||||
|
||||
// 获取用户信息响应
|
||||
message GetUserInfoResponse {
|
||||
string user_id = 1; // 用户唯一 ID
|
||||
string username = 2; // 用户名
|
||||
string email = 3; // 用户邮箱
|
||||
int64 created_at = 4; // 账号创建时间(Unix 时间戳)
|
||||
repeated string roles = 5; // 用户角色列表,可选
|
||||
}
|
||||
Reference in New Issue
Block a user