# DB
- user
- id
- name
- mail
- password
- profile
- path(picture)
- point
- exsercise
- id
- name
- menu
- id
- userId(FK)
- title
- body
- path(movie)
- nice
- point
- ExercisePart (menu_exsercise 中間テーブル)
- id
- exserciseId(FK)
- menuId(FK)
- no
- time
- Favorite(user_menu 中間テーブル)
- id
- userId(FK)
- menuId(FK)
- Follow(user_user 中間テーブル)
- id
- follower:userId(FK)
- followed:userId(FK)
- log
- id
- userId(FK)
- date
- menuId(FK)
# API
## user
- [x] `POST` user/create ユーザー作成 (S)
ユーザーを作成するAPI。メール、ユーザー名、パスワードを以下のようにjsonフォーマットで渡してほしい。
#### Request
application/json
```
{
"mail":"kato@gmail.com",
"username":"nanashi",
"password":"hogehoge"
}
```
#### Response
Status Codeで成否を返す。
Status Codeが200番(成功)でなければ、エラーを表示する。以下同様。
### user/:userId
- [x] `GET` user/:userId 指定したユーザーのプロフィールを取得
##### Request
{
"userId":"c77be640-c88e-4d36-b7c1-65110ad2df68"
}
##### Response
```
{
"id":"c77be640-c88e-4d36-b7c1-65110ad2df68",
"name":"naanshi",
"profile":"頑張っています",
"point":157,
"level":4,
"status":マッチョ見習い
}
```
- [x] `PATCH` user/:userId/username ユーザー名を更新
##### Request
```
{
"username":"nanashi2"
}
```
##### Response
Status Code
- [x] `PATCH` user/:userId/profile 自己紹介文を更新
##### Request
json
```
{
"profile":"そろそろ本気だす"
}
```
##### Response
Status Code
##### Response
Status Code
### /menu
- [x] `POST` /user/:userId/menu 運動メニューを追加
json
```
{
"title":"タイトル",
"body":"細かい説明",
"exerciseId":"3fa85f64-5717-4562-b3fc-2c963f66afa6",
"time":5
}
```
### /log
- [x] `GET` /user/:userId/log 運動記録を取得
→ `GET` /timeline/:userId として実装
- [x] `POST` /user/:userId/log/:menuId 運動記録を追加
##### Req
```
{}
```
### Res
Status Code
### /favorite
- [x] `GET` /user/:userId/favorite 星をつけたメニューを取得
##### Response
```
{
{
"menuId":"3fa85f64-5717-4562-b3fc-2c963f66afa6"
"title":"タイトル"
"userId":"3fa85f64-5717-4562-b3fc-2c963f66afa6"
"username":"メニュー作成者"
"body":"細かい説明"
"nice":10
"point":10
"exercise":{
"exerciseId":"3fa85f64-5717-4562-b3fc-2c963f66afa6",
"exerciseName":"筋トレ"
}
},
{
"menuId":"3fa85f64-5717-4562-b3fc-2c963f66afa6"
"title":"タイトル"
"userId":"3fa85f64-5717-4562-b3fc-2c963f66afa6"
"username":"メニュー作成者"
"body":"細かい説明"
"nice":10
"point":10
"exercise":{
"exerciseId":"3fa85f64-5717-4562-b3fc-2c963f66afa6",
"exerciseName":"筋トレ"
}
}
}
```
- [x] `POST` /user/:userId/favorite/:menuId 星をつけたメニューの追加
##### Request
```
{}
```
##### Response
Status Code
## Search
- [x] `GET` /search?word={検索ワード} メニューを取得
検索する時も、このAPIを用いる。クエリで検索ワードを渡す。urlについてる `/?search={ここに検索ワードが入る}` で渡す
query word
#### Response
最大5人のユーザーと最大5個のメニューを返却する
```
{
"menus":[
{
"menuId":"3fa85f64-5717-4562-b3fc-2c963f66afa6"
"title":"タイトル"
"userId":"3fa85f64-5717-4562-b3fc-2c963f66afa6"
"username":"メニュー作成者"
"body":"細かい説明"
"nice":10
"point":10
"exercise":{
"exerciseId":"3fa85f64-5717-4562-b3fc-2c963f66afa6",
"exerciseName":"筋トレ"
}
},
{
"menuId":"3fa85f64-5717-4562-b3fc-2c963f66afa6"
"title":"タイトル"
"userId":"3fa85f64-5717-4562-b3fc-2c963f66afa6"
"username":"メニュー作成者"
"body":"細かい説明"
"nice":10
"point":10
"exercises":{
"exerciseId":"3fa85f64-5717-4562-b3fc-2c963f66afa6",
"exerciseName":"筋トレ"
}
}
]
}
```
## exercise
- [x] `GET` /exercise エクササイズ一覧を取得
Res
```
{
"exercises":[
{
"ID": "fde8b72a-2f94-11ed-8335-0242ac170004",
"Name": "腹筋"
},
{
"ID": "fde945bc-2f94-11ed-8335-0242ac170004",
"Name": "スクワット"
},
{
"ID": "fde9a4b8-2f94-11ed-8335-0242ac170004",
"Name": "腕立てふせ"
}
]
}
```
## timeline
- [x] `GET` /timeline 全ての人の運動記録を取得
- [x] `GET` /timeline/:userId 自分の運動記録を取得
#### Res
```
{
"userId":"3fa85f64-5717-4562-b3fc-2c963f66afa6",
"username":"nanashi",
"menu":{
"menuId":"3fa85f64-5717-4562-b3fc-2c963f66afa6"
"title":"タイトル"
"userId":"3fa85f64-5717-4562-b3fc-2c963f66afa6"
"username":"メニュー作成者"
"body":"細かい説明"
"nice":10
"point":10
"exercise":{
"exerciseId":"3fa85f64-5717-4562-b3fc-2c963f66afa6",
"exerciseName":"筋トレ"
}
},
"date":"2006-01-02T15:04:05Z"
}
```
## auth
- [x] `POST` /auth/login ログイン
#### Request
```
{
"mail":"00000@gmail.com"
"password":"hogehoge"
}
```
#### Res
```
{"userId":"3fa85f64-5717-4562-b3fc-2c963f66afa6"}
```
#### Response
- [x] `POST` /auth/logout ログアウト
#### Request
なし
#### Reaponse
なし
## メモ
```
docker compose up -d --build ⇔ docker compose down
```
```
exit dockerから抜ける
```
```
docker-compose exec サービス名 bash コンテナに入る
```
```
go run main.go
```
```
sudo docker compose up -d --build
```
https://qiita.com/gold-kou/items/45a95d61d253184b0f33
### menuを返す時
{
"menuId":"3fa85f64-5717-4562-b3fc-2c963f66afa6"
"title":"タイトル"
"userId":"3fa85f64-5717-4562-b3fc-2c963f66afa6"
"username":"メニュー作成者"
"body":"細かい説明"
"nice":10
"point":10
"exercise":{
"exerciseId":"3fa85f64-5717-4562-b3fc-2c963f66afa6",
"exerciseName":"筋トレ"
}
}