parent
db065fafe2
commit
97fe0acdea
@ -0,0 +1,15 @@
|
||||
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,19 @@
|
||||
package wanijo.wanijo2.domain.handler
|
||||
|
||||
import org.springframework.stereotype.Service
|
||||
import wanijo.wanijo2.domain.DocumentTaggingDao
|
||||
import wanijo.wanijo2.domain.event.DeleteTaggingCommand
|
||||
|
||||
@Service
|
||||
class DeleteTaggingHandler(
|
||||
val taggingDao: DocumentTaggingDao
|
||||
) {
|
||||
|
||||
fun exec(command: DeleteTaggingCommand) {
|
||||
taggingDao.delete(
|
||||
command.documentId,
|
||||
command.tagId
|
||||
)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package wanijo.wanijo2.http.controller
|
||||
|
||||
import org.springframework.stereotype.Controller
|
||||
import org.springframework.web.bind.annotation.PostMapping
|
||||
import org.springframework.web.bind.annotation.RequestParam
|
||||
import wanijo.wanijo2.domain.DocumentId
|
||||
import wanijo.wanijo2.domain.TagId
|
||||
import wanijo.wanijo2.domain.event.DeleteTaggingCommand
|
||||
import wanijo.wanijo2.domain.handler.DeleteTaggingHandler
|
||||
|
||||
@Controller
|
||||
class TaggingController(
|
||||
val deleteTaggingHandler: DeleteTaggingHandler
|
||||
) {
|
||||
|
||||
@PostMapping("/tagging/delete")
|
||||
fun delete(
|
||||
@RequestParam("docId")
|
||||
documentId: DocumentId,
|
||||
@RequestParam("tagId")
|
||||
tagId: TagId
|
||||
): String {
|
||||
deleteTaggingHandler.exec(
|
||||
DeleteTaggingCommand(
|
||||
tagId = tagId,
|
||||
documentId = documentId
|
||||
)
|
||||
)
|
||||
return "redirect:/document/${documentId}"
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue