creating and displaying links
parent
c788004de0
commit
b9e52b6ab1
@ -0,0 +1,30 @@
|
||||
package wanijo.wanijo2.domain.handler
|
||||
|
||||
import org.springframework.data.jdbc.core.mapping.AggregateReference
|
||||
import org.springframework.stereotype.Service
|
||||
import org.springframework.transaction.annotation.Transactional
|
||||
import wanijo.wanijo2.domain.DocumentDao
|
||||
import wanijo.wanijo2.domain.Link
|
||||
import wanijo.wanijo2.domain.LinkDao
|
||||
import wanijo.wanijo2.domain.event.AddLinkCommand
|
||||
|
||||
@Service
|
||||
class AddLinkHandler(
|
||||
val documentDao: DocumentDao,
|
||||
val linkDao: LinkDao
|
||||
) {
|
||||
|
||||
@Transactional
|
||||
fun exec(command: AddLinkCommand) {
|
||||
command.otherDocuments.forEach {
|
||||
linkDao.save(
|
||||
Link(
|
||||
from = AggregateReference.to(command.documentId),
|
||||
to = AggregateReference.to(it)
|
||||
)
|
||||
)
|
||||
}
|
||||
documentDao.updated(command.documentId)
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue