@PutMapping("/create")
public Book create(Map<String, Object> map) throws Exception {
System.out.println("Controleer of het boek bestaat " + map);
Book book = new ObjectMapper().convertValue(map, Book.class);
Book b = repo.findByTitle(book.getTitle());
if (b != null) {
throw new Exception("Boek bestaat al");
}
book.setId(UUID.randomUUID().toString());
repo.save(book);
log.debug("Boek {} door {} is gemaakt met id {}", book.getTitle(), book.getAuthor(), book.getId());
return book;
}
public BookStoreController(BooksRepository repo, Boolean bool, List<String> keys) {
this.repo = repo;
if (Boolean.TRUE.equals(bool)) {
// controleer eerste sleutel
if(keys != null && !keys.isEmpty()){
String firstKey = keys.get(0);
if (firstKey == "public") {
for (String key : keys){
// ... wat logica
log.debug("Gebruik sleutel {}", key);
};
}
}
}
}
Oudste