diff --git a/src/main/java/org/ntlab/citrusserver/resources/AccountsRest.java b/src/main/java/org/ntlab/citrusserver/resources/AccountsRest.java index c6d54d3..7b1759c 100644 --- a/src/main/java/org/ntlab/citrusserver/resources/AccountsRest.java +++ b/src/main/java/org/ntlab/citrusserver/resources/AccountsRest.java @@ -5,6 +5,8 @@ import org.ntlab.citrusserver.repositories.AccountManager; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; + +import java.util.ArrayList; import java.util.HashMap; import java.util.Set; @@ -19,19 +21,20 @@ } ///accountの一覧を返す - private HashMap accounts = new HashMap<>(); @GET @Produces(MediaType.APPLICATION_JSON) public Set getAccount(){ - return accounts.keySet(); + return accountManager.getAccountsID(); } //accountの新規作成 @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED)//bodyに入力する値がある時 - public void signup(@FormParam("account_id") String account_id, @FormParam("password") String password) { - accounts.put(account_id, password); + public String signup(@FormParam("account_id") String account_id, @FormParam("password") String password) { + String token; + token = accountManager.newAccount(account_id, password); + return token; } ////////// @@ -39,7 +42,8 @@ //account_idの情報を返す”introduction”と[本] @GET - public Account getAccount(@PathParam("account_id") String accountId){ //account_idを渡してManegerから値が返ってくる + @Produces(MediaType.APPLICATION_JSON) + public Account getAccountInfo(@PathParam("account_id") String accountId){ //account_idを渡してManegerから値が返ってくる Account ac = accountManager.getAccount(accountId); return ac; } @@ -49,49 +53,49 @@ /////// @Path("/{account_id}/password") +//// +// @PUT // - @PUT - - -/////// +// +///////// @Path("/accounts/{account_id}/introduction") //自己紹介を返す @GET + @Produces(MediaType.APPLICATION_JSON) public String getAccount(@PathParam("account_id") String account_id){ //account_idを渡してintroductionが返ってくる - Account ac = accountManager.getAccount(account_id); - return ac.getIntroduction(); + String ac = accountManager.AccountIntro(account_id); + return ac; } @PUT ///////// - @Path("/accounts/{account_id}/photo") -//画像を返す - @GET - public String getAccount(@PathParam("account_id") String account_id){ //account_idを渡してManegerから値が返ってくる - Account ac = accountManager.getAccount(account_id); - return ac.getPhoto(); - } - - @PUT +// @Path("/accounts/{account_id}/photo") +////画像を返す +// @GET +// public String getAccount(@PathParam("account_id") String account_id){ //account_idを渡してManegerから値が返ってくる +// Account ac = accountManager.getAccount(account_id); +// return ac.getPhoto(); +// } +// +// @PUT ///////// @Path("/accounts/{account_id}/favorites") //お気に入りの本のリストを返す @GET - public String getAccount(@PathParam("account_id") String account_id,@QueryParam("token")String token){ //account_idを渡してManegerから値が返ってくる - Account ac = accountManager.getAccount(account_id,token); - return ac.getFavorites(); + @Produces(MediaType.APPLICATION_JSON) + public ArrayList> favoriteBook(@PathParam("account_id") String account_id, @QueryParam("token")String token){ + return accountManager.favoriteBook(account_id,token); } - //////// @Path("/accounts/{account_id}/favorites/{other_account_id}") //お気に入りの本のリストを返す @GET - public String getAccount(@PathParam("account_id") String account_id,@PathParam("other_account_id") String other_account_id,@QueryParam("token")String token){ //account_idを渡してManegerから値が返ってくる - Account ac = accountManager.getAccount(account_id,other_account_id,token); - return ac.getFavoritesBookId(); + @Produces(MediaType.APPLICATION_JSON) + public ArrayList FavoriteBook(@PathParam("account_id") String account_id,@PathParam("other_account_id") String other_account_id,@QueryParam("token")String token){ //account_idを渡してManegerから値が返ってくる + return accountManager.FavoriteBook(account_id,other_account_id,token); } ////////