no message
This commit is contained in:
parent
a2292d6048
commit
9c338a0cde
3 changed files with 36 additions and 81 deletions
|
|
@ -2563,6 +2563,9 @@ export class ProfileController extends Controller {
|
|||
posType: true,
|
||||
},
|
||||
where: { profileId: id },
|
||||
order: {
|
||||
createdAt: "ASC",
|
||||
},
|
||||
});
|
||||
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
|
|||
|
|
@ -665,17 +665,6 @@ export class ProfileEmployeeController extends Controller {
|
|||
const record = await this.profileRepo.findOneBy({ id });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
|
||||
await this.profileHistoryRepo.save(
|
||||
Object.assign(new ProfileEmployeeHistory(), {
|
||||
...record,
|
||||
lastUpdateUserId: request.user.sub,
|
||||
lastUpdateFullName: request.user.name,
|
||||
lastUpdatedAt: new Date(),
|
||||
profileEmployeeId: id,
|
||||
id: undefined,
|
||||
}),
|
||||
);
|
||||
|
||||
if (body.employeeClass == null || body.employeeClass == undefined || body.employeeClass == "") {
|
||||
body.employeeClass = "PERM";
|
||||
}
|
||||
|
|
@ -691,6 +680,16 @@ export class ProfileEmployeeController extends Controller {
|
|||
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
||||
record.citizenId = Extension.CheckCitizen(record.citizenId);
|
||||
record.employeeClass = record.employeeClass.toLocaleUpperCase();
|
||||
await this.profileHistoryRepo.save(
|
||||
Object.assign(new ProfileEmployeeHistory(), {
|
||||
...record,
|
||||
lastUpdateUserId: request.user.sub,
|
||||
lastUpdateFullName: request.user.name,
|
||||
lastUpdatedAt: new Date(),
|
||||
profileEmployeeId: id,
|
||||
id: undefined,
|
||||
}),
|
||||
);
|
||||
await this.profileRepo.save(record);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -1395,11 +1394,11 @@ export class ProfileEmployeeController extends Controller {
|
|||
relations: {
|
||||
posLevel: true,
|
||||
posType: true,
|
||||
// gender: true,
|
||||
// relationship: true,
|
||||
// bloodGroup: true,
|
||||
},
|
||||
where: { profileEmployeeId: id },
|
||||
order: {
|
||||
createdAt: "ASC",
|
||||
},
|
||||
});
|
||||
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -3037,36 +3036,13 @@ export class ProfileEmployeeController extends Controller {
|
|||
@Get("information/history/{profileEmployeeId}")
|
||||
async getInformationHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||
const profileInformation = await this.profileRepo.find({
|
||||
relations: {
|
||||
information_histories: true,
|
||||
const profileInformation = await this.informationHistoryRepository.find({
|
||||
where: { profileEmployeeId: profileEmployeeId },
|
||||
order: {
|
||||
createdAt: "ASC",
|
||||
},
|
||||
where: { id: profileEmployeeId },
|
||||
});
|
||||
if (!profileInformation) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const mapData = profileInformation
|
||||
.flatMap((profile) => profile.information_histories)
|
||||
.map((history) => ({
|
||||
id: history.id,
|
||||
positionEmployeeGroupId: history.positionEmployeeGroupId,
|
||||
positionEmployeeLineId: history.positionEmployeeLineId,
|
||||
positionEmployeePositionId: history.positionEmployeePositionId,
|
||||
employeeOc: history.employeeOc,
|
||||
employeeTypeIndividual: history.employeeTypeIndividual,
|
||||
employeeWage: history.employeeWage,
|
||||
employeeMoneyIncrease: history.employeeMoneyIncrease,
|
||||
employeeMoneyAllowance: history.employeeMoneyAllowance,
|
||||
employeeMoneyEmployee: history.employeeMoneyEmployee,
|
||||
employeeMoneyEmployer: history.employeeMoneyEmployer,
|
||||
createdAt: history.createdAt,
|
||||
createdUserId: history.createdUserId,
|
||||
createdFullName: history.createdFullName,
|
||||
lastUpdatedAt: history.lastUpdatedAt,
|
||||
lastUpdateUserId: history.lastUpdateUserId,
|
||||
lastUpdateFullName: history.lastUpdateFullName,
|
||||
}));
|
||||
return new HttpSuccess(mapData);
|
||||
return new HttpSuccess(profileInformation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -662,14 +662,6 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
const record = await this.profileRepo.findOneBy({ id });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
||||
|
||||
await this.profileHistoryRepo.save(
|
||||
Object.assign(new ProfileEmployeeHistory(), {
|
||||
...record,
|
||||
profileEmployeeId: id,
|
||||
id: undefined,
|
||||
}),
|
||||
);
|
||||
|
||||
if (body.employeeClass == null || body.employeeClass == undefined || body.employeeClass == "") {
|
||||
body.employeeClass = "PERM";
|
||||
}
|
||||
|
|
@ -685,6 +677,13 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
||||
record.citizenId = Extension.CheckCitizen(record.citizenId);
|
||||
record.employeeClass = record.employeeClass.toLocaleUpperCase();
|
||||
await this.profileHistoryRepo.save(
|
||||
Object.assign(new ProfileEmployeeHistory(), {
|
||||
...record,
|
||||
profileEmployeeId: id,
|
||||
id: undefined,
|
||||
}),
|
||||
);
|
||||
await this.profileRepo.save(record);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -1333,11 +1332,11 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
relations: {
|
||||
posLevel: true,
|
||||
posType: true,
|
||||
// gender: true,
|
||||
// relationship: true,
|
||||
// bloodGroup: true,
|
||||
},
|
||||
where: { profileEmployeeId: id },
|
||||
order: {
|
||||
createdAt: "ASC",
|
||||
},
|
||||
});
|
||||
|
||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
@ -2973,36 +2972,13 @@ export class ProfileEmployeeTempController extends Controller {
|
|||
@Get("information/history/{profileEmployeeId}")
|
||||
async getInformationHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||
const profileInformation = await this.profileRepo.find({
|
||||
relations: {
|
||||
information_histories: true,
|
||||
const profileInformation = await this.informationHistoryRepository.find({
|
||||
where: { profileEmployeeId: profileEmployeeId },
|
||||
order: {
|
||||
createdAt: "ASC",
|
||||
},
|
||||
where: { id: profileEmployeeId },
|
||||
});
|
||||
if (!profileInformation) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
||||
const mapData = profileInformation
|
||||
.flatMap((profile) => profile.information_histories)
|
||||
.map((history) => ({
|
||||
id: history.id,
|
||||
positionEmployeeGroupId: history.positionEmployeeGroupId,
|
||||
positionEmployeeLineId: history.positionEmployeeLineId,
|
||||
positionEmployeePositionId: history.positionEmployeePositionId,
|
||||
employeeOc: history.employeeOc,
|
||||
employeeTypeIndividual: history.employeeTypeIndividual,
|
||||
employeeWage: history.employeeWage,
|
||||
employeeMoneyIncrease: history.employeeMoneyIncrease,
|
||||
employeeMoneyAllowance: history.employeeMoneyAllowance,
|
||||
employeeMoneyEmployee: history.employeeMoneyEmployee,
|
||||
employeeMoneyEmployer: history.employeeMoneyEmployer,
|
||||
createdAt: history.createdAt,
|
||||
createdUserId: history.createdUserId,
|
||||
createdFullName: history.createdFullName,
|
||||
lastUpdatedAt: history.lastUpdatedAt,
|
||||
lastUpdateUserId: history.lastUpdateUserId,
|
||||
lastUpdateFullName: history.lastUpdateFullName,
|
||||
}));
|
||||
return new HttpSuccess(mapData);
|
||||
return new HttpSuccess(profileInformation);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue