const { DataTypes } = require('sequelize'); const { sequelize } = require('../config/database'); const TeacherDetail = sequelize.define('teacher_details', { id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true }, user_id: { type: DataTypes.UUID, unique: true, allowNull: false, references: { model: 'user_profiles', key: 'user_id' } }, teacher_code: { type: DataTypes.STRING(50), unique: true, allowNull: false }, teacher_type: { type: DataTypes.ENUM('foreign', 'assistant', 'homeroom', 'specialist'), allowNull: false }, qualification: { type: DataTypes.STRING(200) }, specialization: { type: DataTypes.STRING(200) }, hire_date: { type: DataTypes.DATE }, status: { type: DataTypes.ENUM('active', 'on_leave', 'resigned'), defaultValue: 'active' }, skill_tags: { type: DataTypes.JSON, comment: 'Array of skills: [{"name": "Python", "level": "expert"}]' }, certifications: { type: DataTypes.JSON, comment: 'Array of certificates' }, training_hours: { type: DataTypes.INTEGER, defaultValue: 0, comment: 'Tổng giờ đào tạo' }, last_training_date: { type: DataTypes.DATEONLY, comment: 'Ngày đào tạo gần nhất' }, training_score_avg: { type: DataTypes.DECIMAL(5, 2), comment: 'Điểm TB các khóa học' }, created_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW }, updated_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW }, }, { tableName: 'teacher_details', timestamps: true, underscored: true, indexes: [ { fields: ['user_id'], unique: true }, { fields: ['teacher_code'], unique: true }, { fields: ['teacher_type'] }, ], }); module.exports = TeacherDetail;