Skip to content

Commit

Permalink
[feat] #17 관리자 공지사항 작성 기능 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
jj0526 authored and seokjun01 committed Jan 16, 2025
1 parent a1673c3 commit 6f1b83e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
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());

}

}
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);
}
}

0 comments on commit 6f1b83e

Please sign in to comment.