Esempio n. 1
0
  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);
  }
Esempio n. 2
0
  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;
  }
Esempio n. 3
0
 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());
   }
 }
Esempio n. 4
0
  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();
  }
Esempio n. 5
0
  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;
  }
Esempio n. 6
0
 public Question findByQuestionId(Long id) {
   return questionRepository.findOne(id);
 }
Esempio n. 7
0
 public Page<Question> findsQuestion(Pageable pageable) {
   return questionRepository.findAll(QnaSpecifications.equalsIsDelete(false), pageable);
 }
Esempio n. 8
0
 public Page<Question> findsByTag(String name, Pageable pageable) {
   return questionRepository.findsByTag(name, pageable);
 }
Esempio n. 9
0
 public Question showQuestion(Long id) {
   questionRepository.updateShowCount(id);
   return questionRepository.findOne(id);
 }