Opprydding backend (#35)
* ✨ Backend støtter mulighet for å slette innmeldte feilmeldinger Co-authored-by: Sindre Kjelsrud <sindre.kjelsrud@nav.no> * ✨ Knapp i redigeringsverktøy for sletting av feil * 🐛 Fikset routing bug, Delete was not allowed, og feil endepunkt i frontend * ♻️ Sørger for at http-statuskodene matcher request * ♻️ Rydder opp i response-meldinger --------- Co-authored-by: Sindre Kjelsrud <sindre.kjelsrud@nav.no> Co-authored-by: Markus Johansen <markus.aleksander.rakil.johansen@nav.no> Co-authored-by: Markus A. R. Johansen <90006516+J0hans1@users.noreply.github.com>
This commit is contained in:
		
							parent
							
								
									5c1a7d173b
								
							
						
					
					
						commit
						518d1214f5
					
				
					 2 changed files with 13 additions and 9 deletions
				
			
		|  | @ -50,29 +50,35 @@ fun configureRouting(): ApplicationEngine = embeddedServer(CIO, applicationEngin | |||
|                 call.respondText("READY") | ||||
|             } | ||||
|             get("/api/hentallefeil"){ | ||||
|                 val testMelding = feilmeldingRepository.hentAlleFeilmeldinger() | ||||
|                 call.respond(status = HttpStatusCode.Created, message = testMelding) | ||||
|                 val feilmeldinger = feilmeldingRepository.hentAlleFeilmeldinger() | ||||
|                 call.respond(status = HttpStatusCode.OK, message = feilmeldinger) | ||||
|             } | ||||
|             get("/api/hentsok/{sokestreng}"){ | ||||
|                 val sokestreng = call.parameters["sokestreng"] | ||||
|                     ?: return@get call.respond(HttpStatusCode.BadRequest, "Sokestreng må være definert") | ||||
|                     ?: return@get call.respond(HttpStatusCode.BadRequest, "Søkestreng må være definert") | ||||
|                 val sokeresultat = feilmeldingRepository.hentSokteFeilmeldinger(sokestreng) | ||||
|                 call.respond(status = HttpStatusCode.Created, message = sokeresultat) | ||||
|                 call.respond(status = HttpStatusCode.OK, message = sokeresultat) | ||||
|             } | ||||
|             post("/api/nyfeil") { | ||||
|                 val feilmelding = call.receive<Feilmelding>() | ||||
|                 feilmeldingRepository.lagre(feilmelding) | ||||
|                 call.respond(status = HttpStatusCode.Created, message = "Feilmelding motatt og sendt til database") | ||||
|                 call.respond(status = HttpStatusCode.Created, message = "Feilmelding motatt og lagret") | ||||
|             } | ||||
|             put("/api/oppdaterfeil") { | ||||
|                 val oppdatertFeilmelding = call.receive<Feilmelding>() | ||||
|                 feilmeldingRepository.oppdaterFeilmelding(oppdatertFeilmelding) | ||||
|                 call.respond(status = HttpStatusCode.Created, message = "Feilmelding oppdatert") | ||||
|                 call.respond(status = HttpStatusCode.OK, message = "Feilmelding oppdatert") | ||||
|             } | ||||
|             put("/api/oppdaterkommentar") { | ||||
|                 val innkommendeKommentar = call.receive<InnkommendeKommentar>() | ||||
|                 feilmeldingRepository.oppdaterKommentar(innkommendeKommentar.id, innkommendeKommentar.kommentar) | ||||
|                 call.respond(status = HttpStatusCode.Created, message = "Feilmelding oppdatert") | ||||
|                 call.respond(status = HttpStatusCode.OK, message = "Kommentar oppdatert") | ||||
|             } | ||||
|             delete("api/slettfeilmelding/{id}") { | ||||
|                 val id = call.parameters["id"] | ||||
|                 checkNotNull(id) {"Id kan ikke være null"} | ||||
|                 feilmeldingRepository.slettFeilmelding(id.toInt()) | ||||
|                 call.respond(status = HttpStatusCode.OK, message = "Feilmelding slettet") | ||||
|             } | ||||
|             delete("api/slettfeilmelding/{id}") { | ||||
|                 val id = call.parameters["id"] | ||||
|  |  | |||
		Reference in a new issue
	
	 Amalie
						Amalie