diff --git a/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java b/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java index ecf2664..7185830 100644 --- a/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java +++ b/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java @@ -32,14 +32,12 @@ //本の一覧を返す public HashMap getBooks(String accountId) { - if(accountManager.getAccount(accountId) == null) return null; //アカウントが存在しない return booksMap.get(accountId); } //本の新規作成 public Book createBook(String accountId, String title, String color, Boolean publicity) { - if(accountManager.getAccount(accountId) == null) return null; //アカウントが存在しない if(!booksMap.containsKey(accountId)){ booksMap.put(accountId, new HashMap<>()); } @@ -54,19 +52,13 @@ //本の情報を取得 public Book getBook(String accountId, Integer bookId) { - if(accountManager.getAccount(accountId) == null) return null; //アカウントが存在しない return booksMap.get(accountId).get(bookId); } //本の削除 - public int deleteBook(String accountId, Integer bookId) + public void deleteBook(String accountId, Integer bookId) { - if(accountManager.getAccount(accountId) == null) return -1; //アカウントが存在しない - else - { - booksMap.get(accountId).remove(bookId); - return 1; - } + booksMap.get(accountId).remove(bookId); } //((( いいねは省略 ))) @@ -79,51 +71,39 @@ } //本のタイトルを変更 - public int putTitle(String accountId, Integer bookId, String title) + public void putTitle(String accountId, Integer bookId, String title) { - if(accountManager.getAccount(accountId) == null) return -1; //アカウントが存在しない - else - { booksMap.get(accountId).get(bookId).setTitle(title); - return 1; - } - } //本の公開情報を返す public Boolean getPublicity(String accountId, Integer bookId) { - if(accountManager.getAccount(accountId) == null) return null; //アカウントが存在しない return booksMap.get(accountId).get(bookId).getPublicity(); } //公開情報を変更する - public int putPublicity(String accountId, Integer bookId, Boolean publicity) + public void putPublicity(String accountId, Integer bookId, Boolean publicity) { Account account = accountManager.getAccount(accountId); Book book = booksMap.get(accountId).get(bookId); - if(account == null) return -1; //アカウントが存在しない - else - { - if(book.getPublicity() == publicity) return 1;//変更が無ければ終了 - book.setPublicity(publicity); - notifyListener(account, book); - return 1; - } + if(book.getPublicity() == publicity) return;//変更が無ければ終了 + book.setPublicity(publicity); + notifyListener(account, book); + + } + + public void deleteAllBooks(String accountId) + { + booksMap.get(accountId).clear(); } //((( 目標・振り返りは省略 ))) //本の色を変更する - public int putColor(String accountId, Integer bookId, String color) + public void putColor(String accountId, Integer bookId, String color) { - if(accountManager.getAccount(accountId) == null) return -1; //アカウントが存在しない - else - { booksMap.get(accountId).get(bookId).setColor(color); - return 1; - } - } //---------------------------------------------------------------------------------