🚧 Notice 저장 (진행중...)
This commit is contained in:
14
README.md
14
README.md
@@ -31,7 +31,9 @@ Kotlin + Spring Boot 2 + Spring MVC + Spring Data JPA
|
||||
|
||||
***
|
||||
|
||||
## 프로젝트 구성
|
||||
## 1. demo-app
|
||||
|
||||
### 1.1. 프로젝트 구성
|
||||
|
||||
프로젝트는 멀티 모듈로 구성되어있습니다.
|
||||
|
||||
@@ -53,7 +55,7 @@ Kotlin + Spring Boot 2 + Spring MVC + Spring Data JPA
|
||||
|
||||
***
|
||||
|
||||
## demo-app
|
||||
### 1.2. demo-app
|
||||
|
||||
demo 웹 애플리케이션의 실행 진입점은 `server - demo-app` 모듈의 DemoAppApplication 입니다.
|
||||
|
||||
@@ -63,3 +65,11 @@ demo 웹 애플리케이션의 실행 진입점은 `server - demo-app` 모듈의
|
||||
demo-app은 아래와 같이 `:util:common-util`, `:core:demo-core`, `:infrastructure:datastore-mariadb` 모듈을 포함합니다.
|
||||
|
||||
<img width="724" alt="build.gradle.kts" src="https://user-images.githubusercontent.com/31076826/204640772-f1846649-a21d-459a-9883-3dae61b44536.png">
|
||||
|
||||
***
|
||||
|
||||
## 2. demo-all-in-one-app
|
||||
|
||||
demo-app을 하나의 모듈로 만든 웹 애플리케이션
|
||||
|
||||
adapter + core + domain 을 하나의 프로젝트 내에 구성했습니다.
|
||||
@@ -0,0 +1,4 @@
|
||||
package me.jiniworld.demohx.notice.adapter.`in`.web
|
||||
|
||||
internal class RegisterNoticeController {
|
||||
}
|
||||
@@ -2,14 +2,16 @@ package me.jiniworld.demohx.notice.adapter.out.persistence
|
||||
|
||||
import me.jiniworld.demohx.annotation.PersistenceAdapter
|
||||
import me.jiniworld.demohx.notice.application.port.out.LoadNoticePort
|
||||
import me.jiniworld.demohx.notice.application.port.out.SaveNoticePort
|
||||
import me.jiniworld.demohx.notice.domain.Notice
|
||||
import me.jiniworld.demohx.notice.domain.NoticeContent
|
||||
import org.springframework.data.domain.Pageable
|
||||
import org.springframework.data.repository.findByIdOrNull
|
||||
|
||||
@PersistenceAdapter
|
||||
internal class NoticePersistenceAdapter(
|
||||
private val noticeRepository: NoticeRepository,
|
||||
) : LoadNoticePort {
|
||||
) : LoadNoticePort, SaveNoticePort {
|
||||
override fun loadNotices(pageable: Pageable): List<Notice>? {
|
||||
return noticeRepository.findAllBy(pageable).map { it.mapToNotice() }.toList()
|
||||
}
|
||||
@@ -17,4 +19,8 @@ internal class NoticePersistenceAdapter(
|
||||
override fun loadNotice(id: Long): Notice? {
|
||||
return noticeRepository.findByIdOrNull(id)?.mapToNotice()
|
||||
}
|
||||
|
||||
override fun saveNotice(noticeContent: NoticeContent) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
package me.jiniworld.demohx.notice.application.port.`in`
|
||||
|
||||
data class RegisterNoticeCommand(
|
||||
val title: String,
|
||||
val content: String,
|
||||
)
|
||||
@@ -0,0 +1,5 @@
|
||||
package me.jiniworld.demohx.notice.application.port.`in`
|
||||
|
||||
interface RegisterNoticeUseCase {
|
||||
fun registerNotice(command: RegisterNoticeCommand)
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package me.jiniworld.demohx.notice.application.port.out
|
||||
|
||||
import me.jiniworld.demohx.notice.domain.NoticeContent
|
||||
|
||||
interface SaveNoticePort {
|
||||
fun saveNotice(noticeContent: NoticeContent)
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package me.jiniworld.demohx.notice.application.service
|
||||
|
||||
import me.jiniworld.demohx.annotation.UseCase
|
||||
import me.jiniworld.demohx.notice.application.port.`in`.RegisterNoticeCommand
|
||||
import me.jiniworld.demohx.notice.application.port.`in`.RegisterNoticeUseCase
|
||||
import me.jiniworld.demohx.notice.application.port.out.SaveNoticePort
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
|
||||
@Transactional
|
||||
@UseCase
|
||||
class RegisterNoticeService(
|
||||
private val saveNoticePort: SaveNoticePort,
|
||||
) : RegisterNoticeUseCase {
|
||||
|
||||
|
||||
|
||||
override fun registerNotice(command: RegisterNoticeCommand) {
|
||||
TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user