mirror of
https://github.com/pcvolkmer/grz-metadata-processor.git
synced 2025-07-01 12:02: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")
|
||||
data class File(
|
||||
@Id val id: Long? = null,
|
||||
val labDataId: Long?,
|
||||
var labDataId: Long?,
|
||||
val filePath: String? = null,
|
||||
val fileType: FileType? = null,
|
||||
var fileChecksum: String = "",
|
||||
|
@ -54,7 +54,11 @@ class FileController(
|
||||
|
||||
@DeleteMapping(path = ["/labdatas/{labDataId}/files/{fileId}"])
|
||||
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("files", fileRepository.findByLabDataId(labDataId))
|
||||
return "files"
|
||||
|
Reference in New Issue
Block a user