From 11d81a5fa3cf3a907d7d4f3c296f363f8580a2d9 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 15:52:45 +0900 Subject: [PATCH 01/25] =?UTF-8?q?:recycle:=20refactor:=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../in/web/GetNoticeDetailController.java | 36 +++++++++++++++++++ .../in/web/GetNoticeListController.java} | 23 +++--------- 2 files changed, 41 insertions(+), 18 deletions(-) create mode 100644 src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java rename src/main/java/com/yapp/artie/domain/notice/{controller/NoticeController.java => adapter/in/web/GetNoticeListController.java} (57%) diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java new file mode 100644 index 00000000..b9f285d8 --- /dev/null +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java @@ -0,0 +1,36 @@ +package com.yapp.artie.domain.notice.adapter.in.web; + + +import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; +import com.yapp.artie.domain.notice.service.NoticeService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.responses.ApiResponses; +import lombok.RequiredArgsConstructor; +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RequestMapping("/notice") +@RequiredArgsConstructor +@RestController +public class GetNoticeDetailController { + + private final NoticeService noticeService; + + @Operation(summary = "공지사항 상세 조회", description = "특정 공지사항 상세를 조회") + @ApiResponses(value = { + @ApiResponse( + responseCode = "200", + description = "공지사항 상세가 성공적으로 조회됨", + content = @Content(mediaType = "application/json", schema = @Schema(implementation = GetNoticeDetailResponse.class))), + }) + @GetMapping("/{id}") + public ResponseEntity getNoticeDetail(@PathVariable("id") Long id) { + return ResponseEntity.ok(noticeService.notice(id)); + } +} diff --git a/src/main/java/com/yapp/artie/domain/notice/controller/NoticeController.java b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java similarity index 57% rename from src/main/java/com/yapp/artie/domain/notice/controller/NoticeController.java rename to src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java index e4f162aa..4f1f80b6 100644 --- a/src/main/java/com/yapp/artie/domain/notice/controller/NoticeController.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java @@ -1,7 +1,7 @@ -package com.yapp.artie.domain.notice.controller; +package com.yapp.artie.domain.notice.adapter.in.web; -import com.yapp.artie.domain.notice.dto.NoticeDetailInfo; +import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; import com.yapp.artie.domain.notice.service.NoticeService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.ArraySchema; @@ -13,14 +13,13 @@ import lombok.RequiredArgsConstructor; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; @RequestMapping("/notice") @RequiredArgsConstructor @RestController -public class NoticeController { +public class GetNoticeListController { private final NoticeService noticeService; @@ -29,22 +28,10 @@ public class NoticeController { @ApiResponse( responseCode = "200", description = "공지사항 목록이 성공적으로 조회됨", - content = @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = NoticeDetailInfo.class)))), + content = @Content(mediaType = "application/json", array = @ArraySchema(schema = @Schema(implementation = GetNoticeDetailResponse.class)))), }) @GetMapping() - public ResponseEntity> getNotices() { + public ResponseEntity> getNotices() { return ResponseEntity.ok(noticeService.notices()); } - - @Operation(summary = "공지사항 상세 조회", description = "특정 공지사항 상세를 조회") - @ApiResponses(value = { - @ApiResponse( - responseCode = "200", - description = "공지사항 상세가 성공적으로 조회됨", - content = @Content(mediaType = "application/json", schema = @Schema(implementation = NoticeDetailInfo.class))), - }) - @GetMapping("/{id}") - public ResponseEntity getNoticeDetail(@PathVariable("id") Long id) { - return ResponseEntity.ok(noticeService.notice(id)); - } } From 60ac2d9e0e377a69d194b5fe7675ba54aa505cef Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 15:53:15 +0900 Subject: [PATCH 02/25] =?UTF-8?q?:recycle:=20refactor:=20Dto=20=EB=84=A4?= =?UTF-8?q?=EC=9D=B4=EB=B0=8D=20=EB=B3=80=EA=B2=BD,=20=EC=83=9D=EC=84=B1?= =?UTF-8?q?=EC=9E=90=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../port/in/GetNoticeDetailResponse.java | 26 +++++++++++++++ .../domain/notice/dto/NoticeDetailInfo.java | 32 ------------------- .../notice/repository/NoticeRepository.java | 6 ++-- .../domain/notice/service/NoticeService.java | 8 ++--- .../notice/service/NoticeServiceTest.java | 6 ++-- 5 files changed, 36 insertions(+), 42 deletions(-) create mode 100644 src/main/java/com/yapp/artie/domain/notice/application/port/in/GetNoticeDetailResponse.java delete mode 100644 src/main/java/com/yapp/artie/domain/notice/dto/NoticeDetailInfo.java diff --git a/src/main/java/com/yapp/artie/domain/notice/application/port/in/GetNoticeDetailResponse.java b/src/main/java/com/yapp/artie/domain/notice/application/port/in/GetNoticeDetailResponse.java new file mode 100644 index 00000000..3cc3e16d --- /dev/null +++ b/src/main/java/com/yapp/artie/domain/notice/application/port/in/GetNoticeDetailResponse.java @@ -0,0 +1,26 @@ +package com.yapp.artie.domain.notice.application.port.in; + +import io.swagger.v3.oas.annotations.media.Schema; +import java.time.LocalDateTime; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@Getter +@Schema(description = "공지사항 상세 Response") +@AllArgsConstructor +public class GetNoticeDetailResponse { + + @Schema(description = "공지사항 아이디") + private final Long id; + + @Schema(description = "공지일") + private final LocalDateTime date; + + @Schema(description = "공지사항 제목") + private final String title; + + @Schema(description = "공지 내용") + private String contents; +} + + diff --git a/src/main/java/com/yapp/artie/domain/notice/dto/NoticeDetailInfo.java b/src/main/java/com/yapp/artie/domain/notice/dto/NoticeDetailInfo.java deleted file mode 100644 index e054535f..00000000 --- a/src/main/java/com/yapp/artie/domain/notice/dto/NoticeDetailInfo.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.yapp.artie.domain.notice.dto; - -import io.swagger.v3.oas.annotations.media.Schema; -import java.time.LocalDateTime; -import lombok.AccessLevel; -import lombok.Getter; -import lombok.NoArgsConstructor; - -@Getter -@Schema(description = "공지사항 상세 Response") -@NoArgsConstructor(access = AccessLevel.PROTECTED) -public class NoticeDetailInfo { - - @Schema(description = "공지사항 아이디") - private Long id; - - @Schema(description = "공지일") - private LocalDateTime date; - - @Schema(description = "공지사항 제목") - private String title; - - @Schema(description = "공지 내용") - private String contents; - - public NoticeDetailInfo(Long id, LocalDateTime date, String title, String contents) { - this.id = id; - this.date = date; - this.title = title; - this.contents = contents; - } -} diff --git a/src/main/java/com/yapp/artie/domain/notice/repository/NoticeRepository.java b/src/main/java/com/yapp/artie/domain/notice/repository/NoticeRepository.java index 27f8dea2..3e21bf57 100644 --- a/src/main/java/com/yapp/artie/domain/notice/repository/NoticeRepository.java +++ b/src/main/java/com/yapp/artie/domain/notice/repository/NoticeRepository.java @@ -1,7 +1,7 @@ package com.yapp.artie.domain.notice.repository; +import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; import com.yapp.artie.domain.notice.domain.Notice; -import com.yapp.artie.domain.notice.dto.NoticeDetailInfo; import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; import org.springframework.data.jpa.repository.Query; @@ -10,6 +10,6 @@ @Repository public interface NoticeRepository extends JpaRepository { - @Query("select new com.yapp.artie.domain.notice.dto.NoticeDetailInfo(n.id, n.createdAt, n.title, n.contents) from Notice n") - List findNoticeDto(); + @Query("select new com.yapp.artie.domain.notice.dto.GetNoticeDetailResponse(n.id, n.createdAt, n.title, n.contents) from Notice n") + List findNoticeDto(); } diff --git a/src/main/java/com/yapp/artie/domain/notice/service/NoticeService.java b/src/main/java/com/yapp/artie/domain/notice/service/NoticeService.java index 84d82719..62515903 100644 --- a/src/main/java/com/yapp/artie/domain/notice/service/NoticeService.java +++ b/src/main/java/com/yapp/artie/domain/notice/service/NoticeService.java @@ -1,7 +1,7 @@ package com.yapp.artie.domain.notice.service; +import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; import com.yapp.artie.domain.notice.domain.Notice; -import com.yapp.artie.domain.notice.dto.NoticeDetailInfo; import com.yapp.artie.domain.notice.exception.NoticeNotFoundException; import com.yapp.artie.domain.notice.repository.NoticeRepository; import java.util.List; @@ -16,13 +16,13 @@ public class NoticeService { private final NoticeRepository noticeRepository; - public List notices() { + public List notices() { return noticeRepository.findNoticeDto(); } - public NoticeDetailInfo notice(Long id) { + public GetNoticeDetailResponse notice(Long id) { Notice notice = noticeRepository.findById(id).orElseThrow(NoticeNotFoundException::new); - return new NoticeDetailInfo( + return new GetNoticeDetailResponse( notice.getId(), notice.getCreatedAt(), notice.getTitle(), diff --git a/src/test/java/com/yapp/artie/domain/notice/service/NoticeServiceTest.java b/src/test/java/com/yapp/artie/domain/notice/service/NoticeServiceTest.java index 708eae63..25e9e2c3 100644 --- a/src/test/java/com/yapp/artie/domain/notice/service/NoticeServiceTest.java +++ b/src/test/java/com/yapp/artie/domain/notice/service/NoticeServiceTest.java @@ -4,8 +4,8 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThatThrownBy; +import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; import com.yapp.artie.domain.notice.domain.Notice; -import com.yapp.artie.domain.notice.dto.NoticeDetailInfo; import com.yapp.artie.domain.notice.exception.NoticeNotFoundException; import java.util.List; import javax.persistence.EntityManager; @@ -30,7 +30,7 @@ class NoticeServiceTest { Notice notice = Notice.create("test " + i, "sample data"); em.persist(notice); } - List notices = noticeService.notices(); + List notices = noticeService.notices(); assertThat(notices.size()).isEqualTo(4); } @@ -39,7 +39,7 @@ class NoticeServiceTest { String expectedContents = "sample data"; Notice notice = Notice.create("test1", expectedContents); em.persist(notice); - NoticeDetailInfo detail = noticeService.notice(notice.getId()); + GetNoticeDetailResponse detail = noticeService.notice(notice.getId()); assertThat(detail.getContents()).isEqualTo(expectedContents); } From 72e3c17a597bd3dc28bdd9eba72376ce676060a3 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 16:26:46 +0900 Subject: [PATCH 03/25] =?UTF-8?q?:recycle:=20refactor:=20=EA=B0=81=20?= =?UTF-8?q?=EC=84=9C=EB=B9=84=EC=8A=A4=20=EB=B6=84=EB=A6=AC=20=EB=B0=8F=20?= =?UTF-8?q?Inbound=20Port=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../application/port/in/GetNoticeDetailQuery.java | 6 ++++++ .../application/port/in/GetNoticeListQuery.java | 8 ++++++++ .../service/GetNoticeDetailService.java | 14 ++++++++++++++ .../application/service/GetNoticeListService.java | 15 +++++++++++++++ 4 files changed, 43 insertions(+) create mode 100644 src/main/java/com/yapp/artie/domain/notice/application/port/in/GetNoticeDetailQuery.java create mode 100644 src/main/java/com/yapp/artie/domain/notice/application/port/in/GetNoticeListQuery.java create mode 100644 src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java create mode 100644 src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java diff --git a/src/main/java/com/yapp/artie/domain/notice/application/port/in/GetNoticeDetailQuery.java b/src/main/java/com/yapp/artie/domain/notice/application/port/in/GetNoticeDetailQuery.java new file mode 100644 index 00000000..d3ad9199 --- /dev/null +++ b/src/main/java/com/yapp/artie/domain/notice/application/port/in/GetNoticeDetailQuery.java @@ -0,0 +1,6 @@ +package com.yapp.artie.domain.notice.application.port.in; + +public interface GetNoticeDetailQuery { + + GetNoticeDetailResponse loadNoticeDetail(Long id); +} diff --git a/src/main/java/com/yapp/artie/domain/notice/application/port/in/GetNoticeListQuery.java b/src/main/java/com/yapp/artie/domain/notice/application/port/in/GetNoticeListQuery.java new file mode 100644 index 00000000..d831430c --- /dev/null +++ b/src/main/java/com/yapp/artie/domain/notice/application/port/in/GetNoticeListQuery.java @@ -0,0 +1,8 @@ +package com.yapp.artie.domain.notice.application.port.in; + +import java.util.List; + +public interface GetNoticeListQuery { + + List loadNoticeList(); +} diff --git a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java new file mode 100644 index 00000000..a9f32c0d --- /dev/null +++ b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java @@ -0,0 +1,14 @@ +package com.yapp.artie.domain.notice.application.service; + +import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailQuery; +import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; +import com.yapp.artie.global.common.annotation.UseCase; + +@UseCase +public class GetNoticeDetailService implements GetNoticeDetailQuery { + + @Override + public GetNoticeDetailResponse loadNoticeDetail(Long id) { + return null; + } +} diff --git a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java new file mode 100644 index 00000000..31fb12f1 --- /dev/null +++ b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java @@ -0,0 +1,15 @@ +package com.yapp.artie.domain.notice.application.service; + +import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; +import com.yapp.artie.domain.notice.application.port.in.GetNoticeListQuery; +import com.yapp.artie.global.common.annotation.UseCase; +import java.util.List; + +@UseCase +public class GetNoticeListService implements GetNoticeListQuery { + + @Override + public List loadNoticeList() { + return null; + } +} From 27b036302526491e6540f39e8e3c2e5801693c0b Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 16:40:16 +0900 Subject: [PATCH 04/25] =?UTF-8?q?:recycle:=20refactor:=20Notice=20Outbound?= =?UTF-8?q?=20Port,=20Persistence=20Adapter=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../persistence/NoticePersistenceAdapter.java | 20 +++++++++++++++++++ .../application/port/out/LoadNoticePort.java | 11 ++++++++++ 2 files changed, 31 insertions(+) create mode 100644 src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java create mode 100644 src/main/java/com/yapp/artie/domain/notice/application/port/out/LoadNoticePort.java diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java new file mode 100644 index 00000000..14922dbc --- /dev/null +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java @@ -0,0 +1,20 @@ +package com.yapp.artie.domain.notice.adapter.out.persistence; + +import com.yapp.artie.domain.notice.application.port.out.LoadNoticePort; +import com.yapp.artie.domain.notice.domain.Notice; +import com.yapp.artie.global.common.annotation.PersistenceAdapter; +import java.util.List; + +@PersistenceAdapter +public class NoticePersistenceAdapter implements LoadNoticePort { + + @Override + return null; + public List loadNoticeList() { + } + + @Override + return null; + public Optional loadNoticeDetail(Long id) { + } +} diff --git a/src/main/java/com/yapp/artie/domain/notice/application/port/out/LoadNoticePort.java b/src/main/java/com/yapp/artie/domain/notice/application/port/out/LoadNoticePort.java new file mode 100644 index 00000000..838d0955 --- /dev/null +++ b/src/main/java/com/yapp/artie/domain/notice/application/port/out/LoadNoticePort.java @@ -0,0 +1,11 @@ +package com.yapp.artie.domain.notice.application.port.out; + +import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; +import java.util.List; + +public interface LoadNoticePort { + + List loadNoticeList(); + + GetNoticeDetailResponse loadNoticeDetail(Long id); +} From 62ad32ed4e98c1b6796bef1f6c1731cfecb04ddd Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 16:57:16 +0900 Subject: [PATCH 05/25] =?UTF-8?q?:recycle:=20refactor:=20Repository=20?= =?UTF-8?q?=EC=9D=B4=EB=8F=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../out/persistence}/NoticeRepository.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) rename src/main/java/com/yapp/artie/domain/notice/{repository => adapter/out/persistence}/NoticeRepository.java (68%) diff --git a/src/main/java/com/yapp/artie/domain/notice/repository/NoticeRepository.java b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticeRepository.java similarity index 68% rename from src/main/java/com/yapp/artie/domain/notice/repository/NoticeRepository.java rename to src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticeRepository.java index 3e21bf57..bb316f01 100644 --- a/src/main/java/com/yapp/artie/domain/notice/repository/NoticeRepository.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticeRepository.java @@ -1,4 +1,4 @@ -package com.yapp.artie.domain.notice.repository; +package com.yapp.artie.domain.notice.adapter.out.persistence; import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; import com.yapp.artie.domain.notice.domain.Notice; @@ -10,6 +10,6 @@ @Repository public interface NoticeRepository extends JpaRepository { - @Query("select new com.yapp.artie.domain.notice.dto.GetNoticeDetailResponse(n.id, n.createdAt, n.title, n.contents) from Notice n") + @Query("select new com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse(n.id, n.createdAt, n.title, n.contents) from Notice n") List findNoticeDto(); } From a20506227a0ca80742f34fb97eafc013b231b99f Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 16:58:03 +0900 Subject: [PATCH 06/25] =?UTF-8?q?:recycle:=20refactor:=20=ED=95=84?= =?UTF-8?q?=EC=9A=94=EC=97=86=EB=8A=94=20=EB=A9=94=EC=86=8C=EB=93=9C=20?= =?UTF-8?q?=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notice/adapter/out/persistence/NoticeRepository.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticeRepository.java b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticeRepository.java index bb316f01..f790ad16 100644 --- a/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticeRepository.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticeRepository.java @@ -1,15 +1,10 @@ package com.yapp.artie.domain.notice.adapter.out.persistence; -import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; import com.yapp.artie.domain.notice.domain.Notice; -import java.util.List; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.data.jpa.repository.Query; import org.springframework.stereotype.Repository; @Repository public interface NoticeRepository extends JpaRepository { - @Query("select new com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse(n.id, n.createdAt, n.title, n.contents) from Notice n") - List findNoticeDto(); } From 058082a916a8cec14f485b1a2bf3fdac48a6c268 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 16:59:21 +0900 Subject: [PATCH 07/25] =?UTF-8?q?:recycle:=20refactor:=20Repository?= =?UTF-8?q?=EB=A5=BC=20=EC=82=AC=EC=9A=A9=ED=95=B4=EC=84=9C=20=EB=A9=94?= =?UTF-8?q?=EC=86=8C=EB=93=9C=20=EB=A1=9C=EC=A7=81=20=EA=B5=AC=ED=98=84,?= =?UTF-8?q?=20=EB=A6=AC=ED=84=B4=20=ED=83=80=EC=9E=85=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../out/persistence/NoticePersistenceAdapter.java | 9 +++++++-- .../notice/application/port/out/LoadNoticePort.java | 7 ++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java index 14922dbc..6d91cfbb 100644 --- a/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java @@ -4,17 +4,22 @@ import com.yapp.artie.domain.notice.domain.Notice; import com.yapp.artie.global.common.annotation.PersistenceAdapter; import java.util.List; +import java.util.Optional; +import lombok.AllArgsConstructor; @PersistenceAdapter +@AllArgsConstructor public class NoticePersistenceAdapter implements LoadNoticePort { + final NoticeRepository noticeRepository; + @Override - return null; public List loadNoticeList() { + return noticeRepository.findAll(); } @Override - return null; public Optional loadNoticeDetail(Long id) { + return noticeRepository.findById(id); } } diff --git a/src/main/java/com/yapp/artie/domain/notice/application/port/out/LoadNoticePort.java b/src/main/java/com/yapp/artie/domain/notice/application/port/out/LoadNoticePort.java index 838d0955..65cbbf69 100644 --- a/src/main/java/com/yapp/artie/domain/notice/application/port/out/LoadNoticePort.java +++ b/src/main/java/com/yapp/artie/domain/notice/application/port/out/LoadNoticePort.java @@ -1,11 +1,12 @@ package com.yapp.artie.domain.notice.application.port.out; -import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; +import com.yapp.artie.domain.notice.domain.Notice; import java.util.List; +import java.util.Optional; public interface LoadNoticePort { - List loadNoticeList(); + List loadNoticeList(); - GetNoticeDetailResponse loadNoticeDetail(Long id); + Optional loadNoticeDetail(Long id); } From 9918cb9dc8ee18279145d0f521c962c89ae369ac Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 16:59:41 +0900 Subject: [PATCH 08/25] =?UTF-8?q?:recycle:=20refactor:=20=EA=B0=81=20?= =?UTF-8?q?=EC=84=9C=EB=B9=84=EC=8A=A4=EC=97=90=EC=84=9C=20=ED=8F=AC?= =?UTF-8?q?=ED=8A=B8=EB=A5=BC=20=EC=82=AC=EC=9A=A9=ED=95=98=EC=97=AC=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=EC=9D=84=20=EA=B5=AC=EC=84=B1=ED=95=98?= =?UTF-8?q?=EB=8F=84=EB=A1=9D=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/GetNoticeDetailService.java | 15 ++++++++++++++- .../application/service/GetNoticeListService.java | 15 ++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java index a9f32c0d..00bdeefb 100644 --- a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java +++ b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java @@ -2,13 +2,26 @@ import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailQuery; import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; +import com.yapp.artie.domain.notice.application.port.out.LoadNoticePort; +import com.yapp.artie.domain.notice.domain.Notice; +import com.yapp.artie.domain.notice.exception.NoticeNotFoundException; import com.yapp.artie.global.common.annotation.UseCase; +import lombok.AllArgsConstructor; @UseCase +@AllArgsConstructor public class GetNoticeDetailService implements GetNoticeDetailQuery { + final LoadNoticePort loadNoticePort; + @Override public GetNoticeDetailResponse loadNoticeDetail(Long id) { - return null; + Notice notice = loadNoticePort.loadNoticeDetail(id).orElseThrow(NoticeNotFoundException::new); + return new GetNoticeDetailResponse( + notice.getId(), + notice.getCreatedAt(), + notice.getTitle(), + notice.getContents() + ); } } diff --git a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java index 31fb12f1..e88031f8 100644 --- a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java +++ b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java @@ -2,14 +2,27 @@ import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; import com.yapp.artie.domain.notice.application.port.in.GetNoticeListQuery; +import com.yapp.artie.domain.notice.application.port.out.LoadNoticePort; import com.yapp.artie.global.common.annotation.UseCase; import java.util.List; +import java.util.stream.Collectors; +import lombok.AllArgsConstructor; @UseCase +@AllArgsConstructor public class GetNoticeListService implements GetNoticeListQuery { + final LoadNoticePort loadNoticePort; + @Override public List loadNoticeList() { - return null; + return loadNoticePort.loadNoticeList().stream() + .map(eachNotice -> + new GetNoticeDetailResponse( + eachNotice.getId(), + eachNotice.getCreatedAt(), + eachNotice.getTitle(), + eachNotice.getContents() + )).collect(Collectors.toList()); } } From baca62fc01c92687fedfc5230cbf8d907ac96f0b Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 17:02:59 +0900 Subject: [PATCH 09/25] =?UTF-8?q?:recycle:=20refactor:=20=EC=BB=A8?= =?UTF-8?q?=ED=8A=B8=EB=A1=A4=EB=9F=AC=EA=B0=80=20UseCase=20=EC=9D=B8?= =?UTF-8?q?=ED=84=B0=ED=8E=98=EC=9D=B4=EC=8A=A4=EB=A5=BC=20=EC=82=AC?= =?UTF-8?q?=EC=9A=A9=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notice/adapter/in/web/GetNoticeDetailController.java | 6 +++--- .../notice/adapter/in/web/GetNoticeListController.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java index b9f285d8..5eb00d44 100644 --- a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java @@ -1,8 +1,8 @@ package com.yapp.artie.domain.notice.adapter.in.web; +import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailQuery; import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; -import com.yapp.artie.domain.notice.service.NoticeService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; @@ -20,7 +20,7 @@ @RestController public class GetNoticeDetailController { - private final NoticeService noticeService; + private final GetNoticeDetailQuery getNoticeDetailQuery; @Operation(summary = "공지사항 상세 조회", description = "특정 공지사항 상세를 조회") @ApiResponses(value = { @@ -31,6 +31,6 @@ public class GetNoticeDetailController { }) @GetMapping("/{id}") public ResponseEntity getNoticeDetail(@PathVariable("id") Long id) { - return ResponseEntity.ok(noticeService.notice(id)); + return ResponseEntity.ok(getNoticeDetailQuery.loadNoticeDetail(id)); } } diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java index 4f1f80b6..ae55cad3 100644 --- a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java @@ -2,7 +2,7 @@ import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; -import com.yapp.artie.domain.notice.service.NoticeService; +import com.yapp.artie.domain.notice.application.port.in.GetNoticeListQuery; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; @@ -21,7 +21,7 @@ @RestController public class GetNoticeListController { - private final NoticeService noticeService; + private final GetNoticeListQuery getNoticeListQuery; @Operation(summary = "공지사항 목록 조회", description = "공지사항 목록을 조회") @ApiResponses(value = { @@ -32,6 +32,6 @@ public class GetNoticeListController { }) @GetMapping() public ResponseEntity> getNotices() { - return ResponseEntity.ok(noticeService.notices()); + return ResponseEntity.ok(getNoticeListQuery.loadNoticeList()); } } From abdc7914db64d764345e104e5a6ab0032afd13d7 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 17:03:03 +0900 Subject: [PATCH 10/25] =?UTF-8?q?:recycle:=20refactor:=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/notice/service/NoticeService.java | 32 ------------------- 1 file changed, 32 deletions(-) delete mode 100644 src/main/java/com/yapp/artie/domain/notice/service/NoticeService.java diff --git a/src/main/java/com/yapp/artie/domain/notice/service/NoticeService.java b/src/main/java/com/yapp/artie/domain/notice/service/NoticeService.java deleted file mode 100644 index 62515903..00000000 --- a/src/main/java/com/yapp/artie/domain/notice/service/NoticeService.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.yapp.artie.domain.notice.service; - -import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; -import com.yapp.artie.domain.notice.domain.Notice; -import com.yapp.artie.domain.notice.exception.NoticeNotFoundException; -import com.yapp.artie.domain.notice.repository.NoticeRepository; -import java.util.List; -import lombok.RequiredArgsConstructor; -import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; - -@Service -@Transactional(readOnly = true) -@RequiredArgsConstructor -public class NoticeService { - - private final NoticeRepository noticeRepository; - - public List notices() { - return noticeRepository.findNoticeDto(); - } - - public GetNoticeDetailResponse notice(Long id) { - Notice notice = noticeRepository.findById(id).orElseThrow(NoticeNotFoundException::new); - return new GetNoticeDetailResponse( - notice.getId(), - notice.getCreatedAt(), - notice.getTitle(), - notice.getContents() - ); - } -} From eadbedc57bb19a642c645c225bb9c14411b92b53 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 17:05:36 +0900 Subject: [PATCH 11/25] =?UTF-8?q?:recycle:=20refactor:=20=EB=8F=84?= =?UTF-8?q?=EB=A9=94=EC=9D=B8=20=EB=AA=A8=EB=8D=B8=EC=97=90=20=EA=B4=80?= =?UTF-8?q?=ED=95=9C=20=EC=98=88=EC=99=B8=EB=8A=94=20=EB=8F=84=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=ED=8C=A8=ED=82=A4=EC=A7=80=EB=A1=9C=20=EB=B6=84?= =?UTF-8?q?=EB=A5=98=ED=95=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notice/application/service/GetNoticeDetailService.java | 2 +- .../notice/{exception => domain}/NoticeNotFoundException.java | 2 +- .../com/yapp/artie/domain/notice/service/NoticeServiceTest.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) rename src/main/java/com/yapp/artie/domain/notice/{exception => domain}/NoticeNotFoundException.java (85%) diff --git a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java index 00bdeefb..05358943 100644 --- a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java +++ b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java @@ -4,7 +4,7 @@ import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; import com.yapp.artie.domain.notice.application.port.out.LoadNoticePort; import com.yapp.artie.domain.notice.domain.Notice; -import com.yapp.artie.domain.notice.exception.NoticeNotFoundException; +import com.yapp.artie.domain.notice.domain.NoticeNotFoundException; import com.yapp.artie.global.common.annotation.UseCase; import lombok.AllArgsConstructor; diff --git a/src/main/java/com/yapp/artie/domain/notice/exception/NoticeNotFoundException.java b/src/main/java/com/yapp/artie/domain/notice/domain/NoticeNotFoundException.java similarity index 85% rename from src/main/java/com/yapp/artie/domain/notice/exception/NoticeNotFoundException.java rename to src/main/java/com/yapp/artie/domain/notice/domain/NoticeNotFoundException.java index d7b5263e..4bb7531b 100644 --- a/src/main/java/com/yapp/artie/domain/notice/exception/NoticeNotFoundException.java +++ b/src/main/java/com/yapp/artie/domain/notice/domain/NoticeNotFoundException.java @@ -1,4 +1,4 @@ -package com.yapp.artie.domain.notice.exception; +package com.yapp.artie.domain.notice.domain; import com.yapp.artie.global.common.exception.BusinessException; import com.yapp.artie.global.common.exception.ErrorCode; diff --git a/src/test/java/com/yapp/artie/domain/notice/service/NoticeServiceTest.java b/src/test/java/com/yapp/artie/domain/notice/service/NoticeServiceTest.java index 25e9e2c3..e2031a12 100644 --- a/src/test/java/com/yapp/artie/domain/notice/service/NoticeServiceTest.java +++ b/src/test/java/com/yapp/artie/domain/notice/service/NoticeServiceTest.java @@ -6,7 +6,7 @@ import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; import com.yapp.artie.domain.notice.domain.Notice; -import com.yapp.artie.domain.notice.exception.NoticeNotFoundException; +import com.yapp.artie.domain.notice.domain.NoticeNotFoundException; import java.util.List; import javax.persistence.EntityManager; import org.junit.jupiter.api.Test; From 72f8eee2f8dab21575c6f580759a45f673908984 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 19:22:57 +0900 Subject: [PATCH 12/25] =?UTF-8?q?:recycle:=20refactor:=20Notice=20?= =?UTF-8?q?=EC=83=81=EC=84=B8=20=EC=A1=B0=ED=9A=8C=EC=8B=9C,=20Port=20?= =?UTF-8?q?=EB=8B=A8=EA=B3=84=EC=97=90=EC=84=9C=20=EC=98=88=EC=99=B8?= =?UTF-8?q?=EB=A5=BC=20=EB=8D=98=EC=A7=80=EB=8F=84=EB=A1=9D=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/out/persistence/NoticePersistenceAdapter.java | 6 +++--- .../domain/notice/application/port/out/LoadNoticePort.java | 3 +-- .../notice/application/service/GetNoticeDetailService.java | 3 +-- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java index 6d91cfbb..4b35258d 100644 --- a/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java @@ -2,9 +2,9 @@ import com.yapp.artie.domain.notice.application.port.out.LoadNoticePort; import com.yapp.artie.domain.notice.domain.Notice; +import com.yapp.artie.domain.notice.domain.NoticeNotFoundException; import com.yapp.artie.global.common.annotation.PersistenceAdapter; import java.util.List; -import java.util.Optional; import lombok.AllArgsConstructor; @PersistenceAdapter @@ -19,7 +19,7 @@ public List loadNoticeList() { } @Override - public Optional loadNoticeDetail(Long id) { - return noticeRepository.findById(id); + public Notice loadNoticeDetail(Long id) { + return noticeRepository.findById(id).orElseThrow(NoticeNotFoundException::new); } } diff --git a/src/main/java/com/yapp/artie/domain/notice/application/port/out/LoadNoticePort.java b/src/main/java/com/yapp/artie/domain/notice/application/port/out/LoadNoticePort.java index 65cbbf69..9fa7adc4 100644 --- a/src/main/java/com/yapp/artie/domain/notice/application/port/out/LoadNoticePort.java +++ b/src/main/java/com/yapp/artie/domain/notice/application/port/out/LoadNoticePort.java @@ -2,11 +2,10 @@ import com.yapp.artie.domain.notice.domain.Notice; import java.util.List; -import java.util.Optional; public interface LoadNoticePort { List loadNoticeList(); - Optional loadNoticeDetail(Long id); + Notice loadNoticeDetail(Long id); } diff --git a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java index 05358943..c6712fa4 100644 --- a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java +++ b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java @@ -4,7 +4,6 @@ import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; import com.yapp.artie.domain.notice.application.port.out.LoadNoticePort; import com.yapp.artie.domain.notice.domain.Notice; -import com.yapp.artie.domain.notice.domain.NoticeNotFoundException; import com.yapp.artie.global.common.annotation.UseCase; import lombok.AllArgsConstructor; @@ -16,7 +15,7 @@ public class GetNoticeDetailService implements GetNoticeDetailQuery { @Override public GetNoticeDetailResponse loadNoticeDetail(Long id) { - Notice notice = loadNoticePort.loadNoticeDetail(id).orElseThrow(NoticeNotFoundException::new); + Notice notice = loadNoticePort.loadNoticeDetail(id); return new GetNoticeDetailResponse( notice.getId(), notice.getCreatedAt(), From 48b86352a518466aff6cbbca51f15122e9f06437 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 19:26:39 +0900 Subject: [PATCH 13/25] =?UTF-8?q?:recycle:=20refactor:=20Notice=20Controll?= =?UTF-8?q?er=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../in/web/GetNoticeDetailControllerTest.java | 32 +++++++++++++++++++ .../in/web/GetNoticeListControllerTest.java | 31 ++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 src/test/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailControllerTest.java create mode 100644 src/test/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListControllerTest.java diff --git a/src/test/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailControllerTest.java b/src/test/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailControllerTest.java new file mode 100644 index 00000000..8089d1a7 --- /dev/null +++ b/src/test/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailControllerTest.java @@ -0,0 +1,32 @@ +package com.yapp.artie.domain.notice.adapter.in.web; + +import static com.yapp.artie.common.UserTestData.defaultUser; +import static org.mockito.BDDMockito.then; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import com.yapp.artie.common.BaseControllerIntegrationTest; +import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailQuery; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; + +@WebMvcTest(controllers = GetNoticeDetailController.class) +class GetNoticeDetailControllerTest extends BaseControllerIntegrationTest { + + @MockBean + private GetNoticeDetailQuery getNoticeDetailQuery; + + @Test + void getNoticeDetail() throws Exception { + givenUserByReference(defaultUser().build()); + Long noticeId = 1L; + + mvc.perform(get("/notice/{noticeId}", noticeId).accept(MediaType.APPLICATION_JSON) + .header("Authorization", "sample")) + .andExpect(status().isOk()); + + then(getNoticeDetailQuery).should().loadNoticeDetail(noticeId); + } +} \ No newline at end of file diff --git a/src/test/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListControllerTest.java b/src/test/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListControllerTest.java new file mode 100644 index 00000000..1ce307d3 --- /dev/null +++ b/src/test/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListControllerTest.java @@ -0,0 +1,31 @@ +package com.yapp.artie.domain.notice.adapter.in.web; + +import static com.yapp.artie.common.UserTestData.defaultUser; +import static org.mockito.BDDMockito.then; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; + +import com.yapp.artie.common.BaseControllerIntegrationTest; +import com.yapp.artie.domain.notice.application.port.in.GetNoticeListQuery; +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.http.MediaType; + +@WebMvcTest(controllers = GetNoticeListController.class) +class GetNoticeListControllerTest extends BaseControllerIntegrationTest { + + @MockBean + private GetNoticeListQuery getNoticeListQuery; + + @Test + void getNotices() throws Exception { + givenUserByReference(defaultUser().build()); + + mvc.perform(get("/notice").accept(MediaType.APPLICATION_JSON) + .header("Authorization", "sample")) + .andExpect(status().isOk()); + + then(getNoticeListQuery).should().loadNoticeList(); + } +} \ No newline at end of file From cf7ad149c1ed02cb0e96ffda6ce9275da2873d8b Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 19:35:02 +0900 Subject: [PATCH 14/25] =?UTF-8?q?:recycle:=20refactor:=20Notice=20Adapter?= =?UTF-8?q?=20Test=EB=A5=BC=20=EC=9C=84=ED=95=9C=20SQL=20=ED=8C=8C?= =?UTF-8?q?=EC=9D=BC=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../out/persistence/NoticePersistenceAdapterTest.sql | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/test/resources/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapterTest.sql diff --git a/src/test/resources/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapterTest.sql b/src/test/resources/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapterTest.sql new file mode 100644 index 00000000..b1557e47 --- /dev/null +++ b/src/test/resources/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapterTest.sql @@ -0,0 +1,12 @@ +INSERT INTO `notice` (id, contents, created_at, title) +VALUES (1, '아르티가 업데이트 되었어요~ 1', '2023-04-01 10:58:50', '공지사항 제목1'); +INSERT INTO `notice` (id, contents, created_at, title) +VALUES (2, '아르티가 업데이트 되었어요~ 2', '2023-04-02 12:58:50', '공지사항 제목2'); +INSERT INTO `notice` (id, contents, created_at, title) +VALUES (3, '아르티가 업데이트 되었어요~ 3', '2023-04-03 15:58:50', '공지사항 제목3'); +INSERT INTO `notice` (id, contents, created_at, title) +VALUES (4, '아르티가 업데이트 되었어요~ 4', '2023-04-04 19:58:50', '공지사항 제목4'); +INSERT INTO `notice` (id, contents, created_at, title) +VALUES (5, '아르티가 업데이트 되었어요~ 5', '2023-04-05 08:58:50', '공지사항 제목5'); +INSERT INTO `notice` (id, contents, created_at, title) +VALUES (6, '아르티가 업데이트 되었어요~ 6', '2023-04-20 20:58:50', '공지사항 제목6'); \ No newline at end of file From 9e114fa81006beb37eceb5274365a6c2d24b2d24 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 19:35:06 +0900 Subject: [PATCH 15/25] =?UTF-8?q?:recycle:=20refactor:=20Notice=20Adapter?= =?UTF-8?q?=20Test=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../NoticePersistenceAdapterTest.java | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/test/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapterTest.java diff --git a/src/test/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapterTest.java b/src/test/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapterTest.java new file mode 100644 index 00000000..243ee70e --- /dev/null +++ b/src/test/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapterTest.java @@ -0,0 +1,60 @@ +package com.yapp.artie.domain.notice.adapter.out.persistence; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; + +import com.yapp.artie.domain.notice.domain.Notice; +import com.yapp.artie.domain.notice.domain.NoticeNotFoundException; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase; +import org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureTestDatabase.Replace; +import org.springframework.boot.test.autoconfigure.orm.jpa.DataJpaTest; +import org.springframework.context.annotation.Import; +import org.springframework.test.context.jdbc.Sql; + +@DataJpaTest +@Import({NoticePersistenceAdapter.class}) +@AutoConfigureTestDatabase(replace = Replace.NONE) +class NoticePersistenceAdapterTest { + + @Autowired + NoticePersistenceAdapter noticePersistenceAdapter; + + @Autowired + NoticeRepository noticeRepository; + + @Test + @Sql("NoticePersistenceAdapterTest.sql") + void loadNoticeList_모든_공지_조회() { + List notices = noticePersistenceAdapter.loadNoticeList(); + + assertThat(notices.size()).isEqualTo(6); + assertThat(notices.get(0).getId()).isEqualTo(1L); + } + + @Test + void loadNoticeList_공지가_없을_경우_빈_리스트를_반환한다() { + List notices = noticePersistenceAdapter.loadNoticeList(); + + assertThat(notices.size()).isEqualTo(0); + } + + + @Test + @Sql("NoticePersistenceAdapterTest.sql") + void loadNoticeDetail_공지_ID를_이용해서_공지_세부_내용을_조회한다() { + Notice notice = noticePersistenceAdapter.loadNoticeDetail(1L); + + assertThat(notice.getId()).isEqualTo(1L); + } + + @Test + void loadNoticeDetail_공지_ID를_찾지_못한_경우_예외를_발생한다() { + assertThatThrownBy(() -> { + noticePersistenceAdapter.loadNoticeDetail(1L); + }).isInstanceOf( + NoticeNotFoundException.class); + } +} \ No newline at end of file From 43f91248da42406788d5eb7de746c61c8bccfed4 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 20:07:27 +0900 Subject: [PATCH 16/25] =?UTF-8?q?:recycle:=20refactor:=20=EC=84=9C?= =?UTF-8?q?=EB=B9=84=EC=8A=A4=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/GetNoticeDetailServiceTest.java | 50 +++++++++++++++++++ .../service/GetNoticeListServiceTest.java | 45 +++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 src/test/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailServiceTest.java create mode 100644 src/test/java/com/yapp/artie/domain/notice/application/service/GetNoticeListServiceTest.java diff --git a/src/test/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailServiceTest.java b/src/test/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailServiceTest.java new file mode 100644 index 00000000..72bedae5 --- /dev/null +++ b/src/test/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailServiceTest.java @@ -0,0 +1,50 @@ +package com.yapp.artie.domain.notice.application.service; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.assertThatThrownBy; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; + +import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; +import com.yapp.artie.domain.notice.application.port.out.LoadNoticePort; +import com.yapp.artie.domain.notice.domain.Notice; +import com.yapp.artie.domain.notice.domain.NoticeNotFoundException; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +class GetNoticeDetailServiceTest { + + private final LoadNoticePort loadNoticePort = Mockito.mock(LoadNoticePort.class); + private final GetNoticeDetailService getNoticeDetailService = new GetNoticeDetailService( + loadNoticePort); + + @Test + void loadNoticeDetail_공지_ID를_이용해서_공지_세부_내용을_조회한다() { + Notice notice = Notice.create("공지 제목 1", "공지 내용 1"); + givenNotice(notice); + + GetNoticeDetailResponse noticeDetailResponse = getNoticeDetailService.loadNoticeDetail( + notice.getId()); + + assertThat(noticeDetailResponse.getId()).isEqualTo(notice.getId()); + } + + @Test + void loadNoticeDetail_공지_ID를_찾지_못한_경우_예외를_발생한다() { + givenNoticeByIdWillFail(); + + assertThatThrownBy(() -> getNoticeDetailService.loadNoticeDetail(1L)).isInstanceOf( + NoticeNotFoundException.class); + } + + private void givenNotice(Notice notice) { + given(loadNoticePort.loadNoticeDetail(any())) + .willReturn(notice); + + } + + private void givenNoticeByIdWillFail() { + given(loadNoticePort.loadNoticeDetail(any())) + .willThrow(NoticeNotFoundException.class); + } +} \ No newline at end of file diff --git a/src/test/java/com/yapp/artie/domain/notice/application/service/GetNoticeListServiceTest.java b/src/test/java/com/yapp/artie/domain/notice/application/service/GetNoticeListServiceTest.java new file mode 100644 index 00000000..92791558 --- /dev/null +++ b/src/test/java/com/yapp/artie/domain/notice/application/service/GetNoticeListServiceTest.java @@ -0,0 +1,45 @@ +package com.yapp.artie.domain.notice.application.service; + +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.BDDMockito.given; + +import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; +import com.yapp.artie.domain.notice.application.port.out.LoadNoticePort; +import com.yapp.artie.domain.notice.domain.Notice; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import org.junit.jupiter.api.Test; +import org.mockito.Mockito; + +class GetNoticeListServiceTest { + + private final LoadNoticePort loadNoticePort = Mockito.mock(LoadNoticePort.class); + private final GetNoticeListService getNoticeListService = new GetNoticeListService( + loadNoticePort); + + @Test + void loadNoticeList_모든_공지_조회() { + List notices = Arrays.asList(Notice.create("공지 제목 1", "공지 내용 1"), + Notice.create("공지 제목 2", null)); + givenNoticeList(notices); + + List getNoticeDetailResponses = getNoticeListService.loadNoticeList(); + + assertThat(getNoticeDetailResponses.size()).isEqualTo(2); + assertThat(getNoticeDetailResponses.get(0).getTitle()).isEqualTo("공지 제목 1"); + } + + @Test + void loadNoticeList_공지가_없을_경우_빈_리스트를_반환한다() { + givenNoticeList(new ArrayList<>()); + + List noticeDetailResponses = getNoticeListService.loadNoticeList(); + + assertThat(noticeDetailResponses.size()).isEqualTo(0); + } + + private void givenNoticeList(List notices) { + given(loadNoticePort.loadNoticeList()).willReturn(notices); + } +} \ No newline at end of file From 6c18624513c93e76f84e9f6c3f3c000b09a36de2 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Thu, 20 Apr 2023 20:09:12 +0900 Subject: [PATCH 17/25] =?UTF-8?q?:recycle:=20refactor:=20=EA=B8=B0?= =?UTF-8?q?=EC=A1=B4=20=EC=84=9C=EB=B9=84=EC=8A=A4=20=ED=85=8C=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notice/service/NoticeServiceTest.java | 55 ------------------- 1 file changed, 55 deletions(-) delete mode 100644 src/test/java/com/yapp/artie/domain/notice/service/NoticeServiceTest.java diff --git a/src/test/java/com/yapp/artie/domain/notice/service/NoticeServiceTest.java b/src/test/java/com/yapp/artie/domain/notice/service/NoticeServiceTest.java deleted file mode 100644 index e2031a12..00000000 --- a/src/test/java/com/yapp/artie/domain/notice/service/NoticeServiceTest.java +++ /dev/null @@ -1,55 +0,0 @@ -package com.yapp.artie.domain.notice.service; - - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatThrownBy; - -import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; -import com.yapp.artie.domain.notice.domain.Notice; -import com.yapp.artie.domain.notice.domain.NoticeNotFoundException; -import java.util.List; -import javax.persistence.EntityManager; -import org.junit.jupiter.api.Test; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.transaction.annotation.Transactional; - -@Transactional -@SpringBootTest -class NoticeServiceTest { - - @Autowired - EntityManager em; - - @Autowired - NoticeService noticeService; - - @Test - public void notices_공지사항_목록을_조회한다() throws Exception { - for (int i = 0; i < 4; i++) { - Notice notice = Notice.create("test " + i, "sample data"); - em.persist(notice); - } - List notices = noticeService.notices(); - assertThat(notices.size()).isEqualTo(4); - } - - @Test - public void notice_공지사항_상세를_조회한다() throws Exception { - String expectedContents = "sample data"; - Notice notice = Notice.create("test1", expectedContents); - em.persist(notice); - GetNoticeDetailResponse detail = noticeService.notice(notice.getId()); - assertThat(detail.getContents()).isEqualTo(expectedContents); - } - - @Test - public void notice_존재하지_않는_공지사항을_조회_시도할_경우_예외를_발생() throws Exception { - String expectedContents = "sample data"; - Notice notice = Notice.create("test1", expectedContents); - em.persist(notice); - assertThatThrownBy(() -> { - noticeService.notice(22L); - }).isInstanceOf(NoticeNotFoundException.class); - } -} \ No newline at end of file From 0ee24e65f8ec5c1df29fa45f313c1a3947348073 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Fri, 21 Apr 2023 10:15:36 +0900 Subject: [PATCH 18/25] =?UTF-8?q?:recycle:=20refactor:=20=EC=A0=91?= =?UTF-8?q?=EA=B7=BC=20=EC=A0=9C=EC=96=B4=EC=9E=90=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/notice/adapter/in/web/GetNoticeDetailController.java | 2 +- .../domain/notice/adapter/in/web/GetNoticeListController.java | 2 +- .../adapter/out/persistence/NoticePersistenceAdapter.java | 2 +- .../domain/notice/adapter/out/persistence/NoticeRepository.java | 2 +- .../notice/application/service/GetNoticeDetailService.java | 2 +- .../domain/notice/application/service/GetNoticeListService.java | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java index 5eb00d44..9e8b6cae 100644 --- a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java @@ -18,7 +18,7 @@ @RequestMapping("/notice") @RequiredArgsConstructor @RestController -public class GetNoticeDetailController { +class GetNoticeDetailController { private final GetNoticeDetailQuery getNoticeDetailQuery; diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java index ae55cad3..87934d19 100644 --- a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java @@ -19,7 +19,7 @@ @RequestMapping("/notice") @RequiredArgsConstructor @RestController -public class GetNoticeListController { +class GetNoticeListController { private final GetNoticeListQuery getNoticeListQuery; diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java index 4b35258d..bad03057 100644 --- a/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java @@ -9,7 +9,7 @@ @PersistenceAdapter @AllArgsConstructor -public class NoticePersistenceAdapter implements LoadNoticePort { +class NoticePersistenceAdapter implements LoadNoticePort { final NoticeRepository noticeRepository; diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticeRepository.java b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticeRepository.java index f790ad16..d21293e6 100644 --- a/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticeRepository.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticeRepository.java @@ -5,6 +5,6 @@ import org.springframework.stereotype.Repository; @Repository -public interface NoticeRepository extends JpaRepository { +interface NoticeRepository extends JpaRepository { } diff --git a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java index c6712fa4..aea62094 100644 --- a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java +++ b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java @@ -9,7 +9,7 @@ @UseCase @AllArgsConstructor -public class GetNoticeDetailService implements GetNoticeDetailQuery { +class GetNoticeDetailService implements GetNoticeDetailQuery { final LoadNoticePort loadNoticePort; diff --git a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java index e88031f8..146f520d 100644 --- a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java +++ b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java @@ -10,7 +10,7 @@ @UseCase @AllArgsConstructor -public class GetNoticeListService implements GetNoticeListQuery { +class GetNoticeListService implements GetNoticeListQuery { final LoadNoticePort loadNoticePort; From 63e2e5bffeb9f3c9f4f2510b90d5b54a16e618d3 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Sat, 22 Apr 2023 02:17:54 +0900 Subject: [PATCH 19/25] =?UTF-8?q?:recycle:=20refactor:=20Controller?= =?UTF-8?q?=EC=97=90=20@WebAdapter=20=EC=96=B4=EB=85=B8=ED=85=8C=EC=9D=B4?= =?UTF-8?q?=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/notice/adapter/in/web/GetNoticeDetailController.java | 2 ++ .../domain/notice/adapter/in/web/GetNoticeListController.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java index 9e8b6cae..8a144f05 100644 --- a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java @@ -3,6 +3,7 @@ import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailQuery; import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; +import com.yapp.artie.global.common.annotation.WebAdapter; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.Content; import io.swagger.v3.oas.annotations.media.Schema; @@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +@WebAdapter @RequestMapping("/notice") @RequiredArgsConstructor @RestController diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java index 87934d19..674d3f8e 100644 --- a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java @@ -3,6 +3,7 @@ import com.yapp.artie.domain.notice.application.port.in.GetNoticeDetailResponse; import com.yapp.artie.domain.notice.application.port.in.GetNoticeListQuery; +import com.yapp.artie.global.common.annotation.WebAdapter; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.media.ArraySchema; import io.swagger.v3.oas.annotations.media.Content; @@ -16,6 +17,7 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +@WebAdapter @RequestMapping("/notice") @RequiredArgsConstructor @RestController From a57e734c20988f7acf9da0cece8a381f73701e3b Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Sat, 22 Apr 2023 16:33:30 +0900 Subject: [PATCH 20/25] =?UTF-8?q?:recycle:=20refactor:=20=EC=A0=91?= =?UTF-8?q?=EA=B7=BC=20=EC=A0=9C=EC=96=B4=EC=9E=90=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/out/persistence/NoticePersistenceAdapter.java | 2 +- .../notice/application/service/GetNoticeDetailService.java | 2 +- .../domain/notice/application/service/GetNoticeListService.java | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java index bad03057..9e1fea2a 100644 --- a/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticePersistenceAdapter.java @@ -11,7 +11,7 @@ @AllArgsConstructor class NoticePersistenceAdapter implements LoadNoticePort { - final NoticeRepository noticeRepository; + private final NoticeRepository noticeRepository; @Override public List loadNoticeList() { diff --git a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java index aea62094..16031c6e 100644 --- a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java +++ b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java @@ -11,7 +11,7 @@ @AllArgsConstructor class GetNoticeDetailService implements GetNoticeDetailQuery { - final LoadNoticePort loadNoticePort; + private final LoadNoticePort loadNoticePort; @Override public GetNoticeDetailResponse loadNoticeDetail(Long id) { diff --git a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java index 146f520d..908c7013 100644 --- a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java +++ b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java @@ -12,7 +12,7 @@ @AllArgsConstructor class GetNoticeListService implements GetNoticeListQuery { - final LoadNoticePort loadNoticePort; + private final LoadNoticePort loadNoticePort; @Override public List loadNoticeList() { From eafd3e3f2f543f78b80253b7de93f330c4295fe1 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Sat, 22 Apr 2023 16:35:40 +0900 Subject: [PATCH 21/25] =?UTF-8?q?:recycle:=20refactor:=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20=EA=B3=B5=EB=B0=B1=20=EC=A0=9C?= =?UTF-8?q?=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notice/application/service/GetNoticeDetailServiceTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailServiceTest.java b/src/test/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailServiceTest.java index 72bedae5..0173a114 100644 --- a/src/test/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailServiceTest.java +++ b/src/test/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailServiceTest.java @@ -40,7 +40,6 @@ class GetNoticeDetailServiceTest { private void givenNotice(Notice notice) { given(loadNoticePort.loadNoticeDetail(any())) .willReturn(notice); - } private void givenNoticeByIdWillFail() { From 55804c555ff19ebaa376479be027dd709b3f6569 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Sat, 22 Apr 2023 16:59:11 +0900 Subject: [PATCH 22/25] =?UTF-8?q?:art:=20refactor:=20WebAdapter=20?= =?UTF-8?q?=EC=BB=A4=EC=8A=A4=ED=85=80=20=EC=96=B4=EB=85=B8=ED=85=8C?= =?UTF-8?q?=EC=9D=B4=EC=85=98=EC=9D=B4=20RestController=EC=97=AD=ED=95=A0?= =?UTF-8?q?=EC=9D=84=20=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notice/adapter/in/web/GetNoticeDetailController.java | 2 -- .../notice/adapter/in/web/GetNoticeListController.java | 2 -- .../domain/user/adapter/in/web/GetUserController.java | 2 -- .../user/adapter/in/web/GetUserThumbnailController.java | 2 -- .../domain/user/adapter/in/web/RegisterUserController.java | 2 -- .../domain/user/adapter/in/web/RenameUserController.java | 2 -- .../user/adapter/in/web/UserWithdrawalController.java | 2 -- .../yapp/artie/global/common/annotation/WebAdapter.java | 7 ++++--- 8 files changed, 4 insertions(+), 17 deletions(-) diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java index 8a144f05..8048c59c 100644 --- a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeDetailController.java @@ -14,12 +14,10 @@ import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; @WebAdapter @RequestMapping("/notice") @RequiredArgsConstructor -@RestController class GetNoticeDetailController { private final GetNoticeDetailQuery getNoticeDetailQuery; diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java index 674d3f8e..b9078e8e 100644 --- a/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/in/web/GetNoticeListController.java @@ -15,12 +15,10 @@ import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; @WebAdapter @RequestMapping("/notice") @RequiredArgsConstructor -@RestController class GetNoticeListController { private final GetNoticeListQuery getNoticeListQuery; diff --git a/src/main/java/com/yapp/artie/domain/user/adapter/in/web/GetUserController.java b/src/main/java/com/yapp/artie/domain/user/adapter/in/web/GetUserController.java index b5ccc51e..a82519f1 100644 --- a/src/main/java/com/yapp/artie/domain/user/adapter/in/web/GetUserController.java +++ b/src/main/java/com/yapp/artie/domain/user/adapter/in/web/GetUserController.java @@ -14,10 +14,8 @@ import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; @WebAdapter -@RestController @RequestMapping("/user") @RequiredArgsConstructor class GetUserController { diff --git a/src/main/java/com/yapp/artie/domain/user/adapter/in/web/GetUserThumbnailController.java b/src/main/java/com/yapp/artie/domain/user/adapter/in/web/GetUserThumbnailController.java index 5eabf276..fbacfbba 100644 --- a/src/main/java/com/yapp/artie/domain/user/adapter/in/web/GetUserThumbnailController.java +++ b/src/main/java/com/yapp/artie/domain/user/adapter/in/web/GetUserThumbnailController.java @@ -15,10 +15,8 @@ import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; @WebAdapter -@RestController @RequestMapping("/user") @RequiredArgsConstructor class GetUserThumbnailController { diff --git a/src/main/java/com/yapp/artie/domain/user/adapter/in/web/RegisterUserController.java b/src/main/java/com/yapp/artie/domain/user/adapter/in/web/RegisterUserController.java index c742dee7..39cffaf2 100644 --- a/src/main/java/com/yapp/artie/domain/user/adapter/in/web/RegisterUserController.java +++ b/src/main/java/com/yapp/artie/domain/user/adapter/in/web/RegisterUserController.java @@ -19,10 +19,8 @@ import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; @WebAdapter -@RestController @RequestMapping("/user") @RequiredArgsConstructor class RegisterUserController { diff --git a/src/main/java/com/yapp/artie/domain/user/adapter/in/web/RenameUserController.java b/src/main/java/com/yapp/artie/domain/user/adapter/in/web/RenameUserController.java index f4335f3a..a0389ad9 100644 --- a/src/main/java/com/yapp/artie/domain/user/adapter/in/web/RenameUserController.java +++ b/src/main/java/com/yapp/artie/domain/user/adapter/in/web/RenameUserController.java @@ -19,11 +19,9 @@ import org.springframework.web.bind.annotation.PatchMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; @WebAdapter -@RestController @RequestMapping("/user") @RequiredArgsConstructor class RenameUserController { diff --git a/src/main/java/com/yapp/artie/domain/user/adapter/in/web/UserWithdrawalController.java b/src/main/java/com/yapp/artie/domain/user/adapter/in/web/UserWithdrawalController.java index 29df60c1..f622ad05 100644 --- a/src/main/java/com/yapp/artie/domain/user/adapter/in/web/UserWithdrawalController.java +++ b/src/main/java/com/yapp/artie/domain/user/adapter/in/web/UserWithdrawalController.java @@ -14,10 +14,8 @@ import org.springframework.security.core.Authentication; import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; @WebAdapter -@RestController @RequestMapping("/user") @RequiredArgsConstructor class UserWithdrawalController { diff --git a/src/main/java/com/yapp/artie/global/common/annotation/WebAdapter.java b/src/main/java/com/yapp/artie/global/common/annotation/WebAdapter.java index d4d38c77..f9560fb0 100644 --- a/src/main/java/com/yapp/artie/global/common/annotation/WebAdapter.java +++ b/src/main/java/com/yapp/artie/global/common/annotation/WebAdapter.java @@ -5,13 +5,14 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import org.springframework.core.annotation.AliasFor; -import org.springframework.stereotype.Component; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RestController; @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) -@Component +@RestController public @interface WebAdapter { - @AliasFor(annotation = Component.class) + @AliasFor(annotation = Controller.class) String value() default ""; } From e3b6755f242be365a3ce617c34ebd2c3e5229f47 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Mon, 24 Apr 2023 13:01:03 +0900 Subject: [PATCH 23/25] =?UTF-8?q?:recycle:=20refactor:=20=EB=B6=88?= =?UTF-8?q?=ED=95=84=EC=9A=94=ED=95=9C=20@Respository=20=EC=96=B4=EB=85=B8?= =?UTF-8?q?=ED=85=8C=EC=9D=B4=EC=85=98=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit JPA Repository는 자동으로 빈이 등록되므로, @Respository 어노테이션을 제거함 --- .../domain/notice/adapter/out/persistence/NoticeRepository.java | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticeRepository.java b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticeRepository.java index d21293e6..4fe51e9f 100644 --- a/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticeRepository.java +++ b/src/main/java/com/yapp/artie/domain/notice/adapter/out/persistence/NoticeRepository.java @@ -2,9 +2,7 @@ import com.yapp.artie.domain.notice.domain.Notice; import org.springframework.data.jpa.repository.JpaRepository; -import org.springframework.stereotype.Repository; -@Repository interface NoticeRepository extends JpaRepository { } From ad0c4f05ffa086d3f813fbfd3bc70ee726ab21e4 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Mon, 24 Apr 2023 13:06:00 +0900 Subject: [PATCH 24/25] =?UTF-8?q?:recycle:=20refactor:=20=EC=9D=BD?= =?UTF-8?q?=EA=B8=B0=20=EC=A0=84=EC=9A=A9=20=EA=B3=B5=EC=A7=80=20=EC=A1=B0?= =?UTF-8?q?=ED=9A=8C=20=EC=84=9C=EB=B9=84=EC=8A=A4=EC=97=90=20@Transaction?= =?UTF-8?q?al(readOnly=20=3D=20true)=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../notice/application/service/GetNoticeDetailService.java | 2 ++ .../domain/notice/application/service/GetNoticeListService.java | 2 ++ 2 files changed, 4 insertions(+) diff --git a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java index 16031c6e..03f72511 100644 --- a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java +++ b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeDetailService.java @@ -6,8 +6,10 @@ import com.yapp.artie.domain.notice.domain.Notice; import com.yapp.artie.global.common.annotation.UseCase; import lombok.AllArgsConstructor; +import org.springframework.transaction.annotation.Transactional; @UseCase +@Transactional(readOnly = true) @AllArgsConstructor class GetNoticeDetailService implements GetNoticeDetailQuery { diff --git a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java index 908c7013..023bff0a 100644 --- a/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java +++ b/src/main/java/com/yapp/artie/domain/notice/application/service/GetNoticeListService.java @@ -7,8 +7,10 @@ import java.util.List; import java.util.stream.Collectors; import lombok.AllArgsConstructor; +import org.springframework.transaction.annotation.Transactional; @UseCase +@Transactional(readOnly = true) @AllArgsConstructor class GetNoticeListService implements GetNoticeListQuery { From e4f59f990a7d4354cd812a4f11d4544406ea9f56 Mon Sep 17 00:00:00 2001 From: akalswl14 Date: Mon, 24 Apr 2023 13:40:42 +0900 Subject: [PATCH 25/25] =?UTF-8?q?:recycle:=20refactor:=20Validation=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/yapp/artie/domain/notice/domain/Notice.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/main/java/com/yapp/artie/domain/notice/domain/Notice.java b/src/main/java/com/yapp/artie/domain/notice/domain/Notice.java index f8f1b525..d7d8a914 100644 --- a/src/main/java/com/yapp/artie/domain/notice/domain/Notice.java +++ b/src/main/java/com/yapp/artie/domain/notice/domain/Notice.java @@ -6,6 +6,8 @@ import javax.persistence.GeneratedValue; import javax.persistence.GenerationType; import javax.persistence.Id; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import lombok.AccessLevel; import lombok.Getter; import lombok.NoArgsConstructor; @@ -20,12 +22,14 @@ public class Notice { @GeneratedValue(strategy = GenerationType.IDENTITY) private Long id; + @NotBlank @Column(nullable = false) private String title; @Column(columnDefinition = "text") private String contents; + @NotNull @Column(nullable = false, updatable = false) @CreatedDate private LocalDateTime createdAt;