Files
2026-05-01 12:56:08 +08:00

143 lines
3.8 KiB
Plaintext

syntax = "v1"
info (
title: "文件服务API"
desc: "文件上传、删除、查询等HTTP接口"
author: "sundynix"
version: "v1.0.0"
)
type (
// 文件信息
FileInfo {
Id string `json:"id"`
Name string `json:"name"`
Url string `json:"url"`
Tag string `json:"tag"`
Key string `json:"key"`
Suffix string `json:"suffix"`
Md5 string `json:"md5"`
}
// 批量ID请求
IdsReq {
Ids []string `json:"ids"`
}
// 文件列表查询
FileListReq {
Current int `json:"current,optional"`
PageSize int `json:"pageSize,optional"`
Name string `json:"name,optional"`
}
FileListResp {
List []FileInfo `json:"list"`
Total int64 `json:"total"`
}
// 文件ID请求
FileIdReq {
Id string `path:"id"`
}
// ---------- 存储配置 ----------
StorageConfigInfo {
Id string `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
Endpoint string `json:"endpoint"`
AccessKeyId string `json:"accessKeyId"`
AccessKeySecret string `json:"accessKeySecret"`
BucketName string `json:"bucketName"`
BucketUrl string `json:"bucketUrl"`
Region string `json:"region"`
IsDefault int `json:"isDefault"`
Status int `json:"status"`
Remark string `json:"remark"`
}
CreateStorageConfigReq {
Type string `json:"type"`
Name string `json:"name"`
Endpoint string `json:"endpoint"`
AccessKeyId string `json:"accessKeyId"`
AccessKeySecret string `json:"accessKeySecret"`
BucketName string `json:"bucketName"`
BucketUrl string `json:"bucketUrl"`
Region string `json:"region,optional"`
Status int `json:"status,optional"`
Remark string `json:"remark,optional"`
}
UpdateStorageConfigReq {
Id string `json:"id"`
Type string `json:"type"`
Name string `json:"name"`
Endpoint string `json:"endpoint"`
AccessKeyId string `json:"accessKeyId"`
AccessKeySecret string `json:"accessKeySecret"`
BucketName string `json:"bucketName"`
BucketUrl string `json:"bucketUrl"`
Region string `json:"region,optional"`
Status int `json:"status,optional"`
Remark string `json:"remark,optional"`
}
SetDefaultStorageConfigReq {
Id string `json:"id"`
}
StorageConfigListReq {
Current int `json:"current,optional"`
PageSize int `json:"pageSize,optional"`
Type string `json:"type,optional"`
Name string `json:"name,optional"`
}
StorageConfigListResp {
List []StorageConfigInfo `json:"list"`
Total int64 `json:"total"`
}
)
// ========== 需要鉴权的接口 ==========
@server (
prefix: /api/file
group: file
jwt: Auth
)
service file-api {
@doc "上传文件"
@handler UploadFile
post /upload returns (FileInfo)
@doc "删除文件"
@handler DeleteFile
post /delete (IdsReq)
@doc "文件列表"
@handler GetFileList
post /list (FileListReq) returns (FileListResp)
@doc "获取文件信息"
@handler GetFileById
get /:id (FileIdReq) returns (FileInfo)
@doc "下载文件"
@handler DownloadFile
get /download/:id (FileIdReq)
// ---------- 存储配置管理 ----------
@doc "创建存储配置"
@handler CreateStorageConfig
post /config/create (CreateStorageConfigReq)
@doc "更新存储配置"
@handler UpdateStorageConfig
post /config/update (UpdateStorageConfigReq)
@doc "删除存储配置"
@handler DeleteStorageConfig
post /config/delete (IdsReq)
@doc "设置默认存储配置"
@handler SetDefaultStorageConfig
post /config/setDefault (SetDefaultStorageConfigReq)
@doc "获取存储配置列表"
@handler GetStorageConfigList
post /config/list (StorageConfigListReq) returns (StorageConfigListResp)
}