cronjob อัพเดทสถานะเกษียณอายุราชการ

This commit is contained in:
Bright 2025-01-30 14:40:08 +07:00
parent ca9e79d1a4
commit 21813ffd07
3 changed files with 151 additions and 54 deletions

View file

@ -1160,59 +1160,59 @@ export class OrganizationUnauthorizeController extends Controller {
return new HttpSuccess("Email verified successfully.");
}
@Patch("retirement")
public async updateStatusRetirement(
@Body()
body: {
data: {
profileId: string;
}[];
},
) {
let profiles: Profile[] = [];
let _null: any = null;
await Promise.all(
body.data.map(async (item) => {
const _profile = await this.profileRepo.findOneBy({ id: item.profileId });
if (!_profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
_profile.isRetirement = true;
_profile.isLeave = true;
_profile.leaveType = "RETIRE";
_profile.leaveDate = new Date();
_profile.dateLeave = new Date();
_profile.lastUpdatedAt = new Date();
profiles.push(_profile);
})
);
await this.profileRepo.save(profiles);
return new HttpSuccess();
}
// @Patch("retirement")
// public async updateStatusRetirement(
// @Body()
// body: {
// data: {
// profileId: string;
// }[];
// },
// ) {
// let profiles: Profile[] = [];
// let _null: any = null;
// await Promise.all(
// body.data.map(async (item) => {
// const _profile = await this.profileRepo.findOneBy({ id: item.profileId });
// if (!_profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
// _profile.isRetirement = true;
// _profile.isLeave = true;
// _profile.leaveType = "RETIRE";
// _profile.leaveDate = new Date();
// _profile.dateLeave = new Date();
// _profile.lastUpdatedAt = new Date();
// profiles.push(_profile);
// })
// );
// await this.profileRepo.save(profiles);
// return new HttpSuccess();
// }
@Patch("retirement-employee")
public async updateStatusRetirementEmp(
@Body()
body: {
data: {
profileId: string;
}[];
},
) {
let profiles: ProfileEmployee[] = [];
let _null: any = null;
await Promise.all(
body.data.map(async (item) => {
const _profile = await this.profileEmpRepo.findOneBy({ id: item.profileId });
if (!_profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
_profile.isRetirement = true;
_profile.isLeave = true;
_profile.leaveType = "RETIRE";
_profile.leaveDate = new Date();
_profile.dateLeave = new Date();
_profile.lastUpdatedAt = new Date();
profiles.push(_profile);
})
);
await this.profileEmpRepo.save(profiles);
return new HttpSuccess();
}
// @Patch("retirement-employee")
// public async updateStatusRetirementEmp(
// @Body()
// body: {
// data: {
// profileId: string;
// }[];
// },
// ) {
// let profiles: ProfileEmployee[] = [];
// let _null: any = null;
// await Promise.all(
// body.data.map(async (item) => {
// const _profile = await this.profileEmpRepo.findOneBy({ id: item.profileId });
// if (!_profile) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
// _profile.isRetirement = true;
// _profile.isLeave = true;
// _profile.leaveType = "RETIRE";
// _profile.leaveDate = new Date();
// _profile.dateLeave = new Date();
// _profile.lastUpdatedAt = new Date();
// profiles.push(_profile);
// })
// );
// await this.profileEmpRepo.save(profiles);
// return new HttpSuccess();
// }
}