ผูก log โครงสร้างขรก
This commit is contained in:
parent
79989664d5
commit
b3ecbf5496
7 changed files with 76 additions and 43 deletions
|
|
@ -32,6 +32,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/child2")
|
||||
@Tags("OrgChild2")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -146,6 +147,7 @@ export class OrgChild2Controller extends Controller {
|
|||
},
|
||||
order: { orgChild2Order: "DESC" },
|
||||
});
|
||||
const before = null;
|
||||
const child2 = Object.assign(new OrgChild2(), requestBody) as OrgChild2;
|
||||
child2.orgChild2Name = requestBody.orgChild2Name;
|
||||
child2.createdUserId = request.user.sub;
|
||||
|
|
@ -159,7 +161,8 @@ export class OrgChild2Controller extends Controller {
|
|||
child2.orgChild1Id = String(child1?.id);
|
||||
child2.orgChild2Order =
|
||||
order == null || order.orgChild2Order == null ? 1 : order.orgChild2Order + 1;
|
||||
await this.child2Repository.save(child2);
|
||||
await this.child2Repository.save(child2, { data: request });
|
||||
setLogDataDiff( request, { before, after: child2 } );
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
@ -226,6 +229,7 @@ export class OrgChild2Controller extends Controller {
|
|||
if (!child2) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found.");
|
||||
}
|
||||
const before = structuredClone(child2);
|
||||
child2.lastUpdateUserId = request.user.sub;
|
||||
child2.lastUpdateFullName = request.user.name;
|
||||
child2.lastUpdatedAt = new Date();
|
||||
|
|
@ -233,7 +237,8 @@ export class OrgChild2Controller extends Controller {
|
|||
child2.orgRevisionId = String(child1IdExits?.orgRevisionId);
|
||||
child2.orgChild1Id = String(child1IdExits?.id);
|
||||
this.child2Repository.merge(child2, requestBody);
|
||||
await this.child2Repository.save(child2);
|
||||
await this.child2Repository.save(child2, { data: request });
|
||||
setLogDataDiff( request, { before, after: child2 } );
|
||||
return new HttpSuccess();
|
||||
}
|
||||
|
||||
|
|
@ -288,10 +293,10 @@ export class OrgChild2Controller 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({ orgChild2Id: id });
|
||||
await this.child3Repository.delete({ orgChild2Id: id });
|
||||
await this.child2Repository.delete({ id });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue