컬렉션, 요청 삭제

This commit is contained in:
현성필
2023-05-15 17:24:57 +09:00
parent 78277d271d
commit 239a562d6f
5 changed files with 167 additions and 56 deletions
@@ -30,6 +30,11 @@ public class ApiRequestMgmtService {
}
public void deleteApiCollection(String id) {
ApiCollection collection = apiCollectionRepository.findById(id).orElseThrow(() -> new NotFoundException("api collection[" + id + "] not found"));
if (collection.getApis().size()>0){
throw new RuntimeException("api collection[" + id + "] is not empty");
}
apiCollectionRepository.deleteById(id);
}
@@ -21,4 +21,13 @@ public class CustomGlobalExceptionHandler extends ResponseEntityExceptionHandler
return new ResponseEntity<>(errors, HttpStatus.NOT_FOUND);
}
@ExceptionHandler(RuntimeException.class)
public ResponseEntity<CustomErrorResponse> customHandleRuntime(Exception ex, WebRequest request) {
CustomErrorResponse errors = new CustomErrorResponse();
errors.setTimestamp(LocalDateTime.now());
errors.setError(ex.getMessage());
errors.setStatus(HttpStatus.BAD_REQUEST.value());
return new ResponseEntity<>(errors, HttpStatus.BAD_REQUEST);
}
}