syntax = "proto3"; package file; option go_package = "./file"; // ---------- 通用消息 ---------- message CommonResp { int64 code = 1; string msg = 2; } // ---------- 文件信息 ---------- message FileInfo { string id = 1; string name = 2; string url = 3; string tag = 4; string key = 5; string suffix = 6; string md5 = 7; int64 createdAt = 8; } // ---------- 请求/响应 ---------- message GetFileByIdReq { string id = 1; } message GetFileByIdResp { FileInfo file = 1; } message GetFilesByIdsReq { repeated string ids = 1; } message GetFilesByIdsResp { repeated FileInfo files = 1; } // ---------- 存储配置 ---------- message StorageConfigInfo { string id = 1; string type = 2; string name = 3; string endpoint = 4; string accessKeyId = 5; string accessKeySecret = 6; string bucketName = 7; string bucketUrl = 8; string region = 9; int32 isDefault = 10; int32 status = 11; string remark = 12; } message CreateStorageConfigReq { string type = 1; string name = 2; string endpoint = 3; string accessKeyId = 4; string accessKeySecret = 5; string bucketName = 6; string bucketUrl = 7; string region = 8; int32 status = 9; string remark = 10; } message UpdateStorageConfigReq { string id = 1; string type = 2; string name = 3; string endpoint = 4; string accessKeyId = 5; string accessKeySecret = 6; string bucketName = 7; string bucketUrl = 8; string region = 9; int32 status = 10; string remark = 11; } message SetDefaultStorageConfigReq { string id = 1; } message StorageConfigListReq { int32 current = 1; int32 pageSize = 2; string type = 3; string name = 4; } message StorageConfigListResp { repeated StorageConfigInfo list = 1; int64 total = 2; } message GetDefaultStorageConfigReq {} message GetDefaultStorageConfigResp { StorageConfigInfo config = 1; } message CreateFileReq { string name = 1; string url = 2; string tag = 3; string key = 4; string suffix = 5; string md5 = 6; } message CreateFileResp { FileInfo file = 1; } message CheckFileByMd5Req { string md5 = 1; } message CheckFileByMd5Resp { bool exists = 1; FileInfo file = 2; } message DeleteFilesReq { repeated string ids = 1; } message GetFileListReq { int32 current = 1; int32 pageSize = 2; string name = 3; } message GetFileListResp { repeated FileInfo list = 1; int64 total = 2; } // ---------- 服务定义 ---------- service FileService { // 根据ID获取文件信息 rpc GetFileById(GetFileByIdReq) returns (GetFileByIdResp); // 根据ID列表批量获取文件信息 rpc GetFilesByIds(GetFilesByIdsReq) returns (GetFilesByIdsResp); // 创建文件记录 rpc CreateFile(CreateFileReq) returns (CreateFileResp); // 通过MD5检查文件是否存在 rpc CheckFileByMd5(CheckFileByMd5Req) returns (CheckFileByMd5Resp); // 删除文件记录 rpc DeleteFiles(DeleteFilesReq) returns (CommonResp); // 获取文件列表 rpc GetFileList(GetFileListReq) returns (GetFileListResp); // ---------- 存储配置 ---------- rpc CreateStorageConfig(CreateStorageConfigReq) returns (CommonResp); rpc UpdateStorageConfig(UpdateStorageConfigReq) returns (CommonResp); rpc DeleteStorageConfig(DeleteFilesReq) returns (CommonResp); // 复用idsReq rpc SetDefaultStorageConfig(SetDefaultStorageConfigReq) returns (CommonResp); rpc GetStorageConfigList(StorageConfigListReq) returns (StorageConfigListResp); rpc GetDefaultStorageConfig(GetDefaultStorageConfigReq) returns (GetDefaultStorageConfigResp); }