-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert RomeSearch and AppellationSearch to transactional use cases
- Loading branch information
Showing
9 changed files
with
47 additions
and
27 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
import { RomeDto } from "../../../shared/romeAndAppellationDtos/romeAndAppellation.dto"; | ||
import { zTrimmedString } from "../../../shared/zodUtils"; | ||
import { UseCase } from "../../core/UseCase"; | ||
import { RomeRepository } from "../ports/RomeRepository"; | ||
import { UnitOfWork, UnitOfWorkPerformer } from "../../core/ports/UnitOfWork"; | ||
import { TransactionalUseCase } from "../../core/UseCase"; | ||
|
||
const MIN_SEARCH_TEXT_LENGTH = 3; | ||
|
||
export class RomeSearch extends UseCase<string, RomeDto[]> { | ||
public constructor(readonly romeRepository: RomeRepository) { | ||
super(); | ||
export class RomeSearch extends TransactionalUseCase<string, RomeDto[]> { | ||
constructor(uowPerformer: UnitOfWorkPerformer) { | ||
super(uowPerformer); | ||
} | ||
|
||
inputSchema = zTrimmedString; | ||
|
||
public async _execute(searchText: string): Promise<RomeDto[]> { | ||
public async _execute( | ||
searchText: string, | ||
uow: UnitOfWork, | ||
): Promise<RomeDto[]> { | ||
if (searchText.length <= MIN_SEARCH_TEXT_LENGTH) return []; | ||
return await this.romeRepository.searchRome(searchText); | ||
return await uow.romeRepo.searchRome(searchText); | ||
} | ||
} |
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
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