update
This commit is contained in:
36
routes/chapterLessonRoutes.js
Normal file
36
routes/chapterLessonRoutes.js
Normal file
@@ -0,0 +1,36 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const lessonController = require('../controllers/lessonController');
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Chapter Lessons
|
||||
* description: Quản lý bài học theo chương
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/chapters/{chapter_id}/lessons:
|
||||
* get:
|
||||
* tags: [Chapter Lessons]
|
||||
* summary: Lấy danh sách bài học của chương
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: chapter_id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* format: uuid
|
||||
* - in: query
|
||||
* name: include_unpublished
|
||||
* schema:
|
||||
* type: boolean
|
||||
* default: false
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Danh sách bài học
|
||||
*/
|
||||
router.get('/:chapter_id/lessons', lessonController.getLessonsByChapter);
|
||||
|
||||
module.exports = router;
|
||||
224
routes/lessonRoutes.js
Normal file
224
routes/lessonRoutes.js
Normal file
@@ -0,0 +1,224 @@
|
||||
const express = require('express');
|
||||
const router = express.Router();
|
||||
const lessonController = require('../controllers/lessonController');
|
||||
const { authenticateToken } = require('../middleware/auth');
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* tags:
|
||||
* name: Lessons
|
||||
* description: Quản lý bài học
|
||||
*/
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/lessons:
|
||||
* get:
|
||||
* tags: [Lessons]
|
||||
* summary: Lấy danh sách bài học
|
||||
* description: Lấy tất cả bài học với phân trang và filter
|
||||
* parameters:
|
||||
* - in: query
|
||||
* name: page
|
||||
* schema:
|
||||
* type: integer
|
||||
* default: 1
|
||||
* - in: query
|
||||
* name: limit
|
||||
* schema:
|
||||
* type: integer
|
||||
* default: 20
|
||||
* - in: query
|
||||
* name: is_published
|
||||
* schema:
|
||||
* type: boolean
|
||||
* - in: query
|
||||
* name: is_free
|
||||
* schema:
|
||||
* type: boolean
|
||||
* - in: query
|
||||
* name: lesson_type
|
||||
* schema:
|
||||
* type: string
|
||||
* enum: [json_content, url_content]
|
||||
* - in: query
|
||||
* name: search
|
||||
* schema:
|
||||
* type: string
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Danh sách bài học
|
||||
*/
|
||||
router.get('/', lessonController.getAllLessons);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/lessons/{id}:
|
||||
* get:
|
||||
* tags: [Lessons]
|
||||
* summary: Lấy chi tiết bài học
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* format: uuid
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Chi tiết bài học
|
||||
* 404:
|
||||
* description: Không tìm thấy bài học
|
||||
*/
|
||||
router.get('/:id', lessonController.getLessonById);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/lessons/{id}/games:
|
||||
* get:
|
||||
* tags: [Lessons]
|
||||
* summary: Lấy danh sách game phù hợp với bài học
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* format: uuid
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Danh sách game engines
|
||||
*/
|
||||
router.get('/:id/games', lessonController.getMatchingGames);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/lessons:
|
||||
* post:
|
||||
* tags: [Lessons]
|
||||
* summary: Tạo bài học mới
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required:
|
||||
* - chapter_id
|
||||
* - lesson_title
|
||||
* - lesson_type
|
||||
* properties:
|
||||
* chapter_id:
|
||||
* type: string
|
||||
* format: uuid
|
||||
* lesson_number:
|
||||
* type: integer
|
||||
* lesson_title:
|
||||
* type: string
|
||||
* lesson_type:
|
||||
* type: string
|
||||
* enum: [json_content, url_content]
|
||||
* lesson_description:
|
||||
* type: string
|
||||
* content_json:
|
||||
* type: object
|
||||
* content_url:
|
||||
* type: string
|
||||
* content_type:
|
||||
* type: string
|
||||
* duration_minutes:
|
||||
* type: integer
|
||||
* is_published:
|
||||
* type: boolean
|
||||
* is_free:
|
||||
* type: boolean
|
||||
* responses:
|
||||
* 201:
|
||||
* description: Tạo bài học thành công
|
||||
*/
|
||||
router.post('/', authenticateToken, lessonController.createLesson);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/lessons/{id}:
|
||||
* put:
|
||||
* tags: [Lessons]
|
||||
* summary: Cập nhật bài học
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* format: uuid
|
||||
* requestBody:
|
||||
* required: true
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Cập nhật thành công
|
||||
*/
|
||||
router.put('/:id', authenticateToken, lessonController.updateLesson);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/lessons/{id}:
|
||||
* delete:
|
||||
* tags: [Lessons]
|
||||
* summary: Xóa bài học
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* format: uuid
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Xóa thành công
|
||||
*/
|
||||
router.delete('/:id', authenticateToken, lessonController.deleteLesson);
|
||||
|
||||
/**
|
||||
* @swagger
|
||||
* /api/lessons/{id}/complete:
|
||||
* post:
|
||||
* tags: [Lessons]
|
||||
* summary: Đánh dấu hoàn thành bài học
|
||||
* security:
|
||||
* - bearerAuth: []
|
||||
* parameters:
|
||||
* - in: path
|
||||
* name: id
|
||||
* required: true
|
||||
* schema:
|
||||
* type: string
|
||||
* format: uuid
|
||||
* requestBody:
|
||||
* content:
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* properties:
|
||||
* score:
|
||||
* type: integer
|
||||
* time_spent:
|
||||
* type: integer
|
||||
* results_data:
|
||||
* type: object
|
||||
* responses:
|
||||
* 200:
|
||||
* description: Hoàn thành bài học
|
||||
*/
|
||||
router.post('/:id/complete', authenticateToken, lessonController.completeLesson);
|
||||
|
||||
module.exports = router;
|
||||
Reference in New Issue
Block a user