|
| 1 | +package com.example.semiwiki_backend.domain.notice.controller; |
| 2 | + |
| 3 | +import com.example.semiwiki_backend.domain.notice.dto.request.NoticeCreateRequestDto; |
| 4 | +import com.example.semiwiki_backend.domain.notice.dto.request.NoticeUpdateRequestDto; |
| 5 | +import com.example.semiwiki_backend.domain.notice.dto.response.NoticeResponseDto; |
| 6 | +import com.example.semiwiki_backend.domain.notice.service.NoticeCreateService; |
| 7 | +import com.example.semiwiki_backend.domain.notice.service.NoticeDeleteService; |
| 8 | +import com.example.semiwiki_backend.domain.notice.service.NoticeGetService; |
| 9 | +import com.example.semiwiki_backend.domain.notice.service.NoticeUpdateService; |
| 10 | +import lombok.RequiredArgsConstructor; |
| 11 | +import org.springframework.http.HttpStatus; |
| 12 | +import org.springframework.http.ResponseEntity; |
| 13 | +import org.springframework.stereotype.Controller; |
| 14 | +import org.springframework.web.bind.annotation.*; |
| 15 | + |
| 16 | +import java.util.List; |
| 17 | + |
| 18 | +@Controller |
| 19 | +@RequiredArgsConstructor |
| 20 | +@RequestMapping("/notice") |
| 21 | +public class NoticeController { |
| 22 | + private final NoticeCreateService noticeCreateService; |
| 23 | + private final NoticeGetService noticeGetService; |
| 24 | + private final NoticeDeleteService noticeDeleteService; |
| 25 | + private final NoticeUpdateService noticeUpdateService; |
| 26 | + |
| 27 | + @PostMapping |
| 28 | + public ResponseEntity<NoticeResponseDto> postNotice(@RequestBody NoticeCreateRequestDto noticeCreateRequestDto) { |
| 29 | + return ResponseEntity.status(HttpStatus.CREATED).body(noticeCreateService.postNotice(noticeCreateRequestDto)); |
| 30 | + } |
| 31 | + |
| 32 | + @GetMapping("/{id}") |
| 33 | + public ResponseEntity<NoticeResponseDto> getNotice(@PathVariable Long id) { |
| 34 | + return ResponseEntity.ok().body(noticeGetService.getNotice(id)); |
| 35 | + } |
| 36 | + |
| 37 | + @GetMapping |
| 38 | + public ResponseEntity<List<NoticeResponseDto>> getNoticesAll() { |
| 39 | + return ResponseEntity.ok().body(noticeGetService.getAllNotices()); |
| 40 | + } |
| 41 | + |
| 42 | + @PutMapping("/{id}") |
| 43 | + public ResponseEntity<NoticeResponseDto> updateNotice(@RequestBody NoticeUpdateRequestDto noticeUpdateRequestDto, @PathVariable Long id) { |
| 44 | + return ResponseEntity.ok().body(noticeUpdateService.updateNotice(noticeUpdateRequestDto, id)); |
| 45 | + } |
| 46 | + |
| 47 | + @DeleteMapping("/{id}") |
| 48 | + public ResponseEntity<?> deleteNotice(@PathVariable Long id) { |
| 49 | + noticeDeleteService.deleteNotice(id); |
| 50 | + return ResponseEntity.noContent().build(); |
| 51 | + } |
| 52 | +} |
0 commit comments