예제 #1
0
파일: QnaService.java 프로젝트: shinC/slipp
  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);
  }
예제 #2
0
파일: QnaService.java 프로젝트: shinC/slipp
  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;
  }
예제 #3
0
파일: QnaService.java 프로젝트: shinC/slipp
 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());
   }
 }
예제 #4
0
파일: QnaService.java 프로젝트: shinC/slipp
  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();
  }
예제 #5
0
파일: QnaService.java 프로젝트: shinC/slipp
  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;
  }