This commit is contained in:
Ken
2026-01-19 09:33:35 +07:00
parent 374dc12b2d
commit 70838a4bc1
103 changed files with 16929 additions and 2 deletions

View File

@@ -0,0 +1,79 @@
const { sequelize } = require('../config/database');
const School = require('../models/School');
/**
* Script thêm trung tâm SenaAI vào database
* Chạy: node src/scripts/add-senaai-center.js
*/
async function addSenaAICenter() {
try {
console.log('🚀 Đang thêm trung tâm SenaAI...\n');
// Kết nối database
await sequelize.authenticate();
console.log('✅ Kết nối database thành công\n');
// Kiểm tra trung tâm đã tồn tại chưa
const existingCenter = await School.findOne({
where: { school_code: 'SENAAI' }
});
if (existingCenter) {
console.log('⚠️ Trung tâm SenaAI đã tồn tại!');
console.log(` Tên: ${existingCenter.school_name}`);
console.log(` Mã: ${existingCenter.school_code}`);
console.log(` Địa chỉ: ${existingCenter.address || 'N/A'}`);
console.log('\n');
} else {
// Tạo mới trung tâm SenaAI
const senaAI = await School.create({
school_code: 'SENAAI',
school_name: 'Trung tâm Giáo dục SenaAI',
school_type: 'primary',
address: 'Thành phố Hồ Chí Minh',
city: 'Thành phố Hồ Chí Minh',
district: 'Đang cập nhật',
phone: '',
config: {
type: 'education_center',
services: ['AI Education', 'Technology Training', 'School Management']
},
is_active: true,
});
console.log('✅ Đã tạo trung tâm SenaAI thành công!');
console.log(` ID: ${senaAI.id}`);
console.log(` Tên: ${senaAI.school_name}`);
console.log(` Mã: ${senaAI.school_code}`);
console.log('\n');
}
// Hiển thị tổng số trường
const totalSchools = await School.count();
console.log(`📊 Tổng số trường trong hệ thống: ${totalSchools}`);
console.log('\n✅ Hoàn thành!\n');
} catch (error) {
console.error('❌ Lỗi:', error);
throw error;
} finally {
await sequelize.close();
console.log('🔌 Đã đóng kết nối database');
}
}
// Chạy script
if (require.main === module) {
addSenaAICenter()
.then(() => {
console.log('\n🎉 Script hoàn thành thành công!');
process.exit(0);
})
.catch((error) => {
console.error('\n💥 Script thất bại:', error);
process.exit(1);
});
}
module.exports = { addSenaAICenter };