Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trainee-schedule
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Đoàn Vũ Bình Dương
trainee-schedule
Commits
01fc82c4
Commit
01fc82c4
authored
Apr 10, 2026
by
Blockchain-vn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add/file-md-description-api
parent
4d104c8c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1057 additions
and
0 deletions
+1057
-0
API_DESCRIPTION.md
API_DESCRIPTION.md
+1057
-0
No files found.
API_DESCRIPTION.md
0 → 100644
View file @
01fc82c4
# Trainee Schedule API Contract
## Base URL
```
http://localhost:3001/api/v1.0
```
## Authentication
Currently disabled for development. All endpoints are accessible without authentication.
## Response Format
```
json
{
"success"
:
true
,
"data"
:
{},
"message"
:
"Success"
,
"timestamp"
:
"2026-04-10T20:00:00.000Z"
}
```
## Error Response Format
```
json
{
"success"
:
false
,
"error"
:
{
"code"
:
"ERROR_CODE"
,
"message"
:
"Error description"
,
"details"
:
{}
},
"timestamp"
:
"2026-04-10T20:00:00.000Z"
}
```
---
# STUDENTS API
## 1. Get All Students
**Endpoint:**
`GET /students`
**Description:**
Lấy danh sách tất cả học viên với phân trang và bộ lọc
**Query Parameters:**
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| page | number | No | 1 | Số trang |
| pageSize | number | No | 10 | Số lượng item mỗi trang |
| status | string | No | - | Lọc theo trạng thái (active, inactive, completed) |
| courseId | string | No | - | Lọc theo ID khóa học |
| search | string | No | - | Tìm kiếm theo họ tên hoặc email |
| semester | string | No | - | Lọc theo kỳ học |
**Request Example:**
```
bash
GET /students?page
=
1&pageSize
=
10&status
=
active&search
=
nguyen
```
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"count"
:
50
,
"page"
:
1
,
"pageSize"
:
10
,
"rows"
:
[
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0j"
,
"fullName"
:
"Nguyễn Văn A"
,
"email"
:
"nguyenvana@example.com"
,
"phone"
:
"0123456789"
,
"courseId"
:
"64f1a2b3c4d5e6f7g8h9i0k"
,
"courseName"
:
"Lập trình Node.js"
,
"semester"
:
"2024-1"
,
"status"
:
"active"
,
"startDate"
:
"2024-01-15T00:00:00.000Z"
,
"endDate"
:
"2024-06-15T00:00:00.000Z"
,
"scheduleIds"
:
[
"64f1a2b3c4d5e6f7g8h9i0l"
],
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-10T10:00:00.000Z"
}
]
}
}
```
---
## 2. Get Student by ID
**Endpoint:**
`GET /students/{id}`
**Description:**
Lấy thông tin chi tiết một học viên
**Path Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | string | Yes | ID của học viên |
**Request Example:**
```
bash
GET /students/64f1a2b3c4d5e6f7g8h9i0j
```
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0j"
,
"fullName"
:
"Nguyễn Văn A"
,
"email"
:
"nguyenvana@example.com"
,
"phone"
:
"0123456789"
,
"courseId"
:
"64f1a2b3c4d5e6f7g8h9i0k"
,
"courseName"
:
"Lập trình Node.js"
,
"semester"
:
"2024-1"
,
"status"
:
"active"
,
"startDate"
:
"2024-01-15T00:00:00.000Z"
,
"endDate"
:
"2024-06-15T00:00:00.000Z"
,
"scheduleIds"
:
[
"64f1a2b3c4d5e6f7g8h9i0l"
],
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-10T10:00:00.000Z"
}
}
```
---
## 3. Create Student
**Endpoint:**
`POST /students`
**Description:**
Tạo mới một học viên
**Request Headers:**
```
Content-Type: application/json
```
**Request Body:**
```
json
{
"fullName"
:
"Nguyễn Văn B"
,
"email"
:
"nguyenvanb@example.com"
,
"phone"
:
"0987654321"
,
"courseId"
:
"64f1a2b3c4d5e6f7g8h9i0k"
,
"courseName"
:
"Lập trình Node.js"
,
"semester"
:
"2024-1"
,
"startDate"
:
"2024-01-15T00:00:00.000Z"
,
"endDate"
:
"2024-06-15T00:00:00.000Z"
}
```
**Validation Rules:**
-
`fullName`
: Bắt buộc, max 100 ký tự
-
`email`
: Bắt buộc, định dạng email hợp lệ, unique
-
`phone`
: Bắt buộc, 10-11 số
-
`courseId`
: Bắt buộc, tồn tại trong courses collection
-
`courseName`
: Bắt buộc
-
`semester`
: Bắt buộc
-
`startDate`
: Bắt buộc, định dạng Date
-
`endDate`
: Bắt buộc, phải sau startDate
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0m"
,
"fullName"
:
"Nguyễn Văn B"
,
"email"
:
"nguyenvanb@example.com"
,
"phone"
:
"0987654321"
,
"courseId"
:
"64f1a2b3c4d5e6f7g8h9i0k"
,
"courseName"
:
"Lập trình Node.js"
,
"semester"
:
"2024-1"
,
"status"
:
"active"
,
"startDate"
:
"2024-01-15T00:00:00.000Z"
,
"endDate"
:
"2024-06-15T00:00:00.000Z"
,
"scheduleIds"
:
[],
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-10T10:00:00.000Z"
},
"message"
:
"Student created successfully"
}
```
---
## 4. Update Student
**Endpoint:**
`PUT /students/{id}`
**Description:**
Cập nhật thông tin học viên
**Path Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | string | Yes | ID của học viên |
**Request Headers:**
```
Content-Type: application/json
```
**Request Body:**
```
json
{
"fullName"
:
"Nguyễn Văn B Updated"
,
"email"
:
"nguyenvanb.updated@example.com"
,
"phone"
:
"0987654321"
,
"courseId"
:
"64f1a2b3c4d5e6f7g8h9i0k"
,
"courseName"
:
"Lập trình Node.js Advanced"
,
"semester"
:
"2024-2"
,
"status"
:
"active"
}
```
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0m"
,
"fullName"
:
"Nguyễn Văn B Updated"
,
"email"
:
"nguyenvanb.updated@example.com"
,
"phone"
:
"0987654321"
,
"courseId"
:
"64f1a2b3c4d5e6f7g8h9i0k"
,
"courseName"
:
"Lập trình Node.js Advanced"
,
"semester"
:
"2024-2"
,
"status"
:
"active"
,
"startDate"
:
"2024-01-15T00:00:00.000Z"
,
"endDate"
:
"2024-06-15T00:00:00.000Z"
,
"scheduleIds"
:
[],
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-11T10:00:00.000Z"
},
"message"
:
"Student updated successfully"
}
```
---
## 5. Delete Student
**Endpoint:**
`DELETE /students/{id}`
**Description:**
Xóa một học viên
**Path Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | string | Yes | ID của học viên |
**Request Example:**
```
bash
DELETE /students/64f1a2b3c4d5e6f7g8h9i0j
```
**Response Example:**
```
json
{
"success"
:
true
,
"message"
:
"Student deleted successfully"
}
```
---
# COURSES API
## 1. Get All Courses
**Endpoint:**
`GET /courses`
**Description:**
Lấy danh sách tất cả khóa học với phân trang và bộ lọc
**Query Parameters:**
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| page | number | No | 1 | Số trang |
| pageSize | number | No | 10 | Số lượng item mỗi trang |
| status | string | No | - | Lọc theo trạng thái (active, inactive, completed) |
| instructor | string | No | - | Lọc theo tên giảng viên |
| search | string | No | - | Tìm kiếm theo tên hoặc mã khóa học |
**Request Example:**
```
bash
GET /courses?page
=
1&pageSize
=
10&status
=
active&search
=
nodejs
```
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"count"
:
25
,
"page"
:
1
,
"pageSize"
:
10
,
"rows"
:
[
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0k"
,
"code"
:
"NODEJS101"
,
"name"
:
"Lập trình Node.js"
,
"description"
:
"Khóa học lập trình Node.js từ cơ bản đến nâng cao"
,
"instructor"
:
"Nguyễn Văn C"
,
"duration"
:
12
,
"maxStudents"
:
30
,
"status"
:
"active"
,
"scheduleIds"
:
[
"64f1a2b3c4d5e6f7g8h9i0l"
],
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-10T10:00:00.000Z"
}
]
}
}
```
---
## 2. Get Course by ID
**Endpoint:**
`GET /courses/{id}`
**Description:**
Lấy thông tin chi tiết một khóa học
**Path Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | string | Yes | ID của khóa học |
**Request Example:**
```
bash
GET /courses/64f1a2b3c4d5e6f7g8h9i0k
```
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0k"
,
"code"
:
"NODEJS101"
,
"name"
:
"Lập trình Node.js"
,
"description"
:
"Khóa học lập trình Node.js từ cơ bản đến nâng cao"
,
"instructor"
:
"Nguyễn Văn C"
,
"duration"
:
12
,
"maxStudents"
:
30
,
"status"
:
"active"
,
"scheduleIds"
:
[
"64f1a2b3c4d5e6f7g8h9i0l"
],
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-10T10:00:00.000Z"
}
}
```
---
## 3. Create Course
**Endpoint:**
`POST /courses`
**Description:**
Tạo mới một khóa học
**Request Headers:**
```
Content-Type: application/json
```
**Request Body:**
```
json
{
"code"
:
"REACT102"
,
"name"
:
"Lập trình React"
,
"description"
:
"Khóa học React từ cơ bản đến nâng cao"
,
"instructor"
:
"Nguyễn Văn D"
,
"duration"
:
10
,
"maxStudents"
:
25
,
"status"
:
"active"
}
```
**Validation Rules:**
-
`code`
: Bắt buộc, unique
-
`name`
: Bắt buộc, max 200 ký tự
-
`description`
: Không bắt buộc
-
`instructor`
: Bắt buộc
-
`duration`
: Bắt buộc, số > 0
-
`maxStudents`
: Bắt buộc, số > 0
-
`status`
: Bắt buộc, enum
[
'active', 'inactive', 'completed'
]
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0n"
,
"code"
:
"REACT102"
,
"name"
:
"Lập trình React"
,
"description"
:
"Khóa học React từ cơ bản đến nâng cao"
,
"instructor"
:
"Nguyễn Văn D"
,
"duration"
:
10
,
"maxStudents"
:
25
,
"status"
:
"active"
,
"scheduleIds"
:
[],
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-10T10:00:00.000Z"
},
"message"
:
"Course created successfully"
}
```
---
## 4. Update Course
**Endpoint:**
`PUT /courses/{id}`
**Description:**
Cập nhật thông tin khóa học
**Path Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | string | Yes | ID của khóa học |
**Request Headers:**
```
Content-Type: application/json
```
**Request Body:**
```
json
{
"name"
:
"Lập trình React Advanced"
,
"description"
:
"Khóa học React nâng cao"
,
"instructor"
:
"Nguyễn Văn D Updated"
,
"duration"
:
12
,
"maxStudents"
:
30
,
"status"
:
"active"
}
```
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0n"
,
"code"
:
"REACT102"
,
"name"
:
"Lập trình React Advanced"
,
"description"
:
"Khóa học React nâng cao"
,
"instructor"
:
"Nguyễn Văn D Updated"
,
"duration"
:
12
,
"maxStudents"
:
30
,
"status"
:
"active"
,
"scheduleIds"
:
[],
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-11T10:00:00.000Z"
},
"message"
:
"Course updated successfully"
}
```
---
## 5. Delete Course
**Endpoint:**
`DELETE /courses/{id}`
**Description:**
Xóa một khóa học
**Path Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | string | Yes | ID của khóa học |
**Request Example:**
```
bash
DELETE /courses/64f1a2b3c4d5e6f7g8h9i0k
```
**Response Example:**
```
json
{
"success"
:
true
,
"message"
:
"Course deleted successfully"
}
```
---
# SCHEDULES API
## 1. Get All Schedules
**Endpoint:**
`GET /schedules`
**Description:**
Lấy danh sách tất cả lịch học với phân trang và bộ lọc
**Query Parameters:**
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| page | number | No | 1 | Số trang |
| pageSize | number | No | 10 | Số lượng item mỗi trang |
| courseId | string | No | - | Lọc theo ID khóa học |
| status | string | No | - | Lọc theo trạng thái (scheduled, completed, cancelled) |
| date | string | No | - | Lọc theo ngày (YYYY-MM-DD) |
| search | string | No | - | Tìm kiếm theo tiêu đề hoặc địa điểm |
**Request Example:**
```
bash
GET /schedules?page
=
1&pageSize
=
10&courseId
=
64f1a2b3c4d5e6f7g8h9i0k&status
=
scheduled
```
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"count"
:
40
,
"page"
:
1
,
"pageSize"
:
10
,
"rows"
:
[
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0l"
,
"title"
:
"Buổi 1 - Giới thiệu Node.js"
,
"description"
:
"Giới thiệu tổng quan về Node.js"
,
"courseId"
:
"64f1a2b3c4d5e6f7g8h9i0k"
,
"date"
:
"2024-01-15T09:00:00.000Z"
,
"duration"
:
120
,
"location"
:
"Phòng A101"
,
"status"
:
"scheduled"
,
"studentIds"
:
[
"64f1a2b3c4d5e6f7g8h9i0j"
],
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-10T10:00:00.000Z"
}
]
}
}
```
---
## 2. Get Schedule by ID
**Endpoint:**
`GET /schedules/{id}`
**Description:**
Lấy thông tin chi tiết một lịch học
**Path Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | string | Yes | ID của lịch học |
**Request Example:**
```
bash
GET /schedules/64f1a2b3c4d5e6f7g8h9i0l
```
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0l"
,
"title"
:
"Buổi 1 - Giới thiệu Node.js"
,
"description"
:
"Giới thiệu tổng quan về Node.js"
,
"courseId"
:
"64f1a2b3c4d5e6f7g8h9i0k"
,
"date"
:
"2024-01-15T09:00:00.000Z"
,
"duration"
:
120
,
"location"
:
"Phòng A101"
,
"status"
:
"scheduled"
,
"studentIds"
:
[
"64f1a2b3c4d5e6f7g8h9i0j"
],
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-10T10:00:00.000Z"
}
}
```
---
## 3. Create Schedule
**Endpoint:**
`POST /schedules`
**Description:**
Tạo mới một lịch học
**Request Headers:**
```
Content-Type: application/json
```
**Request Body:**
```
json
{
"title"
:
"Buổi 2 - Node.js Modules"
,
"description"
:
"Tìm hiểu về Node.js modules"
,
"courseId"
:
"64f1a2b3c4d5e6f7g8h9i0k"
,
"date"
:
"2024-01-17T09:00:00.000Z"
,
"duration"
:
120
,
"location"
:
"Phòng A102"
,
"status"
:
"scheduled"
}
```
**Validation Rules:**
-
`title`
: Bắt buộc, max 200 ký tự
-
`description`
: Không bắt buộc
-
`courseId`
: Bắt buộc, tồn tại trong courses collection
-
`date`
: Bắt buộc, định dạng Date
-
`duration`
: Bắt buộc, số > 0 (phút)
-
`location`
: Bắt buộc
-
`status`
: Bắt buộc, enum
[
'scheduled', 'completed', 'cancelled'
]
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0o"
,
"title"
:
"Buổi 2 - Node.js Modules"
,
"description"
:
"Tìm hiểu về Node.js modules"
,
"courseId"
:
"64f1a2b3c4d5e6f7g8h9i0k"
,
"date"
:
"2024-01-17T09:00:00.000Z"
,
"duration"
:
120
,
"location"
:
"Phòng A102"
,
"status"
:
"scheduled"
,
"studentIds"
:
[],
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-10T10:00:00.000Z"
},
"message"
:
"Schedule created successfully"
}
```
---
## 4. Update Schedule
**Endpoint:**
`PUT /schedules/{id}`
**Description:**
Cập nhật thông tin lịch học
**Path Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | string | Yes | ID của lịch học |
**Request Headers:**
```
Content-Type: application/json
```
**Request Body:**
```
json
{
"title"
:
"Buổi 2 - Node.js Modules Updated"
,
"description"
:
"Tìm hiểu sâu về Node.js modules"
,
"location"
:
"Phòng A103"
,
"status"
:
"scheduled"
}
```
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0o"
,
"title"
:
"Buổi 2 - Node.js Modules Updated"
,
"description"
:
"Tìm hiểu sâu về Node.js modules"
,
"courseId"
:
"64f1a2b3c4d5e6f7g8h9i0k"
,
"date"
:
"2024-01-17T09:00:00.000Z"
,
"duration"
:
120
,
"location"
:
"Phòng A103"
,
"status"
:
"scheduled"
,
"studentIds"
:
[],
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-11T10:00:00.000Z"
},
"message"
:
"Schedule updated successfully"
}
```
---
## 5. Delete Schedule
**Endpoint:**
`DELETE /schedules/{id}`
**Description:**
Xóa một lịch học
**Path Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | string | Yes | ID của lịch học |
**Request Example:**
```
bash
DELETE /schedules/64f1a2b3c4d5e6f7g8h9i0l
```
**Response Example:**
```
json
{
"success"
:
true
,
"message"
:
"Schedule deleted successfully"
}
```
---
# BOOKINGS API
## 1. Get All Bookings
**Endpoint:**
`GET /bookings`
**Description:**
Lấy danh sách tất cả đăng ký với phân trang và bộ lọc
**Query Parameters:**
| Parameter | Type | Required | Default | Description |
|-----------|------|----------|---------|-------------|
| page | number | No | 1 | Số trang |
| pageSize | number | No | 10 | Số lượng item mỗi trang |
| studentId | string | No | - | Lọc theo ID học viên |
| scheduleId | string | No | - | Lọc theo ID lịch học |
| status | string | No | - | Lọc theo trạng thái (confirmed, cancelled, completed) |
| search | string | No | - | Tìm kiếm theo ghi chú |
**Request Example:**
```
bash
GET /bookings?page
=
1&pageSize
=
10&status
=
confirmed&studentId
=
64f1a2b3c4d5e6f7g8h9i0j
```
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"count"
:
30
,
"page"
:
1
,
"pageSize"
:
10
,
"rows"
:
[
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0p"
,
"studentId"
:
"64f1a2b3c4d5e6f7g8h9i0j"
,
"scheduleId"
:
"64f1a2b3c4d5e6f7g8h9i0l"
,
"bookingDate"
:
"2024-01-12T10:00:00.000Z"
,
"status"
:
"confirmed"
,
"notes"
:
"Học viên đã xác nhận tham gia"
,
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-10T10:00:00.000Z"
}
]
}
}
```
---
## 2. Get Booking by ID
**Endpoint:**
`GET /bookings/{id}`
**Description:**
Lấy thông tin chi tiết một đăng ký
**Path Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | string | Yes | ID của đăng ký |
**Request Example:**
```
bash
GET /bookings/64f1a2b3c4d5e6f7g8h9i0p
```
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0p"
,
"studentId"
:
"64f1a2b3c4d5e6f7g8h9i0j"
,
"scheduleId"
:
"64f1a2b3c4d5e6f7g8h9i0l"
,
"bookingDate"
:
"2024-01-12T10:00:00.000Z"
,
"status"
:
"confirmed"
,
"notes"
:
"Học viên đã xác nhận tham gia"
,
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-10T10:00:00.000Z"
}
}
```
---
## 3. Create Booking
**Endpoint:**
`POST /bookings`
**Description:**
Tạo mới một đăng ký
**Request Headers:**
```
Content-Type: application/json
```
**Request Body:**
```
json
{
"studentId"
:
"64f1a2b3c4d5e6f7g8h9i0j"
,
"scheduleId"
:
"64f1a2b3c4d5e6f7g8h9i0l"
,
"status"
:
"confirmed"
,
"notes"
:
"Đăng ký tham gia buổi học"
}
```
**Validation Rules:**
-
`studentId`
: Bắt buộc, tồn tại trong students collection
-
`scheduleId`
: Bắt buộc, tồn tại trong schedules collection
-
`status`
: Bắt buộc, enum
[
'confirmed', 'cancelled', 'completed'
]
-
`notes`
: Không bắt buộc, max 500 ký tự
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0q"
,
"studentId"
:
"64f1a2b3c4d5e6f7g8h9i0j"
,
"scheduleId"
:
"64f1a2b3c4d5e6f7g8h9i0l"
,
"bookingDate"
:
"2024-01-12T10:00:00.000Z"
,
"status"
:
"confirmed"
,
"notes"
:
"Đăng ký tham gia buổi học"
,
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-10T10:00:00.000Z"
},
"message"
:
"Booking created successfully"
}
```
---
## 4. Update Booking
**Endpoint:**
`PUT /bookings/{id}`
**Description:**
Cập nhật thông tin đăng ký
**Path Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | string | Yes | ID của đăng ký |
**Request Headers:**
```
Content-Type: application/json
```
**Request Body:**
```
json
{
"status"
:
"completed"
,
"notes"
:
"Học viên đã hoàn thành buổi học"
}
```
**Response Example:**
```
json
{
"success"
:
true
,
"data"
:
{
"_id"
:
"64f1a2b3c4d5e6f7g8h9i0q"
,
"studentId"
:
"64f1a2b3c4d5e6f7g8h9i0j"
,
"scheduleId"
:
"64f1a2b3c4d5e6f7g8h9i0l"
,
"bookingDate"
:
"2024-01-12T10:00:00.000Z"
,
"status"
:
"completed"
,
"notes"
:
"Học viên đã hoàn thành buổi học"
,
"createdAt"
:
"2024-01-10T10:00:00.000Z"
,
"updatedAt"
:
"2024-01-11T10:00:00.000Z"
},
"message"
:
"Booking updated successfully"
}
```
---
## 5. Delete Booking
**Endpoint:**
`DELETE /bookings/{id}`
**Description:**
Xóa một đăng ký
**Path Parameters:**
| Parameter | Type | Required | Description |
|-----------|------|----------|-------------|
| id | string | Yes | ID của đăng ký |
**Request Example:**
```
bash
DELETE /bookings/64f1a2b3c4d5e6f7g8h9i0p
```
**Response Example:**
```
json
{
"success"
:
true
,
"message"
:
"Booking deleted successfully"
}
```
---
# DATA MODELS
## Student Model
```
typescript
interface
IStudent
{
_id
:
string
;
fullName
:
string
;
email
:
string
;
phone
:
string
;
courseId
:
string
;
courseName
:
string
;
semester
:
string
;
status
:
'active'
|
'inactive'
|
'completed'
;
startDate
:
Date
;
endDate
:
Date
;
scheduleIds
:
string
[];
createdAt
:
Date
;
updatedAt
:
Date
;
createdBy
?:
string
;
updatedBy
?:
string
;
}
```
## Course Model
```
typescript
interface
ICourse
{
_id
:
string
;
code
:
string
;
name
:
string
;
description
:
string
;
instructor
:
string
;
duration
:
number
;
maxStudents
:
number
;
status
:
'active'
|
'inactive'
|
'completed'
;
scheduleIds
:
string
[];
createdAt
:
Date
;
updatedAt
:
Date
;
createdBy
?:
string
;
updatedBy
?:
string
;
}
```
## Schedule Model
```
typescript
interface
ISchedule
{
_id
:
string
;
title
:
string
;
description
:
string
;
courseId
:
string
;
date
:
Date
;
duration
:
number
;
location
:
string
;
status
:
'scheduled'
|
'completed'
|
'cancelled'
;
studentIds
:
string
[];
createdAt
:
Date
;
updatedAt
:
Date
;
createdBy
?:
string
;
updatedBy
?:
string
;
}
```
## Booking Model
```
typescript
interface
IBooking
{
_id
:
string
;
studentId
:
string
;
scheduleId
:
string
;
bookingDate
:
Date
;
status
:
'confirmed'
|
'cancelled'
|
'completed'
;
notes
:
string
;
createdAt
:
Date
;
updatedAt
:
Date
;
createdBy
?:
string
;
updatedBy
?:
string
;
}
```
---
# ERROR CODES
| Error Code | HTTP Status | Description |
|------------|-------------|-------------|
| VALIDATION_ERROR | 400 | Request validation failed |
| NOT_FOUND | 404 | Resource not found |
| DUPLICATE_KEY | 409 | Duplicate resource (e.g., email already exists) |
| INTERNAL_ERROR | 500 | Internal server error |
---
# TESTING
## Swagger UI
Interactive API documentation available at:
`http://localhost:3001/api-docs`
## Example cURL Commands
### Get All Students
```
bash
curl
-X
GET
"http://localhost:3001/api/v1.0/students?page=1&pageSize=10"
```
### Create Student
```
bash
curl
-X
POST
"http://localhost:3001/api/v1.0/students"
\
-H
"Content-Type: application/json"
\
-d
'{
"fullName": "Test Student",
"email": "test@example.com",
"phone": "0123456789",
"courseId": "64f1a2b3c4d5e6f7g8h9i0k",
"courseName": "Test Course",
"semester": "2024-1",
"startDate": "2024-01-15T00:00:00.000Z",
"endDate": "2024-06-15T00:00:00.000Z"
}'
```
### Update Student
```
bash
curl
-X
PUT
"http://localhost:3001/api/v1.0/students/64f1a2b3c4d5e6f7g8h9i0j"
\
-H
"Content-Type: application/json"
\
-d
'{
"fullName": "Updated Student Name",
"status": "active"
}'
```
### Delete Student
```
bash
curl
-X
DELETE
"http://localhost:3001/api/v1.0/students/64f1a2b3c4d5e6f7g8h9i0j"
```
---
# VERSION HISTORY
| Version | Date | Changes |
|---------|------|---------|
| 1.0.0 | 2026-04-10 | Initial API contract for Phase 1 - Students, Courses, Schedules, Bookings CRUD APIs |
---
*Last Updated: 2026-04-10*
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment