|
|
@@ -1,35 +0,0 @@
|
|
|
-import { createCrudRoutes } from '@d8d/shared-crud';
|
|
|
-import { OpenAPIHono } from '@hono/zod-openapi';
|
|
|
-import { Goods } from '../entities/goods.entity.js';
|
|
|
-import { GoodsSchema, CreateGoodsDto, UpdateGoodsDto } from '../schemas/goods.schema.js';
|
|
|
-import { authMiddleware } from '@d8d/auth-module';
|
|
|
-import { File } from '@d8d/file-module';
|
|
|
-
|
|
|
-// 创建基础CRUD路由
|
|
|
-const goodsRoutes = createCrudRoutes({
|
|
|
- entity: Goods,
|
|
|
- createSchema: CreateGoodsDto,
|
|
|
- updateSchema: UpdateGoodsDto,
|
|
|
- getSchema: GoodsSchema,
|
|
|
- listSchema: GoodsSchema,
|
|
|
- searchFields: ['name', 'instructions'],
|
|
|
- relations: ['category1', 'category2', 'category3', 'supplier', 'imageFile.uploadUser', 'slideImages.uploadUser'],
|
|
|
- middleware: [authMiddleware],
|
|
|
- userTracking: {
|
|
|
- createdByField: 'createdBy',
|
|
|
- updatedByField: 'updatedBy'
|
|
|
- },
|
|
|
- relationFields: {
|
|
|
- slideImageIds: {
|
|
|
- relationName: 'slideImages',
|
|
|
- targetEntity: File,
|
|
|
- joinTableName: 'goods_slide_images'
|
|
|
- }
|
|
|
- }
|
|
|
-});
|
|
|
-
|
|
|
-// 聚合基础CRUD路由和扩展路由
|
|
|
-const app = new OpenAPIHono()
|
|
|
- .route('/', goodsRoutes);
|
|
|
-
|
|
|
-export default app;
|