> For the complete documentation index, see [llms.txt](https://documenttesting.gitbook.io/ecolog-api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://documenttesting.gitbook.io/ecolog-api-reference/reference/api/post.md).

# 게시물

## 게시물 저장 <a href="#save" id="save"></a>

## 사용자가 작성한 게시물을 저장하는 API

<mark style="color:green;">`POST`</mark> `https://www.eco-log-backend.kro.kr/api/post`

#### Headers

| Name                                    | Type   | Description                                          |
| --------------------------------------- | ------ | ---------------------------------------------------- |
| key<mark style="color:red;">\*</mark>   | String | Authorization                                        |
| value<mark style="color:red;">\*</mark> | String | <p>로그인 시 JWT<br>  - ex. <code>Bearer {토큰}</code></p> |

#### Request Body

| Name                                                  | Type   | Description          |
| ----------------------------------------------------- | ------ | -------------------- |
| behaviorList<mark style="color:red;">\*</mark>        | List   | 사용자가 선택한 실천 ID       |
| customizedBehaviors<mark style="color:red;">\*</mark> | List   | 사용자가 직접 입력한 실천       |
| doingDay<mark style="color:red;">\*</mark>            | String | 게시물을 저장한 일자          |
| comment	<mark style="color:red;">\*</mark>            | String | 유저가 입력한 오늘의 한마디 (소감) |

{% tabs %}
{% tab title="200: OK " %}
{% tabs %}
{% tab title="Schema" %}

**Sample code. 게시물 저장 성공한 경우**

```json
{
	"postId": 2,
	"badgeAchieveList": [
		5
	]
}
```

{% endtab %}
{% endtabs %}
{% endtab %}

{% tab title="400: Bad Request 해당 일자에 이미 발행한 게시물이 존재" %}

```json
{
	"message": "해당 날짜에 이미 게시물이 있습니다."
}
```

{% endtab %}
{% endtabs %}

| 항목               | 타입      | 설명                                                                                                                                                                                                                                                                                                                                                            |
| ---------------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| PostId           | Integer | 저장된 게시물의 ID                                                                                                                                                                                                                                                                                                                                                   |
| badgeAchieveList | List    | <p>게시물 발행 시점 유저가 획득한 뱃지 정보<br>  - 각 뱃지를 번호로 맵핑함<br>  - <code>0</code>: 작심삼일이 모이면<br>  - <code>1</code>: 꾸준함의 재능<br>  - <code>2</code>: 왕발자국<br>  - <code>3</code>: 실천가<br>  - <code>4</code>: 제로웨이스트 고수<br>  - <code>5</code>: 나만의 실천<br>  - <code>6</code>: 웰컴 백<br>  - <code>7</code>: 함께 갈 동료<br>  - <code>8</code>: 작은 마음<br>  - <code>9</code>: 치어 업</p> |

## 게시물 수정 <a href="#edit" id="edit"></a>

## 게시물을 수정할 수 있는 API

<mark style="color:orange;">`PUT`</mark> `https://www.eco-log-backend.kro.kr/api/post/change`

#### Headers

| Name                                    | Type   | Description                                          |
| --------------------------------------- | ------ | ---------------------------------------------------- |
| key<mark style="color:red;">\*</mark>   | String | Authorization                                        |
| value<mark style="color:red;">\*</mark> | String | <p>로그인 시 JWT<br>  - ex. <code>Bearer {토큰}</code></p> |

#### Request Body

| Name                                                  | Type    | Description    |
| ----------------------------------------------------- | ------- | -------------- |
| behaviorList<mark style="color:red;">\*</mark>        | List    | 사용자가 선택한 실천 ID |
| customizedBehaviors<mark style="color:red;">\*</mark> | List    | 사용자가 직접 입력한 실천 |
| comment<mark style="color:red;">\*</mark>             | String  | 수정한 유저 닉네임     |
| postId	<mark style="color:red;">\*</mark>             | Integer | 수정하려는 게시물 ID   |

{% tabs %}
{% tab title="200: OK 수정된 게시물의 ID" %}

{% endtab %}
{% endtabs %}

## 게시물 삭제 <a href="#delete" id="delete"></a>

## 게시물을 삭제할 수 있는 API

<mark style="color:red;">`DELETE`</mark> `https://www.eco-log-backend.kro.kr/api/post`

#### Headers

| Name                                    | Type   | Description                                          |
| --------------------------------------- | ------ | ---------------------------------------------------- |
| key<mark style="color:red;">\*</mark>   | String | Authorization                                        |
| value<mark style="color:red;">\*</mark> | String | <p>로그인 시 JWT<br>  - ex. <code>Bearer {토큰}</code></p> |

#### Request Body

| Name                                      | Type    | Description  |
| ----------------------------------------- | ------- | ------------ |
| postId	<mark style="color:red;">\*</mark> | Integer | 삭제하려는 게시물 ID |

{% tabs %}
{% tab title="200: OK 삭제한 게시물의 ID" %}

{% endtab %}
{% endtabs %}

## 피드 조회 <a href="#feed" id="feed"></a>

## 특정 일자에 저장된 유저 및 팔로워의 일간 게시물을 조회할 수 있는 API

<mark style="color:blue;">`GET`</mark> `https://www.eco-log-backend.kro.kr/api/post/daily?={day}`

특정 일자에 저장된 유저 및 팔로워의 일간 게시물(피드)을 조회할 수 있는 API

#### Path Parameters

| Name                                  | Type   | Description |
| ------------------------------------- | ------ | ----------- |
| day<mark style="color:red;">\*</mark> | String | 조회하려는 일자    |

#### Headers

| Name                                    | Type   | Description                                          |
| --------------------------------------- | ------ | ---------------------------------------------------- |
| key<mark style="color:red;">\*</mark>   | String | Authorization                                        |
| value<mark style="color:red;">\*</mark> | String | <p>로그인 시 JWT<br>  - ex. <code>Bearer {토큰}</code></p> |

{% tabs %}
{% tab title="200: OK " %}
{% tabs %}
{% tab title="Schema" %}

{% endtab %}
{% endtabs %}

```
{
	"postId": 4,
	"userInfo": {
		"userId": 2,
		"userNickname": "앞서가는 활동가",
		"selfIntroduce": "간단한 자기소개글을 적어주세요."
	},
	"customerBehaviorList": [
		"customized 친환경 상점 이용",
		"customized 소비 없는 하루",
		"customized 중고 거래"
	],
	"behaviorList": [
		"친환경 상점 이용",
		"기부와 나눔",
		"손수건 사용"
		"생분해 제품 사용"
	],
	"comment": "한번 팔로우 해보겠습니다.",
	"heartCount": 0,
	"alreadyHeart": false
},
{
	... // 이하 생략
}
```

{% endtab %}
{% endtabs %}

<table><thead><tr><th>항목</th><th width="110">타입</th><th>설명</th></tr></thead><tbody><tr><td>postId</td><td>Integer</td><td>조회하려는 게시물 ID</td></tr><tr><td>userInfo</td><td>String</td><td>게시물을 작성한 유저 정보</td></tr><tr><td>   userId</td><td>Integer</td><td>유저 ID</td></tr><tr><td>   userNickname</td><td>String</td><td>유저 닉네임</td></tr><tr><td>   selfIntroduce</td><td>String</td><td>유저 자기소개</td></tr><tr><td>customerBehaviorList</td><td>List</td><td>유저가 직접 입력한 실천</td></tr><tr><td>behaviorList</td><td>List</td><td>유저가 선택한 실천</td></tr><tr><td>comment</td><td>String</td><td>오늘의 한마디</td></tr><tr><td>heartCount</td><td>Integer</td><td>해당 게시물의 좋아요 개수</td></tr><tr><td>alreadyHeart</td><td>Boolean</td><td>게시물을 조회하는 사용자가 좋아요를 눌렀는지 여부<br>  - <code>true</code>: 좋아요 활성화<br>  - <code>false</code>: 좋아요 비활성화</td></tr></tbody></table>

## 게시물 월 단위 조회 <a href="#monthly" id="monthly"></a>

## 피드 캘린더에 기록 표시바 마킹을 위해 월 단위 게시물을 조회할 수 있는 API

<mark style="color:blue;">`GET`</mark> `https://www.eco-log-backend.kro.kr/api/post/Monthly?month={month}`

#### Path Parameters

| Name                                    | Type   | Description                                        |
| --------------------------------------- | ------ | -------------------------------------------------- |
| month<mark style="color:red;">\*</mark> | String | <p>조회하려는 월<br>  - <code>yyyy-mm</code> 형식으로 입력</p> |

#### Headers

| Name                                    | Type   | Description                                          |
| --------------------------------------- | ------ | ---------------------------------------------------- |
| key<mark style="color:red;">\*</mark>   | String | Authorization                                        |
| value<mark style="color:red;">\*</mark> | String | <p>로그인 시 JWT<br>  - ex. <code>Bearer {토큰}</code></p> |

{% tabs %}
{% tab title="200: OK 해당월에 작성된 게시글의 일자" %}

```
[
	"2022-08-26",
	"2022-08-27",
	"2022-08-30"
]
```

{% endtab %}
{% endtabs %}
