|
|
@@ -5,7 +5,7 @@ import { authMiddleware } from '../../middleware/auth.middleware';
|
|
|
import { ErrorSchema } from '../../utils/errorHandler';
|
|
|
import { AppDataSource } from '../../data-source';
|
|
|
import { AuthContext } from '../../types/context';
|
|
|
-import { UserListResponse, UserSchema } from '../../modules/users/user.schema';
|
|
|
+import { UserListResponse } from '../../modules/users/user.schema';
|
|
|
import { parseWithAwait } from '@/server/utils/parseWithAwait';
|
|
|
|
|
|
const userService = new UserService(AppDataSource);
|
|
|
@@ -69,17 +69,25 @@ const app = new OpenAPIHono<AuthContext>().openapi(listUsersRoute, async (c) =>
|
|
|
keyword
|
|
|
});
|
|
|
|
|
|
- return c.json({
|
|
|
- data: await parseWithAwait(z.array(UserSchema), users),
|
|
|
+ // return c.json({
|
|
|
+ // data: await parseWithAwait(z.array(UserSchema), users),
|
|
|
+ // pagination: {
|
|
|
+ // total,
|
|
|
+ // current: page,
|
|
|
+ // pageSize
|
|
|
+ // }
|
|
|
+ // }, 200);
|
|
|
+ return c.json(await parseWithAwait(UserListResponse, {
|
|
|
+ data: users,
|
|
|
pagination: {
|
|
|
total,
|
|
|
current: page,
|
|
|
pageSize
|
|
|
}
|
|
|
- }, 200);
|
|
|
+ }),200)
|
|
|
} catch (error) {
|
|
|
if (error instanceof z.ZodError) {
|
|
|
- return c.json({ code: 400, message: '参数错误' }, 400);
|
|
|
+ return c.json({ code: 400, message: error.message }, 400);
|
|
|
}
|
|
|
return c.json({
|
|
|
code: 500,
|