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 {
|
try {
|
||||||
let typeCondition: any = {};
|
let typeCondition: any = {};
|
||||||
let checkChildConditions: any = {};
|
let checkChildConditions: any = {};
|
||||||
|
let keywordAsInt: any;
|
||||||
|
|
||||||
if (body.type === 0) {
|
if (body.type === 0) {
|
||||||
typeCondition = {
|
typeCondition = {
|
||||||
orgRootId: body.id,
|
orgRootId: body.id,
|
||||||
|
|
@ -738,7 +740,6 @@ export class PositionController extends Controller {
|
||||||
select: ["posMasterId"],
|
select: ["posMasterId"],
|
||||||
});
|
});
|
||||||
masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId));
|
masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId));
|
||||||
let keywordAsInt: any;
|
|
||||||
keywordAsInt = body.keyword == null ? null : parseInt(body.keyword, 10);
|
keywordAsInt = body.keyword == null ? null : parseInt(body.keyword, 10);
|
||||||
if (isNaN(keywordAsInt)) {
|
if (isNaN(keywordAsInt)) {
|
||||||
keywordAsInt = "P@ssw0rd!z";
|
keywordAsInt = "P@ssw0rd!z";
|
||||||
|
|
@ -1795,18 +1796,16 @@ export class PositionController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Post("dna")
|
@Post("dna")
|
||||||
async dna(@Body() requestBody: { draftPositionId: string; publishPositionId: string }) {
|
async dna(@Body() requestBody: { draftPositionId: string; publishPositionId: string }) {
|
||||||
const dataDraft = await this.posMasterRepository.findOne({
|
const findDraft = await this.orgRevisionRepository.findOne({
|
||||||
where: { id: requestBody.draftPositionId },
|
where: {
|
||||||
|
orgRevisionIsDraft: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
if (!dataDraft) {
|
|
||||||
throw new HttpError(
|
|
||||||
HttpStatusCode.NOT_FOUND,
|
|
||||||
"ไม่พบข้อมูลไอดีนี้(draftPositionId) : " + requestBody.draftPositionId,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const dataPublish = await this.posMasterRepository.findOne({
|
const dataPublish = await this.posMasterRepository.findOne({
|
||||||
where: { id: requestBody.publishPositionId },
|
where: {
|
||||||
|
id: requestBody.publishPositionId,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
if (!dataPublish) {
|
if (!dataPublish) {
|
||||||
throw new HttpError(
|
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 {
|
try {
|
||||||
|
await this.posMasterRepository.update(
|
||||||
|
{ orgRevisionId: findDraft?.id, ancestorDNA: dataPublish.ancestorDNA },
|
||||||
|
{ ancestorDNA: "" },
|
||||||
|
);
|
||||||
|
|
||||||
dataDraft.ancestorDNA = dataPublish.ancestorDNA;
|
dataDraft.ancestorDNA = dataPublish.ancestorDNA;
|
||||||
await this.posMasterRepository.save(dataDraft);
|
await this.posMasterRepository.save(dataDraft);
|
||||||
|
|
||||||
dataPublish.ancestorDNA = "";
|
|
||||||
await this.posMasterRepository.save(dataPublish);
|
|
||||||
|
|
||||||
return new HttpSuccess();
|
return new HttpSuccess();
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return error;
|
return error;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue