This commit is contained in:
silverpro89
2026-01-26 20:23:08 +07:00
parent 53d97ba5db
commit 2c7b4675a7
49 changed files with 12668 additions and 1 deletions

View File

@@ -0,0 +1,273 @@
const express = require('express');
const router = express.Router();
const learningContentController = require('../controllers/learningContentController');
const { authenticateToken } = require('../middleware/auth');
/**
* @swagger
* tags:
* name: Learning Content
* description: Learning content management (Subject → Chapter → Lesson)
*/
/**
* @swagger
* /api/learning-content/guide:
* get:
* summary: Get comprehensive learning content guide for AI
* tags: [Learning Content]
* description: Returns complete guide for Subject → Chapter → Lesson hierarchy and content structure
* responses:
* 200:
* description: Learning content guide
* content:
* application/json:
* schema:
* type: object
* properties:
* success:
* type: boolean
* data:
* type: object
* properties:
* guide_version:
* type: string
* hierarchy:
* type: object
* subject_structure:
* type: object
* chapter_structure:
* type: object
* lesson_structure:
* type: object
* lesson_content_types:
* type: object
*/
router.get('/guide', learningContentController.getLearningContentGuide);
/**
* @swagger
* /api/learning-content/lessons:
* post:
* summary: Create new lesson
* tags: [Learning Content]
* security:
* - bearerAuth: []
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required:
* - chapter_id
* - lesson_number
* - lesson_title
* properties:
* chapter_id:
* type: string
* format: uuid
* description: Parent chapter UUID
* lesson_number:
* type: integer
* description: Sequential lesson number
* lesson_title:
* type: string
* maxLength: 200
* lesson_type:
* type: string
* enum: [json_content, url_content]
* default: json_content
* lesson_description:
* type: string
* lesson_content_type:
* type: string
* enum: [vocabulary, grammar, phonics, review, mixed]
* content_json:
* type: object
* description: JSON content structure (see guide for details)
* content_url:
* type: string
* content_type:
* type: string
* enum: [video, audio, pdf, image, interactive]
* duration_minutes:
* type: integer
* is_published:
* type: boolean
* default: false
* is_free:
* type: boolean
* default: false
* display_order:
* type: integer
* default: 0
* thumbnail_url:
* type: string
* responses:
* 201:
* description: Lesson created successfully
* 400:
* description: Validation error
* 404:
* description: Chapter not found
*/
router.post('/lessons', authenticateToken, learningContentController.createLesson);
/**
* @swagger
* /api/learning-content/lessons:
* get:
* summary: Get all lessons with pagination and filters
* tags: [Learning Content]
* parameters:
* - in: query
* name: page
* schema:
* type: integer
* default: 1
* - in: query
* name: limit
* schema:
* type: integer
* default: 20
* - in: query
* name: chapter_id
* schema:
* type: string
* format: uuid
* description: Filter by chapter
* - in: query
* name: lesson_content_type
* schema:
* type: string
* enum: [vocabulary, grammar, phonics, review, mixed]
* description: Filter by content type
* - in: query
* name: lesson_type
* schema:
* type: string
* enum: [json_content, url_content]
* - in: query
* name: is_published
* schema:
* type: boolean
* - in: query
* name: is_free
* schema:
* type: boolean
* - in: query
* name: search
* schema:
* type: string
* description: Search in title and description
* responses:
* 200:
* description: List of lessons with pagination
*/
router.get('/lessons', learningContentController.getAllLessons);
/**
* @swagger
* /api/learning-content/lessons/{id}:
* get:
* summary: Get lesson by ID
* tags: [Learning Content]
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: string
* format: uuid
* responses:
* 200:
* description: Lesson details
* 404:
* description: Lesson not found
*/
router.get('/lessons/:id', learningContentController.getLessonById);
/**
* @swagger
* /api/learning-content/lessons/{id}:
* put:
* summary: Update lesson
* tags: [Learning Content]
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: string
* format: uuid
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* properties:
* lesson_title:
* type: string
* lesson_description:
* type: string
* content_json:
* type: object
* is_published:
* type: boolean
* is_free:
* type: boolean
* responses:
* 200:
* description: Lesson updated successfully
* 404:
* description: Lesson not found
*/
router.put('/lessons/:id', authenticateToken, learningContentController.updateLesson);
/**
* @swagger
* /api/learning-content/lessons/{id}:
* delete:
* summary: Delete lesson
* tags: [Learning Content]
* security:
* - bearerAuth: []
* parameters:
* - in: path
* name: id
* required: true
* schema:
* type: string
* format: uuid
* responses:
* 200:
* description: Lesson deleted successfully
* 404:
* description: Lesson not found
*/
router.delete('/lessons/:id', authenticateToken, learningContentController.deleteLesson);
/**
* @swagger
* /api/learning-content/lessons/chapter/{chapter_id}:
* get:
* summary: Get all lessons in a chapter
* tags: [Learning Content]
* parameters:
* - in: path
* name: chapter_id
* required: true
* schema:
* type: string
* format: uuid
* responses:
* 200:
* description: List of lessons in chapter
*/
router.get('/lessons/chapter/:chapter_id', learningContentController.getLessonsByChapter);
module.exports = router;