|
|
@@ -3,7 +3,6 @@ import { z } from '@hono/zod-openapi';
|
|
|
import { authMiddleware } from '@/server/middleware/auth.middleware';
|
|
|
import { PassengerService } from '@/server/modules/passengers/passenger.service';
|
|
|
import {
|
|
|
- PassengerCreateSchema,
|
|
|
PassengerUserCreateSchema,
|
|
|
PassengerUpdateSchema,
|
|
|
PassengerResponseSchema,
|
|
|
@@ -111,6 +110,10 @@ const getRouteDef = createRoute({
|
|
|
description: '未授权',
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
+ 403: {
|
|
|
+ description: '无权访问',
|
|
|
+ content: { 'application/json': { schema: ErrorSchema } }
|
|
|
+ },
|
|
|
404: {
|
|
|
description: '乘客不存在',
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
@@ -154,6 +157,10 @@ const updateRouteDef = createRoute({
|
|
|
description: '未授权',
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
+ 403: {
|
|
|
+ description: '无权修改',
|
|
|
+ content: { 'application/json': { schema: ErrorSchema } }
|
|
|
+ },
|
|
|
404: {
|
|
|
description: '乘客不存在',
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
@@ -185,6 +192,10 @@ const deleteRouteDef = createRoute({
|
|
|
description: '未授权',
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
+ 403: {
|
|
|
+ description: '无权删除',
|
|
|
+ content: { 'application/json': { schema: ErrorSchema } }
|
|
|
+ },
|
|
|
404: {
|
|
|
description: '乘客不存在',
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
@@ -219,6 +230,10 @@ const setDefaultRoute = createRoute({
|
|
|
description: '未授权',
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
},
|
|
|
+ 403: {
|
|
|
+ description: '无权设置',
|
|
|
+ content: { 'application/json': { schema: ErrorSchema } }
|
|
|
+ },
|
|
|
404: {
|
|
|
description: '乘客不存在',
|
|
|
content: { 'application/json': { schema: ErrorSchema } }
|
|
|
@@ -318,6 +333,9 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
}
|
|
|
|
|
|
const result = await passengerService.updatePassenger(id, data);
|
|
|
+ if (!result) {
|
|
|
+ return c.json({ code: 500, message: '更新乘客失败' }, 500);
|
|
|
+ }
|
|
|
return c.json(result, 200);
|
|
|
} catch (error) {
|
|
|
console.error('更新乘客失败:', error);
|
|
|
@@ -368,6 +386,9 @@ const app = new OpenAPIHono<AuthContext>()
|
|
|
}
|
|
|
|
|
|
const result = await passengerService.setDefaultPassenger(user.id, id);
|
|
|
+ if (!result) {
|
|
|
+ return c.json({ code: 500, message: '设置默认乘客失败' }, 500);
|
|
|
+ }
|
|
|
return c.json(result, 200);
|
|
|
} catch (error) {
|
|
|
console.error('设置默认乘客失败:', error);
|