This commit is contained in:
@@ -311,7 +311,7 @@ class CategoryController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Build query conditions
|
// Build query conditions
|
||||||
const where = { category_id: id };
|
const where = { id: id };
|
||||||
if (is_active !== undefined) where.is_active = is_active === 'true';
|
if (is_active !== undefined) where.is_active = is_active === 'true';
|
||||||
|
|
||||||
// Query subjects
|
// Query subjects
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ exports.createVocab = async (req, res) => {
|
|||||||
vi,
|
vi,
|
||||||
category,
|
category,
|
||||||
topic,
|
topic,
|
||||||
|
grade_number = 0,
|
||||||
image_small,
|
image_small,
|
||||||
image_square,
|
image_square,
|
||||||
image_normal,
|
image_normal,
|
||||||
@@ -103,6 +104,7 @@ exports.createVocab = async (req, res) => {
|
|||||||
syntax: syntax || null,
|
syntax: syntax || null,
|
||||||
semantics: semantics || null,
|
semantics: semantics || null,
|
||||||
constraints: constraints || null,
|
constraints: constraints || null,
|
||||||
|
grade_number: grade_number || 0,
|
||||||
is_active: true
|
is_active: true
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -166,6 +168,8 @@ exports.getAllVocabs = async (req, res) => {
|
|||||||
base_word,
|
base_word,
|
||||||
text,
|
text,
|
||||||
search,
|
search,
|
||||||
|
grade_start,
|
||||||
|
grade_end,
|
||||||
is_active = true
|
is_active = true
|
||||||
} = req.query;
|
} = req.query;
|
||||||
|
|
||||||
@@ -202,6 +206,21 @@ exports.getAllVocabs = async (req, res) => {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Grade number range filter
|
||||||
|
if (grade_start !== undefined && grade_end !== undefined) {
|
||||||
|
const s = parseInt(grade_start);
|
||||||
|
const e = parseInt(grade_end);
|
||||||
|
if (s === e) {
|
||||||
|
where.grade_number = s;
|
||||||
|
} else if (s < e) {
|
||||||
|
where.grade_number = { [Op.between]: [s, e] };
|
||||||
|
}
|
||||||
|
} else if (grade_start !== undefined) {
|
||||||
|
where.grade_number = { [Op.gte]: parseInt(grade_start) };
|
||||||
|
} else if (grade_end !== undefined) {
|
||||||
|
where.grade_number = { [Op.lte]: parseInt(grade_end) };
|
||||||
|
}
|
||||||
|
|
||||||
const { count, rows } = await Vocab.findAndCountAll({
|
const { count, rows } = await Vocab.findAndCountAll({
|
||||||
where,
|
where,
|
||||||
limit: parseInt(limit),
|
limit: parseInt(limit),
|
||||||
@@ -786,6 +805,8 @@ exports.searchVocabs = async (req, res) => {
|
|||||||
form_key,
|
form_key,
|
||||||
text,
|
text,
|
||||||
vi,
|
vi,
|
||||||
|
grade_start,
|
||||||
|
grade_end,
|
||||||
v_type,
|
v_type,
|
||||||
shuffle_pos,
|
shuffle_pos,
|
||||||
page = 1,
|
page = 1,
|
||||||
@@ -825,6 +846,21 @@ exports.searchVocabs = async (req, res) => {
|
|||||||
where.vi = { [Op.like]: `%${vi}%` };
|
where.vi = { [Op.like]: `%${vi}%` };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Grade number range filter
|
||||||
|
if (grade_start !== undefined && grade_end !== undefined) {
|
||||||
|
const s = parseInt(grade_start);
|
||||||
|
const e = parseInt(grade_end);
|
||||||
|
if (s === e) {
|
||||||
|
where.grade_number = s;
|
||||||
|
} else if (s < e) {
|
||||||
|
where.grade_number = { [Op.between]: [s, e] };
|
||||||
|
}
|
||||||
|
} else if (grade_start !== undefined) {
|
||||||
|
where.grade_number = { [Op.gte]: parseInt(grade_start) };
|
||||||
|
} else if (grade_end !== undefined) {
|
||||||
|
where.grade_number = { [Op.lte]: parseInt(grade_end) };
|
||||||
|
}
|
||||||
|
|
||||||
// Handle v_type: find variants of same base_word
|
// Handle v_type: find variants of same base_word
|
||||||
if (v_type === true) {
|
if (v_type === true) {
|
||||||
// Nếu có v_type, cần tìm tất cả các từ có cùng base_word
|
// Nếu có v_type, cần tìm tất cả các từ có cùng base_word
|
||||||
|
|||||||
@@ -14,11 +14,6 @@
|
|||||||
{
|
{
|
||||||
"grade": "010102",
|
"grade": "010102",
|
||||||
"vocab": [
|
"vocab": [
|
||||||
"red",
|
|
||||||
"green",
|
|
||||||
"blue",
|
|
||||||
"black",
|
|
||||||
"yellow",
|
|
||||||
"leaf",
|
"leaf",
|
||||||
"apple",
|
"apple",
|
||||||
"sky",
|
"sky",
|
||||||
@@ -37,9 +32,7 @@
|
|||||||
"car"
|
"car"
|
||||||
],
|
],
|
||||||
"phonics": [
|
"phonics": [
|
||||||
"C",
|
"c", "/k/"
|
||||||
"c",
|
|
||||||
"/k/"
|
|
||||||
],
|
],
|
||||||
"grammar": []
|
"grammar": []
|
||||||
},
|
},
|
||||||
@@ -65,7 +58,6 @@
|
|||||||
"duck"
|
"duck"
|
||||||
],
|
],
|
||||||
"phonics": [
|
"phonics": [
|
||||||
"D",
|
|
||||||
"d",
|
"d",
|
||||||
"/d/"
|
"/d/"
|
||||||
],
|
],
|
||||||
@@ -119,13 +111,9 @@
|
|||||||
],
|
],
|
||||||
"phonics": [
|
"phonics": [
|
||||||
"A",
|
"A",
|
||||||
"a",
|
|
||||||
"B",
|
"B",
|
||||||
"b",
|
|
||||||
"C",
|
"C",
|
||||||
"c",
|
"D"
|
||||||
"D",
|
|
||||||
"d"
|
|
||||||
],
|
],
|
||||||
"grammar": [
|
"grammar": [
|
||||||
"What color is it?",
|
"What color is it?",
|
||||||
|
|||||||
@@ -97,9 +97,7 @@
|
|||||||
{
|
{
|
||||||
"grade": "010508",
|
"grade": "010508",
|
||||||
"vocab": null,
|
"vocab": null,
|
||||||
"phonics": [
|
"phonics": null,
|
||||||
"letters and sounds from unit"
|
|
||||||
],
|
|
||||||
"grammar": [
|
"grammar": [
|
||||||
"This is...",
|
"This is...",
|
||||||
"These are...",
|
"These are...",
|
||||||
|
|||||||
@@ -60,18 +60,11 @@
|
|||||||
"phonics": null,
|
"phonics": null,
|
||||||
"grammar": [
|
"grammar": [
|
||||||
"One apple",
|
"One apple",
|
||||||
"Two apples",
|
"Two apples"
|
||||||
"Count and say."
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"grade": "010005",
|
"grade": "010005",
|
||||||
"vocab": [
|
|
||||||
"boy",
|
|
||||||
"bag",
|
|
||||||
"bat",
|
|
||||||
"Billy"
|
|
||||||
],
|
|
||||||
"phonics": [
|
"phonics": [
|
||||||
"/b/"
|
"/b/"
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"grade": "051001",
|
"grade": "051001",
|
||||||
"vocab": ["headache", "fever", "toothache", "cold", "cough", "earache", "stomachache", "sore", "throat"],
|
"vocab": ["headache", "fever", "toothache", "cold", "cough", "earache", "stomachache", "sore throat"],
|
||||||
"phonics": null,
|
"phonics": null,
|
||||||
"grammar": ["What's the matter?", "I have a ...", "He has a ...", "She has a ..."],
|
"grammar": ["What's the matter?", "I have a ...", "He has a ...", "She has a ..."],
|
||||||
"target": "Identify words for illness, understand a short story about feeling unwell."
|
"target": "Identify words for illness, understand a short story about feeling unwell."
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ const Categories = sequelize.define('Categories', {
|
|||||||
created_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
|
created_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
|
||||||
updated_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
|
updated_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
|
||||||
}, {
|
}, {
|
||||||
tableName: 'Categories',
|
tableName: 'categories',
|
||||||
timestamps: true,
|
timestamps: true,
|
||||||
underscored: true,
|
underscored: true,
|
||||||
indexes: [
|
indexes: [
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
const { DataTypes } = require('sequelize');
|
const { DataTypes } = require('sequelize');
|
||||||
const { sequelize } = require('../config/database');
|
const { sequelize } = require('../config/database');
|
||||||
|
const Grade = require('./Grade');
|
||||||
|
|
||||||
const Vocab = sequelize.define('Vocab', {
|
const Vocab = sequelize.define('Vocab', {
|
||||||
vocab_id: {
|
vocab_id: {
|
||||||
@@ -36,6 +37,11 @@ const Vocab = sequelize.define('Vocab', {
|
|||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
comment: 'Vietnamese meaning'
|
comment: 'Vietnamese meaning'
|
||||||
},
|
},
|
||||||
|
Grade_number: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
defaultValue: 0,
|
||||||
|
comment: 'Numeric representation of grade unit lesson as GG UU LL for easier querying and sorting'
|
||||||
|
},
|
||||||
category: {
|
category: {
|
||||||
type: DataTypes.STRING(100),
|
type: DataTypes.STRING(100),
|
||||||
comment: 'Category of the word (e.g., Action Verbs, Nouns)'
|
comment: 'Category of the word (e.g., Action Verbs, Nouns)'
|
||||||
|
|||||||
Reference in New Issue
Block a user