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(
|
async updateRequestData(
|
||||||
@Request() req: RequestWithUser,
|
@Request() req: RequestWithUser,
|
||||||
@Body()
|
@Body()
|
||||||
boby: {
|
body: {
|
||||||
defaultMessengerId: string;
|
defaultMessengerId: string;
|
||||||
requestDataId: string[];
|
requestDataId: string[];
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
const record = await prisma.requestData.updateManyAndReturn({
|
if (body.requestDataId.length === 0) return;
|
||||||
where: {
|
|
||||||
id: { in: boby.requestDataId },
|
return await prisma.$transaction(async (tx) => {
|
||||||
quotation: {
|
const record = await tx.requestData.updateManyAndReturn({
|
||||||
registeredBranch: {
|
where: {
|
||||||
OR: permissionCond(req.user),
|
id: { in: body.requestDataId },
|
||||||
|
quotation: {
|
||||||
|
registeredBranch: {
|
||||||
|
OR: permissionCond(req.user),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
data: {
|
||||||
data: {
|
defaultMessengerId: body.defaultMessengerId,
|
||||||
defaultMessengerId: boby.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