# User

## 회원 가입

## 회원가입

<mark style="color:green;">`POST`</mark> `http://localhost:8080/users/regist`

사용자가 서비스에 가입을 할 수 있도록 합니다.

#### Request Body

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| userName<mark style="color:red;">\*</mark> | string | 유저의 이름      |
| userId<mark style="color:red;">\*</mark>   | string | 유저의 아이디     |
| password<mark style="color:red;">\*</mark> | string | 유저의 비밀번호    |
| role<mark style="color:red;">\*</mark>     | String | 유저의 권한      |

{% tabs %}
{% tab title="200 회원가입 성공" %}

```javascript
{
    "success": true,
    "response": null,
    "error": null
}
```

{% endtab %}

{% tab title="500: Internal Server Error 서버의 알 수 없는 에러" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "서버의 알 수 없는 에러입니다.",
        "status": 500
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 이름, 아이디, 비밀번호 중에서 비어있을 경우" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "해당 요청은 잘못되었습니다.",
        "status": 400
    }
}
```

{% endtab %}
{% endtabs %}

## 로그인

## 로그인

<mark style="color:green;">`POST`</mark> `http://localhost:8080/users/login`

사용자가 서비스에 로그인할 수 있도록 합니다.

헤더로 JWT를 응답합니다.

#### Request Body

| Name                                       | Type   | Description |
| ------------------------------------------ | ------ | ----------- |
| userId<mark style="color:red;">\*</mark>   | String | 유저의 아이디     |
| password<mark style="color:red;">\*</mark> | String | 유저의 비밀번호    |

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

```json
{
    "success": true,
    "response": null,
    "error": null
}
```

{% endtab %}

{% tab title="400: Bad Request 아이디나 비밀번호가 비어있을 경우" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "해당 요청은 잘못되었습니다.",
        "status": 400
    }
}
```

{% endtab %}

{% tab title="500: Internal Server Error 서버의 알 수 없는 에러" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "서버의 알 수 없는 에러입니다.",
        "status": 500
    }
}
```

{% endtab %}
{% endtabs %}

## 회원 정보 조회

## 회원 정보 조회

<mark style="color:blue;">`GET`</mark> `http://localhost:8080/users`

로그인 되어있는 유저의 정보를 조회합니다.

#### Headers

| Name                                    | Type   | Description    |
| --------------------------------------- | ------ | -------------- |
| token<mark style="color:red;">\*</mark> | String | 로그인 시 발급받은 JWT |

{% tabs %}
{% tab title="200: OK 유저 정보 조회 성공" %}

```json
{
    "success": true,
    "response": {
        "idx": 1,
        "userId", "rhalstjr1999",
        "userName": "MinseokGo",
        "role": "USER",
        "orderCount": 17,
        "posts": [
            {
                "idx": 1,
                "title": "청학 B동 같이 시켜드실분",
                "createAt": "2023-07-29"
            },
            {
                "idx": 342,
                "title": "가입인사 드립니다.",
                "createAt": "2023-08-03"
            }
        ]        
    },
    "error": null
}
```

{% endtab %}

{% tab title="401: Unauthorized 인증되지 않았을 때" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "인증되지 않았습니다.",
        "status": 401
    }
}
```

{% endtab %}

{% tab title="404: Not Found 해당 유저의 정보를 찾을 수 없을 때" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "해당 유저를 찾을 수 없습니다.",
        "status": 404
    }
}
```

{% endtab %}

{% tab title="500: Internal Server Error 서버의 알 수 없는 에러" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "서버의 알 수 없는 에러입니다.",
        "status": 500
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 잘못된 요청" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "해당 요청은 잘못되었습니다.",
        "status": 400
    }
}
```

{% endtab %}
{% endtabs %}

## 특정 회원 정보 조회

## 특정 회원 정보 조회

<mark style="color:blue;">`GET`</mark> `http://localhost:8080/users/{id}`

&#x20;게시물에서 클릭한 유저의 정보를 조회합니다.

#### Request Body

| Name                                  | Type | Description        |
| ------------------------------------- | ---- | ------------------ |
| idx<mark style="color:red;">\*</mark> | Long | 게시물을 작성한 유저의 고유 ID |

{% tabs %}
{% tab title="200: OK 유저 정보 조회 성공" %}

```json
{
    "success": true,
    "response": {
        "idx": 1,
        "userId", "rhalstjr1999",
        "userName": "MinseokGo",
        "role": "USER",
        "orderCount": 17,
        "posts": [
            {
                "idx": 1,
                "title": "청학 B동 같이 시켜드실분",
                "createAt": "2023-07-29"
            },
            {
                "idx": 342,
                "title": "가입인사 드립니다.",
                "createAt": "2023-08-03"
            }
        ]        
    },
    "error": null
}
```

{% endtab %}

{% tab title="404: Not Found 해당 유저의 정보를 찾을 수 없을 때" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "해당 유저를 찾을 수 없습니다.",
        "status": 404
    }
}
```

{% endtab %}

{% tab title="500: Internal Server Error 서버의 알 수 없는 에러" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "서버의 알 수 없는 에러입니다.",
        "status": 500
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 잘못된 요청" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "해당 요청은 잘못되었습니다.",
        "status": 400
    }
}
```

{% endtab %}
{% endtabs %}

## 회원 주소 추가

## 회원 주소 추가

<mark style="color:green;">`POST`</mark> `http://localhost:8080/users/address/add`

회원이 보유하고 있는 주소를 보여줍니다.

#### Headers

| Name                                    | Type   | Description    |
| --------------------------------------- | ------ | -------------- |
| token<mark style="color:red;">\*</mark> | String | 로그인 시 발급받은 JWT |

#### Request Body

| Name                                      | Type   | Description |
| ----------------------------------------- | ------ | ----------- |
| address<mark style="color:red;">\*</mark> | String | 회원이 등록한 주소  |

{% tabs %}
{% tab title="200: OK 주소 등록 성공" %}

```json

{
    "success": true,
    "response": null,
    "error": null
}
```

{% endtab %}

{% tab title="400: Bad Request 잘못된 요청" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "해당 요청은 잘못되었습니다.",
        "status": 400
    }
}
```

{% endtab %}

{% tab title="401: Unauthorized 인증되지 않았을 때" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "인증되지 않았습니다.",
	"status": 401
    }
}
```

{% endtab %}

{% tab title="500: Internal Server Error 서버의 알 수 없는 에러" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "서버의 알 수 없는 에러입니다.",
        "status": 500
    }
}
```

{% endtab %}
{% endtabs %}

## 회원 주소 조회

## 회원 주소 조회

<mark style="color:blue;">`GET`</mark> `http://localhost:8080/users/address`

회원이 등록한 주소를 조회합니다.

#### Headers

| Name                                    | Type   | Description    |
| --------------------------------------- | ------ | -------------- |
| token<mark style="color:red;">\*</mark> | String | 로그인 시 발급받은 JWT |

{% tabs %}
{% tab title="200: OK 주소 조회 성공" %}

```json
{
    "success": true,
    "response": {
        "addressList": [
            { "address": "연제구 연산동" },
            { "address": "연제구 토곡통" }
        ]
    }
    ,
    "error": null
}
```

{% endtab %}

{% tab title="400: Bad Request 잘못된 요청" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "해당 요청은 잘못되었습니다.",
        "status": 400
    }
}
```

{% endtab %}

{% tab title="401: Unauthorized 인증되지 않았을 때" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "인증되지 않았습니다.",
	"status": 401
    }
}
```

{% endtab %}

{% tab title="500: Internal Server Error 서버의 알 수 없는 에러" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "서버의 알 수 없는 에러입니다.",
        "status": 500
    }
}
```

{% endtab %}
{% endtabs %}

## 회원 정보 수정

## 회원 정보 수정

<mark style="color:orange;">`PUT`</mark> `http://localhost:8080/users/update`

유저의 비밀번호, 닉네임을 수정할 수 있도록 합니다.

비밀번호 변경 시, old, new 패스워드를 모두 입력해야하지만 정보 수정의 경우 닉네임을 변경하지 않을 수도 있기 때문에 Optional로 지정합니다.

닉네임 변경의 경우도 동일합니다.

#### Headers

| Name                                    | Type   | Description    |
| --------------------------------------- | ------ | -------------- |
| token<mark style="color:red;">\*</mark> | String | 로그인 시 발급받은 JWT |

#### Request Body

| Name        | Type   | Description |
| ----------- | ------ | ----------- |
| newNickname | String | 변경할 닉네임     |
| oldPassword | String | 이전 비밀번호     |
| newPassword | String | 변경 비밀번호     |

{% tabs %}
{% tab title="200: OK 정보 수정 성공" %}

```json

{
    "success": true,
    "response": null,
    "error": null
}

```

{% endtab %}

{% tab title="400: Bad Request old, new 비밀번호가 일치하지 않을 경우(프론트에서 한번 체크는 해야함)" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "해당 요청은 잘못되었습니다.",
        "status": 400
    }
}
```

{% endtab %}

{% tab title="409: Conflict 중복 닉네임 존재" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "중복된 닉네임이 존재합니다.",
        "status": 409
    }
}
```

{% endtab %}

{% tab title="500: Internal Server Error 서버의 알 수 없는 에러" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "서버의 알 수 없는 에러입니다.",
        "status": 500
    }
}
```

{% endtab %}

{% tab title="401: Unauthorized 인증되지 않았을 때" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "인증되지 않았습니다.",
	"status": 401
    }
}
```

{% endtab %}
{% endtabs %}

## 회원 탈퇴

## 회원 탈퇴

<mark style="color:red;">`DELETE`</mark> `http://localhost:8080/users/unregist`

회원 탈퇴를 할 수 있도록 합니다.

#### Headers

| Name                                    | Type   | Description    |
| --------------------------------------- | ------ | -------------- |
| token<mark style="color:red;">\*</mark> | String | 로그인 시 발급받은 JWT |

{% tabs %}
{% tab title="200: OK 탈퇴 처리 성공" %}

```json
{
    "success": true,
    "response": null,
    "error": null
}
```

{% endtab %}

{% tab title="401: Unauthorized 인증되지 않았을 때" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "인증되지 않았습니다.",
	"status": 401
    }
}
```

{% endtab %}

{% tab title="400: Bad Request 잘못된 요청" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "해당 요청은 잘못되었습니다.",
        "status": 400
    }
}
```

{% endtab %}

{% tab title="500: Internal Server Error 서버의 알 수 없는 에러" %}

```json
{
    "success": false,
    "response": null,
    "error": {
        "message": "서버의 알 수 없는 에러입니다.",
        "status": 500
    }
}
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://minseokgos-organization.gitbook.io/api/reference/api/user.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
