fix
This commit is contained in:
parent
a7b3d8c974
commit
0f45c75d62
1 changed files with 3 additions and 13 deletions
|
|
@ -26,6 +26,7 @@ import { Profile } from "../entities/Profile";
|
||||||
import { LeaveType } from "../entities/LeaveType";
|
import { LeaveType } from "../entities/LeaveType";
|
||||||
import permission from "../interfaces/permission";
|
import permission from "../interfaces/permission";
|
||||||
import { setLogDataDiff } from "../interfaces/utils";
|
import { setLogDataDiff } from "../interfaces/utils";
|
||||||
|
import { Not } from "typeorm";
|
||||||
@Route("api/v1/org/profile/leave")
|
@Route("api/v1/org/profile/leave")
|
||||||
@Tags("ProfileLeave")
|
@Tags("ProfileLeave")
|
||||||
@Security("bearerAuth")
|
@Security("bearerAuth")
|
||||||
|
|
@ -132,7 +133,7 @@ export class ProfileLeaveController extends Controller {
|
||||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||||
const record = await this.leaveRepo.find({
|
const record = await this.leaveRepo.find({
|
||||||
relations: { leaveType: true },
|
relations: { leaveType: true },
|
||||||
where: { profileId },
|
where: { profileId: profileId, status: Not("cancel") },
|
||||||
order: { createdAt: "ASC" },
|
order: { createdAt: "ASC" },
|
||||||
});
|
});
|
||||||
return new HttpSuccess(record);
|
return new HttpSuccess(record);
|
||||||
|
|
@ -269,26 +270,15 @@ export class ProfileLeaveController extends Controller {
|
||||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการลา");
|
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการลา");
|
||||||
|
|
||||||
const before = structuredClone(record);
|
const before = structuredClone(record);
|
||||||
const history = new ProfileLeaveHistory();
|
|
||||||
|
|
||||||
Object.assign(history, { ...record, id: undefined });
|
record.status = "cancel";
|
||||||
|
|
||||||
record.status = "CANCEL";
|
|
||||||
history.profileLeaveId = leaveId;
|
|
||||||
record.lastUpdateUserId = req.user.sub;
|
record.lastUpdateUserId = req.user.sub;
|
||||||
record.lastUpdateFullName = req.user.name;
|
record.lastUpdateFullName = req.user.name;
|
||||||
record.lastUpdatedAt = new Date();
|
record.lastUpdatedAt = new Date();
|
||||||
history.lastUpdateUserId = req.user.sub;
|
|
||||||
history.lastUpdateFullName = req.user.name;
|
|
||||||
history.createdUserId = req.user.sub;
|
|
||||||
history.createdFullName = req.user.name;
|
|
||||||
history.createdAt = new Date();
|
|
||||||
history.lastUpdatedAt = new Date();
|
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
this.leaveRepo.save(record, { data: req }),
|
this.leaveRepo.save(record, { data: req }),
|
||||||
setLogDataDiff(req, { before, after: record }),
|
setLogDataDiff(req, { before, after: record }),
|
||||||
this.leaveHistoryRepo.save(history, { data: req }),
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue