Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
# Conflicts: # src/controllers/PositionController.ts
This commit is contained in:
commit
7f56d35876
1 changed files with 39 additions and 13 deletions
|
|
@ -662,6 +662,8 @@ export class PositionController extends Controller {
|
|||
try {
|
||||
let typeCondition: any = {};
|
||||
let checkChildConditions: any = {};
|
||||
let keywordAsInt: any;
|
||||
|
||||
if (body.type === 0) {
|
||||
typeCondition = {
|
||||
orgRootId: body.id,
|
||||
|
|
@ -738,7 +740,6 @@ export class PositionController extends Controller {
|
|||
select: ["posMasterId"],
|
||||
});
|
||||
masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId));
|
||||
let keywordAsInt: any;
|
||||
keywordAsInt = body.keyword == null ? null : parseInt(body.keyword, 10);
|
||||
if (isNaN(keywordAsInt)) {
|
||||
keywordAsInt = "P@ssw0rd!z";
|
||||
|
|
@ -1795,18 +1796,16 @@ export class PositionController extends Controller {
|
|||
*/
|
||||
@Post("dna")
|
||||
async dna(@Body() requestBody: { draftPositionId: string; publishPositionId: string }) {
|
||||
const dataDraft = await this.posMasterRepository.findOne({
|
||||
where: { id: requestBody.draftPositionId },
|
||||
const findDraft = await this.orgRevisionRepository.findOne({
|
||||
where: {
|
||||
orgRevisionIsDraft: true,
|
||||
},
|
||||
});
|
||||
if (!dataDraft) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลไอดีนี้(draftPositionId) : " + requestBody.draftPositionId,
|
||||
);
|
||||
}
|
||||
|
||||
const dataPublish = await this.posMasterRepository.findOne({
|
||||
where: { id: requestBody.publishPositionId },
|
||||
where: {
|
||||
id: requestBody.publishPositionId,
|
||||
},
|
||||
});
|
||||
if (!dataPublish) {
|
||||
throw new HttpError(
|
||||
|
|
@ -1815,13 +1814,40 @@ export class PositionController extends Controller {
|
|||
);
|
||||
}
|
||||
|
||||
const dataDraft = await this.posMasterRepository.findOne({
|
||||
where: {
|
||||
id: requestBody.draftPositionId,
|
||||
},
|
||||
});
|
||||
if (!dataDraft) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลไอดีนี้(draftPositionId) : " + requestBody.draftPositionId,
|
||||
);
|
||||
}
|
||||
|
||||
const dataPosMaster = await this.posMasterRepository.find({
|
||||
where: {
|
||||
orgRevisionId: findDraft?.id,
|
||||
ancestorDNA: dataPublish.ancestorDNA,
|
||||
},
|
||||
});
|
||||
if (!dataPosMaster) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลไอดีนี้ใน posMaster (publishPositionId) : " + requestBody.publishPositionId,
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
await this.posMasterRepository.update(
|
||||
{ orgRevisionId: findDraft?.id, ancestorDNA: dataPublish.ancestorDNA },
|
||||
{ ancestorDNA: "" },
|
||||
);
|
||||
|
||||
dataDraft.ancestorDNA = dataPublish.ancestorDNA;
|
||||
await this.posMasterRepository.save(dataDraft);
|
||||
|
||||
dataPublish.ancestorDNA = "";
|
||||
await this.posMasterRepository.save(dataPublish);
|
||||
|
||||
return new HttpSuccess();
|
||||
} catch (error) {
|
||||
return error;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue