refactor: user relation

This commit is contained in:
Methapon2001 2024-07-01 13:24:02 +07:00
parent a74d8b63b1
commit 2bd30b735d
21 changed files with 607 additions and 185 deletions

View file

@ -418,8 +418,8 @@ export class EmployeeController extends Controller {
district: { connect: districtId ? { id: districtId } : undefined },
subDistrict: { connect: subDistrictId ? { id: subDistrictId } : undefined },
customerBranch: { connect: { id: customerBranchId } },
createdBy: req.user.name,
updatedBy: req.user.name,
createdBy: { connect: { id: req.user.sub } },
updatedBy: { connect: { id: req.user.sub } },
},
});
},
@ -578,13 +578,13 @@ export class EmployeeController extends Controller {
where: { id: v.id || "" },
create: {
...v,
createdBy: req.user.name,
updatedBy: req.user.name,
createdByUserId: req.user.sub,
updatedByUserId: req.user.sub,
id: undefined,
},
update: {
...v,
updatedBy: req.user.name,
updatedByUserId: req.user.sub,
},
})),
}
@ -602,13 +602,13 @@ export class EmployeeController extends Controller {
create: {
...v,
provinceId: !v.provinceId ? undefined : v.provinceId,
createdBy: req.user.name,
updatedBy: req.user.name,
createdByUserId: req.user.sub,
updatedByUserId: req.user.sub,
id: undefined,
},
update: {
...v,
updatedBy: req.user.name,
updatedByUserId: req.user.sub,
},
})),
}
@ -631,8 +631,8 @@ export class EmployeeController extends Controller {
connect: subDistrictId ? { id: subDistrictId } : undefined,
disconnect: subDistrictId === null || undefined,
},
createdBy: req.user.name,
updatedBy: req.user.name,
createdBy: { connect: { id: req.user.sub } },
updatedBy: { connect: { id: req.user.sub } },
},
});
});