AccountManagerの機能追加
1 parent 3ace5bd commit a1abd736e2d478f677422b351cc3e82f4f85bdbe
k-suzuki authored on 7 May
Showing 1 changed file
View
33
src/main/java/org/ntlab/citrusserver/repositories/AccountManager.java
 
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import org.ntlab.citrusserver.entities.Account;
import org.ntlab.citrusserver.resources.AccountsRest;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
 
import java.lang.reflect.Array;
import java.util.HashMap;
 
@Repository
public class AccountManager {
private final AccountsRest accountsRest;
private HashMap<String, Account> accounts = new HashMap<String, Account>(); //keyにaccountId,valueにaccount
 
private HashMap<String, String> accountToken = new HashMap<>(); //keyがaccountId,valueがtoken
 
public AccountManager(AccountsRest accountsRest) {
this.accountsRest = accountsRest;
}
 
// アカウントの一覧をリストとして返す(GET)
public Set<String> getAccountsID() {
return accounts.keySet();
}
 
// account_idとpasswordを設定し新しいアカウントを作成する(POST)
public String newAccount(String accountId, String password) {
public String createAccount(String accountId, String password) {
UUID str = UUID.randomUUID();
String token = str.toString();
Account account = new Account(accountId, password);
if(!accounts.containsKey(accountId)) {
accounts.put(accountId, account);
accountToken.put(accountId, token); //accountIDとtokenをHashMapに入れる
}
return token;
}
 
//tokenを返す
public String createToken(String accountId) {
return accountToken.get(accountId);
}
 
// 指定されたアカウントの情報を返す(GET)
public Account getAccount(String accountId) {
return accounts.get(accountId).getIntroduction();
}
 
// 指定されたIDのお気に入りの本のリストを返す(GET)
public ArrayList<HashMap<String, String>> favoriteBook(String accountId, String token) {
public ArrayList<HashMap<String, String>> Favorites(String accountId, String token) {
return null;
}
 
// 指定されたIDのお気に入りの本のリストを返す(指定した人物) (GET)
public ArrayList<Integer> FavoriteBook(String accountId, String otherAccountId, String token) {
public ArrayList<Integer> FavoritesBookId(String accountId, String otherAccountId, String token) {
return null;
}
 
// 指定されたIDのアカウントを変更する (PUT)
public void newpassword() {
// 指定されたIDのパスワードを変更する (PUT)
public void newpassword(String accountId, String token, String password) {
 
}
 
// 指定されたIDの自己紹介を変更する (PUT)
public void newintro() {
public void newintroduction(String accountId, String token, String introduction) {
 
}
 
// お気に入りにの本のbook_idを削除する (DELETE)
public void deletefavbook() {
// お気に入りの本のbook_idを削除する (DELETE)
public void deletefavbookid(String accountId, String token, String otherAccountId, Integer bookId) {
 
}
 
// いいねした本のアカウントIDとbook_idを追加する(いいねした側に追加) (PUT)
public void putfavoriteid() {
public void putfavoriteid(String accountId, String token, String otherAccountId, Integer bookId) {
 
}
 
// アカウントidとパスワードでログインし、tokenを返す (POST)
public void login() {
 
public String login(String accountId, String password) {
return accountToken.get(accountId);
}
}