api soft delete

This commit is contained in:
harid 2026-02-16 10:30:15 +07:00
parent 17f7fc5d84
commit 9382482f06
44 changed files with 1717 additions and 0 deletions

View file

@ -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 });

View file

@ -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 });

View file

@ -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 });

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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 });

View file

@ -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 });

View file

@ -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");

View file

@ -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 });

View file

@ -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 });

View file

@ -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");

View file

@ -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 });

View file

@ -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 });

View file

@ -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");

View file

@ -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 });

View file

@ -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 });

View file

@ -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");

View file

@ -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 });

View file

@ -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 });

View file

@ -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");

View file

@ -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,

View file

@ -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,

View file

@ -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,

View file

@ -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 });

View file

@ -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 });

View file

@ -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");

View file

@ -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 });

View file

@ -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 });

View file

@ -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");

View file

@ -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,

View file

@ -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 });

View file

@ -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");

View file

@ -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 });

View file

@ -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 });

View file

@ -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");

View file

@ -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 });

View file

@ -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 });

View file

@ -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");

View file

@ -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 });

View file

@ -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");