hirodesu85 / GIFTech2024_backend

0 stars 0 forks source link

アイテム一覧APIの作成 #16

Closed ryichk closed 4 months ago

ryichk commented 4 months ago

APIの詳細

所持している靴や髪型の一覧が取得できるAPI

URL

GET /api/items

リクエスト

ソートはクライアント側で行うためリクエストパラメータは不要。

~(未確定)~ ~order(string)~ ~- updated_at_desc (入手日_降順)~ ~- updated_at_asc (入手日_昇順)~ ~- name_desc (名前_降順)~ ~- name_asc (名前_昇順)~

~クエリパラメータ~ ~?order=updated_at_desc~

レスポンス

形式はJSON

{
  "hairs": [
    {
      "id" 1,
      "name": "エメラルドのツインテール",
      "image_url": "https://hoge.image.no.url.desu",
      "gained_at": "2024-04-18T12:34:56Z"
    },
    {
      "id" 2,
      "name": "ルビーのツインテール",
      "image_url": "https://hoge.image.no.url.desu",
      "gained_at": "2024-04-19T12:34:56Z"
    }
  ],
  "shoes": [
    {
      "id" 1,
      "name": "黒い靴",
      "image_url": "https://hoge.image.no.url.desu",
      "gained_at": "2024-04-18T12:34:56Z"
    },
    {
      "id" 2,
      "name": "青い靴",
      "image_url": "https://hoge.image.no.url.desu",
      "gained_at": "2024-04-19T12:34:56Z"
    },
  ],
  "bottoms": [
    {
      "id" 1,
      "name": "ピンクのスカート",
      "image_url": "https://hoge.image.no.url.desu",
      "gained_at": "2024-04-18T12:34:56Z"
    },
    {
      "id" 2,
      "name": "オレンジのスカート",
      "image_url": "https://hoge.image.no.url.desu",
      "gained_at": "2024-04-19T12:34:56Z"
    },
  ],
  "tops": [
    {
      "id" 1,
      "name": "甲冑",
      "image_url": "https://hoge.image.no.url.desu",
      "gained_at": "2024-04-18T12:34:56Z"
    },
    {
      "id" 2,
      "name": "かわいいTシャツ",
      "image_url": "https://hoge.image.no.url.desu",
      "gained_at": "2024-04-19T12:34:56Z"
    },
  ]
}

TODO

必要なモデル

shoes

hair

tops

bottoms

ryichk commented 4 months ago

アイテムの数が多くないので、1つのAPIで全ての種類のアイテムを返してしまって良いかなと思っています。

確認したいこと ・アイテム一覧画面で、現在どのアイテムを装備しているかわかるようにする必要はありますか?

Yoshino-Yukitaro commented 4 months ago

アイテム一覧画面で、現在どのアイテムを装備しているかわかるようにする必要はありますか?

これは鈴木さんに確認した方が良いですね!これが必要だったらbeauty_girlsテーブルの参照とレスポンスの修正が必須になりそうです 👀

ryichk commented 4 months ago

アイテム一覧画面で、現在どのアイテムを装備しているかわかるようにする必要はありますか?

これは鈴木さんに確認した方が良いですね!これが必要だったらbeauty_girlsテーブルの参照とレスポンスの修正が必須になりそうです 👀

@Yoshino-Yukitaro アイテム一覧画面で、現在どのアイテムを装備しているかわかるようにする必要あるようです :pray: beauty_girlsテーブルの参照とレスポンスの修正について、どのようなイメージでしょうか?

アイテム一覧APIのレスポンスは↓のように考えています。

{
  "hairs": [
    {
      "id": 1,
      "name": "エメラルドのツインテール",
      "image_url": "https://hoge.image.no.url.desu",
      "is_equipped": true
    },
    {
      "id" 2,
      "name": "ルビーのツインテール",
      "image_url": "https://hoge.image.no.url.desu",
      "is_equipped": false
    }
  ],
...
Yoshino-Yukitaro commented 4 months ago

@ryichk すみません今更メンションに気づきました 💦 市来さんが書いてくださったのと同様のイメージをしていました!

ryichk commented 4 months ago

@Yoshino-Yukitaro いえいえ! :pray: 了解です 🙆‍♂️ じゃあ一旦このままアイテム一覧APIの作成を進めてみますね 👍

ryichk commented 4 months ago

:memo:

ryichk commented 4 months ago

:memo: APIのURLを変更します :pray: GET /api/beauty-girls/${id}/itemsGET /api/items

理由は、現状女の子は一人だけで増えることもなさそうなので、beauty_girlsのリソースを経由する必要もないですし、URLをシンプルにしたいからです。