fix del
This commit is contained in:
parent
42fd0084aa
commit
46e7495655
5 changed files with 65 additions and 5 deletions
|
|
@ -28,6 +28,8 @@ import { OrgChild3 } from "../entities/OrgChild3";
|
|||
import { OrgChild4 } from "../entities/OrgChild4";
|
||||
import { PosMaster } from "../entities/PosMaster";
|
||||
import { Position } from "../entities/Position";
|
||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
import { EmployeePosition } from "../entities/EmployeePosition";
|
||||
@Route("api/v1/org/child2")
|
||||
@Tags("OrgChild2")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -45,6 +47,8 @@ export class OrgChild2Controller extends Controller {
|
|||
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
||||
private positionRepository = AppDataSource.getRepository(Position);
|
||||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
private empPosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
|
||||
private empPositionRepository = AppDataSource.getRepository(EmployeePosition);
|
||||
|
||||
/**
|
||||
* API รายละเอียดโครงสร้างระดับ 2
|
||||
|
|
@ -270,7 +274,15 @@ export class OrgChild2Controller extends Controller {
|
|||
const positions = await this.positionRepository.find({
|
||||
where: [{ posMasterId: In(posMasters.map((x) => x.id)) }],
|
||||
});
|
||||
|
||||
const empPosMasters = await this.empPosMasterRepository.find({
|
||||
where: { orgRootId: id },
|
||||
});
|
||||
const empPositions = await this.empPositionRepository.find({
|
||||
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.child4Repository.delete({ orgChild2Id: id });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue