diff --git a/backend/src/main/kotlin/io/github/gelassen/manufactory_knowledge_management/HttpControllers.kt b/backend/src/main/kotlin/io/github/gelassen/manufactory_knowledge_management/HttpControllers.kt index 1660880..1f6dabe 100644 --- a/backend/src/main/kotlin/io/github/gelassen/manufactory_knowledge_management/HttpControllers.kt +++ b/backend/src/main/kotlin/io/github/gelassen/manufactory_knowledge_management/HttpControllers.kt @@ -4,6 +4,7 @@ import org.springframework.http.HttpStatus import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.RequestMapping +import org.springframework.web.bind.annotation.RequestParam import org.springframework.web.bind.annotation.RestController import org.springframework.web.server.ResponseStatusException @@ -13,8 +14,8 @@ class MachineController( private val repository: MachinesRepository ) { - @GetMapping("/barcode/{barcode}") - fun getMachineByBarcode(@PathVariable barcode: String) = + @GetMapping + fun getMachineByBarcode(@RequestParam barcode: String) = repository.findMachineByBarcode(barcode) ?: throw ResponseStatusException( HttpStatus.NOT_FOUND, "Machine with $barcode barcode does not exist. Did you send the right barcode?" diff --git a/backend/src/main/kotlin/io/github/gelassen/manufactory_knowledge_management/ProjectConfiguration.kt b/backend/src/main/kotlin/io/github/gelassen/manufactory_knowledge_management/ProjectConfiguration.kt index dd40a01..55e6a5b 100644 --- a/backend/src/main/kotlin/io/github/gelassen/manufactory_knowledge_management/ProjectConfiguration.kt +++ b/backend/src/main/kotlin/io/github/gelassen/manufactory_knowledge_management/ProjectConfiguration.kt @@ -10,14 +10,7 @@ class ProjectConfiguration { @Bean fun databaseInitializer(machineRepository: MachinesRepository) = ApplicationRunner { - var sodickSaved = machineRepository.save( - Machine( - name = "Sodick 360b", - manufacturer = "Sodick", - barcode = "Sodick 360b" - ) - ) -/* var sodickSaved = machineRepository.save(Machine( + var sodickSaved = machineRepository.save(Machine( name = "Sodick 360b", manufacturer = "Sodick", barcode = "Sodick 360b" @@ -27,6 +20,6 @@ class ProjectConfiguration { name = "Fanuc 2000", manufacturer = "Fanuc", barcode = "Fanuc 2000") - )*/ + ) } } \ No newline at end of file