diff --git a/src/main/java/org/ntlab/citrusserver/entities/Book.java b/src/main/java/org/ntlab/citrusserver/entities/Book.java index fb612e1..f9aec9b 100644 --- a/src/main/java/org/ntlab/citrusserver/entities/Book.java +++ b/src/main/java/org/ntlab/citrusserver/entities/Book.java @@ -8,6 +8,12 @@ private int bookId; private int todoId = 0; + public Book(String title, boolean publicity, String color) { + this.title = title; + this.publicity = publicity; + this.color = color; + } + public void setTitle(String t) {title = t;} public String getTitle() {return title;} public void setPublicity(boolean p) {publicity = p;} diff --git a/src/main/java/org/ntlab/citrusserver/entities/Todo.java b/src/main/java/org/ntlab/citrusserver/entities/Todo.java index c65bd5b..8ba929b 100644 --- a/src/main/java/org/ntlab/citrusserver/entities/Todo.java +++ b/src/main/java/org/ntlab/citrusserver/entities/Todo.java @@ -8,6 +8,14 @@ int day; Integer todoId; + public Todo(String t, boolean c, int y, int m, int d, Integer tid) { + title = t; + check = c; + year = y; + month = m; + day = d; + todoId = tid; + } public void setTitle(String t) {title = t;} public String getTitle() {return title;} public void setCheck(boolean c) {check = c;} diff --git a/src/main/java/org/ntlab/citrusserver/repositories/AccountManager.java b/src/main/java/org/ntlab/citrusserver/repositories/AccountManager.java index e7291b8..9efa708 100644 --- a/src/main/java/org/ntlab/citrusserver/repositories/AccountManager.java +++ b/src/main/java/org/ntlab/citrusserver/repositories/AccountManager.java @@ -1,4 +1,39 @@ package org.ntlab.citrusserver.repositories; +import jakarta.ws.rs.*; +import jakarta.ws.rs.core.MediaType; +import org.ntlab.citrusserver.entities.Account; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Repository; + +import java.lang.reflect.Array; +import java.util.*; + +import java.util.HashMap; + +@Repository public class AccountManager { + private HashMap accounts = new HashMap(); + + private HashMap accountToken = new HashMap<>(); //keyがaccountId,valueがtoken + + // アカウントの一覧をリストとして返す + public Set getAccountsID() { + return accounts.keySet(); + } + + // account_idとpasswordを設定し新しいアカウントを作成する + public String newAccount(String accountId, String password) { + UUID str = UUID.randomUUID(); + String token = str.toString(); + //accounts.setId(accountId); + //accounts.setPassword(password); + accountToken.put(accountId, token); //accountIDとtokenをHashMapに入れる + return token; + } + + // 指定されたアカウントの情報を返す + public Account getAccount(String accountId) { + return accounts.get(accountId); + } } diff --git a/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java b/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java index b371ae5..97817d0 100644 --- a/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java +++ b/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java @@ -1,4 +1,73 @@ package org.ntlab.citrusserver.repositories; +import org.ntlab.citrusserver.entities.Account; +import org.ntlab.citrusserver.entities.Book; +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(); //仮(Account作成時に相談) + Book book = new Book(title, publicity, color); + 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 putTitle(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); + } }