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? code String?
namePrefix String? namePrefix String?
firstName String firstName String?
firstNameEN String firstNameEN String
middleName String? middleName String?
middleNameEN String? middleNameEN String?
lastName String lastName String?
lastNameEN String lastNameEN String
username String username String
gender String gender String
@ -497,6 +497,9 @@ model User {
remark String? remark String?
agencyStatus String? agencyStatus String?
contactName String?
contactTel String?
} }
model UserResponsibleArea { model UserResponsibleArea {

View file

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

View file

@ -187,6 +187,16 @@ export class RequestDataController extends Controller {
employeePassport: { employeePassport: {
orderBy: { expireDate: "desc" }, orderBy: { expireDate: "desc" },
}, },
province: {
include: {
employmentOffice: true,
},
},
district: {
include: {
employmentOffice: true,
},
},
}, },
}, },
}, },
@ -197,7 +207,28 @@ export class RequestDataController extends Controller {
prisma.requestData.count({ where }), 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}") @Get("{requestDataId}")