| | 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.*; |
---|
| | |
---|
| | import java.util.HashMap; |
---|
| |
---|
| | private final HashMap<String, Account> accounts = new HashMap<String, Account>(); //keyにaccountId,valueにAccount |
---|
| | |
---|
| | private final HashMap<String, String> accountToken = new HashMap<>(); //keyがaccountId,valueがtoken |
---|
| | |
---|
| | private final List<IAccountListener> iAccountListeners = new ArrayList<>(); |
---|
| | |
---|
| | public AccountManager() { |
---|
| | dummyAccount(); |
---|
| | } |
---|
| | |
---|
| | public void addListener(IAccountListener iAccountListener) |
---|
| | { |
---|
| | iAccountListeners.add(iAccountListener); |
---|
| | } |
---|
| | |
---|
| | public void dummyAccount() { //ダミーアカウントの作成 |
---|
| | String accountId = "fish"; |
---|
| |
---|
| | |
---|
| | // アカウント情報を全削除する(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); |
---|
| | } |
---|
| | } |
---|
| | } |
---|
| |
---|
| | } |
---|
| | return null; |
---|
| | } |
---|
| | |
---|
| | private void notifyDeletedListener(Account account) |
---|
| | { |
---|
| | for(IAccountListener iAccountListener : iAccountListeners) |
---|
| | { |
---|
| | iAccountListener.accountDeleted(account); |
---|
| | } |
---|
| | } |
---|
| | |
---|
| | } |
---|
| | |
---|
| | |