parent
d9e7b2e85a
commit
d235451f07
@ -1,15 +1,12 @@
|
||||
package wanijo.wanijo2.domain.event
|
||||
|
||||
import jakarta.validation.constraints.Min
|
||||
import jakarta.validation.constraints.NotEmpty
|
||||
import wanijo.wanijo2.domain.DocumentId
|
||||
import wanijo.wanijo2.domain.TagId
|
||||
|
||||
data class AssignTaggingCommand(
|
||||
@NotEmpty
|
||||
@Min(1)
|
||||
val tagId: TagId,
|
||||
@NotEmpty
|
||||
@Min(1)
|
||||
val documentId: DocumentId
|
||||
)
|
||||
|
@ -0,0 +1,9 @@
|
||||
package wanijo.wanijo2.domain.event
|
||||
|
||||
import jakarta.validation.constraints.Min
|
||||
import wanijo.wanijo2.domain.DocumentId
|
||||
|
||||
data class DeleteDocumentCommand(
|
||||
@Min(1)
|
||||
val documentId: DocumentId
|
||||
)
|
@ -1,15 +1,12 @@
|
||||
package wanijo.wanijo2.domain.event
|
||||
|
||||
import jakarta.validation.constraints.Min
|
||||
import jakarta.validation.constraints.NotEmpty
|
||||
import wanijo.wanijo2.domain.DocumentId
|
||||
import wanijo.wanijo2.domain.TagId
|
||||
|
||||
data class DeleteTaggingCommand(
|
||||
@NotEmpty
|
||||
@Min(1)
|
||||
val tagId: TagId,
|
||||
@NotEmpty
|
||||
@Min(1)
|
||||
val documentId: DocumentId
|
||||
)
|
||||
|
@ -0,0 +1,16 @@
|
||||
package wanijo.wanijo2.domain.handler
|
||||
|
||||
import org.springframework.stereotype.Service
|
||||
import wanijo.wanijo2.domain.DocumentDao
|
||||
import wanijo.wanijo2.domain.event.DeleteDocumentCommand
|
||||
|
||||
@Service
|
||||
class DeleteDocumentHandler(
|
||||
val documentDao: DocumentDao
|
||||
) {
|
||||
|
||||
fun exec(command: DeleteDocumentCommand) {
|
||||
documentDao.delete(command.documentId)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package wanijo.wanijo2.http.controller
|
||||
|
||||
import jakarta.validation.Valid
|
||||
import org.springframework.stereotype.Controller
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
import wanijo.wanijo2.domain.event.DeleteDocumentCommand
|
||||
import wanijo.wanijo2.domain.handler.DeleteDocumentHandler
|
||||
|
||||
@Controller
|
||||
class DeleteController(
|
||||
val deleteDocumentHandler: DeleteDocumentHandler
|
||||
) {
|
||||
|
||||
@PostMapping("/document/delete")
|
||||
fun delete(
|
||||
@Valid
|
||||
command: DeleteDocumentCommand
|
||||
): String {
|
||||
deleteDocumentHandler.exec(command)
|
||||
|
||||
return "redirect:/"
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue