feat(bookmark): 初始化书签服务并配置路由与权限控制
新增书签服务主程序,使用 Gin 框架搭建 HTTP 服务器,并注册书签相关接口处理器。 配置 CORS 中间件以支持跨域请求。服务监听端口为 8081。 feat(user_np): 初始化用户权限服务并注册认证接口 新增用户权限服务主程序,使用 Gin 框架搭建 HTTP 服务器,并注册登录、注册及修改密码等接口处理器。 服务监听端口为 8082。 refactor(config): 重构 OpenAPI 配置文件结构并拆分模块 将原有合并的 OpenAPI 配置文件按功能模块拆分为 bookmark 和 user_np 两个独立目录, 分别管理各自的 server、client 及 API 定义文件,便于后续维护和扩展。 refactor(vfs): 调整虚拟文件系统 API 接口路径与参数定义 更新 VFS API 配置文件,修改部分接口路径及参数结构, 如将文件路径参数由 path 转为 query 参数,并优化响应结构体定义。
This commit is contained in:
@ -1,775 +0,0 @@
|
||||
openapi: '3.0.3'
|
||||
info:
|
||||
title: zzyxyz_api
|
||||
description: API服务
|
||||
version: '1.0'
|
||||
servers:
|
||||
- url: http://localhost:8080/api
|
||||
description: 开发环境
|
||||
- url: https://api.zzyxyz.com/api
|
||||
description: 生产环境
|
||||
tags:
|
||||
- name: folder
|
||||
description: 文件夹相关操作
|
||||
- name: data
|
||||
description: 书签相关操作
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
|
||||
paths:
|
||||
/bookmarks/v1/folder/serial:
|
||||
get:
|
||||
summary: 导出文件夹树结构
|
||||
description: 递归导出整个文件夹树结构并压缩返回
|
||||
operationId: exportFolderTree
|
||||
tags: [folder]
|
||||
responses:
|
||||
'200':
|
||||
description: 压缩的文件夹树数据
|
||||
content:
|
||||
application/octet-stream:
|
||||
schema:
|
||||
type: string
|
||||
format: binary
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
post:
|
||||
summary: 导入文件夹树结构
|
||||
description: 上传并解压文件夹树结构数据,重建文件系统
|
||||
operationId: importFolderTree
|
||||
tags: [folder]
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/octet-stream:
|
||||
schema:
|
||||
type: string
|
||||
format: binary
|
||||
responses:
|
||||
'200':
|
||||
description: 导入成功
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ImportResponse'
|
||||
'400':
|
||||
description: 数据格式错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
/bookmarks/v1/folder:
|
||||
post:
|
||||
summary: 创建文件夹
|
||||
description: 创建一个存储书签或者文件夹的文件夹
|
||||
operationId: createFolder
|
||||
tags: [folder]
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/FolderRequest'
|
||||
responses:
|
||||
'201':
|
||||
description: 创建成功的文件夹
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/FolderResponse'
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
/bookmarks/v1/folder/{id}:
|
||||
get:
|
||||
summary: 获取文件夹基础信息
|
||||
description: 获取文件夹基础信息不包含内容,只有元数据
|
||||
operationId: getFolderInfo
|
||||
tags: [folder]
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
example: 1
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
responses:
|
||||
'200':
|
||||
description: 文件夹详情
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/FolderResponse'
|
||||
'404':
|
||||
description: 文件夹不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
|
||||
put:
|
||||
summary: 更新文件夹
|
||||
description: 修改文件夹的元数据(包括修改名称和移动文件夹)
|
||||
operationId: updateFolder
|
||||
tags: [folder]
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
example: 1
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/FolderRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: 更新后的文件夹
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/FolderResponse'
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'404':
|
||||
description: 文件夹不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
delete:
|
||||
summary: 删除文件夹
|
||||
description: 删除文件夹(文件夹不能有内容)
|
||||
operationId: deleteFolder
|
||||
tags: [folder]
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
example: 1
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
responses:
|
||||
'204':
|
||||
description: 删除成功
|
||||
'400':
|
||||
description: 文件夹不为空,无法删除
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'404':
|
||||
description: 文件夹不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
/bookmarks/v1/folder/{id}/mount:
|
||||
get:
|
||||
summary: 获取文件夹挂载信息
|
||||
description: 获取指定文件夹的所有挂载信息
|
||||
operationId: getFolderMounts
|
||||
tags: [folder]
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 文件夹ID
|
||||
responses:
|
||||
'200':
|
||||
description: 挂载信息列表
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/MountInfo'
|
||||
'404':
|
||||
description: 文件夹不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
post:
|
||||
summary: 挂载文件夹
|
||||
description: 将指定文件夹挂载到目标位置
|
||||
operationId: mountFolder
|
||||
tags: [folder]
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 要挂载的文件夹ID
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
target_folder_id:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 目标文件夹ID(挂载点)
|
||||
mount_name:
|
||||
type: string
|
||||
description: 挂载后的显示名称(可选,默认使用原文件夹名)
|
||||
required:
|
||||
- target_folder_id
|
||||
responses:
|
||||
'200':
|
||||
description: 挂载成功
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/MountResponse'
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'404':
|
||||
description: 文件夹不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'409':
|
||||
description: 挂载冲突(如循环挂载、重复挂载等)
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
delete:
|
||||
summary: 取消挂载文件夹
|
||||
description: 取消指定文件夹的挂载关系
|
||||
operationId: unmountFolder
|
||||
tags: [folder]
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 要取消挂载的文件夹ID
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
mount_point_id:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 挂载点ID(从哪个位置取消挂载)
|
||||
required:
|
||||
- mount_point_id
|
||||
responses:
|
||||
'200':
|
||||
description: 取消挂载成功
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'404':
|
||||
description: 挂载关系不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
/bookmarks/v1/folder/{id}/content:
|
||||
get:
|
||||
summary: 获取文件夹的内容
|
||||
description: 只获取当前文件夹的内容,不会递归搜索
|
||||
operationId: getFolderContent
|
||||
tags: [folder]
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
example: 1
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
responses:
|
||||
'200':
|
||||
description: 文件夹子节点列表
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/FolderContentResponse'
|
||||
'404':
|
||||
description: 文件夹不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
delete:
|
||||
summary: 删除文件夹的内容
|
||||
description: 删除文件夹的内容(危险操作)
|
||||
operationId: deleteFolderContent
|
||||
tags: [folder]
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
- name: mode
|
||||
in: query
|
||||
description: 删除模式
|
||||
required: false
|
||||
schema:
|
||||
type: string
|
||||
enum: [onlyContent, onlyEmptyFolder, onlyFolder, all]
|
||||
responses:
|
||||
'200':
|
||||
description: 删除成功
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
/bookmarks/v1/data:
|
||||
post:
|
||||
summary: 创建书签
|
||||
description: 在文件夹下创建一个书签
|
||||
operationId: createBookmark
|
||||
tags: [data]
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/BookmarkRequest'
|
||||
responses:
|
||||
'201':
|
||||
description: 创建成功的书签
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/BookmarkResponse'
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
/bookmarks/v1/data/{id}:
|
||||
get:
|
||||
summary: 获取书签详情
|
||||
description: 通过id获取书签内容
|
||||
operationId: getBookmark
|
||||
tags: [data]
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
example: 1
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
responses:
|
||||
'200':
|
||||
description: 书签详情
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/BookmarkResponse'
|
||||
'404':
|
||||
description: 书签不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
|
||||
put:
|
||||
summary: 更新书签
|
||||
description: 更新指定id的书签
|
||||
operationId: updateBookmark
|
||||
tags: [data]
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
example: 1
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/BookmarkRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: 更新后的书签
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/BookmarkResponse'
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'404':
|
||||
description: 书签不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
delete:
|
||||
summary: 删除书签
|
||||
description: 删除指定id的书签
|
||||
operationId: deleteBookmark
|
||||
tags: [data]
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
example: 1
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
responses:
|
||||
'204':
|
||||
description: 删除成功
|
||||
'404':
|
||||
description: 书签不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
components:
|
||||
securitySchemes:
|
||||
ApiKeyAuth:
|
||||
type: apiKey
|
||||
in: header
|
||||
name: X-BookMark-Token
|
||||
responses:
|
||||
ServerInternalError:
|
||||
description: 服务器内部错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
Unauthorized:
|
||||
description: 未授权
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
schemas:
|
||||
ImportResponse:
|
||||
type: object
|
||||
properties:
|
||||
imported_folders:
|
||||
type: integer
|
||||
description: 导入的文件夹数量
|
||||
imported_bookmarks:
|
||||
type: integer
|
||||
description: 导入的书签数量
|
||||
duration:
|
||||
type: string
|
||||
description: 导入耗时
|
||||
required:
|
||||
- imported_folders
|
||||
- imported_bookmarks
|
||||
- duration
|
||||
|
||||
MountResponse:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 挂载关系ID
|
||||
source_folder_id:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 源文件夹ID
|
||||
target_folder_id:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 目标文件夹ID(挂载点)
|
||||
mount_name:
|
||||
type: string
|
||||
description: 挂载显示名称
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 挂载时间
|
||||
required:
|
||||
- id
|
||||
- source_folder_id
|
||||
- target_folder_id
|
||||
- mount_name
|
||||
- created_at
|
||||
|
||||
MountInfo:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 挂载关系ID
|
||||
source_folder:
|
||||
$ref: '#/components/schemas/FolderBriefResponse'
|
||||
target_folder:
|
||||
$ref: '#/components/schemas/FolderBriefResponse'
|
||||
mount_name:
|
||||
type: string
|
||||
description: 挂载显示名称
|
||||
is_mounted_here:
|
||||
type: boolean
|
||||
description: true表示此文件夹被挂载到target_folder,false表示此文件夹挂载了source_folder
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 挂载时间
|
||||
required:
|
||||
- id
|
||||
- source_folder
|
||||
- target_folder
|
||||
- mount_name
|
||||
- is_mounted_here
|
||||
- created_at
|
||||
|
||||
FolderRequest:
|
||||
description: 文件夹请求结构体
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 255
|
||||
description: 文件夹名称
|
||||
example: 测试名称
|
||||
parent_id:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 父文件夹ID 若为空则自动创建在用户根目录下
|
||||
example: null
|
||||
required:
|
||||
- name
|
||||
|
||||
BookmarkRequest:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 255
|
||||
description: 书签名称
|
||||
example: 测试名称
|
||||
link:
|
||||
type: string
|
||||
description: 书签链接
|
||||
example: /swagger/index.html
|
||||
detail:
|
||||
type: string
|
||||
description: 书签详情链接
|
||||
description:
|
||||
type: string
|
||||
description: 书签描述
|
||||
parent_id:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 父文件夹ID 若为空则自动创建在用户根目录下
|
||||
example: null
|
||||
required:
|
||||
- name
|
||||
|
||||
FolderResponse:
|
||||
type: object
|
||||
description: 文件夹响应结构体
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 文件夹ID
|
||||
name:
|
||||
type: string
|
||||
description: 文件夹名称
|
||||
parent_id:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 父文件夹ID
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 创建时间
|
||||
updated_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 更新时间
|
||||
sub_folder_count:
|
||||
type: integer
|
||||
description: 子文件夹数量
|
||||
bookmark_count:
|
||||
type: integer
|
||||
description: 书签数量
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- created_at
|
||||
- updated_at
|
||||
- sub_folder_count
|
||||
- bookmark_count
|
||||
|
||||
BookmarkResponse:
|
||||
type: object
|
||||
description: 书签相应结构体
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 书签ID
|
||||
name:
|
||||
type: string
|
||||
description: 书签名称
|
||||
link:
|
||||
type: string
|
||||
description: 书签链接
|
||||
detail:
|
||||
type: string
|
||||
description: 书签详情链接
|
||||
description:
|
||||
type: string
|
||||
description: 书签描述
|
||||
parent_id:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 父文件夹ID
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 创建时间
|
||||
updated_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 更新时间
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- parent_id
|
||||
- created_at
|
||||
- updated_at
|
||||
|
||||
FolderContentResponse:
|
||||
type: object
|
||||
properties:
|
||||
sub_folders:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/FolderBriefResponse'
|
||||
description: 子文件夹列表
|
||||
bookmarks:
|
||||
type: array
|
||||
items:
|
||||
$ref: '#/components/schemas/BookmarkBriefResponse'
|
||||
description: 书签列表
|
||||
required:
|
||||
- sub_folders
|
||||
- bookmarks
|
||||
|
||||
FolderBriefResponse:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 文件夹ID
|
||||
name:
|
||||
type: string
|
||||
description: 文件夹名称
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
|
||||
BookmarkBriefResponse:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 书签ID
|
||||
name:
|
||||
type: string
|
||||
description: 书签名称
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
|
||||
Error:
|
||||
type: object
|
||||
description: 错误信息
|
||||
properties:
|
||||
errtype:
|
||||
type: string
|
||||
example: "ParameterError"
|
||||
description: 错误类型
|
||||
message:
|
||||
example: "传递的第一个参数错误"
|
||||
type: string
|
||||
description: 错误信息
|
||||
required:
|
||||
- errtype
|
||||
- message
|
213
config/bookmark/bookmark.yaml
Normal file
213
config/bookmark/bookmark.yaml
Normal file
@ -0,0 +1,213 @@
|
||||
openapi: '3.0.3'
|
||||
info:
|
||||
title: zzyxyz_api
|
||||
description: API服务
|
||||
version: '1.0'
|
||||
servers:
|
||||
- url: http://localhost:8081/api
|
||||
description: 开发环境
|
||||
- url: https://api.zzyxyz.com/api
|
||||
description: 生产环境
|
||||
tags:
|
||||
- name: data
|
||||
description: 书签相关操作
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
|
||||
paths:
|
||||
/bookmarks/v1/data/{id}:
|
||||
parameters:
|
||||
- name: id
|
||||
in: path
|
||||
example: 1
|
||||
required: true
|
||||
schema:
|
||||
type: integer
|
||||
format: int64
|
||||
post:
|
||||
summary: 创建书签
|
||||
description: 在文件夹下创建一个书签
|
||||
operationId: createBookmark
|
||||
tags: [data]
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/BookmarkRequest'
|
||||
responses:
|
||||
'201':
|
||||
description: 创建成功的书签
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/BookmarkResponse'
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
get:
|
||||
summary: 获取书签详情
|
||||
description: 通过id获取书签内容
|
||||
operationId: getBookmark
|
||||
tags: [data]
|
||||
responses:
|
||||
'200':
|
||||
description: 书签详情
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/BookmarkResponse'
|
||||
'404':
|
||||
description: 书签不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
|
||||
put:
|
||||
summary: 更新书签
|
||||
description: 更新指定id的书签
|
||||
operationId: updateBookmark
|
||||
tags: [data]
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/BookmarkRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: 更新后的书签
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/BookmarkResponse'
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'404':
|
||||
description: 书签不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
delete:
|
||||
summary: 删除书签
|
||||
description: 删除指定id的书签
|
||||
operationId: deleteBookmark
|
||||
tags: [data]
|
||||
responses:
|
||||
'204':
|
||||
description: 删除成功
|
||||
'404':
|
||||
description: 书签不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
components:
|
||||
securitySchemes:
|
||||
ApiKeyAuth:
|
||||
type: apiKey
|
||||
in: header
|
||||
name: X-BookMark-Token
|
||||
responses:
|
||||
ServerInternalError:
|
||||
description: 服务器内部错误
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
Unauthorized:
|
||||
description: 未授权
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
schemas:
|
||||
BookmarkRequest:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
minLength: 1
|
||||
maxLength: 255
|
||||
description: 书签名称
|
||||
example: 测试名称
|
||||
link:
|
||||
type: string
|
||||
description: 书签链接
|
||||
example: /swagger/index.html
|
||||
detail:
|
||||
type: string
|
||||
description: 书签详情链接
|
||||
description:
|
||||
type: string
|
||||
description: 书签描述
|
||||
required:
|
||||
- name
|
||||
|
||||
BookmarkResponse:
|
||||
type: object
|
||||
description: 书签相应结构体
|
||||
properties:
|
||||
id:
|
||||
type: integer
|
||||
format: int64
|
||||
description: 书签ID
|
||||
name:
|
||||
type: string
|
||||
description: 书签名称
|
||||
link:
|
||||
type: string
|
||||
description: 书签链接
|
||||
detail:
|
||||
type: string
|
||||
description: 书签详情链接
|
||||
description:
|
||||
type: string
|
||||
description: 书签描述
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 创建时间
|
||||
updated_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 更新时间
|
||||
required:
|
||||
- id
|
||||
- name
|
||||
- created_at
|
||||
- updated_at
|
||||
|
||||
Error:
|
||||
type: object
|
||||
description: 错误信息
|
||||
properties:
|
||||
errtype:
|
||||
type: string
|
||||
example: "ParameterError"
|
||||
description: 错误类型
|
||||
message:
|
||||
example: "传递的第一个参数错误"
|
||||
type: string
|
||||
description: 错误信息
|
||||
required:
|
||||
- errtype
|
||||
- message
|
5
config/bookmark/client.yaml
Normal file
5
config/bookmark/client.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
# yaml-language-server: ...
|
||||
package: api
|
||||
generate:
|
||||
client: true
|
||||
output: ./gen/bookmarks/client.go
|
@ -3,4 +3,4 @@ package: api
|
||||
generate:
|
||||
gin-server: true
|
||||
models: true
|
||||
output: ./gen/vfs/gen.go
|
||||
output: ./gen/bookmarks/server.go
|
7
config/user_np/server.yaml
Normal file
7
config/user_np/server.yaml
Normal file
@ -0,0 +1,7 @@
|
||||
# yaml-language-server: ...
|
||||
package: api
|
||||
generate:
|
||||
gin-server: true
|
||||
models: true
|
||||
# strict-server: true
|
||||
output: ./gen/user_np/server.go
|
127
config/user_np/user_np.yaml
Normal file
127
config/user_np/user_np.yaml
Normal file
@ -0,0 +1,127 @@
|
||||
openapi: '3.0.3'
|
||||
info:
|
||||
title: zzyxyz_user_np_api
|
||||
description: 用户节点权限相关操作(user_name and password)
|
||||
version: '1.0'
|
||||
servers:
|
||||
- url: http://localhost:8082/api
|
||||
description: 开发环境
|
||||
- url: https://api.zzyxyz.com/api
|
||||
description: 生产环境
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
|
||||
paths:
|
||||
/auth/login:
|
||||
post:
|
||||
summary: 用户登录
|
||||
description: 使用用户名和密码进行登录
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LoginRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: 登录成功
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/LoginResponse'
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
'401':
|
||||
description: 认证失败
|
||||
|
||||
/auth/register:
|
||||
post:
|
||||
summary: 用户注册
|
||||
description: 创建新用户账户
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/RegisterRequest'
|
||||
responses:
|
||||
'201':
|
||||
description: 注册成功
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
'409':
|
||||
description: 用户名已存在
|
||||
|
||||
/auth/password:
|
||||
put:
|
||||
summary: 修改密码
|
||||
description: 修改已登录用户的密码
|
||||
security:
|
||||
- ApiKeyAuth: []
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/ChangePasswordRequest'
|
||||
responses:
|
||||
'200':
|
||||
description: 密码修改成功
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
'401':
|
||||
description: 认证失败
|
||||
|
||||
components:
|
||||
schemas:
|
||||
LoginRequest:
|
||||
type: object
|
||||
required:
|
||||
- username
|
||||
- password
|
||||
properties:
|
||||
username:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
|
||||
LoginResponse:
|
||||
type: object
|
||||
properties:
|
||||
token:
|
||||
type: string
|
||||
expires_in:
|
||||
type: integer
|
||||
user_id:
|
||||
type: integer
|
||||
format: int64
|
||||
|
||||
RegisterRequest:
|
||||
type: object
|
||||
required:
|
||||
- username
|
||||
- password
|
||||
properties:
|
||||
username:
|
||||
type: string
|
||||
password:
|
||||
type: string
|
||||
email:
|
||||
type: string
|
||||
|
||||
ChangePasswordRequest:
|
||||
type: object
|
||||
required:
|
||||
- old_password
|
||||
- new_password
|
||||
properties:
|
||||
old_password:
|
||||
type: string
|
||||
new_password:
|
||||
type: string
|
||||
|
||||
securitySchemes:
|
||||
ApiKeyAuth:
|
||||
type: apiKey
|
||||
in: header
|
||||
name: Authorization
|
5
config/vfs/client.yaml
Normal file
5
config/vfs/client.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
# yaml-language-server: ...
|
||||
package: api
|
||||
generate:
|
||||
client: true
|
||||
output: ./gen/vfs/client.go
|
@ -3,4 +3,5 @@ package: api
|
||||
generate:
|
||||
gin-server: true
|
||||
models: true
|
||||
output: ./gen/bookmarks/gen.go
|
||||
# strict-server: true
|
||||
output: ./gen/vfs/server.go
|
@ -4,7 +4,7 @@ info:
|
||||
description: 虚拟文件系统API服务
|
||||
version: '1.0'
|
||||
servers:
|
||||
- url: http://localhost:8080/api
|
||||
- url: http://localhost:8083/api
|
||||
description: 开发环境
|
||||
- url: https://api.zzyxyz.com/api
|
||||
description: 生产环境
|
||||
@ -15,10 +15,48 @@ security:
|
||||
- ApiKeyAuth: []
|
||||
|
||||
paths:
|
||||
/vfs/v1/files/{path}:
|
||||
/vfs/v1/users:
|
||||
post:
|
||||
summary: 创建用户
|
||||
description: 创建一个用户
|
||||
operationId: createUser
|
||||
tags: [vfs]
|
||||
requestBody:
|
||||
required: true
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
description: 用户名
|
||||
responses:
|
||||
'201':
|
||||
description: 创建成功
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: string
|
||||
description: X-VFS-TOKEN
|
||||
delete:
|
||||
summary: 删除用户
|
||||
description: 删除一个用户
|
||||
operationId: deleteUser
|
||||
tags: [vfs]
|
||||
responses:
|
||||
'204':
|
||||
description: 删除成功
|
||||
'404':
|
||||
description: 用户不存在
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
/vfs/v1/files:
|
||||
parameters:
|
||||
- name: path
|
||||
in: path
|
||||
in: query
|
||||
required: true
|
||||
description: 文件系统路径,例如 "documents/readme.txt" 或 "services/mysql.service" 或 "folder/"
|
||||
schema:
|
||||
@ -77,6 +115,10 @@ paths:
|
||||
responses:
|
||||
'201':
|
||||
description: 创建成功
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/VFSNodeResponse'
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
content:
|
||||
@ -86,7 +128,7 @@ paths:
|
||||
'500':
|
||||
$ref: '#/components/responses/ServerInternalError'
|
||||
|
||||
put:
|
||||
patch:
|
||||
summary: 修改文件或修改目录
|
||||
description: 修改/移动/重命名 已存在的 文件/目录
|
||||
operationId: updateVFSNode
|
||||
@ -101,19 +143,13 @@ paths:
|
||||
new_name:
|
||||
type: string
|
||||
description: 新名称(用于重命名)
|
||||
new_path:
|
||||
type: string
|
||||
description: 新路径(用于移动)
|
||||
content:
|
||||
type: string
|
||||
description: 新内容(用于修改文件内容)
|
||||
anyOf:
|
||||
- required: [new_name]
|
||||
- required: [new_path]
|
||||
- required: [content]
|
||||
responses:
|
||||
'200':
|
||||
description: 操作成功
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/VFSNodeResponse'
|
||||
'400':
|
||||
description: 请求参数错误
|
||||
content:
|
||||
@ -160,6 +196,32 @@ components:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Error'
|
||||
schemas:
|
||||
VFSNodeType:
|
||||
type: string
|
||||
description: 节点类型
|
||||
enum: [file, directory, service]
|
||||
|
||||
VFSNodeResponse:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
description: 节点名称
|
||||
type:
|
||||
$ref: '#/components/schemas/VFSNodeType'
|
||||
created_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 创建时间
|
||||
updated_at:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 更新时间
|
||||
required:
|
||||
- name
|
||||
- type
|
||||
- created_at
|
||||
- updated_at
|
||||
VFSDirectoryEntry:
|
||||
type: object
|
||||
properties:
|
||||
@ -167,13 +229,7 @@ components:
|
||||
type: string
|
||||
description: 条目名称
|
||||
type:
|
||||
type: string
|
||||
enum: [file, directory, service]
|
||||
description: 条目类型
|
||||
modified:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 修改时间
|
||||
$ref: '#/components/schemas/VFSNodeType'
|
||||
permissions:
|
||||
type: string
|
||||
description: 权限信息,如 "rw"
|
Reference in New Issue
Block a user