|
@@ -1,7 +1,7 @@
|
|
|
import { createRoute, OpenAPIHono } from '@hono/zod-openapi';
|
|
import { createRoute, OpenAPIHono } from '@hono/zod-openapi';
|
|
|
import { z } from '@hono/zod-openapi';
|
|
import { z } from '@hono/zod-openapi';
|
|
|
import { authMiddleware } from '../../../../auth-module-mt/src/middleware/index.mt';
|
|
import { authMiddleware } from '../../../../auth-module-mt/src/middleware/index.mt';
|
|
|
-import { AppDataSource, parseWithAwait } from '@d8d/shared-utils';
|
|
|
|
|
|
|
+import { AppDataSource, parseWithAwait, ErrorSchema } from '@d8d/shared-utils';
|
|
|
import { AuthContext } from '@d8d/shared-types';
|
|
import { AuthContext } from '@d8d/shared-types';
|
|
|
import { SystemConfigServiceMt } from '../../services/system-config.service.mt';
|
|
import { SystemConfigServiceMt } from '../../services/system-config.service.mt';
|
|
|
import { UpdateSystemConfigSchema, SystemConfigSchema } from '../../schemas/system-config.schema.mt';
|
|
import { UpdateSystemConfigSchema, SystemConfigSchema } from '../../schemas/system-config.schema.mt';
|
|
@@ -35,13 +35,16 @@ const updateSystemConfigRoute = createRoute({
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
400: {
|
|
400: {
|
|
|
- description: '请求参数错误'
|
|
|
|
|
|
|
+ description: '请求参数错误',
|
|
|
|
|
+ content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
},
|
|
|
404: {
|
|
404: {
|
|
|
- description: '系统配置不存在'
|
|
|
|
|
|
|
+ description: '系统配置不存在',
|
|
|
|
|
+ content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
},
|
|
|
500: {
|
|
500: {
|
|
|
- description: '服务器内部错误'
|
|
|
|
|
|
|
+ description: '服务器内部错误',
|
|
|
|
|
+ content: { 'application/json': { schema: ErrorSchema } }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
@@ -51,7 +54,6 @@ const updateSystemConfigRoutes = new OpenAPIHono<AuthContext>()
|
|
|
.openapi(updateSystemConfigRoute, async (c) => {
|
|
.openapi(updateSystemConfigRoute, async (c) => {
|
|
|
const { id } = c.req.valid('param');
|
|
const { id } = c.req.valid('param');
|
|
|
const data = c.req.valid('json');
|
|
const data = c.req.valid('json');
|
|
|
- const user = c.get('user');
|
|
|
|
|
|
|
|
|
|
try {
|
|
try {
|
|
|
const systemConfigService = new SystemConfigServiceMt(AppDataSource);
|
|
const systemConfigService = new SystemConfigServiceMt(AppDataSource);
|
|
@@ -60,7 +62,7 @@ const updateSystemConfigRoutes = new OpenAPIHono<AuthContext>()
|
|
|
const result = await systemConfigService.update(id, data);
|
|
const result = await systemConfigService.update(id, data);
|
|
|
|
|
|
|
|
if (!result) {
|
|
if (!result) {
|
|
|
- return c.json({ error: '系统配置不存在' }, 404);
|
|
|
|
|
|
|
+ return c.json({ code: 404, message: '系统配置不存在' }, 404);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 验证响应格式
|
|
// 验证响应格式
|
|
@@ -70,7 +72,7 @@ const updateSystemConfigRoutes = new OpenAPIHono<AuthContext>()
|
|
|
} catch (error) {
|
|
} catch (error) {
|
|
|
console.error('更新系统配置失败:', error);
|
|
console.error('更新系统配置失败:', error);
|
|
|
return c.json(
|
|
return c.json(
|
|
|
- { error: error instanceof Error ? error.message : '更新系统配置失败' },
|
|
|
|
|
|
|
+ { code: 500, message: error instanceof Error ? error.message : '更新系统配置失败' },
|
|
|
500
|
|
500
|
|
|
);
|
|
);
|
|
|
}
|
|
}
|