620 lines
13 KiB
Text
620 lines
13 KiB
Text
generator client {
|
|
provider = "prisma-client-js"
|
|
}
|
|
|
|
datasource db {
|
|
provider = "postgresql"
|
|
url = env("DATABASE_URL")
|
|
}
|
|
|
|
model Menu {
|
|
id String @id @default(uuid())
|
|
|
|
caption String
|
|
captionEN String
|
|
menuType String
|
|
url String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
parent Menu? @relation(name: "MenuRelation", fields: [parentId], references: [id])
|
|
parentId String?
|
|
|
|
children Menu[] @relation(name: "MenuRelation")
|
|
roleMenuPermission RoleMenuPermission[]
|
|
userMenuPermission UserMenuPermission[]
|
|
userComponent MenuComponent[]
|
|
}
|
|
|
|
model RoleMenuPermission {
|
|
id String @id @default(uuid())
|
|
|
|
userRole String
|
|
permission String
|
|
|
|
menu Menu @relation(fields: [menuId], references: [id])
|
|
menuId String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model UserMenuPermission {
|
|
id String @id @default(uuid())
|
|
|
|
permission String
|
|
|
|
menu Menu @relation(fields: [menuId], references: [id])
|
|
menuId String
|
|
|
|
user User @relation(fields: [userId], references: [id])
|
|
userId String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model MenuComponent {
|
|
id String @id @default(uuid())
|
|
|
|
componentId String
|
|
componentTag String
|
|
|
|
menu Menu @relation(fields: [menuId], references: [id])
|
|
menuId String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
roleMenuComponentPermission RoleMenuComponentPermission[]
|
|
userMennuComponentPermission UserMenuComponentPermission[]
|
|
}
|
|
|
|
model RoleMenuComponentPermission {
|
|
id String @id @default(uuid())
|
|
|
|
userRole String
|
|
permission String
|
|
|
|
menuComponent MenuComponent @relation(fields: [menuComponentId], references: [id])
|
|
menuComponentId String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model RunningNo {
|
|
key String @id @unique
|
|
value Int
|
|
}
|
|
|
|
model UserMenuComponentPermission {
|
|
id String @id @default(uuid())
|
|
|
|
userId String
|
|
user User @relation(fields: [userId], references: [id])
|
|
|
|
menuComponent MenuComponent @relation(fields: [menuComponentId], references: [id])
|
|
menuComponentId String
|
|
|
|
permission String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model Province {
|
|
id String @id @default(uuid())
|
|
name String
|
|
nameEN String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
district District[]
|
|
branch Branch[]
|
|
user User[]
|
|
customerBranch CustomerBranch[]
|
|
employee Employee[]
|
|
employeeCheckup EmployeeCheckup[]
|
|
}
|
|
|
|
model District {
|
|
id String @id @default(uuid())
|
|
name String
|
|
nameEN String
|
|
|
|
provinceId String
|
|
province Province @relation(fields: [provinceId], references: [id], onDelete: Cascade)
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
subDistrict SubDistrict[]
|
|
branch Branch[]
|
|
user User[]
|
|
customerBranch CustomerBranch[]
|
|
employee Employee[]
|
|
}
|
|
|
|
model SubDistrict {
|
|
id String @id @default(uuid())
|
|
name String
|
|
nameEN String
|
|
zipCode String
|
|
|
|
district District @relation(fields: [districtId], references: [id], onDelete: Cascade)
|
|
districtId String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
branch Branch[]
|
|
user User[]
|
|
customerBranch CustomerBranch[]
|
|
employee Employee[]
|
|
}
|
|
|
|
enum Status {
|
|
CREATED
|
|
ACTIVE
|
|
INACTIVE
|
|
}
|
|
|
|
model Branch {
|
|
id String @id @default(uuid())
|
|
code String
|
|
taxNo String
|
|
name String
|
|
nameEN String
|
|
address String
|
|
addressEN String
|
|
telephoneNo String
|
|
|
|
province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull)
|
|
provinceId String?
|
|
|
|
district District? @relation(fields: [districtId], references: [id], onDelete: SetNull)
|
|
districtId String?
|
|
|
|
subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull)
|
|
subDistrictId String?
|
|
|
|
zipCode String
|
|
|
|
email String
|
|
contactName String?
|
|
lineId String?
|
|
|
|
latitude String
|
|
longitude String
|
|
|
|
isHeadOffice Boolean @default(false)
|
|
|
|
headOffice Branch? @relation(name: "HeadOfficeRelation", fields: [headOfficeId], references: [id])
|
|
headOfficeId String?
|
|
|
|
status Status @default(CREATED)
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
branch Branch[] @relation(name: "HeadOfficeRelation")
|
|
contact BranchContact[]
|
|
user BranchUser[]
|
|
}
|
|
|
|
model BranchContact {
|
|
id String @id @default(uuid())
|
|
telephoneNo String
|
|
|
|
branch Branch @relation(fields: [branchId], references: [id], onDelete: Cascade)
|
|
branchId String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model BranchUser {
|
|
id String @id @default(uuid())
|
|
|
|
branch Branch @relation(fields: [branchId], references: [id], onDelete: Cascade)
|
|
branchId String
|
|
|
|
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
|
|
userId String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
enum UserType {
|
|
USER
|
|
MESSENGER
|
|
DELEGATE
|
|
AGENCY
|
|
}
|
|
|
|
model User {
|
|
id String @id @default(uuid())
|
|
|
|
code String?
|
|
firstName String
|
|
firstNameEN String
|
|
lastName String
|
|
lastNameEN String
|
|
username String
|
|
gender String
|
|
|
|
address String
|
|
addressEN String
|
|
|
|
province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull)
|
|
provinceId String?
|
|
|
|
district District? @relation(fields: [districtId], references: [id], onDelete: SetNull)
|
|
districtId String?
|
|
|
|
subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull)
|
|
subDistrictId String?
|
|
|
|
zipCode String
|
|
|
|
email String
|
|
telephoneNo String
|
|
|
|
registrationNo String?
|
|
|
|
startDate DateTime?
|
|
retireDate DateTime?
|
|
|
|
checkpoint String?
|
|
checkpointEN String?
|
|
|
|
userType UserType
|
|
userRole String
|
|
|
|
discountCondition String?
|
|
|
|
licenseNo String?
|
|
licenseIssueDate DateTime?
|
|
licenseExpireDate DateTime?
|
|
|
|
sourceNationality String?
|
|
importNationality String?
|
|
|
|
trainingPlace String?
|
|
responsibleArea String?
|
|
|
|
birthDate DateTime?
|
|
|
|
status Status @default(CREATED)
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
branch BranchUser[]
|
|
userMenuPermission UserMenuPermission[]
|
|
userMenuComponentPermission UserMenuComponentPermission[]
|
|
}
|
|
|
|
enum CustomerType {
|
|
CORP
|
|
PERS
|
|
}
|
|
|
|
model Customer {
|
|
id String @id @default(uuid())
|
|
code String
|
|
customerType CustomerType
|
|
customerName String
|
|
customerNameEN String
|
|
taxNo String?
|
|
|
|
status Status @default(CREATED)
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
branch CustomerBranch[]
|
|
}
|
|
|
|
model CustomerBranch {
|
|
id String @id @default(uuid())
|
|
branchNo Int
|
|
legalPersonNo String
|
|
|
|
name String
|
|
nameEN String
|
|
|
|
customer Customer @relation(fields: [customerId], references: [id], onDelete: Cascade)
|
|
customerId String
|
|
|
|
taxNo String?
|
|
registerName String
|
|
registerDate DateTime
|
|
authorizedCapital String
|
|
|
|
address String
|
|
addressEN String
|
|
|
|
province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull)
|
|
provinceId String?
|
|
|
|
district District? @relation(fields: [districtId], references: [id], onDelete: SetNull)
|
|
districtId String?
|
|
|
|
subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull)
|
|
subDistrictId String?
|
|
|
|
zipCode String
|
|
|
|
email String
|
|
telephoneNo String
|
|
|
|
employmentOffice String
|
|
bussinessType String
|
|
bussinessTypeEN String
|
|
jobPosition String
|
|
jobPositionEN String
|
|
jobDescription String
|
|
saleEmployee String
|
|
payDate DateTime
|
|
wageRate Int
|
|
|
|
status Status @default(CREATED)
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
employee Employee[]
|
|
}
|
|
|
|
model Employee {
|
|
id String @id @default(uuid())
|
|
|
|
code String
|
|
nrcNo String
|
|
firstName String
|
|
firstNameEN String
|
|
lastName String
|
|
lastNameEN String
|
|
|
|
dateOfBirth DateTime
|
|
gender String
|
|
nationality String
|
|
|
|
address String
|
|
addressEN String
|
|
|
|
province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull)
|
|
provinceId String?
|
|
|
|
district District? @relation(fields: [districtId], references: [id], onDelete: SetNull)
|
|
districtId String?
|
|
|
|
subDistrict SubDistrict? @relation(fields: [subDistrictId], references: [id], onDelete: SetNull)
|
|
subDistrictId String?
|
|
|
|
zipCode String
|
|
|
|
email String
|
|
telephoneNo String
|
|
|
|
arrivalBarricade String
|
|
arrivalCardNo String
|
|
|
|
customerBranch CustomerBranch? @relation(fields: [customerBranchId], references: [id], onDelete: SetNull)
|
|
customerBranchId String?
|
|
|
|
status Status @default(CREATED)
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
employeeCheckup EmployeeCheckup[]
|
|
employeeWork EmployeeWork[]
|
|
employeeOtherInfo EmployeeOtherInfo[]
|
|
}
|
|
|
|
model EmployeeCheckup {
|
|
id String @id @default(uuid())
|
|
|
|
employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade)
|
|
employeeId String
|
|
|
|
checkupResult String
|
|
checkupType String
|
|
|
|
province Province? @relation(fields: [provinceId], references: [id], onDelete: SetNull)
|
|
provinceId String?
|
|
|
|
hospitalName String
|
|
remark String
|
|
medicalBenefitScheme String
|
|
insuranceCompany String
|
|
coverageStartDate DateTime
|
|
coverageExpireDate DateTime
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model EmployeeWork {
|
|
id String @id @default(uuid())
|
|
|
|
employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade)
|
|
employeeId String
|
|
|
|
ownerName String
|
|
positionName String
|
|
jobType String
|
|
workplace String
|
|
workPermitNo String
|
|
workPermitIssuDate DateTime
|
|
workPermitExpireDate DateTime
|
|
workEndDate DateTime
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model EmployeeOtherInfo {
|
|
id String @id @default(uuid())
|
|
|
|
employee Employee @relation(fields: [employeeId], references: [id], onDelete: Cascade)
|
|
employeeId String
|
|
|
|
citizenId String
|
|
fatherFullName String
|
|
motherFullName String
|
|
birthPlace String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model Service {
|
|
id String @id @default(uuid())
|
|
|
|
code String
|
|
name String
|
|
detail String
|
|
|
|
status Status @default(CREATED)
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
work Work[]
|
|
}
|
|
|
|
model Work {
|
|
id String @id @default(uuid())
|
|
|
|
order Int
|
|
name String
|
|
|
|
service Service @relation(fields: [serviceId], references: [id], onDelete: Cascade)
|
|
serviceId String
|
|
|
|
status Status @default(CREATED)
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
WorkProduct WorkProduct[]
|
|
}
|
|
|
|
model WorkProduct {
|
|
id String @id @default(uuid())
|
|
|
|
work Work @relation(fields: [workId], references: [id], onDelete: Cascade)
|
|
workId String
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|
|
|
|
model ProductGroup {
|
|
id String @id @default(uuid())
|
|
|
|
code String
|
|
name String
|
|
detail String
|
|
remark String
|
|
|
|
status Status @default(CREATED)
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
Product Product[]
|
|
}
|
|
|
|
model ProductType {
|
|
id String @id @default(uuid())
|
|
|
|
code String
|
|
name String
|
|
detail String
|
|
remark String
|
|
|
|
status Status @default(CREATED)
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
|
|
product Product[]
|
|
}
|
|
|
|
model Product {
|
|
id String @id @default(uuid())
|
|
|
|
code String
|
|
name String
|
|
detail String
|
|
process String
|
|
price Int
|
|
agentPrice Int
|
|
serviceCharge Int
|
|
imageUrl String
|
|
|
|
status Status @default(CREATED)
|
|
|
|
productType ProductType? @relation(fields: [productTypeId], references: [id], onDelete: SetNull)
|
|
productTypeId String?
|
|
|
|
productGroup ProductGroup? @relation(fields: [productGroupId], references: [id], onDelete: SetNull)
|
|
productGroupId String?
|
|
|
|
createdBy String?
|
|
createdAt DateTime @default(now())
|
|
updateBy String?
|
|
updatedAt DateTime @updatedAt
|
|
}
|