feat: check invalid data for create taskOrder
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
5dc88c22dc
commit
78669ed7ae
1 changed files with 11 additions and 4 deletions
|
|
@ -77,6 +77,7 @@ export class TaskController extends Controller {
|
||||||
by: ["taskOrderStatus"],
|
by: ["taskOrderStatus"],
|
||||||
_count: true,
|
_count: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
return task.reduce<Record<TaskOrderStatus, number>>(
|
return task.reduce<Record<TaskOrderStatus, number>>(
|
||||||
(a, c) => Object.assign(a, { [c.taskOrderStatus]: c._count }),
|
(a, c) => Object.assign(a, { [c.taskOrderStatus]: c._count }),
|
||||||
{
|
{
|
||||||
|
|
@ -264,6 +265,12 @@ export class TaskController extends Controller {
|
||||||
taskProduct?: { productId: string; discount?: number }[];
|
taskProduct?: { productId: string; discount?: number }[];
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
|
if (!body.taskList || !body.registeredBranchId)
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatus.BAD_REQUEST,
|
||||||
|
"Your created invalid task order",
|
||||||
|
"taskOrderInvalid",
|
||||||
|
);
|
||||||
return await prisma.$transaction(async (tx) => {
|
return await prisma.$transaction(async (tx) => {
|
||||||
const last = await tx.runningNo.upsert({
|
const last = await tx.runningNo.upsert({
|
||||||
where: {
|
where: {
|
||||||
|
|
@ -311,10 +318,10 @@ export class TaskController extends Controller {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (updated.count !== taskList.length) {
|
if (updated.count !== taskList.length) {
|
||||||
throw new HttpError(
|
throw new httperror(
|
||||||
HttpStatus.PRECONDITION_FAILED,
|
httpstatus.precondition_failed,
|
||||||
"All request work to issue task order must be in ready state.",
|
"all request work to issue task order must be in ready state.",
|
||||||
"requestWorkMustReady",
|
"requestworkmustready",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await tx.institution.updateMany({
|
await tx.institution.updateMany({
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue