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 df9eacd..69d7202 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 @@ -21,19 +21,10 @@ // すべてのアカウントを返す @GET @Produces(MediaType.APPLICATION_JSON) - public Collection getAccounts(@QueryParam("uid") Integer uid, @QueryParam("name") String name) { - - // UId一致のアカウントを返却 - if (uid != null) { - var accountsList = new ArrayList(); - var searchAccount = accounts.getAccountByUid(uid); - accountsList.add(searchAccount); - - return accountsList; - } + public Collection getAccounts(@QueryParam("name") String name) { // 名前の一致するアカウントを返す - else if (name != null) return accounts.getAccountsByName(name); + if (name != null) return accounts.getAccountsByName(name); return accounts.getAllAccounts(); } @@ -43,10 +34,11 @@ @GET @Path("/{uid}") @Produces(MediaType.APPLICATION_JSON) - public Account getAccountByUid(@PathParam("uid") Integer uid, @QueryParam("token") String token) { + public Account getAccountByUid(@PathParam("uid") String uidStr, @QueryParam("token") String token) { + var uid = Integer.parseInt(uidStr); var searchAccount = accounts.getAccountByUid(uid); - if (searchAccount.getUid().equals(uid)) throw new WebApplicationException(404); + if (!searchAccount.getUid().equals(uid)) throw new WebApplicationException(404); if (!searchAccount.getToken().equals(token)) throw new WebApplicationException(400); return searchAccount;