| | 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<String, HashMap<Integer, Book>> booksMap = new HashMap<String, HashMap<Integer, Book>>(); |
---|
| | |
---|
| | //本の一覧を返す |
---|
| | public HashMap<String, HashMap<Integer, Book>> 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); |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | |
No description provided.
BookManagerクラスに関数を追加しました
9ec6b26
intomaster
fromBookManager/okada
on 7 MayBookManager/okada
branch on 7 May