feat: add order field
This commit is contained in:
parent
aa8dcdaf86
commit
0bd2c1ecf2
11 changed files with 79 additions and 26 deletions
|
|
@ -95,6 +95,7 @@ export class ProductGroup extends Controller {
|
|||
return await tx.productGroup.create({
|
||||
data: {
|
||||
...body,
|
||||
statusOrder: +(body.status === "INACTIVE"),
|
||||
code: `G${last.value.toString().padStart(2, "0")}`,
|
||||
createdBy: req.user.name,
|
||||
updateBy: req.user.name,
|
||||
|
|
@ -124,7 +125,7 @@ export class ProductGroup extends Controller {
|
|||
}
|
||||
|
||||
const record = await prisma.productGroup.update({
|
||||
data: { ...body, updateBy: req.user.name },
|
||||
data: { ...body, statusOrder: +(body.status === "INACTIVE"), updateBy: req.user.name },
|
||||
where: { id: groupId },
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ export class ProductController extends Controller {
|
|||
return await prisma.product.create({
|
||||
data: {
|
||||
...body,
|
||||
statusOrder: +(body.status === "INACTIVE"),
|
||||
code: `${body.code.toLocaleUpperCase()}${last.value.toString().padStart(3, "0")}`,
|
||||
createdBy: req.user.name,
|
||||
updateBy: req.user.name,
|
||||
|
|
@ -229,13 +230,13 @@ export class ProductController extends Controller {
|
|||
}
|
||||
|
||||
const record = await prisma.product.update({
|
||||
data: { ...body, updateBy: req.user.name },
|
||||
data: { ...body, statusOrder: +(body.status === "INACTIVE"), updateBy: req.user.name },
|
||||
where: { id: productId },
|
||||
});
|
||||
|
||||
if (productType.status === "CREATED") {
|
||||
await prisma.productType.update({
|
||||
where: { id: body.productTypeId },
|
||||
await prisma.productType.updateMany({
|
||||
where: { id: body.productTypeId, status: Status.CREATED },
|
||||
data: { status: Status.ACTIVE },
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ export class ProductType extends Controller {
|
|||
return await tx.productType.create({
|
||||
data: {
|
||||
...body,
|
||||
statusOrder: +(body.status === "INACTIVE"),
|
||||
code: `T${productGroup.code}${last.value.toString().padStart(2, "0")}`,
|
||||
createdBy: req.user.name,
|
||||
updateBy: req.user.name,
|
||||
|
|
@ -161,13 +162,13 @@ export class ProductType extends Controller {
|
|||
}
|
||||
|
||||
const record = await prisma.productType.update({
|
||||
data: { ...body, updateBy: req.user.name },
|
||||
data: { ...body, statusOrder: +(body.status === "INACTIVE"), updateBy: req.user.name },
|
||||
where: { id: typeId },
|
||||
});
|
||||
|
||||
if (productGroup?.status === "CREATED") {
|
||||
await prisma.productGroup.update({
|
||||
where: { id: body.productGroupId },
|
||||
where: { id: body.productGroupId, status: Status.CREATED },
|
||||
data: { status: Status.ACTIVE },
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue