diff --git a/src/main/java/com/example/eatmate/app/domain/notice/controller/NoticeAdminController.java b/src/main/java/com/example/eatmate/app/domain/notice/controller/NoticeAdminController.java new file mode 100644 index 00000000..25832af4 --- /dev/null +++ b/src/main/java/com/example/eatmate/app/domain/notice/controller/NoticeAdminController.java @@ -0,0 +1,35 @@ +package com.example.eatmate.app.domain.notice.controller; + +import org.springframework.http.HttpStatus; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import com.example.eatmate.app.domain.notice.dto.NoticeAdminRequestDto; +import com.example.eatmate.app.domain.notice.service.NoticeService; +import com.example.eatmate.global.response.GlobalResponseDto; + +import jakarta.validation.Valid; +import lombok.RequiredArgsConstructor; + +@RestController +@RequestMapping("/api/admin/notices") +@RequiredArgsConstructor +public class NoticeAdminController { + + private final NoticeService noticeService; + + @PostMapping + public ResponseEntity> save( + @RequestBody @Valid NoticeAdminRequestDto noticeAdminRequestDto) { + + noticeService.createNotice(noticeAdminRequestDto); + + return ResponseEntity.status(HttpStatus.OK) + .body(GlobalResponseDto.success()); + + } + +} diff --git a/src/main/java/com/example/eatmate/app/domain/notice/service/NoticeService.java b/src/main/java/com/example/eatmate/app/domain/notice/service/NoticeService.java new file mode 100644 index 00000000..6abdcc30 --- /dev/null +++ b/src/main/java/com/example/eatmate/app/domain/notice/service/NoticeService.java @@ -0,0 +1,21 @@ +package com.example.eatmate.app.domain.notice.service; + +import org.springframework.stereotype.Service; + +import com.example.eatmate.app.domain.notice.domain.Notice; +import com.example.eatmate.app.domain.notice.domain.repository.NoticeRepository; +import com.example.eatmate.app.domain.notice.dto.NoticeAdminRequestDto; + +import lombok.RequiredArgsConstructor; + +@Service +@RequiredArgsConstructor +public class NoticeService { + + private final NoticeRepository noticeRepository; + + public void createNotice(NoticeAdminRequestDto noticeAdminRequestDto) { + Notice notice = Notice.createNotice(noticeAdminRequestDto); + noticeRepository.save(notice); + } +}