-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
src/main/java/com/example/eatmate/app/domain/notice/controller/NoticeAdminController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<GlobalResponseDto<Void>> save( | ||
@RequestBody @Valid NoticeAdminRequestDto noticeAdminRequestDto) { | ||
|
||
noticeService.createNotice(noticeAdminRequestDto); | ||
|
||
return ResponseEntity.status(HttpStatus.OK) | ||
.body(GlobalResponseDto.success()); | ||
|
||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/com/example/eatmate/app/domain/notice/service/NoticeService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |