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 permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import { Not } from "typeorm";
|
||||
@Route("api/v1/org/profile/leave")
|
||||
@Tags("ProfileLeave")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -132,7 +133,7 @@ export class ProfileLeaveController extends Controller {
|
|||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const record = await this.leaveRepo.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileId },
|
||||
where: { profileId: profileId, status: Not("cancel") },
|
||||
order: { createdAt: "ASC" },
|
||||
});
|
||||
return new HttpSuccess(record);
|
||||
|
|
@ -269,26 +270,15 @@ export class ProfileLeaveController extends Controller {
|
|||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลการลา");
|
||||
|
||||
const before = structuredClone(record);
|
||||
const history = new ProfileLeaveHistory();
|
||||
|
||||
Object.assign(history, { ...record, id: undefined });
|
||||
|
||||
record.status = "CANCEL";
|
||||
history.profileLeaveId = leaveId;
|
||||
record.status = "cancel";
|
||||
record.lastUpdateUserId = req.user.sub;
|
||||
record.lastUpdateFullName = req.user.name;
|
||||
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([
|
||||
this.leaveRepo.save(record, { data: req }),
|
||||
setLogDataDiff(req, { before, after: record }),
|
||||
this.leaveHistoryRepo.save(history, { data: req }),
|
||||
]);
|
||||
|
||||
return new HttpSuccess();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue