diff --git a/src/main/java/org/ntlab/citrusserver/repositories/AccountManager.java b/src/main/java/org/ntlab/citrusserver/repositories/AccountManager.java index 3580f3c..e2a9ca0 100644 --- a/src/main/java/org/ntlab/citrusserver/repositories/AccountManager.java +++ b/src/main/java/org/ntlab/citrusserver/repositories/AccountManager.java @@ -1,6 +1,7 @@ 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.*; @@ -12,10 +13,17 @@ private final HashMap accountToken = new HashMap<>(); //keyがaccountId,valueがtoken + private final List iAccountListeners = new ArrayList<>(); + public AccountManager() { dummyAccount(); } + public void addListener(IAccountListener iAccountListener) + { + iAccountListeners.add(iAccountListener); + } + public void dummyAccount() { //ダミーアカウントの作成 String accountId = "fish"; String password = "abc"; @@ -67,7 +75,8 @@ // アカウント情報を全削除する(DELETE) public void deleteAccount(String accountId, String token, String password) { if(accountToken.get(accountId).equals(token)) { //token比較 - if(accounts.get(accountId).getPassword().equals(password)) { //password比較 + if(accounts.get(accountId).getPassword().equals(password)) {//password比較 + notifyDeletedListener(getAccount(accountId)); accounts.remove(accountId); } } @@ -106,4 +115,12 @@ return null; } + private void notifyDeletedListener(Account account) + { + for(IAccountListener iAccountListener : iAccountListeners) + { + iAccountListener.accountDeleted(account); + } + } + }