Compare commits
2 Commits
c83b11d558
...
a5c2f5024f
| Author | SHA1 | Date |
|---|---|---|
|
|
a5c2f5024f | 4 weeks ago |
|
|
19d9ed1da9 | 4 weeks ago |
@ -0,0 +1,27 @@
|
|||||||
|
package wanijo.wanijo2.domain.event
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.Min
|
||||||
|
import jakarta.validation.constraints.NotEmpty
|
||||||
|
import wanijo.wanijo2.domain.DateField
|
||||||
|
import wanijo.wanijo2.domain.DocumentId
|
||||||
|
import java.time.LocalDateTime
|
||||||
|
import java.time.ZoneId
|
||||||
|
import java.time.ZoneOffset
|
||||||
|
import java.time.ZonedDateTime
|
||||||
|
|
||||||
|
data class AddDateFieldCommand(
|
||||||
|
@Min(1)
|
||||||
|
val documentId: DocumentId,
|
||||||
|
@NotEmpty
|
||||||
|
val dateName: String,
|
||||||
|
@NotEmpty
|
||||||
|
val dateValue: LocalDateTime,
|
||||||
|
val order: Int = 0,
|
||||||
|
) {
|
||||||
|
fun toField() =
|
||||||
|
DateField(
|
||||||
|
name = dateName,
|
||||||
|
value = dateValue,
|
||||||
|
order = order
|
||||||
|
)
|
||||||
|
}
|
||||||
@ -0,0 +1,12 @@
|
|||||||
|
package wanijo.wanijo2.domain.event
|
||||||
|
|
||||||
|
import jakarta.validation.constraints.Min
|
||||||
|
import wanijo.wanijo2.domain.DocumentId
|
||||||
|
import wanijo.wanijo2.domain.FieldId
|
||||||
|
|
||||||
|
data class DeleteDateFieldCommand(
|
||||||
|
@Min(1)
|
||||||
|
val documentId: DocumentId,
|
||||||
|
@Min(1)
|
||||||
|
val dateFieldId: FieldId
|
||||||
|
)
|
||||||
@ -0,0 +1,22 @@
|
|||||||
|
package wanijo.wanijo2.domain.handler
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service
|
||||||
|
import wanijo.wanijo2.domain.DateField
|
||||||
|
import wanijo.wanijo2.domain.DocumentDao
|
||||||
|
import wanijo.wanijo2.domain.LabelField
|
||||||
|
import wanijo.wanijo2.domain.event.AddDateFieldCommand
|
||||||
|
import wanijo.wanijo2.http.DocumentNotFound
|
||||||
|
|
||||||
|
@Service
|
||||||
|
class AddDateFieldHandler(
|
||||||
|
val documentDao: DocumentDao
|
||||||
|
) {
|
||||||
|
|
||||||
|
fun exec(command: AddDateFieldCommand) {
|
||||||
|
val doc = documentDao.findById(command.documentId) ?: throw DocumentNotFound()
|
||||||
|
documentDao.save(
|
||||||
|
doc.withDate(command.toField())
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,18 @@
|
|||||||
|
package wanijo.wanijo2.domain.handler
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service
|
||||||
|
import wanijo.wanijo2.domain.DocumentDao
|
||||||
|
import wanijo.wanijo2.domain.event.DeleteDateFieldCommand
|
||||||
|
import wanijo.wanijo2.http.DocumentNotFound
|
||||||
|
|
||||||
|
@Service
|
||||||
|
class DeleteDateFieldHandler(
|
||||||
|
val dao: DocumentDao
|
||||||
|
) {
|
||||||
|
|
||||||
|
fun exec(command: DeleteDateFieldCommand) {
|
||||||
|
val doc = dao.findById(command.documentId) ?: throw DocumentNotFound()
|
||||||
|
dao.save(doc.withoutDate(command.dateFieldId))
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,2 @@
|
|||||||
|
ALTER TABLE t_document_tagging
|
||||||
|
ADD COLUMN created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now();
|
||||||
Loading…
Reference in New Issue