const { DataTypes } = require('sequelize'); const { sequelize } = require('../config/database'); /** * StaffTrainingAssignment Model - Quản lý phân công đào tạo nhân sự */ const StaffTrainingAssignment = sequelize.define('staff_training_assignments', { id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true, }, staff_id: { type: DataTypes.UUID, allowNull: false, references: { model: 'users_auth', key: 'id', }, comment: 'Nhân viên được giao', }, subject_id: { type: DataTypes.UUID, references: { model: 'subjects', key: 'id', }, comment: 'Khóa học/môn học bắt buộc', }, course_name: { type: DataTypes.STRING(200), comment: 'Tên khóa học (nếu không có subject_id)', }, assigned_by: { type: DataTypes.UUID, allowNull: false, references: { model: 'users_auth', key: 'id', }, comment: 'Admin giao nhiệm vụ', }, assigned_date: { type: DataTypes.DATEONLY, allowNull: false, defaultValue: DataTypes.NOW, comment: 'Ngày giao', }, deadline: { type: DataTypes.DATEONLY, comment: 'Hạn hoàn thành', }, status: { type: DataTypes.ENUM('pending', 'in_progress', 'completed', 'overdue'), defaultValue: 'pending', comment: 'Trạng thái', }, priority: { type: DataTypes.ENUM('low', 'normal', 'high', 'urgent'), defaultValue: 'normal', comment: 'Độ ưu tiên', }, notes: { type: DataTypes.TEXT, comment: 'Ghi chú', }, created_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW, }, updated_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW, }, }, { tableName: 'staff_training_assignments', timestamps: true, underscored: true, indexes: [ { fields: ['staff_id'] }, { fields: ['status'] }, { fields: ['deadline'] }, { fields: ['assigned_by'] }, ], comment: 'Bảng quản lý phân công đào tạo nhân sự', }); module.exports = StaffTrainingAssignment;