fix org_068
This commit is contained in:
parent
019ded1aa3
commit
0926594e33
1 changed files with 36 additions and 12 deletions
|
|
@ -661,6 +661,8 @@ export class PositionController extends Controller {
|
|||
try {
|
||||
let typeCondition: any = {};
|
||||
let checkChildConditions: any = {};
|
||||
let keywordAsInt: any;
|
||||
|
||||
if (body.type === 0) {
|
||||
typeCondition = {
|
||||
orgRootId: body.id,
|
||||
|
|
@ -737,7 +739,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";
|
||||
|
|
@ -1790,28 +1791,51 @@ 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(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลไอดีนี้(publishPositionId) : " + requestBody.publishPositionId);
|
||||
}
|
||||
|
||||
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