import { OpenAPIRegistry } from '@asteasolutions/zod-to-openapi'; import { z } from 'zod'; import { catalogCreateSchema, catalogUpdateSchema, catalogResponseSchema } from '../schemas/catalog.schemas.js'; import { errorResponseSchema, paginatedResponseSchema } from '../schemas/common.js'; export function registerCatalogPaths(registry: OpenAPIRegistry) { // POST /api/consumable-temp-catalog registry.registerPath({ method: 'post', path: '/api/consumable-temp-catalog', tags: ['Consumable Catalog'], summary: '创建耗材目录', request: { body: { content: { 'application/json': { schema: catalogCreateSchema } } } }, responses: { 201: { description: '创建成功', content: { 'application/json': { schema: z.object({ data: catalogResponseSchema }) } } } } }); // GET /api/consumable-temp-catalog registry.registerPath({ method: 'get', path: '/api/consumable-temp-catalog', tags: ['Consumable Catalog'], summary: '查询耗材目录列表', request: { query: z.object({ page: z.string().optional().openapi({ description: '页码' }), pageSize: z.string().optional().openapi({ description: '每页数量' }), isActive: z.string().optional().openapi({ description: '是否激活' }), q: z.string().optional().openapi({ description: '搜索关键词' }) }) }, responses: { 200: { description: '查询成功', content: { 'application/json': { schema: paginatedResponseSchema(catalogResponseSchema) } } } } }); // GET /api/consumable-temp-catalog/:id registry.registerPath({ method: 'get', path: '/api/consumable-temp-catalog/{id}', tags: ['Consumable Catalog'], summary: '获取耗材目录详情', request: { params: z.object({ id: z.string().openapi({ description: '目录ID' }) }) }, responses: { 200: { description: '查询成功', content: { 'application/json': { schema: z.object({ data: catalogResponseSchema }) } } }, 404: { description: '未找到', content: { 'application/json': { schema: errorResponseSchema } } } } }); // PUT /api/consumable-temp-catalog/:id registry.registerPath({ method: 'put', path: '/api/consumable-temp-catalog/{id}', tags: ['Consumable Catalog'], summary: '更新耗材目录', request: { params: z.object({ id: z.string().openapi({ description: '目录ID' }) }), body: { content: { 'application/json': { schema: catalogUpdateSchema } } } }, responses: { 200: { description: '更新成功', content: { 'application/json': { schema: z.object({ data: catalogResponseSchema }) } } }, 404: { description: '未找到', content: { 'application/json': { schema: errorResponseSchema } } } } }); // DELETE /api/consumable-temp-catalog/:id registry.registerPath({ method: 'delete', path: '/api/consumable-temp-catalog/{id}', tags: ['Consumable Catalog'], summary: '停用耗材目录', request: { params: z.object({ id: z.string().openapi({ description: '目录ID' }) }) }, responses: { 204: { description: '停用成功' } } }); }