Ajout d'1 DELETE pour exemple

Springboot
Alix JEUDI--LEMOINE 1 year ago
parent 3fef170148
commit 64c5df029d

@ -21,6 +21,7 @@ import org.springframework.hateoas.CollectionModel;
import org.springframework.hateoas.PagedModel;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
@RestController
@ -62,4 +63,10 @@ public class ScientifiqueController {
indice.setScientifique(this.scientifiqueService.findById(id));
return this.modelMapper.map(this.indiceService.create(indice), IndiceSimpleWithScientifiquesIdDTO.class);
}
@DeleteMapping(value="/{id}/indices/{indiceId}")
@ResponseStatus(HttpStatus.ACCEPTED)
public void deleteIndice(@PathVariable Integer id, @PathVariable Integer indiceId) {
this.indiceService.delete(indiceId);
}
}

@ -48,4 +48,11 @@ public class IndiceService {
}
return destIndice;
}
public void delete(int id){
if(!this.indiceRepository.existsById(id)){
throw new IndiceNotFoundException(id);
}
this.indiceRepository.deleteById(id);
}
}

Loading…
Cancel
Save