feat: add relation businessType
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 5s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 5s
This commit is contained in:
parent
fc22c38472
commit
463a3cafd8
2 changed files with 14 additions and 1 deletions
|
|
@ -789,6 +789,7 @@ model BusinessType {
|
||||||
updatedByUserId String?
|
updatedByUserId String?
|
||||||
|
|
||||||
customerBranch CustomerBranch[]
|
customerBranch CustomerBranch[]
|
||||||
|
employeeWork EmployeeWork[]
|
||||||
}
|
}
|
||||||
|
|
||||||
model Employee {
|
model Employee {
|
||||||
|
|
@ -965,7 +966,6 @@ model EmployeeWork {
|
||||||
|
|
||||||
ownerName String?
|
ownerName String?
|
||||||
positionName String?
|
positionName String?
|
||||||
businessTypeId String?
|
|
||||||
workplace String?
|
workplace String?
|
||||||
identityNo String?
|
identityNo String?
|
||||||
workPermitNo String?
|
workPermitNo String?
|
||||||
|
|
@ -973,6 +973,9 @@ model EmployeeWork {
|
||||||
workPermitExpireDate DateTime? @db.Date
|
workPermitExpireDate DateTime? @db.Date
|
||||||
workPermitAt String?
|
workPermitAt String?
|
||||||
|
|
||||||
|
businessType BusinessType? @relation(fields: [businessTypeId], references: [id], onDelete: SetNull)
|
||||||
|
businessTypeId String?
|
||||||
|
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
createdBy User? @relation(name: "EmployeeWorkCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
createdBy User? @relation(name: "EmployeeWorkCreatedByUser", fields: [createdByUserId], references: [id], onDelete: SetNull)
|
||||||
createdByUserId String?
|
createdByUserId String?
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,7 @@ export class EmployeeWorkController extends Controller {
|
||||||
include: {
|
include: {
|
||||||
createdBy: true,
|
createdBy: true,
|
||||||
updatedBy: true,
|
updatedBy: true,
|
||||||
|
businessType: true,
|
||||||
},
|
},
|
||||||
where: { id: workId, employeeId },
|
where: { id: workId, employeeId },
|
||||||
});
|
});
|
||||||
|
|
@ -86,10 +87,17 @@ export class EmployeeWorkController extends Controller {
|
||||||
@Path() employeeId: string,
|
@Path() employeeId: string,
|
||||||
@Body() body: EmployeeWorkPayload,
|
@Body() body: EmployeeWorkPayload,
|
||||||
) {
|
) {
|
||||||
|
const businessType = await prisma.businessType.findUnique({
|
||||||
|
where: { id: body.businessTypeId },
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!businessType) throw notFoundError("Business Type");
|
||||||
|
|
||||||
const record = await prisma.employeeWork.create({
|
const record = await prisma.employeeWork.create({
|
||||||
include: {
|
include: {
|
||||||
createdBy: true,
|
createdBy: true,
|
||||||
updatedBy: true,
|
updatedBy: true,
|
||||||
|
businessType: true,
|
||||||
},
|
},
|
||||||
data: {
|
data: {
|
||||||
...body,
|
...body,
|
||||||
|
|
@ -120,6 +128,7 @@ export class EmployeeWorkController extends Controller {
|
||||||
include: {
|
include: {
|
||||||
createdBy: true,
|
createdBy: true,
|
||||||
updatedBy: true,
|
updatedBy: true,
|
||||||
|
businessType: true,
|
||||||
},
|
},
|
||||||
where: { id: workId, employeeId },
|
where: { id: workId, employeeId },
|
||||||
data: { ...body, updatedByUserId: req.user.sub },
|
data: { ...body, updatedByUserId: req.user.sub },
|
||||||
|
|
@ -137,6 +146,7 @@ export class EmployeeWorkController extends Controller {
|
||||||
include: {
|
include: {
|
||||||
createdBy: true,
|
createdBy: true,
|
||||||
updatedBy: true,
|
updatedBy: true,
|
||||||
|
businessType: true,
|
||||||
},
|
},
|
||||||
where: { id: workId, employeeId },
|
where: { id: workId, employeeId },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue