154 lines
4.5 KiB
JavaScript
154 lines
4.5 KiB
JavaScript
/**
|
|
* 系统管理模块 Swagger 文档
|
|
* @file swagger-system.js
|
|
* @description 系统管理相关的 Swagger API 文档定义
|
|
*/
|
|
|
|
// 系统管理相关的 API 路径定义
|
|
const systemPaths = {
|
|
'/api/system/configs': {
|
|
get: {
|
|
summary: '获取系统配置列表',
|
|
tags: ['系统管理'],
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [
|
|
{
|
|
name: 'category',
|
|
in: 'query',
|
|
schema: { type: 'string' },
|
|
description: '配置分类'
|
|
},
|
|
{
|
|
name: 'is_public',
|
|
in: 'query',
|
|
schema: { type: 'boolean' },
|
|
description: '是否公开配置'
|
|
}
|
|
],
|
|
responses: {
|
|
200: { $ref: '#/components/responses/Success' },
|
|
401: { $ref: '#/components/responses/Unauthorized' },
|
|
403: { $ref: '#/components/responses/Forbidden' }
|
|
}
|
|
},
|
|
post: {
|
|
summary: '创建系统配置',
|
|
tags: ['系统管理'],
|
|
security: [{ bearerAuth: [] }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: { $ref: '#/components/schemas/SystemConfigInput' }
|
|
}
|
|
}
|
|
},
|
|
responses: {
|
|
201: { $ref: '#/components/responses/Created' },
|
|
400: { $ref: '#/components/responses/BadRequest' },
|
|
403: { $ref: '#/components/responses/Forbidden' }
|
|
}
|
|
}
|
|
},
|
|
'/api/system/configs/{id}': {
|
|
get: {
|
|
summary: '根据ID获取系统配置',
|
|
tags: ['系统管理'],
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ $ref: '#/components/parameters/IdParam' }],
|
|
responses: {
|
|
200: { $ref: '#/components/responses/Success' },
|
|
404: { $ref: '#/components/responses/NotFound' }
|
|
}
|
|
},
|
|
put: {
|
|
summary: '更新系统配置',
|
|
tags: ['系统管理'],
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ $ref: '#/components/parameters/IdParam' }],
|
|
requestBody: {
|
|
required: true,
|
|
content: {
|
|
'application/json': {
|
|
schema: { $ref: '#/components/schemas/SystemConfigInput' }
|
|
}
|
|
}
|
|
},
|
|
responses: {
|
|
200: { $ref: '#/components/responses/Success' },
|
|
404: { $ref: '#/components/responses/NotFound' }
|
|
}
|
|
},
|
|
delete: {
|
|
summary: '删除系统配置',
|
|
tags: ['系统管理'],
|
|
security: [{ bearerAuth: [] }],
|
|
parameters: [{ $ref: '#/components/parameters/IdParam' }],
|
|
responses: {
|
|
200: { $ref: '#/components/responses/Success' },
|
|
404: { $ref: '#/components/responses/NotFound' }
|
|
}
|
|
}
|
|
},
|
|
'/api/system/menus': {
|
|
get: {
|
|
summary: '获取菜单列表',
|
|
tags: ['系统管理'],
|
|
security: [{ bearerAuth: [] }],
|
|
responses: {
|
|
200: { $ref: '#/components/responses/Success' }
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
// 系统管理相关的数据模型定义
|
|
const systemSchemas = {
|
|
SystemConfig: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'integer', description: '配置ID' },
|
|
key: { type: 'string', description: '配置键' },
|
|
value: { type: 'string', description: '配置值' },
|
|
category: { type: 'string', description: '配置分类' },
|
|
description: { type: 'string', description: '配置描述' },
|
|
isPublic: { type: 'boolean', description: '是否公开' },
|
|
createdAt: { type: 'string', format: 'date-time', description: '创建时间' },
|
|
updatedAt: { type: 'string', format: 'date-time', description: '更新时间' }
|
|
}
|
|
},
|
|
SystemConfigInput: {
|
|
type: 'object',
|
|
required: ['key', 'value'],
|
|
properties: {
|
|
key: { type: 'string', description: '配置键' },
|
|
value: { type: 'string', description: '配置值' },
|
|
category: { type: 'string', description: '配置分类' },
|
|
description: { type: 'string', description: '配置描述' },
|
|
isPublic: { type: 'boolean', description: '是否公开' }
|
|
}
|
|
},
|
|
Menu: {
|
|
type: 'object',
|
|
properties: {
|
|
id: { type: 'integer', description: '菜单ID' },
|
|
name: { type: 'string', description: '菜单名称' },
|
|
path: { type: 'string', description: '菜单路径' },
|
|
icon: { type: 'string', description: '菜单图标' },
|
|
parentId: { type: 'integer', description: '父菜单ID' },
|
|
order: { type: 'integer', description: '排序' },
|
|
permissions: {
|
|
type: 'array',
|
|
items: { type: 'string' },
|
|
description: '权限列表'
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
module.exports = {
|
|
systemPaths,
|
|
systemSchemas
|
|
};
|
|
|