Files
sena_db_api_layer/models/ParentStudentMap.js
2026-01-19 09:33:35 +07:00

25 lines
1.3 KiB
JavaScript

const { DataTypes } = require('sequelize');
const { sequelize } = require('../config/database');
const ParentStudentMap = sequelize.define('parent_student_map', {
id: { type: DataTypes.UUID, defaultValue: DataTypes.UUIDV4, primaryKey: true },
parent_id: { type: DataTypes.UUID, allowNull: false },
student_id: { type: DataTypes.UUID, allowNull: false },
relationship: { type: DataTypes.ENUM('father', 'mother', 'guardian', 'other'), allowNull: false },
is_primary_contact: { type: DataTypes.BOOLEAN, defaultValue: false },
can_assign_tasks: { type: DataTypes.BOOLEAN, defaultValue: true, comment: 'Quyền gán bài tập' },
can_view_detailed_grades: { type: DataTypes.BOOLEAN, defaultValue: false, comment: 'Xem điểm chi tiết' },
can_communicate_teacher: { type: DataTypes.BOOLEAN, defaultValue: true, comment: 'Liên hệ giáo viên' },
permission_level: { type: DataTypes.ENUM('limited', 'standard', 'full'), defaultValue: 'standard', comment: 'Cấp quyền' },
created_at: { type: DataTypes.DATE, allowNull: false, defaultValue: DataTypes.NOW },
}, {
tableName: 'parent_student_map',
timestamps: false,
underscored: true,
indexes: [
{ fields: ['can_assign_tasks', 'can_view_detailed_grades'] },
],
});
module.exports = ParentStudentMap;