From cd768129977b2c1d8ff0ee49efa6986bc509c580 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Thu, 4 Apr 2024 13:42:46 +0700 Subject: [PATCH] refactor: remove suffix from field This field does not indicate that it is specific to TH but any locale --- prisma/schema.prisma | 20 ++++++++++---------- src/controllers/branch/branch-controller.ts | 12 ++++++------ src/controllers/branch/user-controller.ts | 6 +++--- src/controllers/user/user-controller.ts | 16 ++++++++-------- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index ad90c97..b0f82be 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -9,7 +9,7 @@ datasource db { model Province { id String @id @default(uuid()) - nameTH String + name String nameEN String createdBy String? @@ -27,7 +27,7 @@ model Province { model District { id String @id @default(uuid()) - nameTH String + name String nameEN String provinceId String @@ -47,7 +47,7 @@ model District { model SubDistrict { id String @id @default(uuid()) - nameTH String + name String nameEN String zipCode String @@ -74,9 +74,9 @@ model Branch { id String @id @default(uuid()) code String @default(uuid()) taxNo String - nameTH String + name String nameEN String - addressTH String + address String addressEN String province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull) @@ -148,12 +148,12 @@ model User { keycloakId String code String @default(uuid()) - firstNameTH String + firstName String firstNameEN String - lastNameTH String + lastName String lastNameEN String - addressTH String + address String addressEN String province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull) @@ -222,7 +222,7 @@ model CustomerBranch { branchNo String legalPersonNo String - nameTH String + name String nameEN String customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade) @@ -270,7 +270,7 @@ model Employee { gender String nationality String - addressTH String + address String addressEN String province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull) diff --git a/src/controllers/branch/branch-controller.ts b/src/controllers/branch/branch-controller.ts index 05e5d01..b4ae109 100644 --- a/src/controllers/branch/branch-controller.ts +++ b/src/controllers/branch/branch-controller.ts @@ -23,9 +23,9 @@ type BranchCreate = { code: string; taxNo: string; nameEN: string; - nameTH: string; + name: string; addressEN: string; - addressTH: string; + address: string; zipCode: string; email: string; telephoneNo: string; @@ -42,9 +42,9 @@ type BranchUpdate = { code?: string; taxNo?: string; nameEN?: string; - nameTH?: string; + name?: string; addressEN?: string; - addressTH?: string; + address?: string; zipCode?: string; email?: string; telephoneNo?: string; @@ -72,7 +72,7 @@ export class BranchController extends Controller { select: { id: true, nameEN: true, - nameTH: true, + name: true, }, }); @@ -92,7 +92,7 @@ export class BranchController extends Controller { const where = { OR: [ { nameEN: { contains: query }, zipCode }, - { nameTH: { contains: query }, zipCode }, + { name: { contains: query }, zipCode }, { email: { contains: query }, zipCode }, ], } satisfies Prisma.BranchWhereInput; diff --git a/src/controllers/branch/user-controller.ts b/src/controllers/branch/user-controller.ts index 1ae434b..483f1c4 100644 --- a/src/controllers/branch/user-controller.ts +++ b/src/controllers/branch/user-controller.ts @@ -34,9 +34,9 @@ export class BranchUserController extends Controller { ) { const where = { OR: [ - { user: { firstNameTH: { contains: query }, zipCode }, branchId }, + { user: { firstName: { contains: query }, zipCode }, branchId }, { user: { firstNameEN: { contains: query }, zipCode }, branchId }, - { user: { lastNameTH: { contains: query }, zipCode }, branchId }, + { user: { lastName: { contains: query }, zipCode }, branchId }, { user: { lastNameEN: { contains: query }, zipCode }, branchId }, { user: { email: { contains: query }, zipCode }, branchId }, { user: { telephoneNo: { contains: query }, zipCode }, branchId }, @@ -131,7 +131,7 @@ export class UserBranchController extends Controller { ) { const where = { OR: [ - { branch: { nameTH: { contains: query }, zipCode }, userId }, + { branch: { name: { contains: query }, zipCode }, userId }, { branch: { nameEN: { contains: query }, zipCode }, userId }, ], } satisfies Prisma.BranchUserWhereInput; diff --git a/src/controllers/user/user-controller.ts b/src/controllers/user/user-controller.ts index 09c78c1..30bfa19 100644 --- a/src/controllers/user/user-controller.ts +++ b/src/controllers/user/user-controller.ts @@ -32,9 +32,9 @@ type UserCreate = { userType: string; userRole: string; - firstNameTH: string; + firstName: string; firstNameEN: string; - lastNameTH: string; + lastName: string; lastNameEN: string; code: string; @@ -49,7 +49,7 @@ type UserCreate = { importNationality: string; trainingPlace: string; - addressTH: string; + address: string; addressEN: string; zipCode: string; email: string; @@ -64,9 +64,9 @@ type UserUpdate = { userType?: string; userRole?: string; - firstNameTH?: string; + firstName?: string; firstNameEN?: string; - lastNameTH?: string; + lastName?: string; lastNameEN?: string; code?: string; @@ -81,7 +81,7 @@ type UserUpdate = { importNationality?: string; trainingPlace?: string; - addressTH?: string; + address?: string; addressEN?: string; zipCode?: string; email?: string; @@ -110,9 +110,9 @@ export class UserController extends Controller { ) { const where = { OR: [ - { firstNameTH: { contains: query }, zipCode, userType }, + { firstName: { contains: query }, zipCode, userType }, { firstNameEN: { contains: query }, zipCode, userType }, - { lastNameTH: { contains: query }, zipCode, userType }, + { lastName: { contains: query }, zipCode, userType }, { lastNameEN: { contains: query }, zipCode, userType }, { email: { contains: query }, zipCode, userType }, { telephoneNo: { contains: query }, zipCode, userType },