-
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.
Merge pull request #1 from mijin0721/devepole
notice 공지사항 작성하는 기능 추가
- Loading branch information
Showing
8 changed files
with
77 additions
and
67 deletions.
There are no files selected for viewing
15 changes: 8 additions & 7 deletions
15
src/main/java/com/hallym/festival/domain/notice/controller/NoticeController.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 |
---|---|---|
@@ -1,21 +1,22 @@ | ||
package com.hallym.festival.domain.notice.controller; | ||
|
||
import com.hallym.festival.domain.notice.dto.NoticeRequestDto; | ||
import com.hallym.festival.domain.notice.dto.NoticeResponseDto; | ||
import com.hallym.festival.domain.notice.entity.Notice; | ||
import com.hallym.festival.domain.notice.dto.NoticeDto; | ||
import com.hallym.festival.domain.notice.service.NoticeService; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
import java.util.Map; | ||
|
||
@RestController | ||
@RequestMapping(value = "api/notice") | ||
@RequestMapping(value = "notice") | ||
@RequiredArgsConstructor | ||
public class NoticeController { | ||
private final NoticeService noticeService; | ||
|
||
@PostMapping | ||
public void createNotice(@RequestBody NoticeRequestDto noticeRequestDto) { | ||
System.out.println(noticeRequestDto); | ||
public Map<String, String> create(@RequestBody NoticeDto noticeDto) { | ||
noticeService.create(noticeDto); | ||
return Map.of("result", "create success"); | ||
} | ||
|
||
} |
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
20 changes: 0 additions & 20 deletions
20
src/main/java/com/hallym/festival/domain/notice/dto/NoticeResponseDto.java
This file was deleted.
Oops, something went wrong.
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
16 changes: 8 additions & 8 deletions
16
src/main/java/com/hallym/festival/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 |
---|---|---|
@@ -1,24 +1,24 @@ | ||
package com.hallym.festival.domain.notice.service; | ||
|
||
import com.hallym.festival.domain.notice.dto.NoticeRequestDto; | ||
import com.hallym.festival.domain.notice.dto.NoticeResponseDto; | ||
import com.hallym.festival.domain.notice.dto.NoticeDto; | ||
import com.hallym.festival.domain.notice.entity.Notice; | ||
import com.hallym.festival.domain.notice.repository.NoticeRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.stereotype.Service; | ||
|
||
import javax.transaction.Transactional; | ||
import java.util.Optional; | ||
|
||
@RequiredArgsConstructor //의존성 주입 생성자 방법 | ||
@RequiredArgsConstructor | ||
@Transactional | ||
@Service | ||
public class NoticeService { | ||
private final NoticeRepository noticeRepository; | ||
|
||
@Transactional | ||
public Notice createNotice(NoticeRequestDto noticeRequestDto) { | ||
Notice notice = noticeRequestDto.toEntity(); | ||
return noticeRepository.save(notice); | ||
public NoticeDto create(NoticeDto noticeDto) { | ||
Notice notice = noticeDto.toEntity(); | ||
noticeRepository.save(notice); | ||
NoticeDto noticeDto1 = notice.toDto(); | ||
return noticeDto1; | ||
} | ||
|
||
} |
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
14 changes: 0 additions & 14 deletions
14
src/test/java/com/hallym/festival/domain/comment/service/NoticeServiceTest.java
This file was deleted.
Oops, something went wrong.
32 changes: 32 additions & 0 deletions
32
src/test/java/com/hallym/festival/service/NoticeServiceTests.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,32 @@ | ||
package com.hallym.festival.service; | ||
|
||
import com.hallym.festival.domain.notice.dto.NoticeDto; | ||
import com.hallym.festival.domain.notice.service.NoticeService; | ||
import lombok.extern.log4j.Log4j2; | ||
import org.junit.jupiter.api.Test; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.boot.test.context.SpringBootTest; | ||
|
||
import java.util.stream.IntStream; | ||
|
||
@SpringBootTest | ||
@Log4j2 | ||
public class NoticeServiceTests { | ||
@Autowired | ||
NoticeService noticeService; | ||
|
||
@Test | ||
public void 게시물_작성() { | ||
IntStream.rangeClosed(1,10).forEach(i -> { | ||
|
||
NoticeDto noticeDto = | ||
NoticeDto.builder() | ||
.title("제목" + i) | ||
.content("내용" + i) | ||
.build(); | ||
|
||
noticeService.create(noticeDto); | ||
}); | ||
System.out.println("----------작성완료!----------"); | ||
} | ||
} |