updata user add employmentOffice
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 5s

This commit is contained in:
Kanjana 2025-04-11 11:28:24 +07:00
parent 70245a2b4f
commit a06d5514fc
5 changed files with 55 additions and 9 deletions

View file

@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "User" ADD COLUMN "contactName" TEXT,
ADD COLUMN "contactTel" TEXT;

View file

@ -0,0 +1,3 @@
-- AlterTable
ALTER TABLE "User" ALTER COLUMN "firstName" DROP NOT NULL,
ALTER COLUMN "lastName" DROP NOT NULL;

View file

@ -371,11 +371,11 @@ model User {
code String?
namePrefix String?
firstName String
firstName String?
firstNameEN String
middleName String?
middleNameEN String?
lastName String
lastName String?
lastNameEN String
username String
gender String
@ -497,6 +497,9 @@ model User {
remark String?
agencyStatus String?
contactName String?
contactTel String?
}
model UserResponsibleArea {

View file

@ -79,11 +79,11 @@ type UserCreate = {
citizenExpire?: Date | null;
namePrefix?: string | null;
firstName: string;
firstName?: string;
firstNameEN: string;
middleName?: string | null;
middleNameEN?: string | null;
lastName: string;
lastName?: string;
lastNameEN: string;
gender: string;
@ -123,6 +123,9 @@ type UserCreate = {
remark?: string;
agencyStatus?: string;
contactName?: string;
contactTel?: string;
};
type UserUpdate = {
@ -139,9 +142,9 @@ type UserUpdate = {
namePrefix?: string | null;
firstName?: string;
firstNameEN?: string;
firstNameEN: string;
middleName?: string | null;
middleNameEN?: string | null;
middleNameEN: string | null;
lastName?: string;
lastNameEN?: string;
gender?: string;
@ -182,6 +185,9 @@ type UserUpdate = {
remark?: string;
agencyStatus?: string;
contactName?: string;
contactTel?: string;
};
const permissionCondCompany = createPermCondition((_) => true);
@ -477,8 +483,8 @@ export class UserController extends Controller {
}
const userId = await createUser(username, username, {
firstName: body.firstName,
lastName: body.lastName,
firstName: body.firstNameEN,
lastName: body.lastNameEN,
email: body.email,
requiredActions: ["UPDATE_PASSWORD"],
enabled: rest.status !== "INACTIVE",

View file

@ -187,6 +187,16 @@ export class RequestDataController extends Controller {
employeePassport: {
orderBy: { expireDate: "desc" },
},
province: {
include: {
employmentOffice: true,
},
},
district: {
include: {
employmentOffice: true,
},
},
},
},
},
@ -197,7 +207,28 @@ export class RequestDataController extends Controller {
prisma.requestData.count({ where }),
]);
return { result, page, pageSize, total };
const dataRequestData = result.map((item) => {
const employee = item.employee;
const dataOffice =
item.employee.provinceId === "10"
? employee.district?.employmentOffice
: employee.province?.employmentOffice;
return {
...item,
employee: {
...employee,
dataOffice,
},
};
});
return {
result: dataRequestData,
page,
pageSize,
total,
};
}
@Get("{requestDataId}")