diff --git a/apps/server/src/modules/board/board.module.ts b/apps/server/src/modules/board/board.module.ts index 1c5efeb5bd3..eae521d9ebb 100644 --- a/apps/server/src/modules/board/board.module.ts +++ b/apps/server/src/modules/board/board.module.ts @@ -16,7 +16,7 @@ import { ContentElementService, SubmissionItemService, } from './service'; -import { BoardDoCopyService } from './service/board-do-copy.service'; +import { BoardDoCopyService } from './service/board-do-copy-service'; import { ColumnBoardCopyService } from './service/column-board-copy.service'; @Module({ diff --git a/apps/server/src/modules/board/service/board-do-copy.service.spec.ts b/apps/server/src/modules/board/service/board-do-copy-service/board-do-copy.service.spec.ts similarity index 100% rename from apps/server/src/modules/board/service/board-do-copy.service.spec.ts rename to apps/server/src/modules/board/service/board-do-copy-service/board-do-copy.service.spec.ts diff --git a/apps/server/src/modules/board/service/board-do-copy-service/board-do-copy.service.ts b/apps/server/src/modules/board/service/board-do-copy-service/board-do-copy.service.ts new file mode 100644 index 00000000000..e93630949a4 --- /dev/null +++ b/apps/server/src/modules/board/service/board-do-copy-service/board-do-copy.service.ts @@ -0,0 +1,29 @@ +import { Injectable } from '@nestjs/common'; +import { AnyBoardDo, EntityId } from '@shared/domain'; +import { CopyStatus } from '@src/modules/copy-helper'; +import { FilesStorageClientAdapterService } from '@src/modules/files-storage-client'; +import { RecursiveCopyVisitor } from './recursive-copy.visitor'; + +export type BoardDoCopyParams = { + originSchoolId: EntityId; + targetSchoolId?: EntityId; + userId: EntityId; + original: AnyBoardDo; +}; + +@Injectable() +export class BoardDoCopyService { + constructor(private readonly filesStorageClientAdapterService: FilesStorageClientAdapterService) {} + + public async copy(params: BoardDoCopyParams): Promise { + const visitor = new RecursiveCopyVisitor(this.filesStorageClientAdapterService, { + userId: params.userId, + originSchoolId: params.originSchoolId, + targetSchoolId: params.targetSchoolId || params.originSchoolId, + }); + + const result = await visitor.copy(params.original); + + return result; + } +} diff --git a/apps/server/src/modules/board/service/board-do-copy-service/index.ts b/apps/server/src/modules/board/service/board-do-copy-service/index.ts new file mode 100644 index 00000000000..7a87fa3ac47 --- /dev/null +++ b/apps/server/src/modules/board/service/board-do-copy-service/index.ts @@ -0,0 +1 @@ +export * from './board-do-copy.service'; diff --git a/apps/server/src/modules/board/service/board-do-copy.service.ts b/apps/server/src/modules/board/service/board-do-copy-service/recursive-copy.visitor.ts similarity index 88% rename from apps/server/src/modules/board/service/board-do-copy.service.ts rename to apps/server/src/modules/board/service/board-do-copy-service/recursive-copy.visitor.ts index d908373391d..5a29935a528 100644 --- a/apps/server/src/modules/board/service/board-do-copy.service.ts +++ b/apps/server/src/modules/board/service/board-do-copy-service/recursive-copy.visitor.ts @@ -1,4 +1,3 @@ -import { Injectable } from '@nestjs/common'; import { AnyBoardDo, BoardCompositeVisitorAsync, @@ -22,7 +21,7 @@ type RecursiveCopyVisitorParams = { userId: EntityId; }; -class RecursiveCopyVisitor implements BoardCompositeVisitorAsync { +export class RecursiveCopyVisitor implements BoardCompositeVisitorAsync { resultMap = new Map(); copyMap = new Map(); @@ -213,27 +212,3 @@ class RecursiveCopyVisitor implements BoardCompositeVisitorAsync { return copies; } } - -export type BoardDoCopyParams = { - originSchoolId: EntityId; - targetSchoolId?: EntityId; - userId: EntityId; - original: AnyBoardDo; -}; - -@Injectable() -export class BoardDoCopyService { - constructor(private readonly filesStorageClientAdapterService: FilesStorageClientAdapterService) {} - - public async copy(params: BoardDoCopyParams): Promise { - const visitor = new RecursiveCopyVisitor(this.filesStorageClientAdapterService, { - userId: params.userId, - originSchoolId: params.originSchoolId, - targetSchoolId: params.targetSchoolId || params.originSchoolId, - }); - - const result = await visitor.copy(params.original); - - return result; - } -} diff --git a/apps/server/src/modules/board/service/column-board-copy.service.spec.ts b/apps/server/src/modules/board/service/column-board-copy.service.spec.ts index 2ce53a7d1ab..5da9cfa48e3 100644 --- a/apps/server/src/modules/board/service/column-board-copy.service.spec.ts +++ b/apps/server/src/modules/board/service/column-board-copy.service.spec.ts @@ -6,7 +6,7 @@ import { columnBoardFactory, courseFactory, schoolFactory, setupEntities, userFa import { CopyElementType, CopyStatus, CopyStatusEnum } from '@src/modules/copy-helper'; import { UserService } from '@src/modules/user'; import { BoardDoRepo } from '../repo'; -import { BoardDoCopyService } from './board-do-copy.service'; +import { BoardDoCopyService } from './board-do-copy-service'; import { ColumnBoardCopyService } from './column-board-copy.service'; describe('column board copy service', () => { diff --git a/apps/server/src/modules/board/service/column-board-copy.service.ts b/apps/server/src/modules/board/service/column-board-copy.service.ts index 0af9a272a27..c2e264eb812 100644 --- a/apps/server/src/modules/board/service/column-board-copy.service.ts +++ b/apps/server/src/modules/board/service/column-board-copy.service.ts @@ -10,7 +10,7 @@ import { CourseRepo } from '@shared/repo'; import { CopyStatus } from '@src/modules/copy-helper'; import { UserService } from '@src/modules/user'; import { BoardDoRepo } from '../repo'; -import { BoardDoCopyService } from './board-do-copy.service'; +import { BoardDoCopyService } from './board-do-copy-service'; @Injectable() export class ColumnBoardCopyService {