update
All checks were successful
Deploy to Production / deploy (push) Successful in 21s

This commit is contained in:
silverpro89
2026-01-28 11:21:21 +07:00
parent 57c45d27a3
commit 3791b7cae1
23 changed files with 1033 additions and 317 deletions

97
models/GameType.js Normal file
View File

@@ -0,0 +1,97 @@
const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
/**
* GameType Model - Loại trò chơi giáo dục
* Định nghĩa các loại game template/engine khác nhau
* Một GameType có thể có nhiều Game instances
*/
const GameType = sequelize.define('game_types', {
id: {
type: DataTypes.UUID,
defaultValue: DataTypes.UUIDV4,
primaryKey: true
},
en_title: {
type: DataTypes.TEXT,
allowNull: false,
comment: 'Tên loại game (tiếng Anh)'
},
vi_title: {
type: DataTypes.TEXT,
allowNull: false,
comment: 'Tên loại game (tiếng Việt)'
},
en_desc: {
type: DataTypes.TEXT,
comment: 'Mô tả loại game (tiếng Anh)'
},
vi_desc: {
type: DataTypes.TEXT,
comment: 'Mô tả loại game (tiếng Việt)'
},
type: {
type: DataTypes.TEXT,
allowNull: false,
unique: true,
comment: 'Mã định danh loại game: counting_quiz, math_game, word_puzzle, etc.'
},
thumb: {
type: DataTypes.TEXT,
comment: 'URL ảnh thumbnail đại diện cho loại game'
},
data: {
type: DataTypes.JSON,
comment: 'Dữ liệu mẫu hoặc template data cho loại game này'
},
config: {
type: DataTypes.JSON,
comment: 'Cấu hình mặc định cho loại game: controls, settings, features, etc.'
},
is_premium: {
type: DataTypes.BOOLEAN,
defaultValue: false,
comment: 'Yêu cầu premium để sử dụng loại game này'
},
is_active: {
type: DataTypes.BOOLEAN,
defaultValue: true,
comment: 'Loại game có đang hoạt động không'
},
difficulty_level: {
type: DataTypes.ENUM('easy', 'medium', 'hard'),
comment: 'Độ khó mặc định'
},
rating: {
type: DataTypes.DECIMAL(3, 2),
comment: 'Đánh giá trung bình (0.00 - 5.00)'
},
display_order: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: 'Thứ tự hiển thị'
},
created_at: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
},
updated_at: {
type: DataTypes.DATE,
allowNull: false,
defaultValue: DataTypes.NOW
},
}, {
tableName: 'game_types',
timestamps: true,
underscored: true,
indexes: [
{ fields: ['type'], unique: true },
{ fields: ['is_active'] },
{ fields: ['is_premium'] },
{ fields: ['display_order'] },
{ fields: ['difficulty_level'] },
],
});
module.exports = GameType;

View File

@@ -29,6 +29,7 @@ const Room = require('./Room');
const Chapter = require('./Chapter');
const Lesson = require('./Lesson');
const Game = require('./Game');
const GameType = require('./GameType');
const LessonComponentProgress = require('./LessonComponentProgress');
const LessonLeaderboard = require('./LessonLeaderboard');
@@ -292,6 +293,7 @@ module.exports = {
Chapter,
Lesson,
Game,
GameType,
LessonComponentProgress,
LessonLeaderboard,