fix: update messenger also update work step messenger
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 4s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 4s
This commit is contained in:
parent
2c9fae400c
commit
35a7f809e1
1 changed files with 35 additions and 15 deletions
|
|
@ -293,28 +293,48 @@ export class RequestDataController extends Controller {
|
|||
async updateRequestData(
|
||||
@Request() req: RequestWithUser,
|
||||
@Body()
|
||||
boby: {
|
||||
body: {
|
||||
defaultMessengerId: string;
|
||||
requestDataId: string[];
|
||||
},
|
||||
) {
|
||||
const record = await prisma.requestData.updateManyAndReturn({
|
||||
where: {
|
||||
id: { in: boby.requestDataId },
|
||||
quotation: {
|
||||
registeredBranch: {
|
||||
OR: permissionCond(req.user),
|
||||
if (body.requestDataId.length === 0) return;
|
||||
|
||||
return await prisma.$transaction(async (tx) => {
|
||||
const record = await tx.requestData.updateManyAndReturn({
|
||||
where: {
|
||||
id: { in: body.requestDataId },
|
||||
quotation: {
|
||||
registeredBranch: {
|
||||
OR: permissionCond(req.user),
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
data: {
|
||||
defaultMessengerId: boby.defaultMessengerId,
|
||||
},
|
||||
data: {
|
||||
defaultMessengerId: body.defaultMessengerId,
|
||||
},
|
||||
});
|
||||
|
||||
if (record.length <= 0) throw notFoundError("Request Data");
|
||||
|
||||
await tx.requestWorkStepStatus.updateMany({
|
||||
where: {
|
||||
workStatus: {
|
||||
in: [
|
||||
RequestWorkStatus.Pending,
|
||||
RequestWorkStatus.Waiting,
|
||||
RequestWorkStatus.InProgress,
|
||||
],
|
||||
},
|
||||
requestWork: {
|
||||
requestDataId: { in: body.requestDataId },
|
||||
},
|
||||
},
|
||||
data: { responsibleUserId: body.defaultMessengerId },
|
||||
});
|
||||
|
||||
return record[0];
|
||||
});
|
||||
|
||||
if (record.length <= 0) throw notFoundError("Request Data");
|
||||
|
||||
return record[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue