Compare commits
No commits in common. 'c788004de0c2e715370814c136b0b8b39d75107e' and '938f2ef619227bb6f1b6e9a1fc87abb1983da56d' have entirely different histories.
c788004de0
...
938f2ef619
@ -1,13 +0,0 @@
|
|||||||
package wanijo.wanijo2.domain.event
|
|
||||||
|
|
||||||
import jakarta.validation.constraints.Min
|
|
||||||
import wanijo.wanijo2.domain.Direction
|
|
||||||
import wanijo.wanijo2.domain.DocumentId
|
|
||||||
|
|
||||||
data class AddLinkCommand(
|
|
||||||
@Min(1)
|
|
||||||
val documentId: DocumentId,
|
|
||||||
@Min.List(Min(1))
|
|
||||||
val otherDocuments: List<DocumentId>,
|
|
||||||
val direction: Direction
|
|
||||||
)
|
|
||||||
@ -1,25 +0,0 @@
|
|||||||
package wanijo.wanijo2.domain
|
|
||||||
|
|
||||||
import org.springframework.data.annotation.Id
|
|
||||||
import org.springframework.data.jdbc.core.mapping.AggregateReference
|
|
||||||
import org.springframework.data.relational.core.mapping.Table
|
|
||||||
import org.springframework.data.repository.Repository
|
|
||||||
import java.time.Instant
|
|
||||||
|
|
||||||
typealias LinkId = Long
|
|
||||||
|
|
||||||
@Table("T_LINK")
|
|
||||||
data class Link(
|
|
||||||
@Id
|
|
||||||
val id: LinkId = 0,
|
|
||||||
val from: AggregateReference<Document, DocumentId>,
|
|
||||||
val to: AggregateReference<Document, DocumentId>,
|
|
||||||
val createdAt: Instant = Instant.now(),
|
|
||||||
)
|
|
||||||
|
|
||||||
enum class Direction {
|
|
||||||
OUTGOING,
|
|
||||||
INCOMING
|
|
||||||
}
|
|
||||||
|
|
||||||
interface LinkDao : Repository<Link, LinkId> {}
|
|
||||||
@ -1,48 +0,0 @@
|
|||||||
package wanijo.wanijo2.http.controller
|
|
||||||
|
|
||||||
import org.springframework.data.domain.Sort
|
|
||||||
import org.springframework.stereotype.Controller
|
|
||||||
import org.springframework.ui.Model
|
|
||||||
import org.springframework.ui.set
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable
|
|
||||||
import wanijo.wanijo2.domain.Direction
|
|
||||||
import wanijo.wanijo2.domain.DocumentBriefDao
|
|
||||||
import wanijo.wanijo2.domain.DocumentId
|
|
||||||
import wanijo.wanijo2.domain.event.AddLinkCommand
|
|
||||||
|
|
||||||
@Controller
|
|
||||||
class LinkController(
|
|
||||||
val documentBriefDao: DocumentBriefDao,
|
|
||||||
) {
|
|
||||||
|
|
||||||
@GetMapping("/document/{id}/link/add")
|
|
||||||
fun addLabel(
|
|
||||||
@PathVariable
|
|
||||||
id: DocumentId,
|
|
||||||
model: Model
|
|
||||||
): String {
|
|
||||||
model["document"] = documentBriefDao.findById(id)
|
|
||||||
model["documents"] = documentBriefDao.findAll(Sort.by(Sort.Direction.ASC, "name"))
|
|
||||||
|
|
||||||
model["addForm"] = AddLinkCommand(
|
|
||||||
id,
|
|
||||||
emptyList(),
|
|
||||||
Direction.OUTGOING
|
|
||||||
)
|
|
||||||
|
|
||||||
return "addLink"
|
|
||||||
}
|
|
||||||
|
|
||||||
/*@PostMapping("/document/{id}/field/label/add")
|
|
||||||
fun addLabel(
|
|
||||||
@PathVariable
|
|
||||||
id: DocumentId,
|
|
||||||
@Valid
|
|
||||||
command: AddLabelFieldCommand
|
|
||||||
): String {
|
|
||||||
addLabelFieldHandler.exec(command)
|
|
||||||
return "redirect:/document/$id"
|
|
||||||
}*/
|
|
||||||
|
|
||||||
}
|
|
||||||
@ -1,15 +0,0 @@
|
|||||||
CREATE TABLE t_link
|
|
||||||
(
|
|
||||||
id INT GENERATED BY DEFAULT AS IDENTITY PRIMARY KEY,
|
|
||||||
document_from INT NOT NULL,
|
|
||||||
document_to INT NOT NULL,
|
|
||||||
created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT now(),
|
|
||||||
|
|
||||||
CONSTRAINT fk_link_document_from
|
|
||||||
FOREIGN KEY (document_from)
|
|
||||||
REFERENCES t_document (id),
|
|
||||||
|
|
||||||
CONSTRAINT fk_link_document_to
|
|
||||||
FOREIGN KEY (document_to)
|
|
||||||
REFERENCES t_document (id)
|
|
||||||
);
|
|
||||||
@ -1,41 +0,0 @@
|
|||||||
<!doctype html>
|
|
||||||
<html xmlns:th="http://www.thymeleaf.org"
|
|
||||||
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout"
|
|
||||||
layout:decorate="~{base}"
|
|
||||||
lang="">
|
|
||||||
<head>
|
|
||||||
<title th:text="${document.name}"></title>
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<main id="content" layout:fragment="content">
|
|
||||||
<a th:href="@{/document/{id}(id=${document.id})}"><< zurück</a>
|
|
||||||
|
|
||||||
<h2>
|
|
||||||
<span class="low-key-hint">verknüpfung für</span>
|
|
||||||
<th:block th:text="${document.name}"/>
|
|
||||||
<span class="low-key-hint">hinzufügen</span>
|
|
||||||
</h2>
|
|
||||||
|
|
||||||
<form th:action="@{/document/{id}/link/add(id=${document.id})}"
|
|
||||||
th:object="${addForm}"
|
|
||||||
method="post">
|
|
||||||
<input type="hidden" th:field="*{documentId}">
|
|
||||||
|
|
||||||
<label for="otherDocuments">dokumente</label>
|
|
||||||
<select th:field="*{otherDocuments}" multiple id="otherDocuments">
|
|
||||||
<option th:each="doc: ${documents}"
|
|
||||||
th:value="${doc.id}"
|
|
||||||
th:if="${doc.id != document.id}"
|
|
||||||
th:text="${doc.name}"></option>
|
|
||||||
</select>
|
|
||||||
|
|
||||||
<button type="submit" value="OUTGOING" name="direction">
|
|
||||||
ausgehend
|
|
||||||
</button>
|
|
||||||
<button type="submit" value="INCOMING" name="direction">
|
|
||||||
eingehend
|
|
||||||
</button>
|
|
||||||
</form>
|
|
||||||
</main>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
Loading…
Reference in New Issue