Include complete API and frontend sources for unified deployment
This commit is contained in:
1 parent
627b0ae60e
commit
d8fcae32b0
93 files changed
+53270
-3
No files matched your search
@@ -0,0 +1,26 @@
|
||||
import { Op } from 'sequelize';
|
||||
import { models } from '../models/index.js';
|
||||
import { AppErrorInvalid, SystemError } from './errors.js';
|
||||
|
||||
export async function assignmentCases(caseIds, transaction) {
|
||||
const tasks = await models.Case.findAll({
|
||||
where: { id: caseIds },
|
||||
order: [['id', 'ASC']],
|
||||
lock: transaction.LOCK.UPDATE,
|
||||
transaction,
|
||||
});
|
||||
if (tasks.length !== caseIds.length) throw new AppErrorInvalid('caseIds');
|
||||
return tasks;
|
||||
}
|
||||
|
||||
export async function assertTechnicalAvailable(user, tasks, transaction) {
|
||||
if (user.role !== 'technical') return;
|
||||
for (const task of tasks) {
|
||||
const assigned = await task.getUsers({
|
||||
where: { role: 'technical', id: { [Op.ne]: user.id } },
|
||||
lock: transaction.LOCK.UPDATE,
|
||||
transaction,
|
||||
});
|
||||
if (assigned.length) throw new SystemError(409, `В кейсе «${task.name}» уже назначен технический эксперт.`);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user