Commit 9327b3ac authored by Simone Vuotto's avatar Simone Vuotto

Add Requirement Delete API

parent f0acf1d4
......@@ -40,6 +40,14 @@ public class RequirementController {
return new ResponseEntity<>(null, HttpStatus.BAD_REQUEST);
}
@DeleteMapping("/{id}")
public ResponseEntity<?> deleteRequirement(@PathVariable("id") Long id) {
if(requirementService.delete(id))
return new ResponseEntity<>(HttpStatus.OK);
else
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
@PostMapping
public ResponseEntity<?> createRequirement(@Valid @RequestBody Requirement requirement) {
requirement = requirementService.create(requirement);
......
......@@ -53,6 +53,14 @@ public class RequirementService {
}
}
public boolean delete(Long id) {
Requirement req = getRequirement(id);
if(req == null)
return false;
requirementRepository.delete(req);
return true;
}
public Requirement update(Requirement req) {
Requirement oldReq = getRequirement(req.getId());
if(isValid(req) && oldReq != null && oldReq.getProject().getId().equals(req.getProject().getId())) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment