The created genre object.
This method takes a DTO containing the name of the genre to be created. It normalizes the genre name and attempts to create a new genre in the database. If a genre with the same name already exists, it throws a ConflictException. If there is any other error during the creation process, it throws an InternalServerErrorException. This method is typically used by admin users to add new genres to the system.
The pagination and filtering parameters.
A list of genres matching the criteria.
The unique identifier of the genre to retrieve.
The genre with the specified ID.
This method takes a genre ID as input and attempts to retrieve the corresponding genre from the database. If the genre is found, it is returned. If no genre with the specified ID exists, a NotFoundException is thrown. This method is typically used to display detailed information about a specific genre.
The where condition for filtering genres.
The number of genres to skip.
The number of genres to take.
The order in which to sort the genres.
A list of genres matching the criteria.
This method takes a genre ID as input and attempts to retrieve the corresponding genre from the database. If the genre is found, it is returned. If no genre with the specified ID exists, a NotFoundException is thrown. This method is typically used to display detailed information about a specific genre.
The list of genre names to process.
The list of genres that were either created or already existed.
This method takes a list of genre names, normalizes them, and checks which ones already exist in the database. It then creates any new genres that do not already exist and returns the complete list of genres corresponding to the provided names. This is useful for efficiently handling bulk operations when associating genres with books or other entities.
A list of top genres with their popular books.
This method retrieves the top 30 genres from the database based on the number of approved books associated with each genre. For each of these top genres, it also retrieves up to 2 of their most popular approved books, sorted by average rating in descending order. This method is useful for displaying popular genres and their top books to users.
The unique identifier of the genre to remove.
The deleted genre.
The query string to search for in genre names.
A list of genres that match the search criteria.
This method takes a query string as input and searches for genres in the database that contain the query string in their name, ignoring case. It returns a list of matching genres, limited to a maximum of 10 results. This is useful for implementing search functionality when users are looking for specific genres.
The DTO containing the genre name to be created.