Skip to content

Commit 8fca9c7

Browse files
committed
Adding update of document
1 parent f2bdc59 commit 8fca9c7

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/main/kotlin/no/nav/klage/document/api/DocumentController.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,19 @@ class DocumentController(
3838
return mapToDocumentView(documentService.createDocument(json))
3939
}
4040

41+
@ApiOperation(
42+
value = "Update document",
43+
notes = "Update document"
44+
)
45+
@PutMapping("/{documentId}")
46+
fun updateDocument(
47+
@PathVariable("documentId") documentId: UUID,
48+
@RequestBody json: String
49+
): DocumentView {
50+
logger.debug("updateDocument: received json: {}", json)
51+
return mapToDocumentView(documentService.updateDocument(documentId, json))
52+
}
53+
4154
@ApiOperation(
4255
value = "Get document",
4356
notes = "Get document"

src/main/kotlin/no/nav/klage/document/service/DocumentService.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ class DocumentService(private val documentRepository: DocumentRepository) {
2222
)
2323
}
2424

25+
fun updateDocument(documentId: UUID, json: String): Document {
26+
val document = documentRepository.getById(documentId)
27+
document.json = json
28+
document.modified = LocalDateTime.now()
29+
return document
30+
}
31+
2532
fun getDocument(documentId: UUID): Document {
2633
return documentRepository.getById(documentId)
2734
}

0 commit comments

Comments
 (0)