update sentences API
All checks were successful
Deploy to Production / deploy (push) Successful in 22s
All checks were successful
Deploy to Production / deploy (push) Successful in 22s
This commit is contained in:
@@ -35,34 +35,16 @@ const Lesson = sequelize.define('lessons', {
|
||||
type: DataTypes.TEXT,
|
||||
comment: 'Mô tả bài học'
|
||||
},
|
||||
|
||||
// Dạng 1: JSON Content - Nội dung học tập dạng JSON
|
||||
// Cấu trúc content_json phụ thuộc vào lesson_content_type:
|
||||
// - vocabulary: { type: "vocabulary", vocabulary_ids: [uuid1, uuid2, ...], exercises: [...] }
|
||||
// - grammar: { type: "grammar", grammar_ids: [uuid1, uuid2, ...], examples: [...], exercises: [...] }
|
||||
// - phonics: { type: "phonics", phonics_rules: [{ipa: "/æ/", words: [...]}], exercises: [...] }
|
||||
// - review: { type: "review", sections: [{type: "vocabulary", ...}, {type: "grammar", ...}, {type: "phonics", ...}] }
|
||||
content_json: {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Nội dung học tập dạng JSON: vocabulary, grammar, phonics, review'
|
||||
},
|
||||
|
||||
// Loại nội dung của bài học (để query dễ dàng)
|
||||
lesson_content_type: {
|
||||
type: DataTypes.ENUM('vocabulary', 'grammar', 'phonics', 'review', 'mixed'),
|
||||
allowNull: true,
|
||||
comment: 'Loại nội dung: vocabulary, grammar, phonics, review, mixed'
|
||||
},
|
||||
|
||||
// Dạng 2: URL Content - Chứa link external
|
||||
content_url: {
|
||||
type: DataTypes.STRING(500),
|
||||
comment: 'URL nội dung: video, audio, document, external link'
|
||||
},
|
||||
content_type: {
|
||||
type: DataTypes.STRING(50),
|
||||
comment: 'Loại content cho URL: video, audio, pdf, external_link, youtube, etc.'
|
||||
},
|
||||
duration_minutes: {
|
||||
type: DataTypes.INTEGER,
|
||||
comment: 'Thời lượng (phút)'
|
||||
@@ -83,7 +65,7 @@ const Lesson = sequelize.define('lessons', {
|
||||
comment: 'Thứ tự hiển thị'
|
||||
},
|
||||
thumbnail_url: {
|
||||
type: DataTypes.STRING(500),
|
||||
type: DataTypes.TEXT,
|
||||
comment: 'URL ảnh thumbnail'
|
||||
},
|
||||
created_at: {
|
||||
|
||||
103
models/Sentences.js
Normal file
103
models/Sentences.js
Normal file
@@ -0,0 +1,103 @@
|
||||
const { DataTypes } = require('sequelize');
|
||||
const { sequelize } = require('../config/database');
|
||||
|
||||
const Sentences = sequelize.define('Sentences', {
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
defaultValue: DataTypes.UUIDV4,
|
||||
primaryKey: true,
|
||||
comment: 'Unique identifier for sentence entry'
|
||||
},
|
||||
// Từ thực tế (wash, washes, washing, ate, eaten...)
|
||||
text: {
|
||||
type: DataTypes.TEXT,
|
||||
allowNull: false
|
||||
},
|
||||
ipa : {
|
||||
type: DataTypes.TEXT,
|
||||
comment: 'International Phonetic Alphabet representation'
|
||||
},
|
||||
// Nội dung dùng chung (có thể lưu JSON để dễ quản lý hoặc dùng chung cho cả group)
|
||||
vi: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
comment: 'Vietnamese meaning'
|
||||
},
|
||||
grade : {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '0',
|
||||
comment: 'Grade level (e.g., Grade 1, Grade 2)'
|
||||
},
|
||||
category: {
|
||||
type: DataTypes.TEXT,
|
||||
comment: 'Category of the sentence (e.g., Action Verbs, Nouns)'
|
||||
},
|
||||
topic: {
|
||||
type: DataTypes.TEXT,
|
||||
comment: 'Topic of the sentence (e.g., Food, Travel, Education)'
|
||||
},
|
||||
image_small: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: [],
|
||||
comment: 'Array of image URLs'
|
||||
},
|
||||
image_square: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: [],
|
||||
comment: 'Array of image URLs'
|
||||
},
|
||||
image_normal: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: [],
|
||||
comment: 'Array of image URLs'
|
||||
},
|
||||
audio : {
|
||||
type: DataTypes.JSON,
|
||||
comment: 'Array of audio URLs'
|
||||
},
|
||||
tags: {
|
||||
type: DataTypes.JSON,
|
||||
defaultValue: [],
|
||||
comment: 'Array of tags for categorization'
|
||||
},
|
||||
usage_note: {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
comment: 'Lưu ý về ngữ cảnh sử dụng câu này'
|
||||
},
|
||||
etc : {
|
||||
type: DataTypes.TEXT,
|
||||
defaultValue: '',
|
||||
comment: 'Các thông tin khác liên quan đến câu này (ví dụ: level, grammar points, etc.)'
|
||||
},
|
||||
is_active: {
|
||||
type: DataTypes.BOOLEAN,
|
||||
defaultValue: true,
|
||||
comment: 'Whether this sentence entry is active'
|
||||
},
|
||||
created_at: {
|
||||
type: DataTypes.DATE,
|
||||
defaultValue: DataTypes.NOW
|
||||
},
|
||||
updated_at: {
|
||||
type: DataTypes.DATE,
|
||||
defaultValue: DataTypes.NOW
|
||||
}
|
||||
}, {
|
||||
tableName: 'sentences',
|
||||
timestamps: true,
|
||||
createdAt: 'created_at',
|
||||
updatedAt: 'updated_at',
|
||||
indexes: [
|
||||
{
|
||||
name: 'idx_sentences_text',
|
||||
fields: [{ name: 'text', length: 191 }]
|
||||
},
|
||||
{
|
||||
name: 'idx_category',
|
||||
fields: [{ name: 'category', length: 191 }]
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
module.exports = Sentences;
|
||||
@@ -36,6 +36,9 @@ const LessonLeaderboard = require('./LessonLeaderboard');
|
||||
// Group 3.2: Vocabulary System (NEW)
|
||||
const Vocab = require('./Vocab');
|
||||
|
||||
// Group 3.2.1: Sentences System (NEW)
|
||||
const Sentences = require('./Sentences');
|
||||
|
||||
// Group 3.3: Grammar System (NEW)
|
||||
const Grammar = require('./Grammar');
|
||||
const GrammarMapping = require('./GrammarMapping');
|
||||
@@ -289,6 +292,9 @@ module.exports = {
|
||||
|
||||
// Group 3.2: Vocabulary System (NEW)
|
||||
Vocab,
|
||||
|
||||
// Group 3.2.1: Sentences System (NEW)
|
||||
Sentences,
|
||||
|
||||
// Group 3.3: Grammar System (NEW)
|
||||
Grammar,
|
||||
|
||||
Reference in New Issue
Block a user