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