-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f3a4b1
commit be3a086
Showing
8 changed files
with
123 additions
and
38 deletions.
There are no files selected for viewing
Empty file removed
0
libs/pathway-design/server/pathway/application/src/lib/change-title/command/.keep
Empty file.
38 changes: 38 additions & 0 deletions
38
.../pathway/application/src/lib/change-title/command/change-title-pathway.command-handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { | ||
type PDSPBPChangeTitlePathwayPersistencePort, | ||
type PDSPBPPathwayPresenterPort, | ||
PDSPBP_CHANGE_TITLE_PATHWAY_PERSISTENCE_PORT, | ||
PDSPBP_PATHWAY_PRESENTER_PORT, | ||
} from '@bewoak/pathway-design-server-pathway-business'; | ||
|
||
import { Inject } from '@nestjs/common'; | ||
// biome-ignore lint/style/useImportType: <explanation> | ||
import { CommandHandler, EventPublisher, type ICommandHandler } from '@nestjs/cqrs'; | ||
|
||
// biome-ignore lint/style/useImportType: <explanation> | ||
import { PDSPACUChangeTitlePathwayUseCase } from '../usecase/change-title-pathway.usecase'; | ||
import { PDSPAChangeTitlePathwayCommand } from './change-title-pathway.command'; | ||
|
||
@CommandHandler(PDSPAChangeTitlePathwayCommand) | ||
export class PDSPAChangeTitlePathwayCommandHandler implements ICommandHandler<PDSPAChangeTitlePathwayCommand> { | ||
constructor( | ||
private readonly pDSPACUChangeTitlePathwayUseCase: PDSPACUChangeTitlePathwayUseCase, | ||
@Inject(PDSPBP_CHANGE_TITLE_PATHWAY_PERSISTENCE_PORT) | ||
private readonly pDSPBPChangeTitlePathwayPersistencePort: PDSPBPChangeTitlePathwayPersistencePort, | ||
@Inject(PDSPBP_PATHWAY_PRESENTER_PORT) | ||
private readonly pDSPBPPathwayPresenterPort: PDSPBPPathwayPresenterPort, | ||
private readonly eventPublisher: EventPublisher | ||
) {} | ||
|
||
execute(pDSPAChangeTitlePathwayCommand: PDSPAChangeTitlePathwayCommand) { | ||
return this.pDSPACUChangeTitlePathwayUseCase.execute( | ||
this.pDSPBPChangeTitlePathwayPersistencePort, | ||
this.pDSPBPPathwayPresenterPort, | ||
this.eventPublisher, | ||
{ | ||
pathwayId: pDSPAChangeTitlePathwayCommand.pathwayId, | ||
title: pDSPAChangeTitlePathwayCommand.title, | ||
} | ||
); | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...n/server/pathway/application/src/lib/change-title/command/change-title-pathway.command.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export class PDSPAChangeTitlePathwayCommand { | ||
constructor( | ||
public readonly pathwayId: string, | ||
public readonly title: string | ||
) {} | ||
} |
Empty file removed
0
libs/pathway-design/server/pathway/application/src/lib/change-title/service/.keep
Empty file.
14 changes: 14 additions & 0 deletions
14
...n/server/pathway/application/src/lib/change-title/service/change-title-pathway.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import type { PDSPBPPathwayPresenters } from '@bewoak/pathway-design-server-pathway-business'; | ||
import { Injectable } from '@nestjs/common'; | ||
// biome-ignore lint/style/useImportType: <explanation> | ||
import { CommandBus } from '@nestjs/cqrs'; | ||
import type { PDSPAChangeTitlePathwayCommand } from '../command/change-title-pathway.command'; | ||
|
||
@Injectable() | ||
export class PDSPAChangeTitlePathwayService { | ||
constructor(private readonly commandBus: CommandBus) {} | ||
|
||
execute(pDSPAChangeTitlePathwayCommand: PDSPAChangeTitlePathwayCommand) { | ||
return this.commandBus.execute<PDSPAChangeTitlePathwayCommand, PDSPBPPathwayPresenters>(pDSPAChangeTitlePathwayCommand); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 25 additions & 11 deletions
36
...n/server/pathway/application/src/lib/change-title/usecase/change-title-pathway.usecase.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,28 @@ | ||
import { type PDSPBEPathwayEntity, PDSPBVOTitleValueObjects } from '@bewoak/pathway-design-server-pathway-business'; | ||
import type { | ||
PDSPBEPathwayEntity, | ||
PDSPBPChangeTitlePathwayPersistencePort, | ||
PDSPBPPathwayPresenterPort, | ||
} from '@bewoak/pathway-design-server-pathway-business'; | ||
import type { EventPublisher } from '@nestjs/cqrs'; | ||
|
||
export class PDSPBUChangeTitlePathwayUseCase { | ||
execute({ | ||
pathway, | ||
title, | ||
}: { | ||
pathway: PDSPBEPathwayEntity; | ||
title: string; | ||
}) { | ||
const newTitle = new PDSPBVOTitleValueObjects(title); | ||
pathway.changeTitle(newTitle); | ||
export class PDSPACUChangeTitlePathwayUseCase { | ||
async execute( | ||
pDSPBPChangeTitlePathwayPersistencePort: PDSPBPChangeTitlePathwayPersistencePort, | ||
pDSPBPPathwayPresenterPort: PDSPBPPathwayPresenterPort, | ||
eventPublisher: EventPublisher, | ||
{ | ||
pathway, | ||
title, | ||
}: { | ||
pathway: PDSPBEPathwayEntity; | ||
title: string; | ||
} | ||
) { | ||
const pathwayFromPersistence = await pDSPBPChangeTitlePathwayPersistencePort.changeTitle(pathway, title); | ||
|
||
eventPublisher.mergeObjectContext(pathway); | ||
pathway.commit(); | ||
|
||
return pDSPBPPathwayPresenterPort.present(pathwayFromPersistence); | ||
} | ||
} |