---
# System prepended metadata

title: 使用者管理

---

# 使用者管理

## 使用者管理

### (OK) 新增使用者

Request:

    POST /user

Payload：

```json=
    {
        "username": "帳號（證件號碼） <string>",
        "name": "使用者名稱 <string>",
        "birthDate": "使用者生日 <string>",
        // birthDate Regex: ([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1]))?)?
        "gender": "性別 <string> enum: [ male | female | other | unknown ]",
        "telecomEmail": "主要信箱 <string>",
        "telecomSubEmail": "次要信箱 <string>",
        "telecomPhone": "手機號碼 <string>",
        "managingOrganization": "單位組織編號(FHIR Server 中的 org id) <number>",
        "role": ["角色 ID <string>"], // 非必填，不填則無任角色 / 權限
        "nationality": "國籍 <string> 參考 ISO 3166-1 二位字母代號",
        "comment": "備註 <string>",
        "active": "是否啟用 <boolean>",
        "createdAt": "建立時間 <number, bigint>"
    }
```

Response (成功):

```json=
    {
        "success": true,
        "data": {
            "id": "使用者編號 <string>",
            "username": "帳號（證件號碼） <string>",
            "name": "使用者名稱 <string>",
            "birthDate": "使用者生日 <string>",
            // birthDate Regex: ([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1]))?)?
            "gender": "性別 <string> enum: [ male | female | other | unknown ]",
            "telecomEmail": "主要信箱 <string>",
            "telecomSubEmail": "次要信箱 <string>",
            "telecomPhone": "手機號碼 <string>",
            "managingOrganization": "單位組織編號 <string>",
            "role": ["角色 ID <string>"], // 非必填，不填則無任角色 / 權限
            "nationality": "國籍 <string> 參考 ISO 3166-1 二位字母代號",
            "comment": "備註 <string>",
            "active": "是否啟用 <boolean>",
            "createdAt": "建立時間 <number, bigint>"
          }
    }
```

### (OK) 編輯使用者

Request:

    PUT /user/$id

Payload：

```json=
    {
        "username": "帳號（證件號碼） <string>",
        "name": "使用者名稱 <string>",
        "birthDate": "使用者生日 <string>",
        // birthDate Regex: ([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1]))?)?
        "gender": "性別 <string> enum: [ male | female | other | unknown ]",
        "telecomEmail": "主要信箱 <string>",
        "telecomSubEmail": "次要信箱 <string>",
        "telecomPhone": "手機號碼 <string>",
        "managingOrganization": "單位組織編號 <string>",
        "role": ["角色 ID <string>"], // 非必填，不填則無任角色 / 權限
        "nationality": "國籍 <string> 參考 ISO 3166-1 二位字母代號",
        "comment": "備註 <string>",
        "active": "是否啟用 <boolean>",
        "role": ["角色 ID"]
    }
```

Response (成功):

```json=
    {
        "success": true,
        "data": [
            "updatedAt": "更新時間 <number, bigint>"
        ]
    }
```

### (OK) 移除使用者

Request:

    DEL /user/$id

Response (成功):

```json=
    {
        "success": true
    }
```

### (OK) 停用／啟用使用者

Request:

    PUT /user/$id/activate

Payload：

```json=
    { 
        "active": "是否啟用 <boolean>"
    }
```

Response (成功):

```json=
    {
        "success": true
    }
```

### (OK) 查看使用者清單

Request:

    GET /user?$queryParams

[Query Params:](Untitled%202/Query%20Params.csv)

Response (成功):

```json=
    {
        "success": true,
        "data": [
            {
                "id": "使用者編號 <string>",
                "username": "帳號（證件號碼） <string>",
                "name": "使用者名稱 <string>",
                "birthDate": "使用者生日 <string>",
                // birthDate Regex: ([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1]))?)?
                "gender": "性別 <string> enum: [ male | female | other | unknown ]",
                "telecomEmail": "主要信箱 <string>",
                "telecomSubEmail": "次要信箱 <string>",
                "telecomPhone": "手機號碼 <string>",
                "managingOrganizationId": "單位組織編號 <string>",
                "managingOrganizationName": "單位組織名稱 <string>",
                "managingOrganizationType": "單位組織類型 <string>",
                "role": ["角色 <string>"],
                "nationality": "國籍 <string> 參考 ISO 3166-1 二位字母代號",
                "comment": "備註 <string>",
                "active": "是否啟用 <boolean>",
                "updateAt": "更新時間 <number, bigint>"
            },
            ...
        ]
    }
```

### (OK) 查看個別使用者資料

Request:

    GET /user/$id

Response (成功):

```json=
    {
        "success": true,
        "data": [
            {
                "id": "使用者編號 <string>",
                "name": "使用者名稱 <string>",
                "birthDate": "使用者生日 <string>",
                // birthDate Regex: ([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1]))?)?
                "gender": "性別 <string> enum: [ male | female | other | unknown ]",
                "email": "主要信箱 <string>",
                "subEmail": "次要信箱 <string>",
                "phone": "手機號碼 <string>",
                "managingOrganizationId": "單位組織編號 <string>",
                "managingOrganizationName": "單位組織名稱 <string>",
                "managingOrganizationType": "單位組織類型 <string>",
                "role": ["角色 ID <string>"],
                "nationality": "國籍 <string> 參考 ISO 3166-1 二位字母代號",
                "comment": "備註 <string>",
                "active": "是否啟用 <boolean>",
                "updateAt": "更新時間 <number, bigint>"
            }
        ]
    }
```

### (OK) 查看使用者資料（自己的）

Request:

    GET /user/me

Response (成功):

```json=
    {
        "success": true,
        "data": {
                "id": "使用者編號 <string>",
                "name": "使用者名稱 <string>",
                "birthDate": "使用者生日 <string>",
                // birthDate Regex: ([0-9]([0-9]([0-9][1-9]|[1-9]0)|[1-9]00)|[1-9]000)(-(0[1-9]|1[0-2])(-(0[1-9]|[1-2][0-9]|3[0-1]))?)?
                "gender": "性別 <string> enum: [ male | female | other | unknown ]",
                "email": "主要信箱 <string>",
                "subEmail": "次要信箱 <string>",
                "phone": "手機號碼 <string>",
                "managingOrganizationId": "單位組織編號 <string>",
                "managingOrganizationName": "單位組織名稱 <string>",
                "managingOrganizationType": "單位組織類型 <string>",
                "role": ["角色 ID <string>"],
                "nationality": "國籍 <string> 參考 ISO 3166-1 二位字母代號",
                "comment": "備註 <string>",
                "active": "是否啟用 <boolean>",
                "updateAt": "更新時間 <number, bigint>"
            }
    }
```

### (OK) 查看使用者權限

Request:

    GET /user/permission/$id

Response (成功):

```json=
{
    "success": true,
    "data":{
        "permission": {
            "caseMgmt": {
                "caseList": {
                    "addCase": "RW"
                },
                "caseContent": {
                    "info": "RW",
                    "physiological": "RW",
                    "diet": "RW",
                    "state": "RW",
                    "course": "RW"
                }
            },
            "calendarMgmt": {
                "courseReservation": "RW"
            },
            "statisticalReport": {
                "physiological": "R",
                "caseMgmt": "R",
                "course": "R"
            },
            "courseMgmt": {
                "courseSchedule": "R",
                "courseLesson": "RW"
            },
            "caseTypeMgmt": {
                "caseTypeMgmt": "R"
            }
        }
    }
}
```