# Users

## 일반유저 회원가입

<mark style="color:green;">`POST`</mark> `/public/signup`

#### Request Body

| Name                                       | Type   | Description  |
| ------------------------------------------ | ------ | ------------ |
| email<mark style="color:red;">\*</mark>    | String | userEmail    |
| password<mark style="color:red;">\*</mark> | String | userPassword |
| nickname<mark style="color:red;">\*</mark> | String | userNickname |

{% tabs %}
{% tab title="201: Created 회원가입 성공" %}

```javascript
{
    // Response
    "message": "일반유저 회원가입 완료"
}
```

{% endtab %}

{% tab title="400: Bad Request 항목이 비어있을 때" %}

```javascript
{
    // Response
    "message": "잘못된 요청"
}
```

{% endtab %}

{% tab title="409: Conflict 이메일이 존재할 때" %}

```javascript
{
    // Response
    "message": "동일한 이메일 존재"
}
```

{% endtab %}

{% tab title="409: Conflict 닉네임이 존재할 때" %}

```javascript
{
    // Response
    "message": "동일한 닉네임 존재"
}
```

{% endtab %}
{% endtabs %}

## 의사 회원가입

<mark style="color:green;">`POST`</mark> `/doctor/signup`

#### Request Body

| Name                                           | Type   | Description     |
| ---------------------------------------------- | ------ | --------------- |
| email<mark style="color:red;">\*</mark>        | String | doctor email    |
| name<mark style="color:red;">\*</mark>         | String | doctor name     |
| password<mark style="color:red;">\*</mark>     | String | doctor password |
| hospitalName<mark style="color:red;">\*</mark> | String | hospitalName    |
| license<mark style="color:red;">\*</mark>      | Number | license         |

{% tabs %}
{% tab title="201: Created 의사 가입 성공" %}

```javascript
{
    // Response
    "message": "의사유저 회원가입 완료"
}
```

{% endtab %}

{% tab title="400: Bad Request 항목이 비었을 때" %}

```javascript
{
    // Response
    "message": "잘못된 요청"
}
```

{% endtab %}

{% tab title="409: Conflict 이메일이 존재할 때" %}

```javascript
{
    // Response
    "message": "동일한 이메일 존재"
}
```

{% endtab %}
{% endtabs %}

## 공통 로그인

<mark style="color:green;">`POST`</mark> `/common/signin`

#### Request Body

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| email<mark style="color:red;">\*</mark>    | String | email       |
| password<mark style="color:red;">\*</mark> | String | password    |

{% tabs %}
{% tab title="200: OK 로그인 성공" %}

```javascript
{
    // Response
    "message": "로그인 성공",
    data: auth
}
```

{% endtab %}

{% tab title="401: Unauthorized 로그인 실패(이메일또는 패스워드 유효하지않음)" %}

```javascript
{
    // Response
    "message": "아이디 또는 비밀번호가 유효하지 않음"
}
```

{% endtab %}

{% tab title="400 이메일또는 패스워드를 적지 않음" %}

```javascript
{
    // Response
    "message": "잘못된 요청"
}
```

{% endtab %}

{% tab title="403: Forbidden 의사가입 신청이 승인나지 않았을 때" %}

```javascript
{
    // Response
    "message": "회원가입 신청이 승낙되지 않음"
}
```

{% endtab %}
{% endtabs %}

## 공통 로그아웃

<mark style="color:blue;">`GET`</mark> `/common/signout`

#### Cookies

| Name                                    | Type   | Description |
| --------------------------------------- | ------ | ----------- |
| token<mark style="color:red;">\*</mark> | String | accessToken |

{% tabs %}
{% tab title="200: OK 로그아웃 성공" %}

```javascript
{
    // Response
    "message": "로그아웃 성공"
}
```

{% endtab %}
{% endtabs %}

## 공통 회원 탈퇴

<mark style="color:red;">`DELETE`</mark> `/common/users`

#### Cookies

| Name                                    | Type   | Description |
| --------------------------------------- | ------ | ----------- |
| token<mark style="color:red;">\*</mark> | String | accessToken |

{% tabs %}
{% tab title="200: OK 일반유저 회원탈퇴 성공" %}

```javascript
{
    // Response
    "message": "일반유저 삭제 완료"
}
```

{% endtab %}

{% tab title="200: OK 의사유저 회원탈퇴 성공" %}

```javascript
{
    // Response
    "message": "의사유저 삭제 완료"
}
```

{% endtab %}

{% tab title="400: Bad Request 일반유저나 의사가 아닐 때" %}

```javascript
{
    // Response
    "message": "잘못된 요청"
}
```

{% endtab %}
{% endtabs %}

## 일반유저 정보 요청

<mark style="color:blue;">`GET`</mark> `/public/userinfo`

#### Cookies

| Name                                    | Type   | Description |
| --------------------------------------- | ------ | ----------- |
| token<mark style="color:red;">\*</mark> | String | accessToken |

{% tabs %}
{% tab title="200: OK 사용자정보조회완료" %}

```javascript
{
    // Response
    userInfo: {
        id: 1,
        email: test@test.com,
        nickname: test,
        profile_img: route,
        auth: 2
        createdAt: 2021-12-30 00:00:00,
        updatedAt: 2021-12-30 00:00:00,
    },
    "message": "일반유저 정보 요청 성공"
}
```

{% endtab %}

{% tab title="401: Unauthorized 토큰이 올바르지 않을때" %}

```javascript
{
    // Response
    "message": "토큰이 유효하지 않음"
}
```

{% endtab %}
{% endtabs %}

## 의사 정보 요청

<mark style="color:blue;">`GET`</mark> `/doctor/userinfo`

#### Cookies

| Name                                    | Type   | Description |
| --------------------------------------- | ------ | ----------- |
| token<mark style="color:red;">\*</mark> | String | accessToken |

{% tabs %}
{% tab title="200: OK 의사정보요청 성공" %}

```javascript
{
    // Response
    userInfo: {
        id: 1,
        email: doctor@test.com,
        name: 김의사,
        hospitalName: 코드의원,
        profile_img: route,
        auth: 1,
        agree: true,
        createdAt: 2021-12-30 00:00:00,
        updatedAt: 2021-12-30 00:00:00,
    },
    "message": "의사유저 정보 요청 성공"
}
```

{% endtab %}

{% tab title="401: Unauthorized 요청실패 토큰 유효하지않음" %}

```javascript
{
    // Response
    "message": "토큰이 유효하지 않음"
}
```

{% endtab %}

{% tab title="200: OK 관리자가 의사리스트 요청했을 때" %}

```javascript
{
    // Response
    doctorList: {
        userInfo: {
            id: 1,
            email: doctor@test.com,
            name: 김의사,
            hospitalName: 코드의원,
            profile_img: route,
            auth: 1,
            agree: true,
            createdAt: 2021-12-30 00:00:00,
            updatedAt: 2021-12-30 00:00:00,
        },
        userInfo: {
            id: 2,
            email: doctor@test.com,
            name: 김의사,
            hospitalName: 코드의원,
            profile_img: route,
            auth: 1,
            agree: true,
            createdAt: 2021-12-30 00:00:00,
            updatedAt: 2021-12-30 00:00:00,
        },
        userInfo: {
            id: 3,
            email: doctor@test.com,
            name: 김의사,
            hospitalName: 코드의원,
            profile_img: route,
            auth: 1,
            agree: true,
            createdAt: 2021-12-30 00:00:00,
            updatedAt: 2021-12-30 00:00:00,
        },
    },
    "message": "의사리스트 요청 성공"
}
```

{% endtab %}
{% endtabs %}

## 일반유저 정보 수정

<mark style="color:orange;">`PUT`</mark> `/public/profile`

#### Cookies

| Name                                    | Type   | Description |
| --------------------------------------- | ------ | ----------- |
| token<mark style="color:red;">\*</mark> | String | accessToken |

#### Request Body

| Name         | Type   | Description |
| ------------ | ------ | ----------- |
| nickname     | String | nickname    |
| profile\_img | String | route       |
| password     | String | password    |

{% tabs %}
{% tab title="200: OK 정보수정완료" %}

```javascript
{
    // Response
    "message": "닉네임 수정 완료",
    "message": "프로필 수정 완료",
    "message": "닉네임, 프로필사진 수정 완료"
    "message": "비밀번호 수정 완료"
}
```

{% endtab %}

{% tab title="401: Unauthorized 비밀번호가 틀렸을 때" %}

```javascript
{
    // Response
    "message": "비밀번호 일치하지 않음"
}
```

{% endtab %}
{% endtabs %}

## 의사 정보 수정

<mark style="color:orange;">`PUT`</mark> `/doctor/profile`

#### Cookies

| Name                                    | Type   | Description |
| --------------------------------------- | ------ | ----------- |
| token<mark style="color:red;">\*</mark> | String | accessToken |

#### Request Body

| Name         | Type   | Description  |
| ------------ | ------ | ------------ |
| name         | String | doctor name  |
| profile\_img | String | route        |
| hospital     | String | hospitalName |
| password     | String | password     |

{% tabs %}
{% tab title="200: OK 의사 정보 수정 완료" %}

```javascript
{
    // Response
    "message": "이름, 병원명 수정완료",
    "message": "의사 프로필 수정 완료",
    "message": "비밀번호 수정 완료",
    "message": "이름, 병원명, 프로필사진 수정 완료",
    "message": "의사 신청 완료"
}
```

{% endtab %}

{% tab title="401: Unauthorized 비밀번호가 틀렸을 때" %}

```javascript
{
    // Response
    "message": "비밀번호 일치하지 않음"
}
```

{% endtab %}
{% endtabs %}
