const { DataTypes } = require('sequelize'); const { sequelize } = require('../config/database'); const GradeItem = sequelize.define('grade_items', { id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true }, item_name: { type: DataTypes.STRING(200), allowNull: false }, category_id: { type: DataTypes.UUID, allowNull: false }, class_id: { type: DataTypes.UUID, allowNull: false }, max_score: { type: DataTypes.DECIMAL(5, 2), defaultValue: 100 }, exam_date: { type: DataTypes.DATE }, description: { type: DataTypes.TEXT }, is_premium: { type: DataTypes.BOOLEAN, defaultValue: false, comment: 'Nội dung premium' }, is_training: { type: DataTypes.BOOLEAN, defaultValue: false, comment: 'Nội dung đào tạo nhân sự' }, is_public: { type: DataTypes.BOOLEAN, defaultValue: false, comment: 'Nội dung công khai' }, min_subscription_tier: { type: DataTypes.STRING(50), comment: 'Gói tối thiểu' }, min_interaction_time: { type: DataTypes.INTEGER, defaultValue: 0, comment: 'Thời gian tương tác tối thiểu (giây)' }, created_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW }, updated_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW }, }, { tableName: 'grade_items', timestamps: true, underscored: true, indexes: [ { fields: ['is_premium'] }, { fields: ['is_training'] }, ], }); module.exports = GradeItem;