update
All checks were successful
Deploy to Production / deploy (push) Successful in 21s

This commit is contained in:
silverpro89
2026-01-28 11:21:21 +07:00
parent 57c45d27a3
commit 3791b7cae1
23 changed files with 1033 additions and 317 deletions

View File

@@ -1,6 +1,5 @@
const { TeacherDetail, UserProfile, UsersAuth } = require('../models');
const { cacheUtils } = require('../config/redis');
const { addDatabaseWriteJob } = require('../config/bullmq');
const teacherProfileService = require('../services/teacherProfileService');
/**
@@ -205,25 +204,30 @@ class TeacherController {
}
/**
* Update teacher (async via BullMQ)
* Update teacher
*/
async updateTeacher(req, res, next) {
try {
const { id } = req.params;
const updates = req.body;
const job = await addDatabaseWriteJob('update', 'TeacherDetail', {
id,
updates,
});
const teacher = await TeacherDetail.findByPk(id);
if (!teacher) {
return res.status(404).json({
success: false,
message: 'Teacher not found',
});
}
await teacher.update(updates);
await cacheUtils.delete(`teacher:${id}`);
await cacheUtils.deletePattern('teachers:list:*');
res.status(202).json({
res.status(200).json({
success: true,
message: 'Teacher update job queued',
jobId: job.id,
message: 'Teacher updated successfully',
data: teacher,
});
} catch (error) {
next(error);
@@ -237,17 +241,28 @@ class TeacherController {
try {
const { id } = req.params;
const job = await addDatabaseWriteJob('update', 'TeacherDetail', {
id,
updates: { status: 'resigned' },
});
const teacher = await TeacherDetail.findByPk(id);
if (!teacher) {
return res.status(404).json({
success: false,
message: 'Teacher not found',
});
}
await teacher.update({ status: 'resigned' });
await cacheUtils.delete(`teacher:${id}`);
await cacheUtils.deletePattern('teachers:list:*');
res.status(202).json({
res.status(200).json({
success: true,
message: 'Teacher deletion job queued',
message: 'Teacher status updated to resigned',
data: teacher,
});
} catch (error) {
next(error);
}
}
jobId: job.id,
});
} catch (error) {