From 1789fe1de0160a6524f6b98ffcf0165b63b74017 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 14 Aug 2025 13:10:44 +0700 Subject: [PATCH 1/4] feat: add updated at to step status --- prisma/schema.prisma | 1 + 1 file changed, 1 insertion(+) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 9cf97fd..00bd192 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -1612,6 +1612,7 @@ model RequestWork { model RequestWorkStepStatus { step Int workStatus RequestWorkStatus @default(Pending) + updatedAt DateTime @default(now()) @updatedAt requestWork RequestWork @relation(fields: [requestWorkId], references: [id], onDelete: Cascade) requestWorkId String From c2eaa5fba817f9107cce3bee349fa69589ae9052 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 14 Aug 2025 13:10:49 +0700 Subject: [PATCH 2/4] chore: migration --- .../20250814060937_add_updated_at_to_work_step/migration.sql | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 prisma/migrations/20250814060937_add_updated_at_to_work_step/migration.sql diff --git a/prisma/migrations/20250814060937_add_updated_at_to_work_step/migration.sql b/prisma/migrations/20250814060937_add_updated_at_to_work_step/migration.sql new file mode 100644 index 0000000..d1bf6c5 --- /dev/null +++ b/prisma/migrations/20250814060937_add_updated_at_to_work_step/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "RequestWorkStepStatus" ADD COLUMN "updatedAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP; From df38eebbcccb1839efad45150ec66eb41abdb9a9 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Fri, 22 Aug 2025 09:33:49 +0700 Subject: [PATCH 3/4] fix: permission --- src/controllers/03-customer-branch-controller.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/03-customer-branch-controller.ts b/src/controllers/03-customer-branch-controller.ts index aada50c..eda1546 100644 --- a/src/controllers/03-customer-branch-controller.ts +++ b/src/controllers/03-customer-branch-controller.ts @@ -623,7 +623,7 @@ export class CustomerBranchFileController extends Controller { }, }); if (!data) throw notFoundError("Customer Branch"); - await permissionCheck(user, data.customer.registeredBranch); + await permissionCheckCompany(user, data.customer.registeredBranch); } @Get("attachment") From 2c9fae400caab11738532aa823dbc3bee342df25 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Fri, 22 Aug 2025 09:41:43 +0700 Subject: [PATCH 4/4] fix: permission employee --- src/controllers/03-employee-controller.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/controllers/03-employee-controller.ts b/src/controllers/03-employee-controller.ts index 99d69ef..411b817 100644 --- a/src/controllers/03-employee-controller.ts +++ b/src/controllers/03-employee-controller.ts @@ -65,7 +65,9 @@ function globalAllow(user: RequestWithUser["user"]) { return user.roles?.some((v) => listAllowed.includes(v)) || false; } +const permissionCondCompany = createPermCondition((_) => true); const permissionCond = createPermCondition(globalAllow); +const permissionCheckCompany = createPermCheck((_) => true); const permissionCheck = createPermCheck(globalAllow); type EmployeeCreate = { @@ -669,7 +671,7 @@ export class EmployeeFileController extends Controller { }, }); if (!data) throw notFoundError("Employee"); - await permissionCheck(user, data.customerBranch.customer.registeredBranch); + await permissionCheckCompany(user, data.customerBranch.customer.registeredBranch); } @Get("image")