---
# System prepended metadata

title: 角色權限管理

---

# 角色權限管理

# 角色權限管理

## (OK) 取得角色列表

Request:

    GET /role?$queryParams

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

Response (成功):

```json=
    {
        "success": true,
        "total": "總數量 <number>",
        "data": [
            {
                "id": "角色編號 <string>",
                "name": "角色名稱 <string>",
                "amount": "人數 <string>",
                "updateAt": "更新時間 <number, bigint>"
            }
        ]
    }
```

## (OK) 新增角色

Request:

    POST /role

Payload：

```json=
    {
        "name": "角色名稱 <string>",
        "permission": "[{
            "function": "功能名稱 <string>",
            "read": "讀寫權限 <boolean>",
            "write": "讀寫權限 <boolean>"
        }]"
    }
```

Response (成功):

```json=
    {
        "success": true,
        "data": {
            "id": "角色 ID <string>"
        }
    }
```

## (OK) 編輯角色

Request:

    PUT /role/$id

Payload：

```json=
    {
        "name": "角色名稱 <string>",
        "permission": "[{
            "function": "功能（頁面）名稱 <string>",
            "read": "讀寫權限 <boolean>",
            "write": "讀寫權限 <boolean>"
        }]"
    }
```

Response (成功):

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

## (OK) 刪除角色

Request:

    DEL /role/$id

Response (成功):

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

```

## (OK) 取得權限表
Request:

    GET /role/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"
                }
            } 
        }
    }
```

## (OK) 更新權限表
Request:

    PUT /role/permission/$id

Payload:

```json=
{
    "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"
        }
    }
}
```

Response (成功):

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

```