Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
This commit is contained in:
commit
22b80868d4
1 changed files with 26 additions and 2 deletions
|
|
@ -24,7 +24,7 @@ import { PosType } from "../entities/PosType";
|
|||
import { PosLevel } from "../entities/PosLevel";
|
||||
import { CreatePosDict, PosDict } from "../entities/PosDict";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { In, Like } from "typeorm";
|
||||
import { In, IsNull, Like } from "typeorm";
|
||||
import { CreatePosMaster, PosMaster } from "../entities/PosMaster";
|
||||
import { OrgRevision } from "../entities/OrgRevision";
|
||||
import { OrgRoot } from "../entities/OrgRoot";
|
||||
|
|
@ -731,23 +731,44 @@ export class PositionController extends Controller {
|
|||
) {
|
||||
try {
|
||||
let typeCondition: any = {};
|
||||
let checkChildConditions: any = {};
|
||||
|
||||
if (body.type === 0) {
|
||||
typeCondition = {
|
||||
orgRootId: body.id,
|
||||
};
|
||||
if (!body.isAll) {
|
||||
checkChildConditions = {
|
||||
orgChild1Id: IsNull(),
|
||||
};
|
||||
}
|
||||
} else if (body.type === 1) {
|
||||
typeCondition = {
|
||||
orgChild1Id: body.id,
|
||||
};
|
||||
if (!body.isAll) {
|
||||
checkChildConditions = {
|
||||
orgChild2Id: IsNull(),
|
||||
};
|
||||
}
|
||||
} else if (body.type === 2) {
|
||||
typeCondition = {
|
||||
orgChild2Id: body.id,
|
||||
};
|
||||
if (!body.isAll) {
|
||||
checkChildConditions = {
|
||||
orgChild3Id: IsNull(),
|
||||
};
|
||||
}
|
||||
} else if (body.type === 3) {
|
||||
typeCondition = {
|
||||
orgChild3Id: body.id,
|
||||
};
|
||||
if (!body.isAll) {
|
||||
checkChildConditions = {
|
||||
orgChild4Id: IsNull(),
|
||||
};
|
||||
}
|
||||
} else if (body.type === 4) {
|
||||
typeCondition = {
|
||||
orgChild4Id: body.id,
|
||||
|
|
@ -755,7 +776,10 @@ export class PositionController extends Controller {
|
|||
}
|
||||
|
||||
const posMaster = await this.posMasterRepository.find({
|
||||
where: typeCondition,
|
||||
where: {
|
||||
...typeCondition,
|
||||
...checkChildConditions,
|
||||
},
|
||||
});
|
||||
if (!posMaster || posMaster.length === 0) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue