public void deleteQuestion(SocialUser loginUser, Long questionId) { Assert.notNull(loginUser, "loginUser should be not null!"); Assert.notNull(questionId, "questionId should be not null!"); Question question = questionRepository.findOne(questionId); question.delete(loginUser); }
public Question updateQuestion(SocialUser loginUser, QuestionDto questionDto) { Assert.notNull(loginUser, "loginUser should be not null!"); Assert.notNull(questionDto, "question should be not null!"); Question question = questionRepository.findOne(questionDto.getQuestionId()); Set<Tag> tags = tagService.processTags(questionDto.getPlainTags()); question.update(loginUser, questionDto.getTitle(), questionDto.getContents(), tags); return question; }
public void createAnswer(SocialUser loginUser, Long questionId, Answer answer) { Question question = questionRepository.findOne(questionId); answer.writedBy(loginUser); answer.answerTo(question); Answer savedAnswer = answerRepository.saveAndFlush(answer); notificationService.notifyToFacebook( loginUser, question, question.findNotificationUser(loginUser)); if (answer.isConnected()) { log.info("firing sendAnswerMessageToFacebook!"); facebookService.sendToAnswerMessage(loginUser, savedAnswer.getAnswerId()); } }
public void deleteAnswer(SocialUser loginUser, Long questionId, Long answerId) { Assert.notNull(loginUser, "loginUser should be not null!"); Assert.notNull(questionId, "questionId should be not null!"); Assert.notNull(answerId, "answerId should be not null!"); Answer answer = answerRepository.findOne(answerId); if (!answer.isWritedBy(loginUser)) { throw new AccessDeniedException(loginUser + " is not owner!"); } answerRepository.delete(answer); Question question = questionRepository.findOne(questionId); question.deAnswered(); }
public Question createQuestion(SocialUser loginUser, QuestionDto questionDto) { Assert.notNull(loginUser, "loginUser should be not null!"); Assert.notNull(questionDto, "question should be not null!"); Set<Tag> tags = tagService.processTags(questionDto.getPlainTags()); Question newQuestion = new Question(loginUser, questionDto.getTitle(), questionDto.getContents(), tags); Question savedQuestion = questionRepository.saveAndFlush(newQuestion); if (questionDto.isConnected()) { log.info("firing sendMessageToFacebook!"); facebookService.sendToQuestionMessage(loginUser, savedQuestion.getQuestionId()); } return savedQuestion; }
public Question findByQuestionId(Long id) { return questionRepository.findOne(id); }
public Page<Question> findsQuestion(Pageable pageable) { return questionRepository.findAll(QnaSpecifications.equalsIsDelete(false), pageable); }
public Page<Question> findsByTag(String name, Pageable pageable) { return questionRepository.findsByTag(name, pageable); }
public Question showQuestion(Long id) { questionRepository.updateShowCount(id); return questionRepository.findOne(id); }