# 보드 API

## &#x20;게시물 불러오기

<mark style="color:blue;">`GET`</mark> `http://sejabo.com/get_posts/<string:build>`

&#x20;게시물들을 불러오는 API이다. build 인자에 지정된 건물명을 넘겨 해당 건물에 등록된 모든 게시물을 조회한다. 인자가 입력되지 않을 경우, 모든 건물의 게시물을 불러오는 것으로 취급한다.

#### Path Parameters

| Name  | Type   | Description                                   |
| ----- | ------ | --------------------------------------------- |
| build | string | <p>보여질 대상의 건물 게시판<br>입력하지 않을 경우, all로 취급.</p> |

{% tabs %}
{% tab title="200 " %}

```coffeescript
//날짜는 ISODATE 규격
{
    "result":"success",
    "post_list":<array:json>{
        "post_id":<int>,
        "author_name":<string>,
        "author_id":<int>,
        "author_major":<string>,
        "title":<string>,
        "content"<string>,
        "reg_date":<string>,
        "exp_date":<string>,
        "like_count":<int>,
        "dislike_count":<int>,
        "url":<string>,
        "img_url":<string>,
        "size":<int>,
        "build_yul":<int>,
        "build_dae":<int>,
        "build_hak":<int>,
        "build_gwang":<int>,
        "build_count":<int>,
        "color":<string>
    }
}
```

{% endtab %}

{% tab title="400  해당 건물명이 존재하지 않을 경우" %}

```coffeescript
{
    "result":"bad request"
}
```

{% endtab %}
{% endtabs %}

## 게시물 조회수 증가

<mark style="color:blue;">`GET`</mark> `http://sejabo.com/view_add/<int:post_id>`

&#x20;게시물의 조회수를 1 상승시킨다.

#### Path Parameters

| Name     | Type   | Description     |
| -------- | ------ | --------------- |
| post\_id | number | 조회수를 올릴 게시물 아이디 |

{% tabs %}
{% tab title="200 " %}

```coffeescript
{
   "result":"success"
}
```

{% endtab %}

{% tab title="400  해당 게시물 아이디가 존재하지 않을 경우" %}

```coffeescript
{
    "result":"bad request"
}
```

{% endtab %}
{% endtabs %}

## 게시물 호감/비호감 등록

<mark style="color:blue;">`GET`</mark> `http://sejabo.com/like/<int:post_id>/<int:interest>`

&#x20;해당 게시물에 대한 좋아요/싫어요 등록 기능을 수행하는 API이다.  이미 등록된 경우 혹은 호감/비호감 간의 이동이 있을 경우, 그대로 갱신한다.

#### Path Parameters

| Name     | Type   | Description                           |
| -------- | ------ | ------------------------------------- |
| post\_id | number | 게시물 아이디                               |
| interest | number | <p> 호감/비호감 상태<br>1: 좋아요<br>0: 싫어요</p> |

#### Headers

| Name          | Type   | Description |
| ------------- | ------ | ----------- |
| Authorization | string | JWT 토큰      |

{% tabs %}
{% tab title="200 1. 게시물에 대한 아무런 등록이 안되어 있을때, 호감/비호감 간의 전환이 있을때
2\. 이미 호감을 등록한 게시물에 똑같은 호감을 등록할 때" %}

```coffeescript
1.
{
   "result":"success"
}
2.
{
   "result":"success",
   "comment":"aleady"
}
```

{% endtab %}

{% tab title="400  1. 해당 게시물 아이디가 존재하지 않을 경우
2\. 잘못된 호감/비호감 상태가 입력된 경우" %}

```coffeescript
{
    "result":"bad request"
}
```

{% endtab %}
{% endtabs %}

## 게시물 검색

<mark style="color:blue;">`GET`</mark> `http://sejabo.com/search/<string:words>`

&#x20;게시물에 대한 검색 기능을 수행하는 API이다. 검색 문자열이 게시물의 제목, 내용, 작성자의 이름, 학번, 학과 정보 중, 어느 한곳이라도 포함된다면 해당 게시물들을 반환한다.

#### Path Parameters

| Name  | Type   | Description |
| ----- | ------ | ----------- |
| words | string | 검색어         |

{% tabs %}
{% tab title="200 " %}

```coffeescript
//날짜는 ISODATE 규격
{
    "result":"success",
    "post_list":<array:json>{
        "post_id":<int>,
        "author_name":<string>,
        "author_id":<int>,
        "author_major":<string>,
        "title":<string>,
        "content"<string>,
        "reg_date":<string>,
        "exp_date":<string>,
        "like_count":<int>,
        "dislike_count":<int>,
        "url":<string>,
        "img_url":<string>,
        "size":<int>,
        "build_yul":<int>,
        "build_dae":<int>,
        "build_hak":<int>,
        "build_gwang":<int>,
        "build_count":<int>,
        "color":<string>
    }
}
```

{% endtab %}

{% tab title="400  잘못된 검색어 입력이 되었을 경우" %}

```coffeescript
{
    "result":"bad request"
}
```

{% endtab %}
{% endtabs %}

## &#x20;단일 게시물 정보 반환

<mark style="color:blue;">`GET`</mark> `http://sejabo.com/v/<int:post_id>`

&#x20; 단일 게시물에 대한 조회 기능을 수행하는 API이다. 외부 링크를 생성해 타 서비스에서 공유하기 위해 사용된다.

#### Path Parameters

| Name     | Type   | Description |
| -------- | ------ | ----------- |
| post\_id | number | 게시물 아이디     |

{% tabs %}
{% tab title="200 " %}

```coffeescript
//날짜는 ISODATE 규격
{
    "result":"success",
    "post":<json>{
        "post_id":<int>,
        "author_name":<string>,
        "author_id":<int>,
        "author_major":<string>,
        "title":<string>,
        "content"<string>,
        "reg_date":<string>,
        "exp_date":<string>,
        "like_count":<int>,
        "dislike_count":<int>,
        "url":<string>,
        "img_url":<string>,
        "size":<int>,
        "build_yul":<int>,
        "build_dae":<int>,
        "build_hak":<int>,
        "build_gwang":<int>,
        "build_count":<int>,
        "color":<string>
    }
}
```

{% endtab %}

{% tab title="400  잘못된 검색어 입력이 되었을 경우" %}

```coffeescript
{
    "result":"bad request"
}
```

{% endtab %}
{% endtabs %}
