|
|
|
|
@ -7,36 +7,44 @@ import org.springframework.ui.set
|
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping
|
|
|
|
|
import org.springframework.web.bind.annotation.PathVariable
|
|
|
|
|
import org.springframework.web.bind.annotation.PostMapping
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping
|
|
|
|
|
import wanijo.wanijo2.domain.DocumentBriefDao
|
|
|
|
|
import wanijo.wanijo2.domain.DocumentId
|
|
|
|
|
import wanijo.wanijo2.domain.event.AddDateFieldCommand
|
|
|
|
|
import wanijo.wanijo2.domain.event.AddLabelFieldCommand
|
|
|
|
|
import wanijo.wanijo2.domain.handler.AddDateFieldHandler
|
|
|
|
|
import wanijo.wanijo2.domain.handler.AddLabelFieldHandler
|
|
|
|
|
import java.time.LocalDateTime
|
|
|
|
|
import java.time.ZonedDateTime.now
|
|
|
|
|
|
|
|
|
|
@Controller
|
|
|
|
|
@RequestMapping("/document/{id}/field/label/add")
|
|
|
|
|
class AddLabelFieldController(
|
|
|
|
|
class AddFieldController(
|
|
|
|
|
val documentBriefDao: DocumentBriefDao,
|
|
|
|
|
val addLabelFieldHandler: AddLabelFieldHandler
|
|
|
|
|
val addLabelFieldHandler: AddLabelFieldHandler,
|
|
|
|
|
val addDateFieldHandler: AddDateFieldHandler
|
|
|
|
|
) {
|
|
|
|
|
|
|
|
|
|
@GetMapping
|
|
|
|
|
@GetMapping("/document/{id}/field/add")
|
|
|
|
|
fun addLabel(
|
|
|
|
|
@PathVariable
|
|
|
|
|
id: DocumentId,
|
|
|
|
|
model: Model
|
|
|
|
|
): String {
|
|
|
|
|
model["form"] = AddLabelFieldCommand(
|
|
|
|
|
model["labelForm"] = AddLabelFieldCommand(
|
|
|
|
|
documentId = id,
|
|
|
|
|
labelName = "",
|
|
|
|
|
labelValue = ""
|
|
|
|
|
)
|
|
|
|
|
model["dateForm"] = AddDateFieldCommand(
|
|
|
|
|
documentId = id,
|
|
|
|
|
dateName = "",
|
|
|
|
|
dateValue = LocalDateTime.now()
|
|
|
|
|
)
|
|
|
|
|
model["document"] = documentBriefDao.findById(id)
|
|
|
|
|
|
|
|
|
|
return "addLabelField"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping
|
|
|
|
|
@PostMapping("/document/{id}/field/label/add")
|
|
|
|
|
fun addLabel(
|
|
|
|
|
@PathVariable
|
|
|
|
|
id: DocumentId,
|
|
|
|
|
@ -47,4 +55,15 @@ class AddLabelFieldController(
|
|
|
|
|
return "redirect:/document/$id"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/document/{id}/field/date/add")
|
|
|
|
|
fun addDate(
|
|
|
|
|
@PathVariable
|
|
|
|
|
id: DocumentId,
|
|
|
|
|
@Valid
|
|
|
|
|
command: AddDateFieldCommand
|
|
|
|
|
): String {
|
|
|
|
|
addDateFieldHandler.exec(command)
|
|
|
|
|
return "redirect:/document/$id"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|