Newer
Older
CitrusServer / src / main / java / org / ntlab / citrusserver / resources / BooksRest.java
package org.ntlab.citrusserver.resources;

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")
@Component


public class BookRest {//BookRestはクラス

    private final BookManager bookManager;
    @Autowired //スプリングブートにいうサイン
    public BookRest(BookManager bm){ //public クラス名()がコンストラクタ
        bookManager = bm;
    }


/// {account_id}/books
    private final HashMap<String, HashMap<Integer, Book>> books = new HashMap<>();
    @Path("/{account_id}/books")

  /// 本一覧を返す
    @GET
    @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}")

  ///






}