api soft delete
This commit is contained in:
parent
17f7fc5d84
commit
9382482f06
44 changed files with 1717 additions and 0 deletions
|
|
@ -174,6 +174,45 @@ export class ProfileAbilityController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลความสามารถพิเศษ
|
||||
* @summary API ลบข้อมูลความสามารถพิเศษ
|
||||
* @param abilityId คีย์ความสามารถพิเศษ
|
||||
*/
|
||||
@Patch("update-delete/{abilityId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() abilityId: string,
|
||||
) {
|
||||
const record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileAbilityHistory();
|
||||
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.profileAbilityId = abilityId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.profileAbilityRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.profileAbilityHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{abilityId}")
|
||||
public async deleteProfileAbility(@Path() abilityId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||
|
|
|
|||
|
|
@ -183,6 +183,45 @@ export class ProfileAbilityEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลความสามารถพิเศษ
|
||||
* @summary API ลบข้อมูลความสามารถพิเศษ
|
||||
* @param abilityId คีย์ความสามารถพิเศษ
|
||||
*/
|
||||
@Patch("update-delete/{abilityId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() abilityId: string,
|
||||
) {
|
||||
const record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||
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 ProfileAbilityHistory();
|
||||
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.profileAbilityId = abilityId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.profileAbilityRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.profileAbilityHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{abilityId}")
|
||||
public async deleteProfileAbility(@Path() abilityId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||
|
|
|
|||
|
|
@ -173,6 +173,45 @@ export class ProfileAbilityEmployeeTempController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลความสามารถพิเศษ
|
||||
* @summary API ลบข้อมูลความสามารถพิเศษ
|
||||
* @param abilityId คีย์ความสามารถพิเศษ
|
||||
*/
|
||||
@Patch("update-delete/{abilityId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() abilityId: string,
|
||||
) {
|
||||
const record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileAbilityHistory();
|
||||
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.profileAbilityId = abilityId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.profileAbilityRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.profileAbilityHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{abilityId}")
|
||||
public async deleteProfileAbility(@Path() abilityId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
|
||||
|
|
|
|||
|
|
@ -186,6 +186,45 @@ export class ProfileAssessmentsController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลผลการประเมินการปฏิบัติราชการ
|
||||
* @summary API ลบข้อมูลผลการประเมินการปฏิบัติราชการ
|
||||
* @param assessmentId คีย์ผลการประเมินการปฏิบัติราชการ
|
||||
*/
|
||||
@Patch("update-delete/{assessmentId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() assessmentId: string,
|
||||
) {
|
||||
const record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileAssessmentHistory();
|
||||
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.profileAssessmentId = assessmentId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.profileAssessmentsRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.profileAssessmentsHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{assessmentId}")
|
||||
public async deleteProfileAssessment(
|
||||
@Path() assessmentId: string,
|
||||
|
|
|
|||
|
|
@ -193,6 +193,45 @@ export class ProfileAssessmentsEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลผลการประเมินการปฏิบัติราชการ
|
||||
* @summary API ลบข้อมูลผลการประเมินการปฏิบัติราชการ
|
||||
* @param assessmentId คีย์ผลการประเมินการปฏิบัติราชการ
|
||||
*/
|
||||
@Patch("update-delete/{assessmentId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() assessmentId: string,
|
||||
) {
|
||||
const record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
|
||||
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 ProfileAssessmentHistory();
|
||||
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.profileAssessmentId = assessmentId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.profileAssessmentsRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.profileAssessmentsHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{assessmentId}")
|
||||
public async deleteProfileAssessment(
|
||||
@Path() assessmentId: string,
|
||||
|
|
|
|||
|
|
@ -181,6 +181,45 @@ export class ProfileAssessmentsEmployeeTempController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลผลการประเมินการปฏิบัติราชการ
|
||||
* @summary API ลบข้อมูลผลการประเมินการปฏิบัติราชการ
|
||||
* @param assessmentId คีย์ผลการประเมินการปฏิบัติราชการ
|
||||
*/
|
||||
@Patch("update-delete/{assessmentId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() assessmentId: string,
|
||||
) {
|
||||
const record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileAssessmentHistory();
|
||||
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.profileAssessmentId = assessmentId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.profileAssessmentsRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.profileAssessmentsHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{assessmentId}")
|
||||
public async deleteProfileAssessment(
|
||||
@Path() assessmentId: string,
|
||||
|
|
|
|||
|
|
@ -175,6 +175,45 @@ export class ProfileAssistanceController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลช่วยราชการ
|
||||
* @summary API ลบข้อมูลช่วยราชการ
|
||||
* @param assistanceId คีย์ช่วยราชการ
|
||||
*/
|
||||
@Patch("update-delete/{assistanceId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() assistanceId: string,
|
||||
) {
|
||||
const record = await this.profileAssistanceRepo.findOneBy({ id: assistanceId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileAssistanceHistory();
|
||||
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.profileAssistanceId = assistanceId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.profileAssistanceRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.profileAssistanceHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{assistanceId}")
|
||||
public async deleteProfileAssistance(
|
||||
@Path() assistanceId: string,
|
||||
|
|
|
|||
|
|
@ -183,6 +183,46 @@ export class ProfileAssistanceEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลช่วยราชการ
|
||||
* @summary API ลบข้อมูลช่วยราชการ
|
||||
* @param assistanceId คีย์ช่วยราชการ
|
||||
*/
|
||||
@Patch("update-delete/{assistanceId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() assistanceId: string,
|
||||
) {
|
||||
const record = await this.profileAssistanceRepo.findOneBy({ id: assistanceId });
|
||||
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 ProfileAssistanceHistory();
|
||||
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.profileAssistanceId = assistanceId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.profileAssistanceRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.profileAssistanceHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{assistanceId}")
|
||||
public async deleteProfileAssistance(
|
||||
@Path() assistanceId: string,
|
||||
|
|
|
|||
|
|
@ -173,6 +173,45 @@ export class ProfileAssistanceEmployeeTempController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลช่วยราชการ
|
||||
* @summary API ลบข้อมูลช่วยราชการ
|
||||
* @param assistanceId คีย์ช่วยราชการ
|
||||
*/
|
||||
@Patch("update-delete/{assistanceId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() assistanceId: string,
|
||||
) {
|
||||
const record = await this.profileAssistanceRepo.findOneBy({ id: assistanceId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileAssistanceHistory();
|
||||
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.profileAssistanceId = assistanceId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.profileAssistanceRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.profileAssistanceHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{assistanceId}")
|
||||
public async deleteProfileAssistance(
|
||||
@Path() assistanceId: string,
|
||||
|
|
|
|||
|
|
@ -166,6 +166,45 @@ export class ProfileCertificateController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลใบอนุญาตประกอบวิชาชีพ
|
||||
* @summary API ลบข้อมูลใบอนุญาตประกอบวิชาชีพ
|
||||
* @param certificateId คีย์ใบอนุญาตประกอบวิชาชีพ
|
||||
*/
|
||||
@Patch("update-delete/{certificateId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() certificateId: string,
|
||||
) {
|
||||
const record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileCertificateHistory();
|
||||
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.profileCertificateId = certificateId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.certificateRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.certificateHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{certificateId}")
|
||||
public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||
|
|
|
|||
|
|
@ -174,6 +174,45 @@ export class ProfileCertificateEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลใบอนุญาตประกอบวิชาชีพ
|
||||
* @summary API ลบข้อมูลใบอนุญาตประกอบวิชาชีพ
|
||||
* @param certificateId คีย์ใบอนุญาตประกอบวิชาชีพ
|
||||
*/
|
||||
@Patch("update-delete/{certificateId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() certificateId: string,
|
||||
) {
|
||||
const record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||
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 ProfileCertificateHistory();
|
||||
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.profileCertificateId = certificateId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.certificateRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.certificateHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{certificateId}")
|
||||
public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||
|
|
|
|||
|
|
@ -162,6 +162,45 @@ export class ProfileCertificateEmployeeTempController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลใบอนุญาตประกอบวิชาชีพ
|
||||
* @summary API ลบข้อมูลใบอนุญาตประกอบวิชาชีพ
|
||||
* @param certificateId คีย์ใบอนุญาตประกอบวิชาชีพ
|
||||
*/
|
||||
@Patch("update-delete/{certificateId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() certificateId: string,
|
||||
) {
|
||||
const record = await this.certificateRepo.findOneBy({ id: certificateId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileCertificateHistory();
|
||||
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.profileCertificateId = certificateId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.certificateRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.certificateHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{certificateId}")
|
||||
public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
|
|
|
|||
|
|
@ -191,6 +191,45 @@ export class ProfileChangeNameController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลประวัติการเปลี่ยนชื่อ - นามสกุล
|
||||
* @summary API ลบข้อมูลประวัติการเปลี่ยนชื่อ - นามสกุล
|
||||
* @param trainingId คีย์ประวัติการเปลี่ยนชื่อ - นามสกุล
|
||||
*/
|
||||
@Patch("update-delete/{changeNameId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() changeNameId: string,
|
||||
) {
|
||||
const record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileChangeNameHistory();
|
||||
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.profileChangeNameId = changeNameId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.changeNameRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.changeNameHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{changeNameId}")
|
||||
public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||
|
|
|
|||
|
|
@ -189,6 +189,45 @@ export class ProfileChangeNameEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลประวัติการเปลี่ยนชื่อ - นามสกุล
|
||||
* @summary API ลบข้อมูลประวัติการเปลี่ยนชื่อ - นามสกุล
|
||||
* @param trainingId คีย์ประวัติการเปลี่ยนชื่อ - นามสกุล
|
||||
*/
|
||||
@Patch("update-delete/{changeNameId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() changeNameId: string,
|
||||
) {
|
||||
const record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||
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 ProfileChangeNameHistory();
|
||||
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.profileChangeNameId = changeNameId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.changeNameRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.changeNameHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{changeNameId}")
|
||||
public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||
|
|
|
|||
|
|
@ -181,6 +181,45 @@ export class ProfileChangeNameEmployeeTempController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลประวัติการเปลี่ยนชื่อ - นามสกุล
|
||||
* @summary API ลบข้อมูลประวัติการเปลี่ยนชื่อ - นามสกุล
|
||||
* @param trainingId คีย์ประวัติการเปลี่ยนชื่อ - นามสกุล
|
||||
*/
|
||||
@Patch("update-delete/{changeNameId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() changeNameId: string,
|
||||
) {
|
||||
const record = await this.changeNameRepository.findOneBy({ id: changeNameId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileChangeNameHistory();
|
||||
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.profileChangeNameId = changeNameId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.changeNameRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.changeNameHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{changeNameId}")
|
||||
public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
|
|
|
|||
|
|
@ -143,6 +143,45 @@ export class ProfileChildrenController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลบุตร
|
||||
* @summary API ลบข้อมูลบุตร
|
||||
* @param trainingId คีย์บุตร
|
||||
*/
|
||||
@Patch("update-delete/{childrenId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() childrenId: string,
|
||||
) {
|
||||
const record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileChildrenHistory();
|
||||
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.profileChildrenId = childrenId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.childrenRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.childrenHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{childrenId}")
|
||||
public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||
|
|
|
|||
|
|
@ -156,6 +156,45 @@ export class ProfileChildrenEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลบุตร
|
||||
* @summary API ลบข้อมูลบุตร
|
||||
* @param trainingId คีย์บุตร
|
||||
*/
|
||||
@Patch("update-delete/{childrenId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() childrenId: string,
|
||||
) {
|
||||
const record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||
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 ProfileChildrenHistory();
|
||||
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.profileChildrenId = childrenId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.childrenRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.childrenHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{childrenId}")
|
||||
public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||
|
|
|
|||
|
|
@ -143,6 +143,45 @@ export class ProfileChildrenEmployeeTempController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลบุตร
|
||||
* @summary API ลบข้อมูลบุตร
|
||||
* @param trainingId คีย์บุตร
|
||||
*/
|
||||
@Patch("update-delete/{childrenId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() childrenId: string,
|
||||
) {
|
||||
const record = await this.childrenRepository.findOneBy({ id: childrenId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileChildrenHistory();
|
||||
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.profileChildrenId = childrenId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.childrenRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.childrenHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{childrenId}")
|
||||
public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
|
|
|
|||
|
|
@ -175,6 +175,45 @@ export class ProfileDisciplineController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลวินัย
|
||||
* @summary API ลบข้อมูลวินัย
|
||||
* @param disciplineId คีย์วินัย
|
||||
*/
|
||||
@Patch("update-delete/{disciplineId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() disciplineId: string,
|
||||
) {
|
||||
const record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileDisciplineHistory();
|
||||
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.profileDisciplineId = disciplineId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.disciplineRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.disciplineHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{disciplineId}")
|
||||
public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
||||
|
|
|
|||
|
|
@ -179,6 +179,45 @@ export class ProfileDisciplineEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลวินัย
|
||||
* @summary API ลบข้อมูลวินัย
|
||||
* @param disciplineId คีย์วินัย
|
||||
*/
|
||||
@Patch("update-delete/{disciplineId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() disciplineId: string,
|
||||
) {
|
||||
const record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
||||
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 ProfileDisciplineHistory();
|
||||
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.profileDisciplineId = disciplineId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.disciplineRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.disciplineHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{disciplineId}")
|
||||
public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
||||
|
|
|
|||
|
|
@ -169,6 +169,45 @@ export class ProfileDisciplineEmployeeTempController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลวินัย
|
||||
* @summary API ลบข้อมูลวินัย
|
||||
* @param disciplineId คีย์วินัย
|
||||
*/
|
||||
@Patch("update-delete/{disciplineId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() disciplineId: string,
|
||||
) {
|
||||
const record = await this.disciplineRepository.findOneBy({ id: disciplineId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileDisciplineHistory();
|
||||
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.profileDisciplineId = disciplineId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.disciplineRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.disciplineHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{disciplineId}")
|
||||
public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
|
|
|
|||
|
|
@ -150,6 +150,45 @@ export class ProfileDutyController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลปฏิบัติราชการพิเศษ
|
||||
* @summary API ลบข้อมูลปฏิบัติราชการพิเศษ
|
||||
* @param dutyId คีย์ปฏิบัติราชการพิเศษ
|
||||
*/
|
||||
@Patch("update-delete/{dutyId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() dutyId: string,
|
||||
) {
|
||||
const record = await this.dutyRepository.findOneBy({ id: dutyId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileDutyHistory();
|
||||
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.profileDutyId = dutyId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.dutyRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.dutyHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{dutyId}")
|
||||
public async deleteDuty(@Path() dutyId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.dutyRepository.findOneBy({ id: dutyId });
|
||||
|
|
|
|||
|
|
@ -159,6 +159,45 @@ export class ProfileDutyEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลปฏิบัติราชการพิเศษ
|
||||
* @summary API ลบข้อมูลปฏิบัติราชการพิเศษ
|
||||
* @param dutyId คีย์ปฏิบัติราชการพิเศษ
|
||||
*/
|
||||
@Patch("update-delete/{dutyId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() dutyId: string,
|
||||
) {
|
||||
const record = await this.dutyRepository.findOneBy({ id: dutyId });
|
||||
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 ProfileDutyHistory();
|
||||
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.profileDutyId = dutyId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.dutyRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.dutyHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{dutyId}")
|
||||
public async deleteDuty(@Path() dutyId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.dutyRepository.findOneBy({ id: dutyId });
|
||||
|
|
|
|||
|
|
@ -148,6 +148,45 @@ export class ProfileDutyEmployeeTempController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลปฏิบัติราชการพิเศษ
|
||||
* @summary API ลบข้อมูลปฏิบัติราชการพิเศษ
|
||||
* @param dutyId คีย์ปฏิบัติราชการพิเศษ
|
||||
*/
|
||||
@Patch("update-delete/{dutyId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() dutyId: string,
|
||||
) {
|
||||
const record = await this.dutyRepository.findOneBy({ id: dutyId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileDutyHistory();
|
||||
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.profileDutyId = dutyId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.dutyRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.dutyHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{dutyId}")
|
||||
public async deleteDuty(@Path() dutyId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
|
|
|
|||
|
|
@ -208,6 +208,45 @@ export class ProfileEducationsController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลประวัติการศึกษา
|
||||
* @summary API ลบข้อมูลประวัติการศึกษา/ดูงาน
|
||||
* @param educationId คีย์ประวัติการศึกษา
|
||||
*/
|
||||
@Patch("update-delete/{educationId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() educationId: string,
|
||||
) {
|
||||
const record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileEducationHistory();
|
||||
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.profileEducationId = educationId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.profileEducationRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.profileEducationHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{educationId}")
|
||||
public async deleteProfileEducation(
|
||||
@Path() educationId: string,
|
||||
|
|
|
|||
|
|
@ -220,6 +220,45 @@ export class ProfileEducationsEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลประวัติการศึกษา
|
||||
* @summary API ลบข้อมูลประวัติการศึกษา/ดูงาน
|
||||
* @param educationId คีย์ประวัติการศึกษา
|
||||
*/
|
||||
@Patch("update-delete/{educationId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() educationId: string,
|
||||
) {
|
||||
const record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
||||
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 ProfileEducationHistory();
|
||||
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.profileEducationId = educationId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.profileEducationRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.profileEducationHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{educationId}")
|
||||
public async deleteProfileEducation(
|
||||
@Path() educationId: string,
|
||||
|
|
|
|||
|
|
@ -210,6 +210,45 @@ export class ProfileEducationsEmployeeTempController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลประวัติการศึกษา
|
||||
* @summary API ลบข้อมูลประวัติการศึกษา/ดูงาน
|
||||
* @param educationId คีย์ประวัติการศึกษา
|
||||
*/
|
||||
@Patch("update-delete/{educationId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() educationId: string,
|
||||
) {
|
||||
const record = await this.profileEducationRepo.findOneBy({ id: educationId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileEducationHistory();
|
||||
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.profileEducationId = educationId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.profileEducationRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.profileEducationHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{educationId}")
|
||||
public async deleteProfileEducation(
|
||||
@Path() educationId: string,
|
||||
|
|
|
|||
|
|
@ -176,6 +176,45 @@ export class ProfileHonorController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลประกาศเกียรติคุณ
|
||||
* @summary API ลบข้อมูลประกาศเกียรติคุณ
|
||||
* @param honorId คีย์ประกาศเกียรติคุณ
|
||||
*/
|
||||
@Patch("update-delete/{honorId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() honorId: string,
|
||||
) {
|
||||
const record = await this.honorRepo.findOneBy({ id: honorId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileHonorHistory();
|
||||
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.profileHonorId = honorId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.honorRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.honorHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{honorId}")
|
||||
public async deleteTraning(@Path() honorId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.honorRepo.findOneBy({ id: honorId });
|
||||
|
|
|
|||
|
|
@ -188,6 +188,45 @@ export class ProfileHonorEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลประกาศเกียรติคุณ
|
||||
* @summary API ลบข้อมูลประกาศเกียรติคุณ
|
||||
* @param honorId คีย์ประกาศเกียรติคุณ
|
||||
*/
|
||||
@Patch("update-delete/{honorId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() honorId: string,
|
||||
) {
|
||||
const record = await this.honorRepo.findOneBy({ id: honorId });
|
||||
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 ProfileHonorHistory();
|
||||
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.profileHonorId = honorId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.honorRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.honorHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{honorId}")
|
||||
public async deleteTraning(@Path() honorId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.honorRepo.findOneBy({ id: honorId });
|
||||
|
|
|
|||
|
|
@ -176,6 +176,45 @@ export class ProfileHonorEmployeeTempController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลประกาศเกียรติคุณ
|
||||
* @summary API ลบข้อมูลประกาศเกียรติคุณ
|
||||
* @param honorId คีย์ประกาศเกียรติคุณ
|
||||
*/
|
||||
@Patch("update-delete/{honorId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() honorId: string,
|
||||
) {
|
||||
const record = await this.honorRepo.findOneBy({ id: honorId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileHonorHistory();
|
||||
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.profileHonorId = honorId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.honorRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.honorHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{honorId}")
|
||||
public async deleteTraning(@Path() honorId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
|
|
|
|||
|
|
@ -199,6 +199,45 @@ export class ProfileInsigniaController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลเครื่องราชอิสริยาภรณ์
|
||||
* @summary API ลบข้อมูลเครื่องราชอิสริยาภรณ์
|
||||
* @param insigniaId คีย์เครื่องราชอิสริยาภรณ์
|
||||
*/
|
||||
@Patch("update-delete/{insigniaId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() insigniaId: string,
|
||||
) {
|
||||
const record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileInsigniaHistory();
|
||||
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.profileInsigniaId = insigniaId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.insigniaRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.insigniaHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{insigniaId}")
|
||||
public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
||||
|
|
|
|||
|
|
@ -207,6 +207,45 @@ export class ProfileInsigniaEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลเครื่องราชอิสริยาภรณ์
|
||||
* @summary API ลบข้อมูลเครื่องราชอิสริยาภรณ์
|
||||
* @param insigniaId คีย์เครื่องราชอิสริยาภรณ์
|
||||
*/
|
||||
@Patch("update-delete/{insigniaId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() insigniaId: string,
|
||||
) {
|
||||
const record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
||||
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 ProfileInsigniaHistory();
|
||||
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.profileInsigniaId = insigniaId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.insigniaRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.insigniaHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{insigniaId}")
|
||||
public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
||||
|
|
|
|||
|
|
@ -196,6 +196,45 @@ export class ProfileInsigniaEmployeeTempController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลเครื่องราชอิสริยาภรณ์
|
||||
* @summary API ลบข้อมูลเครื่องราชอิสริยาภรณ์
|
||||
* @param insigniaId คีย์เครื่องราชอิสริยาภรณ์
|
||||
*/
|
||||
@Patch("update-delete/{insigniaId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() insigniaId: string,
|
||||
) {
|
||||
const record = await this.insigniaRepo.findOneBy({ id: insigniaId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileInsigniaHistory();
|
||||
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.profileInsigniaId = insigniaId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.insigniaRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.insigniaHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{insigniaId}")
|
||||
public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
|
|
|
|||
|
|
@ -265,6 +265,45 @@ export class ProfileLeaveController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลการลา
|
||||
* @summary API ลบข้อมูลการลา
|
||||
* @param leaveId คีย์การลา
|
||||
*/
|
||||
@Patch("update-delete/{leaveId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() leaveId: string,
|
||||
) {
|
||||
const record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileLeaveHistory();
|
||||
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.profileLeaveId = leaveId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.leaveRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.leaveHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Patch("cancel/{leaveId}")
|
||||
public async updateCancel(
|
||||
@Request() req: RequestWithUser,
|
||||
|
|
|
|||
|
|
@ -192,6 +192,45 @@ export class ProfileLeaveEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลการลา
|
||||
* @summary API ลบข้อมูลการลา
|
||||
* @param leaveId คีย์การลา
|
||||
*/
|
||||
@Patch("update-delete/{leaveId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() leaveId: string,
|
||||
) {
|
||||
const record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||
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 ProfileLeaveHistory();
|
||||
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.profileLeaveId = leaveId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.leaveRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.leaveHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{leaveId}")
|
||||
public async deleteLeave(@Path() leaveId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||
|
|
|
|||
|
|
@ -179,6 +179,45 @@ export class ProfileLeaveEmployeeTempController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลการลา
|
||||
* @summary API ลบข้อมูลการลา
|
||||
* @param leaveId คีย์การลา
|
||||
*/
|
||||
@Patch("update-delete/{leaveId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() leaveId: string,
|
||||
) {
|
||||
const record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileLeaveHistory();
|
||||
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.profileLeaveId = leaveId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.leaveRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.leaveHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{leaveId}")
|
||||
public async deleteLeave(@Path() leaveId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
|
|
|
|||
|
|
@ -140,6 +140,45 @@ export class ProfileNopaidController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลบันทึกวันที่ไม่ได้รับเงินเงินเดือนฯ
|
||||
* @summary API ลบข้อมูลบันทึกวันที่ไม่ได้รับเงินเงินเดือนฯ
|
||||
* @param nopaidId คีย์บันทึกวันที่ไม่ได้รับเงินเงินเดือนฯ
|
||||
*/
|
||||
@Patch("update-delete/{nopaidId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() nopaidId: string,
|
||||
) {
|
||||
const record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileNopaidHistory();
|
||||
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.profileNopaidId = nopaidId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.nopaidRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.nopaidHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{nopaidId}")
|
||||
public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||
|
|
|
|||
|
|
@ -147,6 +147,45 @@ export class ProfileNopaidEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลบันทึกวันที่ไม่ได้รับเงินเงินเดือนฯ
|
||||
* @summary API ลบข้อมูลบันทึกวันที่ไม่ได้รับเงินเงินเดือนฯ
|
||||
* @param nopaidId คีย์บันทึกวันที่ไม่ได้รับเงินเงินเดือนฯ
|
||||
*/
|
||||
@Patch("update-delete/{nopaidId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() nopaidId: string,
|
||||
) {
|
||||
const record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||
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 ProfileNopaidHistory();
|
||||
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.profileNopaidId = nopaidId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.nopaidRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.nopaidHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{nopaidId}")
|
||||
public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||
|
|
|
|||
|
|
@ -144,6 +144,45 @@ export class ProfileNopaidEmployeeTempController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลบันทึกวันที่ไม่ได้รับเงินเงินเดือนฯ
|
||||
* @summary API ลบข้อมูลบันทึกวันที่ไม่ได้รับเงินเงินเดือนฯ
|
||||
* @param nopaidId คีย์บันทึกวันที่ไม่ได้รับเงินเงินเดือนฯ
|
||||
*/
|
||||
@Patch("update-delete/{nopaidId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() nopaidId: string,
|
||||
) {
|
||||
const record = await this.nopaidRepository.findOneBy({ id: nopaidId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileNopaidHistory();
|
||||
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.profileNopaidId = nopaidId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.nopaidRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.nopaidHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{nopaidId}")
|
||||
public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
|
|
|
|||
|
|
@ -149,6 +149,45 @@ export class ProfileOtherController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลข้อมูลอื่นๆ
|
||||
* @summary API ลบข้อมูลข้อมูลอื่นๆ
|
||||
* @param otherId คีย์ข้อมูลอื่นๆ
|
||||
*/
|
||||
@Patch("update-delete/{otherId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() otherId: string,
|
||||
) {
|
||||
const record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileOtherHistory();
|
||||
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.profileOtherId = otherId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.otherRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.otherHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{otherId}")
|
||||
public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
|
|
|
|||
|
|
@ -160,6 +160,45 @@ export class ProfileOtherEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลข้อมูลอื่นๆ
|
||||
* @summary API ลบข้อมูลข้อมูลอื่นๆ
|
||||
* @param otherId คีย์ข้อมูลอื่นๆ
|
||||
*/
|
||||
@Patch("update-delete/{otherId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() otherId: string,
|
||||
) {
|
||||
const record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
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 ProfileOtherHistory();
|
||||
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.profileOtherId = otherId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.otherRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.otherHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{otherId}")
|
||||
public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
|
|
|
|||
|
|
@ -148,6 +148,45 @@ export class ProfileOtherEmployeeTempController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลข้อมูลอื่นๆ
|
||||
* @summary API ลบข้อมูลข้อมูลอื่นๆ
|
||||
* @param otherId คีย์ข้อมูลอื่นๆ
|
||||
*/
|
||||
@Patch("update-delete/{otherId}")
|
||||
public async updateIsDeleted(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() otherId: string,
|
||||
) {
|
||||
const record = await this.otherRepository.findOneBy({ id: otherId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileOtherHistory();
|
||||
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.profileOtherId = otherId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.otherRepository.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.otherHistoryRepository.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{otherId}")
|
||||
public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
|
|
|
|||
|
|
@ -168,6 +168,45 @@ export class ProfileTrainingEmployeeController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลการฝึกอบรม/ดูงาน
|
||||
* @summary API ลบข้อมูลการฝึกอบรม/ดูงาน
|
||||
* @param trainingId คีย์การฝึกอบรม/ดูงาน
|
||||
*/
|
||||
@Patch("update-delete/{trainingId}")
|
||||
public async updateIsDeletedTraining(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() trainingId: string,
|
||||
) {
|
||||
const record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||
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 ProfileTrainingHistory();
|
||||
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.profileTrainingId = trainingId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.trainingRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.trainingHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{trainingId}")
|
||||
public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||
|
|
|
|||
|
|
@ -156,6 +156,45 @@ export class ProfileTrainingEmployeeTempController extends Controller {
|
|||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
* API ลบข้อมูลการฝึกอบรม/ดูงาน
|
||||
* @summary API ลบข้อมูลการฝึกอบรม/ดูงาน
|
||||
* @param trainingId คีย์การฝึกอบรม/ดูงาน
|
||||
*/
|
||||
@Patch("update-delete/{trainingId}")
|
||||
public async updateIsDeletedTraining(
|
||||
@Request() req: RequestWithUser,
|
||||
@Path() trainingId: string,
|
||||
) {
|
||||
const record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
if (record.isDeleted === true) {
|
||||
return new HttpSuccess();
|
||||
}
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileTrainingHistory();
|
||||
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.profileTrainingId = trainingId;
|
||||
history.createdUserId = req.user.sub;
|
||||
history.createdFullName = req.user.name;
|
||||
history.createdAt = now;
|
||||
|
||||
await Promise.all([
|
||||
this.trainingRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.trainingHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
@Delete("{trainingId}")
|
||||
public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_TEMP");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue