Skip to content

Commit 668b2a7

Browse files
committed
🔧 chore : 충돌 해결
1 parent 180d751 commit 668b2a7

File tree

2 files changed

+23
-12
lines changed

2 files changed

+23
-12
lines changed

backend/src/main/java/io/f1/backend/domain/question/api/QuestionController.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,15 @@ public class QuestionController {
2121
private final QuestionService questionService;
2222

2323
@PutMapping("/{questionId}")
24-
public ResponseEntity<Void> updateQuestion(
25-
@PathVariable Long questionId, @RequestBody QuestionUpdateRequest request) {
26-
questionService.updateQuestion(questionId, request);
24+
public ResponseEntity<Void> updateQuestion(@PathVariable Long questionId, @RequestBody QuestionUpdateRequest request) {
25+
26+
if(request.content()!=null) {
27+
questionService.updateQuestionContent(questionId, request.content());
28+
}
29+
30+
if(request.content()!=null) {
31+
questionService.updateQuestionAnswer(questionId, request.answer());
32+
}
2733

2834
return ResponseEntity.noContent().build();
2935
}

backend/src/main/java/io/f1/backend/domain/question/app/QuestionService.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,29 @@ public void saveQuestion(Quiz quiz, QuestionRequest request) {
3838
}
3939

4040
@Transactional
41-
public void updateQuestion(Long questionId, QuestionUpdateRequest request) {
41+
public void updateQuestionContent(Long questionId, String content) {
42+
43+
validateContent(content);
4244

4345
Question question =
4446
questionRepository
4547
.findById(questionId)
4648
.orElseThrow(() -> new NoSuchElementException("존재하지 않는 문제입니다."));
4749

4850
TextQuestion textQuestion = question.getTextQuestion();
51+
textQuestion.changeContent(content);
52+
}
4953

50-
if (request.content() != null) {
51-
validateContent(request.content());
52-
textQuestion.changeContent(request.content());
53-
}
54+
@Transactional
55+
public void updateQuestionAnswer(Long questionId, String answer) {
56+
57+
validateAnswer(answer);
58+
59+
Question question = questionRepository.findById(questionId)
60+
.orElseThrow(() -> new NoSuchElementException("존재하지 않는 문제입니다."));
61+
62+
question.changeAnswer(answer);
5463

55-
if (request.answer() != null) {
56-
validateAnswer(request.answer());
57-
question.changeAnswer(request.answer());
58-
}
5964
}
6065

6166
@Transactional

0 commit comments

Comments
 (0)