stud-manager / models.js
dvc890's picture
Upload 44 files
ac9de5d verified
raw
history blame
7.48 kB
const mongoose = require('mongoose');
const SchoolSchema = new mongoose.Schema({ name: String, code: String });
const School = mongoose.model('School', SchoolSchema);
const UserSchema = new mongoose.Schema({
username: String,
password: String,
trueName: String,
phone: String,
email: String,
schoolId: String,
role: String,
status: String,
avatar: String,
createTime: Date,
teachingSubject: String,
homeroomClass: String,
studentNo: String,
parentName: String,
parentPhone: String,
address: String,
gender: String,
seatNo: String,
idCard: String,
classApplication: {
type: { type: String },
targetClass: String,
status: String
}
});
const User = mongoose.model('User', UserSchema);
const StudentSchema = new mongoose.Schema({
schoolId: String,
studentNo: String,
seatNo: String,
name: String,
gender: String,
birthday: String,
idCard: String,
phone: String,
className: String,
status: String,
parentName: String,
parentPhone: String,
address: String,
teamId: String,
drawAttempts: { type: Number, default: 0 },
dailyDrawLog: { date: String, count: { type: Number, default: 0 } },
flowerBalance: { type: Number, default: 0 }
});
const Student = mongoose.model('Student', StudentSchema);
const CourseSchema = new mongoose.Schema({ schoolId: String, courseCode: String, courseName: String, teacherName: String, credits: Number, capacity: Number, enrolled: Number });
const Course = mongoose.model('Course', CourseSchema);
const ScoreSchema = new mongoose.Schema({ schoolId: String, studentName: String, studentNo: String, courseName: String, score: Number, semester: String, type: String, examName: String, status: String });
const Score = mongoose.model('Score', ScoreSchema);
const ClassSchema = new mongoose.Schema({ schoolId: String, grade: String, className: String, teacherName: String });
const ClassModel = mongoose.model('Class', ClassSchema);
const SubjectSchema = new mongoose.Schema({ schoolId: String, name: String, code: String, color: String, excellenceThreshold: Number, thresholds: { type: Map, of: Number } });
const SubjectModel = mongoose.model('Subject', SubjectSchema);
const ExamSchema = new mongoose.Schema({ schoolId: String, name: String, date: String, type: String, semester: String });
const ExamModel = mongoose.model('Exam', ExamSchema);
const ScheduleSchema = new mongoose.Schema({ schoolId: String, className: String, teacherName: String, subject: String, dayOfWeek: Number, period: Number });
const ScheduleModel = mongoose.model('Schedule', ScheduleSchema);
const ConfigSchema = new mongoose.Schema({
key: String,
systemName: String,
semester: String,
semesters: [String],
allowRegister: Boolean,
allowAdminRegister: Boolean,
allowPrincipalRegister: Boolean,
allowStudentRegister: Boolean,
maintenanceMode: Boolean,
emailNotify: Boolean
});
const ConfigModel = mongoose.model('Config', ConfigSchema);
const NotificationSchema = new mongoose.Schema({ schoolId: String, targetRole: String, targetUserId: String, title: String, content: String, type: String, createTime: { type: Date, default: Date.now } });
const NotificationModel = mongoose.model('Notification', NotificationSchema);
const GameSessionSchema = new mongoose.Schema({ schoolId: String, className: String, isEnabled: Boolean, maxSteps: Number, teams: [{ id: String, name: String, score: Number, avatar: String, color: String, members: [String] }], rewardsConfig: [{ scoreThreshold: Number, rewardType: String, rewardName: String, rewardValue: Number, achievementId: String }] });
const GameSessionModel = mongoose.model('GameSession', GameSessionSchema);
const StudentRewardSchema = new mongoose.Schema({ schoolId: String, studentId: String, studentName: String, rewardType: String, name: String, count: { type: Number, default: 1 }, status: String, source: String, createTime: { type: Date, default: Date.now } });
const StudentRewardModel = mongoose.model('StudentReward', StudentRewardSchema);
const LuckyDrawConfigSchema = new mongoose.Schema({ schoolId: String, className: String, prizes: [{ id: String, name: String, probability: Number, count: Number, icon: String }], dailyLimit: Number, cardCount: Number, defaultPrize: String, consolationWeight: { type: Number, default: 0 } });
const LuckyDrawConfigModel = mongoose.model('LuckyDrawConfig', LuckyDrawConfigSchema);
const GameMonsterConfigSchema = new mongoose.Schema({
schoolId: String,
className: String,
duration: { type: Number, default: 300 },
sensitivity: { type: Number, default: 25 },
difficulty: { type: Number, default: 5 },
useKeyboardMode: { type: Boolean, default: false },
rewardConfig: {
enabled: Boolean,
type: { type: String },
val: String,
count: Number
}
});
const GameMonsterConfigModel = mongoose.model('GameMonsterConfig', GameMonsterConfigSchema);
const GameZenConfigSchema = new mongoose.Schema({
schoolId: String,
className: String,
durationMinutes: { type: Number, default: 40 },
threshold: { type: Number, default: 30 },
passRate: { type: Number, default: 90 },
rewardConfig: {
enabled: Boolean,
type: { type: String },
val: String,
count: Number
}
});
const GameZenConfigModel = mongoose.model('GameZenConfig', GameZenConfigSchema);
const AchievementConfigSchema = new mongoose.Schema({ schoolId: String, className: String, achievements: [{ id: String, name: String, icon: String, points: Number, description: String }], exchangeRules: [{ id: String, cost: Number, rewardType: String, rewardName: String, rewardValue: Number }] });
const AchievementConfigModel = mongoose.model('AchievementConfig', AchievementConfigSchema);
const StudentAchievementSchema = new mongoose.Schema({ schoolId: String, studentId: String, studentName: String, achievementId: String, achievementName: String, achievementIcon: String, semester: String, createTime: { type: Date, default: Date.now } });
const StudentAchievementModel = mongoose.model('StudentAchievement', StudentAchievementSchema);
const AttendanceSchema = new mongoose.Schema({ schoolId: String, studentId: String, studentName: String, className: String, date: String, status: String, checkInTime: Date });
const AttendanceModel = mongoose.model('Attendance', AttendanceSchema);
const LeaveRequestSchema = new mongoose.Schema({ schoolId: String, studentId: String, studentName: String, className: String, reason: String, startDate: String, endDate: String, status: { type: String, default: 'Pending' }, createTime: { type: Date, default: Date.now } });
const LeaveRequestModel = mongoose.model('LeaveRequest', LeaveRequestSchema);
const SchoolCalendarSchema = new mongoose.Schema({ schoolId: String, className: String, type: String, startDate: String, endDate: String, name: String });
const SchoolCalendarModel = mongoose.model('SchoolCalendar', SchoolCalendarSchema);
module.exports = {
School, User, Student, Course, Score, ClassModel, SubjectModel, ExamModel, ScheduleModel,
ConfigModel, NotificationModel, GameSessionModel, StudentRewardModel, LuckyDrawConfigModel, GameMonsterConfigModel, GameZenConfigModel,
AchievementConfigModel, StudentAchievementModel, AttendanceModel, LeaveRequestModel, SchoolCalendarModel
};