Переглянути джерело

✨ feat(crud): 提取ConcreteCrudService到独立文件

- 将ConcreteCrudService从generic-crud.routes.ts移至新文件concrete-crud.service.ts
- 在generic-crud.routes.ts中导入ConcreteCrudService以保持功能完整性
- 优化代码组织结构,提高可维护性和模块复用性
yourname 2 місяців тому
батько
коміт
5dc25a7a22

+ 10 - 0
src/server/utils/concrete-crud.service.ts

@@ -0,0 +1,10 @@
+import { AppDataSource } from '../data-source';
+import { GenericCrudService, UserTrackingOptions, RelationFieldOptions } from './generic-crud.service';
+import { ObjectLiteral } from 'typeorm';
+
+// 创建具体CRUD服务类
+export class ConcreteCrudService<T extends ObjectLiteral> extends GenericCrudService<T> {
+  constructor(entity: new () => T, options?: { userTracking?: UserTrackingOptions; relationFields?: RelationFieldOptions }) {
+    super(AppDataSource, entity, options);
+  }
+}

+ 2 - 9
src/server/utils/generic-crud.routes.ts

@@ -1,18 +1,11 @@
 import { createRoute, OpenAPIHono } from '@hono/zod-openapi';
 import { z } from '@hono/zod-openapi';
-import { GenericCrudService, CrudOptions, UserTrackingOptions, RelationFieldOptions } from './generic-crud.service';
+import { GenericCrudService, CrudOptions } from './generic-crud.service';
 import { ErrorSchema } from './errorHandler';
 import { AuthContext } from '../types/context';
 import { ObjectLiteral } from 'typeorm';
-import { AppDataSource } from '../data-source';
 import { parseWithAwait } from './parseWithAwait';
-
-// 创建具体CRUD服务类
-export class ConcreteCrudService<T extends ObjectLiteral> extends GenericCrudService<T> {
-  constructor(entity: new () => T, options?: { userTracking?: UserTrackingOptions; relationFields?: RelationFieldOptions }) {
-    super(AppDataSource, entity, options);
-  }
-}
+import { ConcreteCrudService } from './concrete-crud.service';
 
 export function createCrudRoutes<
   T extends ObjectLiteral,