-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add updateCollectionFeaturedItems use case
- Loading branch information
Showing
7 changed files
with
126 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export type CollectionFeaturedItemsDTO = CollectionFeaturedItemDTO[] | ||
|
||
export interface CollectionFeaturedItemDTO { | ||
id?: number | ||
content: string | ||
displayOrder: number | ||
file?: File | ||
keepFile: boolean | ||
} |
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
32 changes: 32 additions & 0 deletions
32
src/collections/domain/useCases/UpdateCollectionFeaturedItems.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,32 @@ | ||
import { UseCase } from '../../../core/domain/useCases/UseCase' | ||
import { CollectionFeaturedItemsDTO } from '../dtos/CollectionFeaturedItemsDTO' | ||
import { ROOT_COLLECTION_ID } from '../models/Collection' | ||
import { CollectionFeaturedItem } from '../models/CollectionFeaturedItem' | ||
import { ICollectionsRepository } from '../repositories/ICollectionsRepository' | ||
|
||
export class UpdateCollectionFeaturedItems implements UseCase<CollectionFeaturedItem[]> { | ||
private collectionsRepository: ICollectionsRepository | ||
|
||
constructor(collectionsRepository: ICollectionsRepository) { | ||
this.collectionsRepository = collectionsRepository | ||
} | ||
|
||
/** | ||
* Updates all featured items, given a collection identifier and a CollectionFeaturedItemsDTO. | ||
* | ||
* @param {number | string} [collectionIdOrAlias = ':root'] - A generic collection identifier, which can be either a string (for queries by CollectionAlias), or a number (for queries by CollectionId) | ||
* If this parameter is not set, the default value is: ':root' | ||
* @param {CollectionFeaturedItemsDTO} [newCollectionFeaturedItems] - CollectionFeaturedItemsDTO object including the updated collection featured items data. | ||
* @returns {Promise<CollectionFeaturedItem[]>} -This method returns the updated collection featured items upon successful completion. | ||
* @throws {WriteError} - If there are errors while writing data. | ||
*/ | ||
async execute( | ||
collectionIdOrAlias: number | string = ROOT_COLLECTION_ID, | ||
featuredItemsDTO: CollectionFeaturedItemsDTO | ||
): Promise<CollectionFeaturedItem[]> { | ||
return await this.collectionsRepository.updateCollectionFeaturedItems( | ||
collectionIdOrAlias, | ||
featuredItemsDTO | ||
) | ||
} | ||
} |
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