204 lines
5.1 KiB
Protocol Buffer
204 lines
5.1 KiB
Protocol Buffer
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);
|
|
|
|
// 根据系统ID获取分类
|
|
rpc GetSystemCategories(GetSystemCategoriesRequest) returns (GetSystemCategoriesResponse);
|
|
|
|
// 获取某一个类别的完整类别(从根类别到当前类别的所有类别)
|
|
rpc GetFullCategories(GetCategoryRequest) returns (GetFullCategoriesResponse);
|
|
}
|
|
|
|
// 健康检查请求
|
|
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 GetFullCategoriesResponse {
|
|
string full_category_name = 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
|
|
}
|
|
|
|
message GetSystemCategoriesRequest {
|
|
string system_id = 1; // 系统标识 (必需)
|
|
string parent_id = 2; // 父分类ID (可选)
|
|
int32 page = 3; // 分页参数
|
|
int32 page_size = 4; // 分页参数
|
|
bool include_descendants = 5; // 是否包含后代
|
|
}
|
|
|
|
message GetSystemCategoriesResponse {
|
|
repeated CategoryInfo categories = 1;
|
|
int64 total = 2;
|
|
int32 current_page = 3;
|
|
int32 page_size = 4;
|
|
} |