Skip to content

Commit 2c0ca85

Browse files
authored
feat: 다솜소식 수정 삭제 명세서 추가
feat: 다솜소식 수정 삭제 명세서 추가
1 parent cb612ba commit 2c0ca85

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/main/java/dmu/dasom/api/domain/news/controller/NewsController.java

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public NewsController(NewsService newsService) {
2626
this.newsService = newsService;
2727
}
2828

29+
// 전체 조회
2930
@Operation(summary = "소식 조회", description = "리스트로 조회")
3031
@ApiResponse(responseCode = "200", description = "정상 응답",
3132
content = @Content(mediaType = "application/json"))
@@ -35,18 +36,54 @@ public ResponseEntity<List<NewsResponseDto>> getAllNews() {
3536
return ResponseEntity.ok(newsList);
3637
}
3738

39+
// 개별 조회
40+
@Operation(summary = "소식 상세 조회", description = "ID로 특정 소식을 조회")
41+
@ApiResponses({
42+
@ApiResponse(responseCode = "200", description = "조회 성공"),
43+
@ApiResponse(responseCode = "404", description = "소식을 찾을 수 없음")
44+
})
45+
@GetMapping("/{id}")
46+
public ResponseEntity<NewsResponseDto> getNewsById(@PathVariable Long id) {
47+
NewsResponseDto responseDto = newsService.getNewsById(id);
48+
return ResponseEntity.ok(responseDto);
49+
}
50+
51+
// 생성
3852
@Operation(summary = "소식 등록", description = "새로운 소식을 등록")
3953
@ApiResponses(value = {
4054
@ApiResponse(responseCode = "201", description = "생성 완료"),
4155
@ApiResponse(responseCode = "400", description = "유효하지 않은 요청 데이터",
4256
content = @Content(mediaType = "application/json",
4357
examples = @ExampleObject(value = "{ \"errorCode\": \"E003\", \"errorMessage\": \"유효하지 않은 입력입니다.\" }")))
4458
})
45-
4659
@PostMapping
4760
public ResponseEntity<NewsResponseDto> createNews(@Valid @RequestBody NewsRequestDto requestDto) {
4861
NewsResponseDto responseDto = newsService.createNews(requestDto);
4962
return ResponseEntity.status(201).body(responseDto);
5063
}
5164

65+
// 수정
66+
@Operation(summary = "소식 수정", description = "ID로 특정 소식을 수정")
67+
@ApiResponses({
68+
@ApiResponse(responseCode = "200", description = "수정 성공"),
69+
@ApiResponse(responseCode = "404", description = "소식을 찾을 수 없음")
70+
})
71+
@PutMapping("/{id}")
72+
public ResponseEntity<NewsResponseDto> updateNews(@PathVariable Long id, @Valid @RequestBody NewsRequestDto requestDto) {
73+
NewsResponseDto updatedNews = newsService.updateNews(id, requestDto);
74+
return ResponseEntity.ok(updatedNews);
75+
}
76+
77+
// 삭제
78+
@Operation(summary = "소식 삭제", description = "ID로 특정 소식을 삭제")
79+
@ApiResponses({
80+
@ApiResponse(responseCode = "204", description = "삭제 성공"),
81+
@ApiResponse(responseCode = "404", description = "소식을 찾을 수 없음")
82+
})
83+
@DeleteMapping("/{id}")
84+
public ResponseEntity<Void> deleteNews(@PathVariable Long id) {
85+
newsService.deleteNews(id);
86+
return ResponseEntity.noContent().build();
87+
}
88+
5289
}

0 commit comments

Comments
 (0)