const { DataTypes } = require('sequelize'); const { sequelize } = require('../config/database'); /** * ParentAssignedTask Model - Phụ huynh gán bài tập cho con */ const ParentAssignedTask = sequelize.define('parent_assigned_tasks', { id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true, }, parent_id: { type: DataTypes.UUID, allowNull: false, references: { model: 'users_auth', key: 'id', }, comment: 'Phụ huynh gán', }, student_id: { type: DataTypes.UUID, allowNull: false, references: { model: 'student_details', key: 'id', }, comment: 'Học sinh được gán', }, grade_item_id: { type: DataTypes.UUID, allowNull: false, references: { model: 'grade_items', key: 'id', }, comment: 'Bài tập được gán', }, assigned_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW, comment: 'Thời gian gán', }, due_date: { 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', }, message: { type: DataTypes.TEXT, comment: 'Lời nhắn của phụ huynh', }, priority: { type: DataTypes.ENUM('low', 'normal', 'high'), defaultValue: 'normal', comment: 'Độ ưu tiên', }, completion_date: { type: DataTypes.DATE, comment: 'Ngày hoàn thành', }, student_notes: { type: DataTypes.TEXT, comment: 'Ghi chú của học sinh khi hoàn thành', }, created_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW, }, updated_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW, }, }, { tableName: 'parent_assigned_tasks', timestamps: true, underscored: true, indexes: [ { fields: ['parent_id'] }, { fields: ['student_id'] }, { fields: ['status'] }, { fields: ['due_date'] }, ], comment: 'Bảng quản lý bài tập phụ huynh gán cho con', }); module.exports = ParentAssignedTask;