diff --git a/src/main/java/org/ntlab/citrusserver/resources/BooksRest.java b/src/main/java/org/ntlab/citrusserver/resources/BooksRest.java index 57e5a44..1c7ac5d 100644 --- a/src/main/java/org/ntlab/citrusserver/resources/BooksRest.java +++ b/src/main/java/org/ntlab/citrusserver/resources/BooksRest.java @@ -1,14 +1,13 @@ package org.ntlab.citrusserver.resources; -import jakarta.ws.rs.GET; -import jakarta.ws.rs.Path; -import jakarta.ws.rs.Produces; +import jakarta.ws.rs.*; import jakarta.ws.rs.core.MediaType; import org.ntlab.citrusserver.entities.Book; import org.ntlab.citrusserver.repositories.BookManager; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import java.util.HashMap; @Path("/accounts") @@ -17,19 +16,93 @@ public class BookRest {//BookRestはクラス - private final BookManager bookManeger; + private final BookManager bookManager; @Autowired //スプリングブートにいうサイン - public BookRest(bookManeger bm){ //public クラス名()がコンストラクタ - bookManeger = bm; //bookManagerって変数? + public BookRest(BookManager bm){ //public クラス名()がコンストラクタ + bookManager = bm; } - @Path("/{account_id}/books/{book_id}") -/// 本の情報を取得 +/// {account_id}/books + private final HashMap> books = new HashMap<>(); + @Path("/{account_id}/books") + + /// 本一覧を返す @GET - @Produces(MediaType.APPLICATION_JSON) //returnの形をどうするか - public Book getBook(@PathParam("account_id") String account_id, @PathParam("book_id") Integer book_id){ - Book book = bookManeger.getBook(account_id, book_id); + @Produces(MediaType.APPLICATION_JSON) + public Book getBook(@PathParam("account_id") String account_id){ + Book book = bookManager.getBook(account_id); return book; } + /// 本の新規作成 + @POST + @Consumes(MediaType.APPLICATION_JSON) + +/// {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){ + Book book = bookManager.getBook(account_id, book_id); + return book; + } + /// 本の削除 + @DELETE + +/// /{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/{other_account_id} + @Path("/{account_id}/books/{book_id}/favorited/{other_account_id}") + /// いいねした人を追加 + @PUT + + /// いいねしたアカウントの削除 + @DELETE + +/// /{account_id}/books/{book_id}/title + @Path("/{account_id}/books/{book_id}/title") + + /// 本のタイトルを返す + @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; + } + /// 本のタイトル変更 + @PUT + +/// /accounts/{account_id}/books/{book_id}/public + @Path("/{account_id}/books/{book_id}/public") + + /// 本の公開状態を返す + @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; + } + /// 公開状態を変更する + @PUT + +/// /accounts/{account_id}/books/{book_id}/goals/{year}/{month} + @Path("/accounts/{account_id}/books/{book_id}/goals/{year}/{month}") + + /// + + + + + + } \ No newline at end of file