Skip to content

Commit 8c20fd6

Browse files
author
zahar.kalosha
committed
Changes the signature of the delete function
1 parent 9919849 commit 8c20fd6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

src/main/java/com/example/postgresdemo/controller/QuestionController.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ public QuestionResponseDTO createQuestion(@Valid @RequestBody QuestionRequestDTO
2929

3030
@PutMapping("/questions/{questionId}")
3131
public QuestionResponseDTO updateQuestion(@PathVariable Long questionId,
32-
@Valid @RequestBody QuestionRequestDTO questionRequest) {
32+
@Valid @RequestBody QuestionRequestDTO questionRequest) {
3333
return questionService.update(questionId, questionRequest);
3434
}
3535

3636
@DeleteMapping("/questions/{questionId}")
37-
public ResponseEntity<?> deleteQuestion(@PathVariable Long questionId) {
38-
return questionService.delete(questionId);
37+
public void deleteQuestion(@PathVariable Long questionId) {
38+
questionService.delete(questionId);
3939
}
4040
}

src/main/java/com/example/postgresdemo/service/QuestionService.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,11 @@ public QuestionResponseDTO update(Long questionId, QuestionRequestDTO questionRe
4040

4141
}
4242

43-
public ResponseEntity<?> delete(Long questionId) {
44-
return questionRepository.findById(questionId)
43+
public void delete(Long questionId) {
44+
questionRepository.findById(questionId)
4545
.map(question -> {
4646
questionRepository.delete(question);
47-
return ResponseEntity.ok().build();
47+
return true;
4848
}).orElseThrow(() -> new ResourceNotFoundException("Question not found with id " + questionId));
4949
}
5050

0 commit comments

Comments
 (0)