feat: also update parent status on change status
This commit is contained in:
parent
b4b61905a1
commit
f201add95c
1 changed files with 29 additions and 0 deletions
|
|
@ -263,8 +263,12 @@ export class RequestListController extends Controller {
|
||||||
@Path() requestWorkId: string,
|
@Path() requestWorkId: string,
|
||||||
@Path() step: number,
|
@Path() step: number,
|
||||||
@Body() payload: { requestWorkStatus?: RequestWorkStatus; attributes?: Record<string, any> },
|
@Body() payload: { requestWorkStatus?: RequestWorkStatus; attributes?: Record<string, any> },
|
||||||
|
@Query() successAll: boolean,
|
||||||
) {
|
) {
|
||||||
const record = await prisma.requestWorkStepStatus.upsert({
|
const record = await prisma.requestWorkStepStatus.upsert({
|
||||||
|
include: {
|
||||||
|
requestWork: true,
|
||||||
|
},
|
||||||
where: {
|
where: {
|
||||||
step_requestWorkId: {
|
step_requestWorkId: {
|
||||||
step: step,
|
step: step,
|
||||||
|
|
@ -282,6 +286,31 @@ export class RequestListController extends Controller {
|
||||||
attributes: payload.attributes,
|
attributes: payload.attributes,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
switch (payload.requestWorkStatus) {
|
||||||
|
case "InProgress":
|
||||||
|
case "Waiting":
|
||||||
|
case "Validate":
|
||||||
|
await prisma.requestData.update({
|
||||||
|
where: {
|
||||||
|
id: record.requestWork.requestDataId,
|
||||||
|
},
|
||||||
|
data: { requestDataStatus: "InProgress" },
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
case "Completed":
|
||||||
|
case "Ended":
|
||||||
|
if (successAll) {
|
||||||
|
await prisma.requestData.update({
|
||||||
|
where: {
|
||||||
|
id: record.requestWork.requestDataId,
|
||||||
|
},
|
||||||
|
data: { requestDataStatus: "Completed" },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
return record;
|
return record;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue