diff --git a/src/main/java/org/ntlab/citrusserver/resources/BooksRest.java b/src/main/java/org/ntlab/citrusserver/resources/BooksRest.java index badab34..3132746 100644 --- a/src/main/java/org/ntlab/citrusserver/resources/BooksRest.java +++ b/src/main/java/org/ntlab/citrusserver/resources/BooksRest.java @@ -14,18 +14,17 @@ @Component -public class BooksRest {//BookRestはクラス +public class BooksRest { // BookRestはクラス private final BookManager bookManager; - @Autowired //スプリングブートにいうサイン + @Autowired // スプリングブートにいうサイン public BooksRest(BookManager bm){ //public クラス名()がコンストラクタ bookManager = bm; } -/// {account_id}/books private final HashMap> books = new HashMap<>(); - +/// {account_id}/books /// その人の本のタイトルとかを返す @Path("/{account_id}/books") @GET @@ -43,51 +42,61 @@ /// {account_id}/books/{book_id} - @Path("/{account_id}/books/{book_id}") - /// 本の情報を取得 + @Path("/{account_id}/books/{book_id}") @GET @Produces(MediaType.APPLICATION_JSON) public Book getBook(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id){ 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 g(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id){ -// Book book = bookManager.getBook(account_id, book_id); -// return book; -// } - + /// 本の削除 + @Path("/{account_id}/books/{book_id}") + @DELETE + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public void deleteTodoById(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id){ + bookManager.deleteBook(account_id, book_id); + } /// /{account_id}/books/{book_id}/title - @Path("/{account_id}/books/{book_id}/title") - /// 本のタイトルを返す + @Path("/{account_id}/books/{book_id}/title") @GET @Produces(MediaType.TEXT_PLAIN) 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 - @Path("/{account_id}/books/{book_id}/public") + /// 本のタイトル変更 + @Path("/{account_id}/books/{book_id}/title") + @PUT + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public void putTitle(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id, @FormParam("title") String title){ + bookManager.putTitle(account_id, book_id, title); + } +/// /accounts/{account_id}/books/{book_id}/public /// 本の公開状態を返す + @Path("/{account_id}/books/{book_id}/public") @GET @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); } + /// 公開情報を変更する + @Path("/{account_id}/books/{book_id}/public") + @PUT + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public void putPublicity(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id, @FormParam("publicity") Boolean publicity){ + bookManager.putPublicity(account_id, book_id, publicity); + } - - - - - +/// /accounts/{account_id}/books/{book_id}/color + /// 公開情報を変更する + @Path("/{account_id}/books/{book_id}/color") + @PUT + @Consumes(MediaType.APPLICATION_FORM_URLENCODED) + public void putColor(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id, @FormParam("color") String color){ + bookManager.putColor(account_id, book_id, color); + } } \ No newline at end of file