API ลบข้อมูลการฝึกอบรม/ดูงาน และ การพัฒนารายบุคคล IDP รายบุคคล
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m17s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m17s
This commit is contained in:
parent
5ef5f7d4ed
commit
6b3d1dc67b
2 changed files with 121 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ import {
|
|||
import permission from "../interfaces/permission";
|
||||
import { DevelopmentProject } from "../entities/DevelopmentProject";
|
||||
import { In, Brackets } from "typeorm";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
@Route("api/v1/org/profile-employee/development")
|
||||
@Tags("ProfileDevelopment")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -273,6 +274,44 @@ export class ProfileDevelopmentEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลการพัฒนารายบุคคล IDP
|
||||
* @summary API ลบข้อมูลการพัฒนารายบุคคล IDP
|
||||
* @param developmentId คีย์การพัฒนารายบุคคล IDP
|
||||
*/
|
||||
@Patch("update-delete/{developmentId}")
|
||||
public async updateIsDeletedTraining(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() developmentId: string,
|
||||
) {
|
||||
const record = await this.developmentRepository.findOneBy({ id: developmentId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", record.profileEmployeeId);
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileDevelopmentHistory();
|
||||
const now = new Date();
|
||||
record.isDeleted = true;
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
record.lastUpdatedAt = now;
|
||||
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.developmentRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.developmentHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{developmentId}")
|
||||
public async deleteDevelopment(@Path() developmentId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.developmentRepository.findOneBy({ id: developmentId });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue