---
# System prepended metadata

title: 課程行事曆管理

---

# 課程行事曆管理

# Schema

### 個人課程班次(PersonalLesson)

[個人課程班次](Untitled%2012/Untitled.csv)

|  欄位 | 型態  | 長度限制   | 說明  | 
|---|---|---|---|---|
| id | number | | 課程班次編號|
| supervision | string | | 課程班次名稱|
| user | number |  | 學員id|
| cycleType | number | | 循環模式 enum: [1: 每天, 2: 每週, 3: 每月]|
| cycleDetail | array<number> |  | 循環模式細節, 僅"每週"需要填入 ex: 每週一, 五, 日 帶入[1, 5, 7]|
| duration | number | | 課程長度（秒）|
| personalCourse | array<object> |  | 個人課程時間設定
| -id | number | | 預約Id(reservationId)|
| -startedAt | timestamp | | 訓練單元#預約開始時間 |
| -endAt | timestamp | | 訓練單元#預約結束時間 |
| -date | timestamp | | 暫時同startedAt |
| -duration | number | | 訓練時間長度(seconds) |
| -lesson | number | | 課程班次id |
| -unitId | number | | 課程單元id |
| -unitName | string | | 課程單元名稱(關聯欄位) |
| courseId | number | | 系列課程id |
| startedAt | string | 10 | 課程開始時間(HH:MM)|
| startDate | timestamp | | 班次開始時間 |
| endDate | timestamp | | 班次結束時間 |
| status | number | | 狀態 enum: [1: 未開始, 2: 進行中, 3: 已結束] |

example:

```json=
    {
        "id": 1,
        "supervision": "督導員",
        "cycleType": 2,
        "cycleDetail": [1, 4, 7],
        "user": 12,
        "duration": 300,
        "startedAt": 1583958097651,
        "updatedAt": 1583958097651,
        "personalCourse": [
            PersonalCourse,
            ...
        ]
    }
```

### 個人課程(PersonalCourse)

[個人課程](Untitled%2012/Untitled%201.csv)

example:

```json=
    {
        "comment": "安排平衡訓練項目",
        "startedAt": 1583950000000,
        "endAt": 1583960000000
    }
```

### 團體課程班次(GroupLesson)

[團體課程班次](Untitled%2012/Untitled%202.csv)

example:

```json=
    {
        "id": 1,
        "supervision": "督導員",
        "cycleType": 2,
        "cycleDetail": [1, 4, 7],
        "user": 12,
        "duration": 300,
        "startedAt": 1583958097651,
        "updatedAt": 1583958097651,
        "groupCourse": [
            GroupCourse,
            ...
        ]
    }
```

### 團體課程(GroupCourse)

[團體課程](Untitled%2012/Untitled%203.csv)

example:

```json=
    {
        "id": 666,
    		"date": 1583950000000,
    		"duration": 120,
        "startedAt": 1583950000000,
        "endAt": 1583960000000
    }
```

# API

## 查詢班次課程能否被刪除

Request:

    GET /lesson/isdeletable/$id
    
Response (成功):

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

## (OK) 查詢程班次列表（所有）

Request:

    GET /lesson/?$queryParams

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

Response (成功):

```json=
{
  "success": true,
  "total": 1,
  "data": [
    {
      "reservationInfo": [
        {
          "id": 17,
          "startedAt": 1594605600000,
          "endAt": 1594609200000,
          "date": "1594605600000",
          "comment": null,
          "duration": 3600,
          "lesson": 5,
          "unitId": null, //CourseUnitId
          "unitName": null //CourseUnitName
        }
      ],
      "user": [
        17 //UserId
      ],
      "id": 5,
      "createdAt": 1594531514945,
      "updatedAt": 1594622159434,
      "name": "林玉清 / A123111111",
      "type": 2,
      "limit": 1,
      "supervision": "James",
      "cycleType": null,
      "cycleDetail": [],
      "duration": 1594486800574,
      "startedAt": "1594519200097",
      "courseId": null,
      "organizationId": 1,
      "startDate": 1594605600000,
      "endDate": 1594881343304,
      "status": 2,
      "unitCount": 1,
      "userCount": 1
    },
    ...
  ]
}
```

## 個人課程班次

### 查詢個人程班次列表

Request:

    GET /lesson/personal?$queryParams

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

Response (成功):

```json=
    {
        "success": true,
    	"total": 5,
    	"data": [
    	    {
                "user":17,
                "id":5,
                "createdAt":1594531514945,
                "updatedAt":1594622159434,
                "name":"林玉清 / A123111111",
                "type":2,
                "limit":1,
                "supervision":"James",
                "cycleType":null,
                "cycleDetail":[
                ],
                "duration":1594486800574,
                "startedAt":"1594519200097",
                "courseId":null,
                "organizationId":1,
                "startDate":1594605600000,
                "endDate":1594881343304,
                "status":2,
                "unitCount":1, //CourseUnit Count
                "userCount":1,
                "personalCourse":[
                    {
                        "id":17, //ReservationId
                        "startedAt":1594605600000,
                        "endAt":1594609200000,
                        "comment":null,
                        "courseUnit":null, //CourseUnitId
                        "lesson":5 //LessonId
                    }
                ]
            }
    	]
    }
```

### 新增個人課程班次

Request:

    POST /lesson/personal

Payload:

```json=
{
    "name":"test record",
    "supervision":"tester",
    "cycleType":1, //循環模式
    "cycleDetail":[1,4,7], //週期
    "user":1,
    "duration":300,
    "startedAt":"23:00",
    "startDate":1594825200000,
    "endDate":1594912200000,
    "personalCourse":[
        {
            "startedAt":1594825200000,
            "endAt":1594825800000,
            "comment":"test-1" //備註
        },{
            "startedAt":1594911600000,
            "endAt":1594912200000,
            "comment":"test-2"
        }
    ]
}
```

Response (成功):

```json=
    {
    	"success": true,
    	"data": {
            "name":"test record",
            "supervision":"tester",
            "user":1,
            "cycleType":1,
            "cycleDetail":"[1,4,7]",
            "duration":300,
            "personalCourse":[
                {
                    "startedAt":1594911600000,
                    "endAt":1594912200000,
                    "comment":"test-1"
                },{
                    "startedAt":1594998000000,
                    "endAt":1594998600000,
                    "comment":"test-2"
                }
            ],
            "startedAt":"23:00",
            "startDate":1594911600000,
            "endDate":1594998600000,
            "type":2,
            "limit":1,
            "organizationId":1,
            "id":23
        }
    }
```

### 編輯個人課程班次

Request:

    PUT /lesson/personal/$id

Payload:

```json=
    {
        "name":"test record",
        "supervision":"tester",
        "cycleType":1,"cycleDetail":[1,4,7],
        "user":1,
        "duration":300,
        "startedAt":"23:00",
        "startDate":"1594825200000",
        "endDate":"1594912200000",
        "personalCourse":[
            {
                "startedAt":1594825200000,
                "endAt":1594825800000,
                "comment":"test-1 after revised"
            },{
                "startedAt":1594911600000,
                "endAt":1594912200000,
                "comment":"test-2 after revised"
            }
        ]
    }
```

Response (成功):

```json=
    {
    		"success": true,
    		"data": {
    						PersonalLesson
    		}
    }
```

### 查詢個人課程班次列表

Request:

    GET /lesson/personal?$queryParams

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

Response (成功):

```json=
    {
    		"success": true,
    	  "total": 5,
    		"data": [
    						PersonalLesson,
    						PersonalLesson,
             ...
    		]
    }
```

### 查詢個人課程班次

Request:

    GET /lesson/personal/$id

Response (成功):

```json=
    {
    		"success": true,
    		"data": {
            PersonalLesson
        }
    }
```

### 刪除個人課程班次

Request:

    DELETE /lesson/personal/$id

Response (成功):

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

## 團體課程班次

### (OK) 新增團體課程班次

Request:

    POST /lesson/group

Payload:

```json=
    {
       GroupLesson
    }
```

Response (成功):

```json=
    {
    		"success": true,
    		"data": {
    			GroupLesson
    		}
    }
```

### (OK) 編輯團體課程班次

Request:

    PUT /lesson/group/$id

Payload:

```json=
    {
       GroupLesson
    }
```

Response (成功):

```json=
    {
    		"success": true,
    		"data": {
    			GroupLesson
    		}
    }
```

### (OK) 查詢團體課程班次列表

Request:

    GET /lesson/group?$queryParams

[Params:](Untitled%2012/Params.csv)

### (OK) 查詢團體課程班次

Request:

    GET /lesson/group/$id

Response (成功):

```json=
    {
    		"success": true,
    		"data": [
            {
    					GroupLesson,
    				]
        ]
    }
```

### (OK) 刪除團體課程班次

Request:

    DELETE /lesson/group/$id

Response (成功):

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

### (OK) 新增團體課程班次學員

Request:

    POST /lesson/group/$id/user

Payload:

```json=
    {
       user: [1,2,444,666,888]
    }
```

Response (成功):

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

### (OK) 查詢團體課程班次學員清單

Request:

    GET /lesson/group/$id/user

Response (成功):

```json=
    {
    		"success": true,
    		"data": [
    			{
            "id": 1,
            "checkIn": true
          },
          {
            "id": 2,
            "checkIn": false
          }
    		]
    }
```

### (OK) 簽到團體課程班次學員

Request:

    PUT /lesson/group/$gid/user/$uid/$lessonCourseUnitId

Response (成功):

```json=
    {
    		"success": true,
    		"data": {
    			"updatedAt": 1583958097651,
    		}
    }
```

### (待確認) 刪除團體課程班次學員

Request:

    POST /lesson/group/$gid/delete/$gid

Response (成功):

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