mirror of
https://github.com/pcvolkmer/grz-metadata-processor.git
synced 2025-07-01 20:12:54 +00:00
feat: do not delete but remove files from lab data
This commit is contained in:
@ -14,7 +14,7 @@ import kotlin.io.path.inputStream
|
|||||||
@Table("tbl_file")
|
@Table("tbl_file")
|
||||||
data class File(
|
data class File(
|
||||||
@Id val id: Long? = null,
|
@Id val id: Long? = null,
|
||||||
val labDataId: Long?,
|
var labDataId: Long?,
|
||||||
val filePath: String? = null,
|
val filePath: String? = null,
|
||||||
val fileType: FileType? = null,
|
val fileType: FileType? = null,
|
||||||
var fileChecksum: String = "",
|
var fileChecksum: String = "",
|
||||||
|
@ -54,7 +54,11 @@ class FileController(
|
|||||||
|
|
||||||
@DeleteMapping(path = ["/labdatas/{labDataId}/files/{fileId}"])
|
@DeleteMapping(path = ["/labdatas/{labDataId}/files/{fileId}"])
|
||||||
fun deleteFile(@PathVariable fileId: Long, @PathVariable labDataId: Long, model: Model): String {
|
fun deleteFile(@PathVariable fileId: Long, @PathVariable labDataId: Long, model: Model): String {
|
||||||
fileRepository.deleteById(fileId)
|
val file = fileRepository.findById(fileId)
|
||||||
|
file.ifPresent {
|
||||||
|
it.apply { this.labDataId = null }
|
||||||
|
fileRepository.save(it)
|
||||||
|
}
|
||||||
model.addAttribute("fileId", fileId)
|
model.addAttribute("fileId", fileId)
|
||||||
model.addAttribute("files", fileRepository.findByLabDataId(labDataId))
|
model.addAttribute("files", fileRepository.findByLabDataId(labDataId))
|
||||||
return "files"
|
return "files"
|
||||||
|
Reference in New Issue
Block a user