From 7fe0512a2f3ba5d5bb9ebd533d5b53e5e1b074ea Mon Sep 17 00:00:00 2001 From: Kanjana Date: Fri, 25 Apr 2025 11:59:46 +0700 Subject: [PATCH] add troubleshooting controller and field otherNationality --- .../20250425040315_add/migration.sql | 2 ++ .../20250425041426_add/migration.sql | 2 ++ prisma/schema.prisma | 32 ++++++++++--------- src/controllers/03-employee-controller.ts | 2 ++ .../03-employee-passport-controller.ts | 1 + src/controllers/05-quotation-controller.ts | 4 +++ src/controllers/09-debit-note-controller.ts | 2 ++ .../10-troubleshooting-controller.ts | 25 +++++++++++++++ 8 files changed, 55 insertions(+), 15 deletions(-) create mode 100644 prisma/migrations/20250425040315_add/migration.sql create mode 100644 prisma/migrations/20250425041426_add/migration.sql create mode 100644 src/controllers/10-troubleshooting-controller.ts diff --git a/prisma/migrations/20250425040315_add/migration.sql b/prisma/migrations/20250425040315_add/migration.sql new file mode 100644 index 0000000..9393a9a --- /dev/null +++ b/prisma/migrations/20250425040315_add/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "Employee" ADD COLUMN "otherNationality" TEXT; diff --git a/prisma/migrations/20250425041426_add/migration.sql b/prisma/migrations/20250425041426_add/migration.sql new file mode 100644 index 0000000..a004873 --- /dev/null +++ b/prisma/migrations/20250425041426_add/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "EmployeePassport" ADD COLUMN "otherNationality" TEXT; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index ab19cb5..73be520 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -787,9 +787,10 @@ model Employee { lastName String? lastNameEN String? - dateOfBirth DateTime? @db.Date - gender String - nationality String + dateOfBirth DateTime? @db.Date + gender String + nationality String + otherNationality String? address String? addressEN String? @@ -864,18 +865,19 @@ model EmployeePassport { issuePlace String previousPassportRef String? - workerStatus String? - nationality String? - namePrefix String? - firstName String? - firstNameEN String? - middleName String? - middleNameEN String? - lastName String? - lastNameEN String? - gender String? - birthDate String? - birthCountry String? + workerStatus String? + nationality String? + otherNationality String? + namePrefix String? + firstName String? + firstNameEN String? + middleName String? + middleNameEN String? + lastName String? + lastNameEN String? + gender String? + birthDate String? + birthCountry String? employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade) employeeId String diff --git a/src/controllers/03-employee-controller.ts b/src/controllers/03-employee-controller.ts index fe4c57b..03ab1cc 100644 --- a/src/controllers/03-employee-controller.ts +++ b/src/controllers/03-employee-controller.ts @@ -74,6 +74,7 @@ type EmployeeCreate = { dateOfBirth?: Date | null; gender: string; nationality: string; + otherNationality?: string; namePrefix?: string | null; firstName?: string; @@ -110,6 +111,7 @@ type EmployeeUpdate = { dateOfBirth?: Date; gender?: string; nationality?: string; + otherNationality?: string; namePrefix?: string | null; firstName?: string; diff --git a/src/controllers/03-employee-passport-controller.ts b/src/controllers/03-employee-passport-controller.ts index 8f8c253..5509373 100644 --- a/src/controllers/03-employee-passport-controller.ts +++ b/src/controllers/03-employee-passport-controller.ts @@ -43,6 +43,7 @@ type EmployeePassportPayload = { workerStatus: string; nationality: string; + otherNationality: string; namePrefix?: string | null; firstName: string; firstNameEN: string; diff --git a/src/controllers/05-quotation-controller.ts b/src/controllers/05-quotation-controller.ts index 8d53973..9fddd04 100644 --- a/src/controllers/05-quotation-controller.ts +++ b/src/controllers/05-quotation-controller.ts @@ -55,6 +55,7 @@ type QuotationCreate = { dateOfBirth: Date; gender: string; nationality: string; + otherNationality?: string; namePrefix?: string; firstName: string; firstNameEN: string; @@ -112,6 +113,7 @@ type QuotationUpdate = { dateOfBirth: Date; gender: string; nationality: string; + otherNationality?: string; namePrefix?: string; firstName?: string; @@ -1008,6 +1010,7 @@ export class QuotationActionController extends Controller { dateOfBirth: Date; gender: string; nationality: string; + otherNationality?: string; namePrefix?: string; firstName: string; firstNameEN: string; @@ -1030,6 +1033,7 @@ export class QuotationActionController extends Controller { dateOfBirth: Date; gender: string; nationality: string; + otherNationality?: string; namePrefix?: string; firstName: string; firstNameEN: string; diff --git a/src/controllers/09-debit-note-controller.ts b/src/controllers/09-debit-note-controller.ts index 5d6307d..118575b 100644 --- a/src/controllers/09-debit-note-controller.ts +++ b/src/controllers/09-debit-note-controller.ts @@ -76,6 +76,7 @@ type DebitNoteCreate = { dateOfBirth: Date; gender: string; nationality: string; + otherNationality: string; namePrefix?: string; firstName: string; firstNameEN: string; @@ -111,6 +112,7 @@ type DebitNoteUpdate = { dateOfBirth: Date; gender: string; nationality: string; + otherNationality: string; namePrefix?: string; firstName?: string; firstNameEN: string; diff --git a/src/controllers/10-troubleshooting-controller.ts b/src/controllers/10-troubleshooting-controller.ts new file mode 100644 index 0000000..2c5418a --- /dev/null +++ b/src/controllers/10-troubleshooting-controller.ts @@ -0,0 +1,25 @@ +import express from "express"; +import { Controller, Get, Path, Request, Route } from "tsoa"; +import { getFile } from "../utils/minio"; + +@Route("api/v1/troubleshooting") +export class TroubleshootingController extends Controller { + @Get() + async get(@Request() req: express.Request) { + return req.res?.redirect(await getFile(".troubleshooting/toc.json")); + } + + @Get("{category}/assets/{name}") + async getAsset(@Request() req: express.Request, @Path() category: string, @Path() name: string) { + return req.res?.redirect(await getFile(`.troubleshooting/${category}/assets/${name}`)); + } + + @Get("{category}/page/{page}") + async getContent( + @Request() req: express.Request, + @Path() category: string, + @Path() page: string, + ) { + return req.res?.redirect(await getFile(`.troubleshooting/${category}/${page}.md`)); + } +}