Package com.espacogeek.geek.controllers
Class UserMediaListController
java.lang.Object
com.espacogeek.geek.controllers.UserMediaListController
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddMediaToUserLibrary(Integer mediaId, org.springframework.security.core.Authentication authentication) Adds the specified media to the authenticated user's library with default status (PLANNING) and progress 0.findUserMediaLibrary(Integer userId, String status, Integer statusId, Integer categoryId, String categoryName, Integer genreId, String genreName, Integer mediaId, String mediaName, String altTitle, org.springframework.security.core.Authentication authentication) Returns a user's media library, optionally filtered by status, statusId, category, categoryName, genre, genreId, mediaId, media name, or alternative title.removeMediaFromUserLibrary(Integer mediaId, org.springframework.security.core.Authentication authentication) Removes the specified media from the authenticated user's library.upsertUserMedia(UpdateUserMediaInput input, org.springframework.security.core.Authentication authentication) Creates or updates the authenticated user's library entry for the media specified ininput.mediaId(upsert).
-
Constructor Details
-
UserMediaListController
public UserMediaListController()
-
-
Method Details
-
findUserMediaLibrary
@QueryMapping(name="findUserMediaLibrary") @PreAuthorize("hasRole(\'user\')") public List<UserMediaListModel> findUserMediaLibrary(@Argument(name="userId") Integer userId, @Argument(name="status") String status, @Argument(name="statusId") Integer statusId, @Argument(name="categoryId") Integer categoryId, @Argument(name="categoryName") String categoryName, @Argument(name="genreId") Integer genreId, @Argument(name="genreName") String genreName, @Argument(name="mediaId") Integer mediaId, @Argument(name="mediaName") String mediaName, @Argument(name="altTitle") String altTitle, org.springframework.security.core.Authentication authentication) Returns a user's media library, optionally filtered by status, statusId, category, categoryName, genre, genreId, mediaId, media name, or alternative title.If
userIdis omitted, returns the authenticated user's own library. IfuserIdis provided and different from the authenticated user, only returns results if the target user's library is not marked as private.- Parameters:
userId- optional target user ID; defaults to the authenticated userstatus- optional user tracking status string filter (e.g. "IN_PROGRESS")statusId- optional media production status ID filter (MediaStatusModel.id)categoryId- optional media category ID filtercategoryName- optional media category name filter (e.g. "ANIME")genreId- optional genre ID filtergenreName- optional genre name filtermediaId- optional media ID filtermediaName- optional media name filter (partial match)altTitle- optional alternative title filter (partial match)authentication- the currently authenticated user (required)- Returns:
- list of matching library entries belonging to the target user
-
addMediaToUserLibrary
@MutationMapping(name="addMediaToUserLibrary") @PreAuthorize("hasRole(\'user\')") public UserMediaListModel addMediaToUserLibrary(@Argument(name="mediaId") Integer mediaId, org.springframework.security.core.Authentication authentication) Adds the specified media to the authenticated user's library with default status (PLANNING) and progress 0. Throws an error if the media is already in the user's library.- Parameters:
mediaId- the ID of the media to addauthentication- the currently authenticated user- Returns:
- the newly created library entry
-
upsertUserMedia
@MutationMapping(name="upsertUserMedia") @PreAuthorize("hasRole(\'user\')") public UserMediaListModel upsertUserMedia(@Argument(name="input") UpdateUserMediaInput input, org.springframework.security.core.Authentication authentication) Creates or updates the authenticated user's library entry for the media specified ininput.mediaId(upsert). Non-null fields in the input are applied to the entry; absent fields are left unchanged on update. When the resulting status isPLANNING,datePlannedis automatically set to the current timestamp.- Parameters:
input- the create-or-update payloadauthentication- the currently authenticated user- Returns:
- the persisted (created or updated) library entry
-
removeMediaFromUserLibrary
@MutationMapping(name="removeMediaFromUserLibrary") @PreAuthorize("hasRole(\'user\')") public Boolean removeMediaFromUserLibrary(@Argument(name="mediaId") Integer mediaId, org.springframework.security.core.Authentication authentication) Removes the specified media from the authenticated user's library.- Parameters:
mediaId- the ID of the media to removeauthentication- the currently authenticated user- Returns:
trueif the entry was removed,falseif not found
-