> For the complete documentation index, see [llms.txt](https://kopens.gitbook.io/plantpulse-platform/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kopens.gitbook.io/plantpulse-platform/developer/api-manual/customer-service.md).

# 13. Customer 서비스

`client.customer()` 으로 접근합니다. 고객(Customer)의 CRUD와 사이트별 조회를 제공합니다.

## 13.1 메서드 일람

| 메서드                                      | 반환 타입                          | HTTP   | 엔드포인트                          |
| ---------------------------------------- | ------------------------------ | ------ | ------------------------------ |
| `create(CustomerRequestV5)`              | `CustomerResponseV5` 또는 `null` | POST   | `/api/v5/customer`             |
| `update(customer_id, CustomerRequestV5)` | `CustomerResponseV5` 또는 `null` | PUT    | `/api/v5/customer/{id}`        |
| `delete(customer_id)`                    | `boolean`                      | DELETE | `/api/v5/customer/{id}`        |
| `get(customer_id)`                       | `CustomerResponseV5` 또는 `null` | GET    | `/api/v5/customer/{id}`        |
| `list()`                                 | `List<CustomerResponseV5>`     | GET    | `/api/v5/customer`             |
| `listBySite(site_id)`                    | `List<CustomerResponseV5>`     | GET    | `/api/v5/customer?site_id=...` |
| `exists(customer_id)`                    | `boolean`                      | GET    | `/api/v5/customer/{id}/exists` |
| `count()`                                | `long`                         | GET    | `/api/v5/customer/count`       |

## 13.2 CustomerRequestV5 / CustomerResponseV5

| 필드                     | 타입     | 설명                  |
| ---------------------- | ------ | ------------------- |
| `customer_id`          | String | 고객 ID (PK)          |
| `customer_name`        | String | 고객명                 |
| `site_id`              | String | 소속 사이트              |
| `description`          | String | 설명                  |
| `manager_name`         | String | 담당자명                |
| `manager_email`        | String | 담당자 이메일             |
| `manager_phone`        | String | 담당자 전화번호            |
| `external_customer_id` | String | 외부 시스템(ERP 등) 고객 ID |
| `company_code`         | String | 회사 코드               |
| `address`              | String | 주소                  |

## 13.3 사용 예시

### 고객 생성

```java
import plantpulse.api.v5.dto.request.CustomerRequestV5;
import plantpulse.api.v5.dto.response.CustomerResponseV5;

CustomerRequestV5 req = new CustomerRequestV5();
req.setCustomer_id("CUST_001");
req.setCustomer_name("삼성전자");
req.setSite_id("SITE_DJ");
req.setExternal_customer_id("ERP_C001");
req.setCompany_code("SEC");
req.setAddress("경기도 수원시");
req.setManager_name("홍길동");
req.setManager_email("hong@example.com");
req.setManager_phone("01012345678");

CustomerResponseV5 created = client.customer().create(req);
```

### 조회 / 존재 확인

```java
CustomerResponseV5 c = client.customer().get("CUST_001");
boolean exists      = client.customer().exists("CUST_001");
long total          = client.customer().count();
```

### 전체 / 사이트별 목록

```java
import java.util.List;

List<CustomerResponseV5> all     = client.customer().list();
List<CustomerResponseV5> djCusts = client.customer().listBySite("SITE_DJ");
```

### 수정 / 삭제

```java
CustomerRequestV5 update = new CustomerRequestV5();
update.setCustomer_id("CUST_001");
update.setCustomer_name("삼성전자 DS");
update.setSite_id("SITE_DJ");
// ... 변경할 필드 ...
client.customer().update("CUST_001", update);

client.customer().delete("CUST_001");
```

## 13.4 활용 시나리오

### 시나리오 — ERP 고객 마스터 동기화

```java
// 1) ERP에서 가져온 고객 데이터
for (ErpCustomer erp : erpData) {
    CustomerRequestV5 req = new CustomerRequestV5();
    req.setCustomer_id("CUST_" + erp.code);
    req.setCustomer_name(erp.name);
    req.setExternal_customer_id(erp.id);
    req.setCompany_code(erp.companyCode);

    if (client.customer().exists("CUST_" + erp.code)) {
        client.customer().update("CUST_" + erp.code, req);
    } else {
        client.customer().create(req);
    }
}
```

## 다음 단계

* [Employee 서비스](/plantpulse-platform/developer/api-manual/employee-service.md) — 직원 마스터
* [Product 서비스](/plantpulse-platform/developer/api-manual/product-service.md) — 제품 마스터
