|
|
@@ -1,17 +1,33 @@
|
|
|
+import { createCrudRoutes } from '@/server/utils/generic-crud.routes';
|
|
|
+import { SilverUserProfile } from '@/server/modules/silver-users/silver-user-profile.entity';
|
|
|
+import {
|
|
|
+ SilverUserProfileSchema,
|
|
|
+ CreateSilverUserProfileDto,
|
|
|
+ UpdateSilverUserProfileDto
|
|
|
+} from '@/server/modules/silver-users/silver-user-profile.entity';
|
|
|
+import { authMiddleware } from '@/server/middleware/auth.middleware';
|
|
|
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
|
-import listRoute from './get';
|
|
|
-import getByIdRoute from './[id]/get';
|
|
|
-import patchRoute from './[id]/patch';
|
|
|
-import putRoute from './[id]/put';
|
|
|
-import deleteRoute from './[id]/delete';
|
|
|
import statsRoute from './stats';
|
|
|
|
|
|
+// 创建通用CRUD路由
|
|
|
+const crudRoutes = createCrudRoutes({
|
|
|
+ entity: SilverUserProfile,
|
|
|
+ createSchema: CreateSilverUserProfileDto,
|
|
|
+ updateSchema: UpdateSilverUserProfileDto,
|
|
|
+ getSchema: SilverUserProfileSchema,
|
|
|
+ listSchema: SilverUserProfileSchema,
|
|
|
+ searchFields: ['realName', 'phone', 'email', 'organization', 'personalIntro', 'personalSkills'],
|
|
|
+ relations: ['user'],
|
|
|
+ middleware: [authMiddleware],
|
|
|
+ userTracking: {
|
|
|
+ createdByField: 'createdBy',
|
|
|
+ updatedByField: 'updatedBy'
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+// 创建应用并组合路由
|
|
|
const app = new OpenAPIHono()
|
|
|
- .route('/', listRoute)
|
|
|
- .route('/', getByIdRoute)
|
|
|
- .route('/', patchRoute)
|
|
|
- .route('/', putRoute)
|
|
|
- .route('/', deleteRoute)
|
|
|
+ .route('/', crudRoutes)
|
|
|
.route('/', statsRoute);
|
|
|
|
|
|
export default app;
|