diff --git a/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java b/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java index b371ae5..ff9d9f5 100644 --- a/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java +++ b/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java @@ -1,4 +1,75 @@ package org.ntlab.citrusserver.repositories; +import org.ntlab.citrusserver.entities.Account; +import org.springframework.stereotype.Repository; +import java.util.HashMap; + +@Repository public class BookManager { + + private HashMap> booksMap = new HashMap>(); + + //本の一覧を返す + public HashMap> getBooksMap() + { + return booksMap; + } + + //本の新規作成 + public int createBook(String accountId, String title, String color, Boolean publicity) + { + Account account = new Account(accountId); //仮(Account作成時に相談) + Book book = new Book(accountId); + book.setTitle(title); + book.setColor(color); + book.setPublicity(publicity); + account.setBookCount(); //仮(本作成時、Account側で持っている数の加算を行ってもらう) + return account.getnewId(); //仮(本の数を更新し、AccountIDを返してもらう) + } + + //本の情報を取得 + public Book getBook(String accountId, Integer bookId) + { + return booksMap.get(accountId).get(bookId); + } + + //本の削除 + public void deleteBook(String accountId, Integer bookId) + { + booksMap.get(accountId).remove(bookId); + } + + //((( いいねは省略 ))) + + //本のタイトルを返す + public String getTitle(String accountId, Integer bookId) + { + return booksMap.get(accountId).get(bookId).getTitle(); + } + + //本のタイトルを変更 + public void putColor(String accountId, Integer bookId, String title) + { + booksMap.get(accountId).get(bookId).setTitle(title); + } + + //本の公開情報を返す + public Boolean getPublicity(String accountId, Integer bookId) + { + return booksMap.get(accountId).get(bookId).getPublicity(); + } + + //公開情報を変更する + public void putPublicity(String accountId, Integer bookId, Boolean publicity) + { + booksMap.get(accountId).get(bookId).setPublicity(publicity); + } + + //((( 目標・振り返りは省略 ))) + + //本の色を変更する + public void putColor(String accountId, Integer bookId, String color) + { + booksMap.get(accountId).get(bookId).setColor(color); + } }