migrate + fix issue #993
This commit is contained in:
parent
7a0ab2271d
commit
4011abe5ea
5 changed files with 142 additions and 43 deletions
|
|
@ -1,4 +1,4 @@
|
|||
import { Controller, Get, Post, Route, Tags, Body, Path, Response } from "tsoa";
|
||||
import { Controller, Get, Post, Route, Tags, Body, Path, Response, Patch } from "tsoa";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
|
|
@ -1159,4 +1159,60 @@ export class OrganizationUnauthorizeController extends Controller {
|
|||
await this.profileRepo.save(profile);
|
||||
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-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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue