ผูก log โครงสร้างขรก
This commit is contained in:
parent
79989664d5
commit
b3ecbf5496
7 changed files with 76 additions and 43 deletions
|
|
@ -31,6 +31,7 @@ import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
|||
import { EmployeePosition } from "../entities/EmployeePosition";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
|
||||
@Route("api/v1/org/child4")
|
||||
@Tags("OrgChild4")
|
||||
|
|
@ -144,6 +145,7 @@ export class OrgChild4Controller extends Controller {
|
|||
},
|
||||
order: { orgChild4Order: "DESC" },
|
||||
});
|
||||
const before = null;
|
||||
const child4 = Object.assign(new OrgChild4(), requestBody) as OrgChild4;
|
||||
child4.orgChild4Name = requestBody.orgChild4Name;
|
||||
child4.createdUserId = request.user.sub;
|
||||
|
|
@ -159,7 +161,8 @@ export class OrgChild4Controller extends Controller {
|
|||
child4.orgChild3Id = String(child3?.id);
|
||||
child4.orgChild4Order =
|
||||
order == null || order.orgChild4Order == null ? 1 : order.orgChild4Order + 1;
|
||||
await this.child4Repository.save(child4);
|
||||
await this.child4Repository.save(child4, { data: request });
|
||||
setLogDataDiff(request, { before, after: child4 });
|
||||
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
@ -227,6 +230,7 @@ export class OrgChild4Controller extends Controller {
|
|||
if (!child4) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
const before = structuredClone(child4);
|
||||
child4.lastUpdateUserId = request.user.sub;
|
||||
child4.lastUpdateFullName = request.user.name;
|
||||
child4.lastUpdatedAt = new Date();
|
||||
|
|
@ -236,7 +240,8 @@ export class OrgChild4Controller extends Controller {
|
|||
child4.orgRevisionId = String(child3IdExits?.orgRevisionId);
|
||||
child4.orgChild3Id = String(child3IdExits?.id);
|
||||
this.child4Repository.merge(child4, requestBody);
|
||||
await this.child4Repository.save(child4);
|
||||
await this.child4Repository.save(child4, { data: request });
|
||||
setLogDataDiff(request, { before, after: child4 });
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
@ -283,10 +288,10 @@ export class OrgChild4Controller extends Controller {
|
|||
where: [{ posMasterId: In(empPosMasters.map((x) => x.id)) }],
|
||||
});
|
||||
|
||||
await this.empPositionRepository.remove(empPositions);
|
||||
await this.empPosMasterRepository.remove(empPosMasters);
|
||||
await this.positionRepository.remove(positions);
|
||||
await this.posMasterRepository.remove(posMasters);
|
||||
await this.empPositionRepository.remove(empPositions, { data: request });
|
||||
await this.empPosMasterRepository.remove(empPosMasters, { data: request });
|
||||
await this.positionRepository.remove(positions, { data: request });
|
||||
await this.posMasterRepository.remove(posMasters, { data: request });
|
||||
await this.child4Repository.delete(id);
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue