@PutMapping("/create")
public Book create(Map<String, Object> map) throws Exception {
System.out.println("Vérifier si le livre existe " + map);
Book book = new ObjectMapper().convertValue(map, Book.class);
Book b = repo.findByTitle(book.getTitle());
if (b != null) {
throw new Exception("Le livre existe déjà");
}
book.setId(UUID.randomUUID().toString());
repo.save(book);
log.debug("Livre {} par {} a été créé avec l'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)) {
// vérifier la première clé
if(keys != null && !keys.isEmpty()){
String firstKey = keys.get(0);
if (firstKey == "public") {
for (String key : keys){
// ... une logique
log.debug("Utilisation de la clé {}", key);
};
}
}
}
}
Sénior