Package usecase.comment
Class CommentService
- java.lang.Object
-
- usecase.comment.CommentService
-
@ApplicationScoped public class CommentService extends Object
Classe che fornisce i servizi relativi ai commenti.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedCommentService()protectedCommentService(GenericRepository genericRepository, CommentRepository commentRepository, CurrentUser currentUser)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddelete(int id)Cancella un commento dato il suo idvoideditComment(int id, @NotBlank @Size(max=65535) String text)Modifica un commento dato il suo idCommentDTOgetComment(int id)Ritorna un commento dato il suo idMap<Integer,List<CommentDTO>>getPostComments(int postId)Ritorna una mappa la cui chiave è l'id del commento padre e il valore una lista di CommentDTOMap<Integer,List<CommentDTO>>getReplies(int commentId)Ritorna una mappa la cui chiave è l'id del commento padre e il valore una lista di CommentDTOintnewComment(@NotBlank @Size(max=65535) String text, int postId)Crea un nuovo commento e ne restituisce l'idintnewCommentReply(@NotBlank @Size(max=65535) String text, int parentCommentId)Crea una risposta a un commento e ne restituisce l'id
-
-
-
Constructor Detail
-
CommentService
protected CommentService()
-
CommentService
@Inject protected CommentService(GenericRepository genericRepository, CommentRepository commentRepository, CurrentUser currentUser)
-
-
Method Detail
-
getPostComments
public Map<Integer,List<CommentDTO>> getPostComments(@PostExists int postId)
Ritorna una mappa la cui chiave è l'id del commento padre e il valore una lista di CommentDTO- Parameters:
postId- l'id di un post esistente di cui si vuole ottenere i commenti- Returns:
- mappa con i commenti del post
-
getReplies
public Map<Integer,List<CommentDTO>> getReplies(@CommentExists int commentId)
Ritorna una mappa la cui chiave è l'id del commento padre e il valore una lista di CommentDTO- Parameters:
commentId- l'id di un commento esistente di cui si vuole ottenere le risposte- Returns:
- mappa con le risposte al commento
-
getComment
public CommentDTO getComment(@CommentExists int id)
Ritorna un commento dato il suo id- Parameters:
id- l'id di un commento esistente- Returns:
- commento avente l'id specificato
-
delete
@AuthenticationRequired public void delete(@CommentExists int id)
Cancella un commento dato il suo id- Parameters:
id- l'id di un commento esistente
-
editComment
@AuthenticationRequired public void editComment(@CommentExists int id, @NotBlank @Size(max=65535) @NotBlank @Size(max=65535) String text)
Modifica un commento dato il suo id- Parameters:
id- l'id di un commento esistentetext- stringa con testo da sostituire
-
newComment
@AuthenticationRequired @DenyBannedUsers public int newComment(@NotBlank @Size(max=65535) @NotBlank @Size(max=65535) String text, @PostExists int postId)
Crea un nuovo commento e ne restituisce l'id- Parameters:
text- una stringa non vuota di massimo 65535 caratteripostId- id di un post esistente- Returns:
- id del commento creato
-
newCommentReply
@AuthenticationRequired public int newCommentReply(@NotBlank @Size(max=65535) @NotBlank @Size(max=65535) String text, @CommentExists int parentCommentId)
Crea una risposta a un commento e ne restituisce l'id- Parameters:
text- una stringa non vuota di massimo 1000 caratteriparentCommentId- id di un commento esistente- Returns:
- id del commento creato
-
-