Explorar el Código

Merge branch 'starter' of 139-template-116/d8d-vite-starter into starter

18617351030 hace 4 meses
padre
commit
64100d82c9
Se han modificado 1 ficheros con 3 adiciones y 3 borrados
  1. 3 3
      src/server/api/users/[id]/get.ts

+ 3 - 3
src/server/api/users/[id]/get.ts

@@ -10,9 +10,9 @@ import { UserSchema } from '@/server/modules/users/user.entity';
 const userService = new UserService(AppDataSource);
 
 const GetParams = z.object({
-  id: z.string().openapi({
+  id: z.coerce.number().openapi({
     param: { name: 'id', in: 'path' },
-    example: '1',
+    example: 1,
     description: '用户ID'
   })
 });
@@ -43,7 +43,7 @@ const routeDef = createRoute({
 const app = new OpenAPIHono<AuthContext>().openapi(routeDef, async (c) => {
   try {
     const { id } = c.req.valid('param');
-    const user = await userService.getUserById(parseInt(id));
+    const user = await userService.getUserById(id);
     if (!user) {
       return c.json({ code: 404, message: '用户不存在' }, 404);
     }