api soft delete
This commit is contained in:
parent
17f7fc5d84
commit
9382482f06
44 changed files with 1717 additions and 0 deletions
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue