---
# System prepended metadata

title: 租戶管理員-角色權限管理(Draft)

---

# 租戶管理員-角色權限管理(Draft)

[TOC]

## 租戶角色列表

```url
POST /tenant-role/list
```
Request
| 欄位 | 型態 | 必填 | 說明 |
|---|---|---|---|
| query | json | | 查詢條件 |
| - status | bool | | 啟用狀態, true: 啟用, false: 停用, 未填則表示全部 |
| - name | string | | 關鍵字,查詢角色名稱 |
| - tenantId | string | | 租戶id |
| pagination | json | | 分頁 |
| - current | int | | 當前頁數 |
| - pageSize | int | | 每頁結果數量，預設為10|
| sorter | json | | 排序欄位, 預設是用更新時間降序排列 |
| - field | string | | 排序欄位, 預設為updateTime, 可排序欄位:name, account, status, updateTime |
| - order | string | | 升序或降序, 預設為desc|

```javascript
{
  "query": {
      "name": "",
      "status": true,
      "tenantId": ""
  },
  "pagination": {
      "current": 1,
      "pageSize": 10
  },
  "sorter": {
      "field": "updateTime",
      "order": "asc"
  }
}
```

Response
| 欄位 | 型態 | 說明 |
|---|---|---|
| id | string | 角色 id |
| name | string | 角色名稱 |
| tenantId | string | 租戶id |
| functions | string | 已設定功能權限列表,以','分隔 |
| menus | json | 角色功能權限列表 |
| - id | string | menuId |
| - name | string | 功能名稱 |
| - i18n | string | i18n |
| - menu | json array | 子功能json array |
| - - id | string | menuId |
| - - name | string | 功能名稱 |
| - - i18n | string | i18n |
| - - parentId | string | 父功能選單id |
| - - read | bool | true 表示啟用 |
| status | bool | 啟用狀態, true: 啟用, false: 停用 |
| updateTime | timestamp | 最後更新時間 |

```javascript
{
  "httpCode": 200,
  "result": {
    "data": [
      {
        "id": "594bcf8d-a134-4efd-9366-392b8194e631",
        "tenantId": "edf7f695-6d27-47c3-af9f-f57669bba45d",
        "name": "心臟科醫師",
        "functions": "CASE_OVERVIEW,CASE_CALENDAR,EDUCATION_LIST",
        "menus": {
                    "EDUCATION_MANAGEMENT": {
                        "id": "EDUCATION_MANAGEMENT",
                        "name": "衛教資訊管理",
                        "i18n": "MENU.EDUCATION_MANAGEMENT",
                        "level": 0,
                        "menu": [
                            {
                                "id": "EDUCATION_LIST",
                                "name": "衛教資訊列表",
                                "i18n": "MENU.EDUCATION_LIST",
                                "parentId": "EDUCATION_MANAGEMENT",
                                "level": 1,
                                "read": true
                            }
                        ]
                    },
                    "SYSTEM_MANAGEMENT": {
                        "id": "SYSTEM_MANAGEMENT",
                        "name": "系統管理",
                        "i18n": "MENU.SYSTEM_MANAGEMENT",
                        "level": 0,
                        "menu": [
                            {
                                "id": "SYSTEM_DIVISION",
                                "name": "科別管理",
                                "i18n": "MENU.SYSTEM_DIVISION",
                                "parentId": "SYSTEM_MANAGEMENT",
                                "level": 1
                            },
                            {
                                "id": "SYSTEM_DISEASE",
                                "name": "疾病別管理",
                                "i18n": "MENU.SYSTEM_DISEASE",
                                "parentId": "SYSTEM_MANAGEMENT",
                                "level": 1
                            },
                            {
                                "id": "RESERVATION_ITEM",
                                "name": "排程項目管理",
                                "i18n": "MENU.RESERVATION_ITEM",
                                "parentId": "SYSTEM_MANAGEMENT",
                                "level": 1
                            }
                        ]
                    },
                    "CASE_MANAGEMENT": {
                        "id": "CASE_MANAGEMENT",
                        "name": "個案追蹤管理",
                        "i18n": "MENU.CASE_MANAGEMENT",
                        "level": 0,
                        "menu": [
                            {
                                "id": "CASE_CALENDAR",
                                "name": "排程行事曆",
                                "i18n": "MENU.CASE_CALENDAR",
                                "parentId": "CASE_MANAGEMENT",
                                "level": 1,
                                "read": true
                            },
                            {
                                "id": "CASE_OVERVIEW",
                                "name": "個案總覽",
                                "i18n": "MENU.CASE_OVERVIEW",
                                "parentId": "CASE_MANAGEMENT",
                                "level": 1,
                                "read": true
                            },
                            {
                                "id": "CASE_LIST",
                                "name": "個案名單",
                                "i18n": "MENU.CASE_LIST",
                                "parentId": "CASE_MANAGEMENT",
                                "level": 1
                            },
                            {
                                "id": "CASE_ANNUAL_STATISTIC",
                                "name": "指標分析",
                                "i18n": "MENU.CASE_ANNUAL_STATISTIC",
                                "parentId": "CASE_MANAGEMENT",
                                "level": 1
                            },
                            {
                                "id": "CASE_CARE",
                                "name": "個案關懷",
                                "i18n": "MENU.CASE_CARE",
                                "parentId": "CASE_MANAGEMENT",
                                "level": 1
                            },
                            {
                                "id": "CASE_GIS",
                                "name": "個案GIS",
                                "i18n": "MENU.CASE_GIS",
                                "parentId": "CASE_MANAGEMENT",
                                "level": 1
                            }
                        ]
                    },
                    "ACCOUNT_MANAGEMENT": {
                        "id": "ACCOUNT_MANAGEMENT",
                        "name": "帳號管理",
                        "i18n": "MENU.ACCOUNT_MANAGEMENT",
                        "level": 0,
                        "menu": [
                            {
                                "id": "SYSTEM_USERS",
                                "name": "帳號管理",
                                "i18n": "MENU.SYSTEM_USERS",
                                "parentId": "ACCOUNT_MANAGEMENT",
                                "level": 1
                            },
                            {
                                "id": "ROLE_MANAGEMENT",
                                "name": "角色權限管理",
                                "i18n": "MENU.ROLE_MANAGEMENT",
                                "parentId": "ACCOUNT_MANAGEMENT",
                                "level": 1
                            }
                        ]
                    },
                    "PLATFORM_MANAGEMENT": {
                        "id": "PLATFORM_MANAGEMENT",
                        "name": "平台管理",
                        "i18n": "MENU.PLATFORM_MANAGEMENT",
                        "level": 0,
                        "menu": [
                            {
                                "id": "TENANT_MANAGEMENT",
                                "name": "租戶管理",
                                "i18n": "MENU.TENANT_MANAGEMENT",
                                "parentId": "PLATFORM_MANAGEMENT",
                                "level": 1
                            },
                            {
                                "id": "PURCHASE_SETTINGS",
                                "name": "方案參數設定",
                                "i18n": "MENU.PURCHASE_SETTINGS",
                                "parentId": "PLATFORM_MANAGEMENT",
                                "level": 1
                            },
                            {
                                "id": "PURCHASE_MANAGEMENT",
                                "name": "方案管理",
                                "i18n": "MENU.PURCHASE_MANAGEMENT",
                                "parentId": "PLATFORM_MANAGEMENT",
                                "level": 1
                            }
                        ]
                    },
                    "INTELL_DIST_SERVICE": {
                        "id": "INTELL_DIST_SERVICE",
                        "name": "遠距智能服務",
                        "i18n": "MENU.INTELL_DIST_SERVICE",
                        "level": 0,
                        "menu": [
                            {
                                "id": "INTELL_DIST_CONSULT",
                                "name": "諮詢服務",
                                "i18n": "MENU.INTELL_DIST_CONSULT",
                                "parentId": "INTELL_DIST_SERVICE",
                                "level": 1
                            },
                            {
                                "id": "INTELL_DIST_WOUND_PATIENT",
                                "name": "傷口照顧管理",
                                "i18n": "MENU.INTELL_DIST_WOUND_PATIENT",
                                "parentId": "INTELL_DIST_SERVICE",
                                "level": 1
                            },
                            {
                                "id": "INTELL_DIST_HEALTH",
                                "name": "個人健康管理",
                                "i18n": "MENU.INTELL_DIST_HEALTH",
                                "parentId": "INTELL_DIST_SERVICE",
                                "level": 1
                            }
                        ]
                    }
                },
        "status": true,
        "updateTime": 1610588709000
      }, 
      ...
    ]
  }
}
```


## 新增租戶角色

```url
POST /tenant-role/add
```
Request
| 欄位 | 型態 | 必填 | 說明 |
|---|---|---|---|
| name | string | Y | 姓名 |
| tenantId | string | Y | 租戶id |


```javascript
{
    "name": "心臟科醫師",
    "tenantId": "5253249c-edd1-4bd0-b63a-3826beb9b9b2"
}
```

Response
| 欄位 | 型態 | 說明 |
|---|---|---|
| id | string | 租戶角色 id |
| name | string | 租戶角色名稱 |
| tenantId | string | 租戶id |
| status | bool | 啟用狀態, true: 啟用, false: 停用 |
| updateTime | timestamp | 最後更新時間 |

```javascript
//httpCode: 200
{
  "httpCode": 200,
  "result": {
    "data": {
        "id": "594bcf8d-a134-4efd-9366-392b8194e631",
        "name": "心臟科醫師",
        "tenantId": "5253249c-edd1-4bd0-b63a-3826beb9b9b2", 
        "status": true,
        "updateTime": 1610588709000
    }
  }
}

//httpCode: 422
{
    "errorMsg": "SERVICE_ERROR.TENANT_ROLE_DUPLICATE",
    "httpCode": 422
}
```

## 編輯租戶角色

```url
POST /tenant-role/update
```
Request
| 欄位 | 型態 | 必填 | 說明 |
|---|---|---|---|
| id | string | 租戶角色 id |
| name | string | 租戶角色名稱 |
| tenantId | string | 租戶id |
| functions | string array | 功能權限設定array, 功能選單id |
| status | bool | 啟用狀態, true: 啟用, false: 停用 |
| updateTime | timestamp | 最後更新時間 |

```javascript
{
    "id": "594bcf8d-a134-4efd-9366-392b8194e631",
    "name": "心臟科醫師",
    "tenantId": "5253249c-edd1-4bd0-b63a-3826beb9b9b2",
    "functions": [
        "CASE_GIS",
        "INTELL_DIST_CONSULT",
    ], 
    "status": true
}
```

Response
| 欄位 | 型態 | 說明 |
|---|---|---|
| id | string | 租戶角色 id |
| name | string | 租戶角色名稱 |
| tenantId | string | 租戶id |
| status | bool | 啟用狀態, true: 啟用, false: 停用 |
| updateTime | timestamp | 最後更新時間 |

```javascript
//httpCode: 200
{
  "httpCode": 200,
  "result": {
    "data": {
        "id": "594bcf8d-a134-4efd-9366-392b8194e631",
        "name": "心臟科醫師",
        "tenantId": "5253249c-edd1-4bd0-b63a-3826beb9b9b2", 
        "status": true,
        "updateTime": 1610588709000
    }
  }
}

//httpCode: 422
{
    "errorMsg": "SERVICE_ERROR.TENANT_ROLE_NAME_DUPLICATE",
    "httpCode": 422
}
```

## 啟用停用租戶角色

```url
POST /tenant-role/status
```
Request
| 欄位 | 型態 | 必填 | 說明 |
|---|---|---|---|
| id | string | Y | 租戶角色id |
| status | bool | Y | 啟用狀態, true: 啟用, false: 停用 |


```javascript
{
    "id": "594bcf8d-a134-4efd-9366-392b8194e631",
    "status": true
}
```

Response
| 欄位 | 型態 | 說明 |
|---|---|---|
| id | string | 租戶角色 id |
| name | string | 租戶角色名稱 |
| tenantId | string | 租戶id |
| status | bool | 啟用狀態, true: 啟用, false: 停用 |
| updateTime | timestamp | 最後更新時間 |

```javascript
//httpCode: 200
{
  "httpCode": 200,
  "result": {
    "data": {
        "id": "594bcf8d-a134-4efd-9366-392b8194e631",
        "name": "心臟科醫師",
        "tenantId": "5253249c-edd1-4bd0-b63a-3826beb9b9b2", 
        "status": true,
        "updateTime": 1610588709000
    }
  }
}

//httpCode: 422
{
    "errorMsg": "SERVICE_ERROR.TENANT_ROLE_DUPLICATE",
    "httpCode": 422
}
```
