@PermitAll public class StoryService extends Object
| Constructor and Description |
|---|
StoryService() |
| Modifier and Type | Method and Description |
|---|---|
es.uvigo.esei.microstories.domain.entities.Story |
addReadingLogEntryForA_Story_aux(es.uvigo.esei.microstories.domain.entities.Story story,
Date date) |
void |
addReadingLogEntryForA_Story(Long id)
Adds a new reading log entry for a specific story.
|
List<StoryResponseDto> |
getRecentStories(int limit) |
List<StoryResponseDto> |
getStoriesByFilter(es.uvigo.esei.microstories.domain.types.GenreType genre,
es.uvigo.esei.microstories.domain.types.ThemeType theme,
Date initialDate,
Date finalDate) |
List<StoryResponseDto> |
getStoriesByUser_aux(String username,
int page,
int size) |
List<StoryResponseDto> |
getStoriesByUser(String username,
int page,
int size)
Retrieves a paginated list of stories authored by a specific user.
|
StoryResponseDto |
getStoryById(Long id) |
Map<es.uvigo.esei.microstories.domain.types.GenreType,List<StoryResponseDto>> |
getTop2ReadStoriesLastMonthByGenre()
Retrieves the top 2 most read stories from last month grouped by genre.
|
List<StoryResponseDto> |
searchStoriesByText(String text,
int page,
int size)
Busca relatos cuyo título o contenido contenga el texto indicado.
|
public List<StoryResponseDto> getRecentStories(int limit)
public StoryResponseDto getStoryById(Long id)
public List<StoryResponseDto> searchStoriesByText(String text, int page, int size)
text - el texto a buscar en el título o contenido de los relatospage - el número de página (0-based index)size - el número de relatos por páginaStoryResponseDto que coinciden con el texto de búsquedaIllegalArgumentException - si el texto está vacío, page es negativo o size es menor que 1public List<StoryResponseDto> getStoriesByFilter(es.uvigo.esei.microstories.domain.types.GenreType genre, es.uvigo.esei.microstories.domain.types.ThemeType theme, Date initialDate, Date finalDate)
public Map<es.uvigo.esei.microstories.domain.types.GenreType,List<StoryResponseDto>> getTop2ReadStoriesLastMonthByGenre()
Stories are ranked by the number of views they received during the previous calendar month. For each genre, up to 2 stories are returned, ordered by view count (descending) and then by publication date (descending).
public void addReadingLogEntryForA_Story(Long id)
This method retrieves a story by its identifier and records a new reading
event associated with the current date and time. If the story does not exist,
an EntityNotFoundException is thrown. The updated story, including
the newly added reading log entry, is then merged back into the persistence
context and flushed to the database.
id - The unique identifier of the story for which a reading log entry
should be added. Must not be null.EntityNotFoundException - if no story exists with the provided id.public es.uvigo.esei.microstories.domain.entities.Story addReadingLogEntryForA_Story_aux(es.uvigo.esei.microstories.domain.entities.Story story,
Date date)
public List<StoryResponseDto> getStoriesByUser(String username, int page, int size)
This method fetches stories written by the given username, ordered by
publication date in descending order (newest first). Pagination is applied
based on the provided page number and page size. If either page or
size is less than 1, an IllegalArgumentException is thrown.
The resulting list of Story entities is transformed into
StoryResponseDto objects before being returned.
username - the username of the author whose stories are to be retrieved;
must not be null.page - the page number to retrieve (1-based index); must be >= 1.size - the number of stories per page; must be >= 1.StoryResponseDto objects representing the stories
authored by the specified user, limited and ordered according to the
pagination parameters.IllegalArgumentException - if page < 1 or size < 1.public List<StoryResponseDto> getStoriesByUser_aux(String username, int page, int size)
Copyright © 2025. All rights reserved.