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,
|
posType: true,
|
||||||
},
|
},
|
||||||
where: { profileId: id },
|
where: { profileId: id },
|
||||||
|
order: {
|
||||||
|
createdAt: "ASC",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
|
||||||
|
|
@ -665,17 +665,6 @@ export class ProfileEmployeeController extends Controller {
|
||||||
const record = await this.profileRepo.findOneBy({ id });
|
const record = await this.profileRepo.findOneBy({ id });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
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 == "") {
|
if (body.employeeClass == null || body.employeeClass == undefined || body.employeeClass == "") {
|
||||||
body.employeeClass = "PERM";
|
body.employeeClass = "PERM";
|
||||||
}
|
}
|
||||||
|
|
@ -691,6 +680,16 @@ export class ProfileEmployeeController extends Controller {
|
||||||
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
||||||
record.citizenId = Extension.CheckCitizen(record.citizenId);
|
record.citizenId = Extension.CheckCitizen(record.citizenId);
|
||||||
record.employeeClass = record.employeeClass.toLocaleUpperCase();
|
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);
|
await this.profileRepo.save(record);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -1395,11 +1394,11 @@ export class ProfileEmployeeController extends Controller {
|
||||||
relations: {
|
relations: {
|
||||||
posLevel: true,
|
posLevel: true,
|
||||||
posType: true,
|
posType: true,
|
||||||
// gender: true,
|
|
||||||
// relationship: true,
|
|
||||||
// bloodGroup: true,
|
|
||||||
},
|
},
|
||||||
where: { profileEmployeeId: id },
|
where: { profileEmployeeId: id },
|
||||||
|
order: {
|
||||||
|
createdAt: "ASC",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -3037,36 +3036,13 @@ export class ProfileEmployeeController extends Controller {
|
||||||
@Get("information/history/{profileEmployeeId}")
|
@Get("information/history/{profileEmployeeId}")
|
||||||
async getInformationHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
async getInformationHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_EMP", profileEmployeeId);
|
||||||
const profileInformation = await this.profileRepo.find({
|
const profileInformation = await this.informationHistoryRepository.find({
|
||||||
relations: {
|
where: { profileEmployeeId: profileEmployeeId },
|
||||||
information_histories: true,
|
order: {
|
||||||
|
createdAt: "ASC",
|
||||||
},
|
},
|
||||||
where: { id: profileEmployeeId },
|
|
||||||
});
|
});
|
||||||
if (!profileInformation) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
return new HttpSuccess(profileInformation);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -662,14 +662,6 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
const record = await this.profileRepo.findOneBy({ id });
|
const record = await this.profileRepo.findOneBy({ id });
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลโปรไฟล์นี้");
|
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 == "") {
|
if (body.employeeClass == null || body.employeeClass == undefined || body.employeeClass == "") {
|
||||||
body.employeeClass = "PERM";
|
body.employeeClass = "PERM";
|
||||||
}
|
}
|
||||||
|
|
@ -685,6 +677,13 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
record.dateRetireLaw = calculateRetireLaw(record.birthDate);
|
||||||
record.citizenId = Extension.CheckCitizen(record.citizenId);
|
record.citizenId = Extension.CheckCitizen(record.citizenId);
|
||||||
record.employeeClass = record.employeeClass.toLocaleUpperCase();
|
record.employeeClass = record.employeeClass.toLocaleUpperCase();
|
||||||
|
await this.profileHistoryRepo.save(
|
||||||
|
Object.assign(new ProfileEmployeeHistory(), {
|
||||||
|
...record,
|
||||||
|
profileEmployeeId: id,
|
||||||
|
id: undefined,
|
||||||
|
}),
|
||||||
|
);
|
||||||
await this.profileRepo.save(record);
|
await this.profileRepo.save(record);
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
}
|
}
|
||||||
|
|
@ -1333,11 +1332,11 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
relations: {
|
relations: {
|
||||||
posLevel: true,
|
posLevel: true,
|
||||||
posType: true,
|
posType: true,
|
||||||
// gender: true,
|
|
||||||
// relationship: true,
|
|
||||||
// bloodGroup: true,
|
|
||||||
},
|
},
|
||||||
where: { profileEmployeeId: id },
|
where: { profileEmployeeId: id },
|
||||||
|
order: {
|
||||||
|
createdAt: "ASC",
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
if (!profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
|
@ -2973,36 +2972,13 @@ export class ProfileEmployeeTempController extends Controller {
|
||||||
@Get("information/history/{profileEmployeeId}")
|
@Get("information/history/{profileEmployeeId}")
|
||||||
async getInformationHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
async getInformationHistory(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");
|
||||||
const profileInformation = await this.profileRepo.find({
|
const profileInformation = await this.informationHistoryRepository.find({
|
||||||
relations: {
|
where: { profileEmployeeId: profileEmployeeId },
|
||||||
information_histories: true,
|
order: {
|
||||||
|
createdAt: "ASC",
|
||||||
},
|
},
|
||||||
where: { id: profileEmployeeId },
|
|
||||||
});
|
});
|
||||||
if (!profileInformation) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
return new HttpSuccess(profileInformation);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue