|
|
@@ -0,0 +1,28 @@
|
|
|
+import { createCrudRoutes } from '@d8d/shared-crud';
|
|
|
+import { authMiddleware } from '@d8d/auth-module';
|
|
|
+import { Goods } from '../entities/goods.entity.js';
|
|
|
+import { AdminGoodsSchema, AdminCreateGoodsDto, AdminUpdateGoodsDto } from '../schemas/admin-goods.schema.js';
|
|
|
+import { File } from '@d8d/file-module';
|
|
|
+
|
|
|
+export const adminGoodsRoutes = createCrudRoutes({
|
|
|
+ entity: Goods,
|
|
|
+ createSchema: AdminCreateGoodsDto,
|
|
|
+ updateSchema: AdminUpdateGoodsDto,
|
|
|
+ getSchema: AdminGoodsSchema,
|
|
|
+ listSchema: AdminGoodsSchema,
|
|
|
+ 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功能
|
|
|
+});
|