---
# System prepended metadata

title: API說明文件
tags: [Smart Construction]

---

API說明文件
===
[TOC]
###### tags: `Smart Construction`

# Host
- Main Server
    - Development: `http://localhost:3000/`
    - Production: `http://35.221.204.113:3000/`
- Object Detection Server
    - Production: `http://34.80.209.101:8000/predict`


# auth: 身份認證

## `POST`/auth/register : ==使用者註冊==
### Request
:::info
#### HEADERS
`Content-Type:application/json`
#### BODY
```json
{
    "name": "Cody Chen",
    "corporation": "臺大BIM中心",
    "email": "cdxvy30@caece.net",
    "password": "123",
}
```
:::
### Response
:::success
#### STATUS
`200`
#### HEADERS
`Content-Type:application/json`
#### BODY
```json
{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkNWIxZGNkOS0xNThlLTQ0MjYtOTAyZC04ZTY4MmZiOGNkM2QiLCJpYXQiOjE2NzM2MDYzNDEsImV4cCI6MTY3MzY5Mjc0MX0.Q7Z_dj6nuI1Gd2j6_UKjw4P8Ci8-sNUQ5r3S05c1Khg",
    "user": {
        "uuid": "d5b1dcd9-158e-4426-902d-8e682fb8cd3d",
        "name": "Cody Chen",
        "corporation": "臺大BIM中心",
        "email": "cdxvy30@caece.net",
        "permission": "訪客",
        "job": "訪客"
    }
}
```
:::

:::danger
#### STATUS
`401`
#### HEADERS
`Content-Type:application/json`
#### BODY
```json
{
    "使用者已存在"
}
```
:::


## `POST`/auth/login : ==使用者登入==
### Request
:::info
#### HEADERS
`Content-Type:application/json`
#### BODY
```json
{
    "email": "cdxvy30@caece.net",
    "password": "123"
}
```
:::
### Response
:::success
#### STATUS
`200`
#### HEADERS
`Content-Type:application/json`
#### BODY
```json
{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJkNWIxZGNkOS0xNThlLTQ0MjYtOTAyZC04ZTY4MmZiOGNkM2QiLCJpYXQiOjE2NzM2MDYzNDEsImV4cCI6MTY3MzY5Mjc0MX0.Q7Z_dj6nuI1Gd2j6_UKjw4P8Ci8-sNUQ5r3S05c1Khg",
    "user": {
        "uuid": "d5b1dcd9-158e-4426-902d-8e682fb8cd3d",
        "name": "Cody Chen",
        "corporation": "臺大BIM中心",
        "email": "cdxvy30@caece.net",
        "permission": "管理員",
        "job": "開發人員"
    }
}
```
:::
:::danger
#### STATUS
`401`
#### HEADERS
`Content-Type:application/json`
#### BODY
```json
{
    "使用者不存在或密碼錯誤"
}
```
:::


## `POST`/auth/logout : ==使用者登出==
### Request
:::info
#### AUTHORIZATION
`Type:Bearer Token`
#### HEADERS
`Content-Type:application/json`
#### BODY
```json
{
    "user_uuid": "d5b1dcd9-158e-4426-902d-8e682fb8cd3d"
}
```
:::
### Response
:::success
#### STATUS
`200`
#### HEADERS
`Content-Type:application/json`
#### BODY
```json
{
    "您已登出"
}
```
:::

# users : 獲取使用者清單
## `GET`/users/all : ==[管理員]獲取所有使用者==
### Request
:::info
#### AUTHORIZATION
`Type:Bearer Token`
#### HEADERS
`Content-Type:application/json`
#### BODY
`NULL`
:::
### Response
:::success
#### STATUS
`200`
#### HEADERS
`Content-Type:application/json`
#### BODY
```json
[
    {
        "user_id": "41d4a21f-67f7-4bb4-a3c8-38585f20ded1",
        "user_name": "林之謙",
        "user_corporation": "臺大BIM中心",
        "user_permission": "管理員",
        "user_job": "教授"
    },
    ...
]
```
:::

## `GET`/users/:corporation : ==[公司負責人]獲取公司內所有使用者==
### Request
:::info
#### AUTHORIZATION
Type: Bearer Token
#### HEADERS
`Content-Type:application/json`
#### BODY
`NULL`
#### PARAMETERS
`corporation`: String of corporation name.
:::
### Response
:::success
#### STATUS
`200`
#### HEADERS
`Content-Type:application/json`
#### BODY
```json
[
    {
        "user_id": "81c46dda-efab-462e-9845-2bd39ace8b33",
        "user_name": "葉奕昌",
        "user_corporation": "豐譽營造股份有限公司",
        "user_permission": "專案管理員",
        "user_job": "專任工程人員"
    },
    ...
]
```
:::


# projects : 新增、獲取、刪除、編輯專案
## `POST`/projects : ==新增專案==
### Request
:::info
#### AUTHORIZATION
Type: Bearer Token
#### HEADERS
`Content-Type:multipart/form-data`
#### BODY
```json
{
    "metadata": {
      "name": "國立台灣大學人文館",
      "address": "臺北市大安區新生南路三段",
      "corporation": "豐譽營造股份有限公司",
      "manager": "陳仁崇",
      "inspector": "陳仁崇",
      "email": "fyAdminA@gmail.com"
    },
    "project_thumbnail": file
}
```
:::
### Response
:::success
#### STATUS
`200`
#### HEADERS
`Content-Type:application/json`
#### BODY
```json
{
    "path": "images/豐譽營造股份有限公司_國立台灣大學人文館_thumbnail.jpg",
    "message": "新增成功"
}
```
:::

## `GET`/projects/all : ==[管理員]獲取所有專案==


## `GET`/projects/:corporation : ==獲取專案==


## `GET`/projects/thumbnail/:id : ==獲取專案縮圖==


## `DELETE`/projects/:id : ==刪除專案==(in progress)


## `PATCH`/projects/:id : ==編輯專案==(in progress)



# issues : 新增、獲取、刪除、編輯缺失


# manage : 管理使用者身份

