diff --git a/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java b/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java index c5bbf15..cadd0f9 100644 --- a/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java +++ b/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java @@ -9,6 +9,11 @@ public class BookManager { private HashMap> booksMap = new HashMap<>(); + private final AccountManager accountManager; //仮 + + public BookManager(AccountManager accountManager) { + this.accountManager = accountManager; + } //本の一覧を返す public HashMap> getBooks() @@ -19,9 +24,9 @@ //本の新規作成 public int createBook(String accountId, String title, String color, Boolean publicity) { - Account account = new Account(); //仮(Account作成時に相談) - Book book = new Book(title, publicity, color); - int newBookId = account.getNewBookId(); //仮(本の数を更新し、AccountIDを返してもらう) + Account account = accountManager.getAccount(accountId); //アカウントの取得 + Book book = new Book(title, publicity, color); //本の初期化 + int newBookId = account.getNewBookId(); //新たに生成されたIdを取得(作成数もここで加算している) booksMap.get(accountId).put(newBookId, book); //ブックに追加 return newBookId; }