const { DataTypes } = require('sequelize'); const { sequelize } = require('../config/database'); /** * StaffAchievement Model - Lưu trữ chứng chỉ và thành tích đào tạo */ const StaffAchievement = sequelize.define('staff_achievements', { 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', }, course_id: { type: DataTypes.UUID, references: { model: 'subjects', key: 'id', }, comment: 'Khóa học trong hệ thống', }, course_name: { type: DataTypes.STRING(200), allowNull: false, comment: 'Tên khóa học', }, completion_date: { type: DataTypes.DATEONLY, allowNull: false, defaultValue: DataTypes.NOW, comment: 'Ngày hoàn thành', }, certificate_url: { type: DataTypes.STRING(500), comment: 'URL file chứng chỉ', }, certificate_code: { type: DataTypes.STRING(100), comment: 'Mã chứng chỉ', }, type: { type: DataTypes.ENUM('mandatory', 'self_study', 'external'), allowNull: false, comment: 'Loại: bắt buộc, tự học, bên ngoài', }, score: { type: DataTypes.DECIMAL(5, 2), comment: 'Điểm số (0-100)', }, total_hours: { type: DataTypes.INTEGER, comment: 'Tổng số giờ học', }, verified_by: { type: DataTypes.UUID, references: { model: 'users_auth', key: 'id', }, comment: 'Admin xác nhận', }, verified_at: { type: DataTypes.DATE, comment: 'Thời gian xác nhận', }, created_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW, }, }, { tableName: 'staff_achievements', timestamps: false, underscored: true, indexes: [ { fields: ['staff_id'] }, { fields: ['type'] }, { fields: ['completion_date'] }, { fields: ['certificate_code'] }, ], comment: 'Bảng lưu trữ chứng chỉ và thành tích đào tạo', }); module.exports = StaffAchievement;