diff --git a/src/main/java/org/ntlab/acanthus_server/models/Accounts.java b/src/main/java/org/ntlab/acanthus_server/models/Accounts.java index e4eda11..2a8976e 100644 --- a/src/main/java/org/ntlab/acanthus_server/models/Accounts.java +++ b/src/main/java/org/ntlab/acanthus_server/models/Accounts.java @@ -11,9 +11,9 @@ * */ public class Accounts { - private static Accounts _theInstance = null; + private static Accounts theInstance = null; - private HashMap _accountHashMap = new HashMap<>(); + private HashMap accountHashMap = new HashMap<>(); //----------------------------------------------------------------- // インスタンス生成禁止 @@ -24,8 +24,8 @@ // シングルトン取得 //----------------------------------------------------------------- public static Accounts getInstance() { - if (_theInstance == null) _theInstance = new Accounts(); - return _theInstance; + if (theInstance == null) theInstance = new Accounts(); + return theInstance; } //----------------------------------------------------------------- @@ -33,14 +33,14 @@ // Uidからアカウントを返す //----------------------------------------------------------------- public Account getAccountByUid(int uid) { - return _accountHashMap.get(uid); + return accountHashMap.get(uid); } //----------------------------------------------------------------- // e-Mailからアカウントを返す //----------------------------------------------------------------- public Account getAccountByEMail(String email) { - for (var account : _accountHashMap.values()) { + for (var account : accountHashMap.values()) { if (account.getEmail().equals(email)) return account; } return null; @@ -48,13 +48,15 @@ //----------------------------------------------------------------- //accountを全て返す public Collection getAllAccounts(){ - return _accountHashMap.values(); + return accountHashMap.values(); } + //----------------------------------------------------------------- //accountを追加する - public int resistAccount(String name, String email, String password){ + public int registAccount(String name, String email, String password){ var newAccount = new Account(name, email, password); var uid = new Random().nextInt(); - _accountHashMap.put(uid,newAccount); + + accountHashMap.put(uid,newAccount); return uid; } diff --git a/src/main/java/org/ntlab/acanthus_server/resources/accounts/AccountsRest.java b/src/main/java/org/ntlab/acanthus_server/resources/accounts/AccountsRest.java index 9128c74..2b183cb 100644 --- a/src/main/java/org/ntlab/acanthus_server/resources/accounts/AccountsRest.java +++ b/src/main/java/org/ntlab/acanthus_server/resources/accounts/AccountsRest.java @@ -12,15 +12,19 @@ @Path("/accounts") public class AccountsRest { private Accounts accounts = Accounts.getInstance(); + + //----------------------------------------------------------------- @GET @Produces(MediaType.APPLICATION_JSON) public Collection getAccounts(@QueryParam("uid") int uid, @QueryParam("token") String token) { return accounts.getAllAccounts(); } + + //----------------------------------------------------------------- @POST @Produces(MediaType.APPLICATION_JSON) public int createAccount(@FormParam("name") String name , @FormParam("email") String email, @FormParam("password") String password){ - return accounts.resistAccount(name,email,password); + return accounts.registAccount(name,email,password); } } diff --git a/src/main/java/org/ntlab/acanthus_server/resources/accounts/LoginRest.java b/src/main/java/org/ntlab/acanthus_server/resources/accounts/LoginRest.java index 461387e..6882981 100644 --- a/src/main/java/org/ntlab/acanthus_server/resources/accounts/LoginRest.java +++ b/src/main/java/org/ntlab/acanthus_server/resources/accounts/LoginRest.java @@ -13,7 +13,6 @@ private Accounts accounts = Accounts.getInstance(); //----------------------------------------------------------- - /** * ログイン時のトークン認証 * アカウントが存在して, かつトークンを持っているかを確認する @@ -31,7 +30,6 @@ } //----------------------------------------------------------- - /** * ログイン時, トークンをアカウントに発行させる *