diff --git a/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java b/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java index af3fb10..779fa8b 100644 --- a/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java +++ b/src/main/java/org/ntlab/citrusserver/repositories/BookManager.java @@ -18,9 +18,9 @@ } //本の一覧を返す - public HashMap> getBooks() + public HashMap getBooks(String accountId) { - return booksMap; + return booksMap.get(accountId); } //本の新規作成 diff --git a/src/main/java/org/ntlab/citrusserver/resources/AccountsRest.java b/src/main/java/org/ntlab/citrusserver/resources/AccountsRest.java index 7b1759c..fcc7a81 100644 --- a/src/main/java/org/ntlab/citrusserver/resources/AccountsRest.java +++ b/src/main/java/org/ntlab/citrusserver/resources/AccountsRest.java @@ -20,7 +20,7 @@ accountManager = am; } -///accountの一覧を返す + //accountの一覧を返す @GET @Produces(MediaType.APPLICATION_JSON) public Set getAccount(){ @@ -28,19 +28,19 @@ } -//accountの新規作成 + //accountの新規作成 @POST @Consumes(MediaType.APPLICATION_FORM_URLENCODED)//bodyに入力する値がある時 - public String signup(@FormParam("account_id") String account_id, @FormParam("password") String password) { + public String signup(@FormParam("account_id") String accountId, @FormParam("password") String password) { String token; - token = accountManager.newAccount(account_id, password); + token = accountManager.createAccount(accountId, password); return token; } ////////// @Path("/{account_id}") -//account_idの情報を返す”introduction”と[本] + //account_idの情報を返す”introduction”と[本] @GET @Produces(MediaType.APPLICATION_JSON) public Account getAccountInfo(@PathParam("account_id") String accountId){ //account_idを渡してManegerから値が返ってくる @@ -48,33 +48,33 @@ return ac; } - @DELETE +// @DELETE /////// - @Path("/{account_id}/password") +// @Path("/{account_id}/password") //// // @PUT // // ///////// @Path("/accounts/{account_id}/introduction") -//自己紹介を返す + //自己紹介を返す @GET @Produces(MediaType.APPLICATION_JSON) - public String getAccount(@PathParam("account_id") String account_id){ //account_idを渡してintroductionが返ってくる - String ac = accountManager.AccountIntro(account_id); + public String getAccount(@PathParam("account_id") String accountId){ //account_idを渡してintroductionが返ってくる + String ac = accountManager.AccountIntro(accountId); return ac; } - @PUT +// @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); +// public String getAccount(@PathParam("account_id") String accountId){ //account_idを渡してManegerから値が返ってくる +// Account ac = accountManager.getAccount(accountId); // return ac.getPhoto(); // } // @@ -82,31 +82,31 @@ ///////// @Path("/accounts/{account_id}/favorites") -//お気に入りの本のリストを返す + //指定されたIDのお気に入りの本のリストを返す @GET @Produces(MediaType.APPLICATION_JSON) - public ArrayList> favoriteBook(@PathParam("account_id") String account_id, @QueryParam("token")String token){ - return accountManager.favoriteBook(account_id,token); + public ArrayList> favoriteBook(@PathParam("account_id") String accountId, @QueryParam("token")String token){ + return accountManager.favoriteBook(accountId,token); } //////// @Path("/accounts/{account_id}/favorites/{other_account_id}") -//お気に入りの本のリストを返す + //指定されたIDのお気に入りの本のリストを返す(指定した人物) @GET @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); + public ArrayList FavoriteBook(@PathParam("account_id") String accountId,@PathParam("other_account_id") String otherAccountId,@QueryParam("token")String token){ //account_idを渡してManegerから値が返ってくる + return accountManager.FavoriteBook(accountId,otherAccountId,token); } +////////// +// @Path("/accounts/{account_id}/favorites/{other_account_id}/{book_id}") +// @DELETE +// @PUT //////// - @Path("/accounts/{account_id}/favorites/{other_account_id}/{book_id}") - @DELETE - @PUT -//////// - @Path("/accounts/{account_id}/login") - @POST - @Consumes(MediaType.APPLICATION_JSON) - public void login(@PathParam("account_id") String account_id),@FormParam("password") String password) { - accounts.put(account_id, password); - } +// @Path("/accounts/{account_id}/login") +// @POST +// @Consumes(MediaType.APPLICATION_JSON) +// public void login(@PathParam("account_id") String accountId,@FormParam("password") String password) { +// accountManager.put(accountId, password); +// } } diff --git a/src/main/java/org/ntlab/citrusserver/resources/BooksRest.java b/src/main/java/org/ntlab/citrusserver/resources/BooksRest.java index 99945c0..f5be882 100644 --- a/src/main/java/org/ntlab/citrusserver/resources/BooksRest.java +++ b/src/main/java/org/ntlab/citrusserver/resources/BooksRest.java @@ -14,11 +14,11 @@ @Component -public class BookRest {//BookRestはクラス +public class BooksRest {//BookRestはクラス private final BookManager bookManager; @Autowired //スプリングブートにいうサイン - public BookRest(BookManager bm){ //public クラス名()がコンストラクタ + public BooksRest(BookManager bm){ //public クラス名()がコンストラクタ bookManager = bm; } @@ -27,11 +27,11 @@ private final HashMap> books = new HashMap<>(); @Path("/{account_id}/books") - /// 本一覧を返す + /// その人の本のタイトルとかを返す @GET @Produces(MediaType.APPLICATION_JSON) - public HashMap> getBooks(){ - return bookManager.getBooks(); + public HashMap getBooks(@PathParam("account_id") String account_id){ + return bookManager.getBooks(account_id); } /// {account_id}/books/{book_id} @@ -41,20 +41,19 @@ @GET @Produces(MediaType.APPLICATION_JSON) public Book getBook(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id){ - - return ; + return bookManager.getBook(account_id, book_id); } -/// /{account_id}/books/{book_id}/favorited - @Path("/{account_id}/books/{book_id}/favorited") - - /// いいねしたアカウントを返す - @GET - @Produces(MediaType.APPLICATION_JSON) - public Book getBook(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id){ - Book book = bookManager.getBook(account_id, book_id); - return book; - } +///// /{account_id}/books/{book_id}/favorited +// @Path("/{account_id}/books/{book_id}/favorited") +// +// /// いいねしたアカウントを返す +// @GET +// @Produces(MediaType.APPLICATION_JSON) +// public Book g(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id){ +// Book book = bookManager.getBook(account_id, book_id); +// return book; +// } /// /{account_id}/books/{book_id}/title @@ -63,9 +62,8 @@ /// 本のタイトルを返す @GET @Produces(MediaType.TEXT_PLAIN) - public Book getBook(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id){ - Book book = bookManager.getBook(account_id, book_id); - return book; + public String getTitle(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id){ + return bookManager.getTitle(account_id, book_id); } /// /accounts/{account_id}/books/{book_id}/public @@ -73,10 +71,9 @@ /// 本の公開状態を返す @GET - @Produces(MediaType.APPLICATION_JSON) - public Book getBook(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id){ - Book book = bookManager.getBook(account_id, book_id); - return book; + @Produces(MediaType.TEXT_PLAIN) + public Boolean getPublicity(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id){ + return bookManager.getPublicity(account_id, book_id); } diff --git a/src/main/java/org/ntlab/citrusserver/resources/TodoRest.java b/src/main/java/org/ntlab/citrusserver/resources/TodoRest.java index 5990081..ffea96d 100644 --- a/src/main/java/org/ntlab/citrusserver/resources/TodoRest.java +++ b/src/main/java/org/ntlab/citrusserver/resources/TodoRest.java @@ -45,7 +45,7 @@ @Path("/accounts/{account_id}/books/{book_id}/todos/{year}/{month}") @GET @Produces(MediaType.APPLICATION_JSON) - public HashMap getTodoMonth(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id, @PathParam("year") Integer year, @PathParam("month") Integer month, @QueryParam("token") String token) { + public HashMap> getTodoMonth(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id, @PathParam("year") Integer year, @PathParam("month") Integer month, @QueryParam("token") String token) { return todoManager.getTodosByMonth(account_id, book_id, year, month,token); } @@ -81,13 +81,18 @@ @PUT @Path("/accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}/{todo_id}/check") @Consumes(MediaType.APPLICATION_FORM_URLENCODED) - public void putTodo(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id, @PathParam("year") Integer year, @PathParam("month") Integer month, @PathParam("day") Integer day,@PathParam("todo_id") Integer todo_id, @FormParam("check") boolean check, @QueryParam("token") String token){ + public void setCheck(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id, @PathParam("year") Integer year, @PathParam("month") Integer month, @PathParam("day") Integer day,@PathParam("todo_id") Integer todo_id, @FormParam("check") boolean check, @QueryParam("token") String token){ todoManager.setCheck(account_id, book_id, year, month, day, todo_id,check,token); } //delete追加必要 - - + //本のtodoを年月日とtodo_idを指定してそのtodoを削除する + @DELETE + @Path("/accounts/{account_id}/books/{book_id}/todos/{year}/{month}/{day}/{todo_id}") + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public void deleteTodoById(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id, @PathParam("year") Integer year, @PathParam("month") Integer month, @PathParam("day") Integer day, @PathParam("todo_id") Integer todo_id, @QueryParam("token") String token){ + todoManager.deleteTodoById(account_id, book_id, year, month, day, todo_id,token); + }