fix del
This commit is contained in:
parent
42fd0084aa
commit
46e7495655
5 changed files with 65 additions and 5 deletions
|
|
@ -26,6 +26,8 @@ import { In, Not } from "typeorm";
|
|||
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/child1")
|
||||
@Tags("OrgChild1")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -43,6 +45,8 @@ export class OrgChild1Controller {
|
|||
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 รายละเอียดโครงสร้างระดับ 1
|
||||
|
|
@ -259,7 +263,15 @@ export class OrgChild1Controller {
|
|||
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({ orgChild1Id: id });
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ import HttpError from "../interfaces/http-error";
|
|||
import { In } from "typeorm";
|
||||
import { PosMaster } from "../entities/PosMaster";
|
||||
import { Position } from "../entities/Position";
|
||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
import { EmployeePosition } from "../entities/EmployeePosition";
|
||||
@Route("api/v1/org/child3")
|
||||
@Tags("OrgChild3")
|
||||
@Security("bearerAuth")
|
||||
|
|
@ -41,6 +43,8 @@ export class OrgChild3Controller {
|
|||
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 รายละเอียดโครงสร้างระดับ 3
|
||||
|
|
@ -240,7 +244,15 @@ export class OrgChild3Controller {
|
|||
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({ orgChild3Id: id });
|
||||
|
|
|
|||
|
|
@ -27,6 +27,8 @@ import { OrgChild1 } from "../entities/OrgChild1";
|
|||
import { OrgChild3 } from "../entities/OrgChild3";
|
||||
import { PosMaster } from "../entities/PosMaster";
|
||||
import { Position } from "../entities/Position";
|
||||
import { EmployeePosMaster } from "../entities/EmployeePosMaster";
|
||||
import { EmployeePosition } from "../entities/EmployeePosition";
|
||||
|
||||
@Route("api/v1/org/child4")
|
||||
@Tags("OrgChild4")
|
||||
|
|
@ -43,6 +45,8 @@ export class OrgChild4Controller 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 รายละเอียดโครงสร้างระดับ 4
|
||||
|
|
@ -265,7 +269,15 @@ export class OrgChild4Controller 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(id);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,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/root")
|
||||
@Tags("OrgRoot")
|
||||
|
|
@ -39,6 +41,8 @@ export class OrgRootController extends Controller {
|
|||
private orgRevisionRepository = AppDataSource.getRepository(OrgRevision);
|
||||
private posMasterRepository = AppDataSource.getRepository(PosMaster);
|
||||
private positionRepository = AppDataSource.getRepository(Position);
|
||||
private empPosMasterRepository = AppDataSource.getRepository(EmployeePosMaster);
|
||||
private empPositionRepository = AppDataSource.getRepository(EmployeePosition);
|
||||
|
||||
/**
|
||||
* API รายละเอียดโครงสร้างระดับ Root
|
||||
|
|
@ -250,7 +254,15 @@ export class OrgRootController 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.orgChild4Repository.delete({ orgRootId: id });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue