ประวัติอัตรากำลัง
This commit is contained in:
parent
c574726522
commit
e90e3a27c6
2 changed files with 279 additions and 189 deletions
|
|
@ -24,7 +24,7 @@ import { PosType } from "../entities/PosType";
|
||||||
import { PosLevel } from "../entities/PosLevel";
|
import { PosLevel } from "../entities/PosLevel";
|
||||||
import { CreatePosDict, PosDict } from "../entities/PosDict";
|
import { CreatePosDict, PosDict } from "../entities/PosDict";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { ILike, In, IsNull, Like, Not } from "typeorm";
|
import { Equal, ILike, In, IsNull, Like, Not } from "typeorm";
|
||||||
import { CreatePosMaster, PosMaster } from "../entities/PosMaster";
|
import { CreatePosMaster, PosMaster } from "../entities/PosMaster";
|
||||||
import { OrgRevision } from "../entities/OrgRevision";
|
import { OrgRevision } from "../entities/OrgRevision";
|
||||||
import { OrgRoot } from "../entities/OrgRoot";
|
import { OrgRoot } from "../entities/OrgRoot";
|
||||||
|
|
@ -546,11 +546,11 @@ export class PositionController extends Controller {
|
||||||
if (!posMaster) {
|
if (!posMaster) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลอัตรากำลัง");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลอัตรากำลัง");
|
||||||
}
|
}
|
||||||
posMaster.orgRootId = "";
|
posMaster.orgRootId = null;
|
||||||
posMaster.orgChild1Id = "";
|
posMaster.orgChild1Id = null;
|
||||||
posMaster.orgChild2Id = "";
|
posMaster.orgChild2Id = null;
|
||||||
posMaster.orgChild3Id = "";
|
posMaster.orgChild3Id = null;
|
||||||
posMaster.orgChild4Id = "";
|
posMaster.orgChild4Id = null;
|
||||||
|
|
||||||
let orgRoot: any = null;
|
let orgRoot: any = null;
|
||||||
if (requestBody.orgRootId != null)
|
if (requestBody.orgRootId != null)
|
||||||
|
|
@ -619,11 +619,6 @@ export class PositionController extends Controller {
|
||||||
posMaster.lastUpdateUserId = request.user.sub;
|
posMaster.lastUpdateUserId = request.user.sub;
|
||||||
posMaster.lastUpdateFullName = request.user.name;
|
posMaster.lastUpdateFullName = request.user.name;
|
||||||
await this.posMasterRepository.save(posMaster);
|
await this.posMasterRepository.save(posMaster);
|
||||||
|
|
||||||
const positions = await this.positionRepository.find({
|
|
||||||
where: [{ posMasterId: posMaster.id }],
|
|
||||||
});
|
|
||||||
await this.positionRepository.remove(positions);
|
|
||||||
await this.positionRepository.delete({ posMasterId: posMaster.id });
|
await this.positionRepository.delete({ posMasterId: posMaster.id });
|
||||||
requestBody.positions.forEach(async (x: any) => {
|
requestBody.positions.forEach(async (x: any) => {
|
||||||
const position = Object.assign(new Position());
|
const position = Object.assign(new Position());
|
||||||
|
|
@ -737,182 +732,145 @@ export class PositionController extends Controller {
|
||||||
try {
|
try {
|
||||||
let typeCondition: any = {};
|
let typeCondition: any = {};
|
||||||
let checkChildConditions: any = {};
|
let checkChildConditions: any = {};
|
||||||
//******** ของตั้ม(เก่า) *********//
|
if (body.type === 0) {
|
||||||
// if (body.type === 0) {
|
typeCondition = {
|
||||||
// typeCondition = {
|
orgRootId: body.id,
|
||||||
// orgRootId: body.id,
|
};
|
||||||
// };
|
if (!body.isAll) {
|
||||||
// if (!body.isAll) {
|
checkChildConditions = {
|
||||||
// checkChildConditions = {
|
orgChild1Id: IsNull(),
|
||||||
// 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,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
let findPosition: any;
|
||||||
|
let masterId = new Array();
|
||||||
|
const findTypes: PosType[] = await this.posTypeRepository.find({
|
||||||
|
where: { posTypeName: Like(`%${body.keyword}%`) },
|
||||||
|
select: ["id"],
|
||||||
|
});
|
||||||
|
findPosition = await this.positionRepository.find({
|
||||||
|
where: { posTypeId: In(findTypes.map((x) => x.id)) },
|
||||||
|
select: ["posMasterId"],
|
||||||
|
});
|
||||||
|
masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId));
|
||||||
|
const findLevel: PosLevel[] = await this.posLevelRepository.find({
|
||||||
|
where: { posLevelName: Like(`%${body.keyword}%`) },
|
||||||
|
select: ["id"],
|
||||||
|
});
|
||||||
|
findPosition = await this.positionRepository.find({
|
||||||
|
where: { posLevelId: In(findLevel.map((x) => x.id)) },
|
||||||
|
select: ["posMasterId"],
|
||||||
|
});
|
||||||
|
masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId));
|
||||||
|
const findExecutive: PosExecutive[] = await this.posExecutiveRepository.find({
|
||||||
|
where: { posExecutiveName: Like(`%${body.keyword}%`) },
|
||||||
|
select: ["id"],
|
||||||
|
});
|
||||||
|
findPosition = await this.positionRepository.find({
|
||||||
|
where: { posExecutiveId: In(findExecutive.map((x) => x.id)) },
|
||||||
|
select: ["posMasterId"],
|
||||||
|
});
|
||||||
|
masterId = masterId.concat(findPosition.map((position: any) => position.posMasterId));
|
||||||
|
findPosition = await this.positionRepository.find({
|
||||||
|
where: { positionName: Like(`%${body.keyword}%`) },
|
||||||
|
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 = "";
|
||||||
// }
|
// }
|
||||||
// } else if (body.type === 1) {
|
const posMaster = await this.posMasterRepository.find({
|
||||||
// typeCondition = {
|
where: {
|
||||||
// orgChild1Id: body.id,
|
...typeCondition,
|
||||||
// };
|
...checkChildConditions,
|
||||||
// if (!body.isAll) {
|
// posMasterNo: Like(`%${keywordAsInt}%`),
|
||||||
// checkChildConditions = {
|
id: In(masterId),
|
||||||
// orgChild2Id: IsNull(),
|
},
|
||||||
// };
|
order: { posMasterOrder: "ASC" },
|
||||||
// }
|
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3", "orgChild4"],
|
||||||
// } else if (body.type === 2) {
|
skip: (body.page - 1) * body.pageSize,
|
||||||
// typeCondition = {
|
take: body.pageSize,
|
||||||
// orgChild2Id: body.id,
|
});
|
||||||
// };
|
const total = posMaster.length;
|
||||||
// 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,
|
|
||||||
// };
|
|
||||||
// }
|
|
||||||
|
|
||||||
// const keywordPosMasterCondition = body.keyword
|
const formattedData = await Promise.all(
|
||||||
// ? {
|
posMaster.map(async (posMaster) => {
|
||||||
// posMasterNoPrefix: Like(`%${body.keyword}%`),
|
const positions = await this.positionRepository.find({
|
||||||
// positionName: Like(`%${body.keyword}%`),
|
where: {
|
||||||
// posTypeName: Like(`%${body.keyword}%`),
|
posMasterId: posMaster.id,
|
||||||
// posLevelName: Like(`%${body.keyword}%`),
|
},
|
||||||
// }
|
relations: ["posLevel", "posType", "posExecutive"],
|
||||||
// : {};
|
});
|
||||||
//******** จบของตั้ม(เก่า) *********//
|
|
||||||
|
|
||||||
//******** ของมอส *********//
|
return {
|
||||||
// return {
|
id: posMaster.id,
|
||||||
// id: posMaster.id,
|
posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
||||||
// posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
posMasterNo: posMaster.posMasterNo,
|
||||||
// posMasterNo: posMaster.posMasterNo,
|
posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
||||||
// posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
orgShortname:
|
||||||
// orgShortname:
|
body.type === 0
|
||||||
// body.type === 0
|
? posMaster.orgRoot.orgRootShortName
|
||||||
// ? posMaster.orgRoot.orgRootShortName
|
: body.type === 1
|
||||||
// : body.type === 1
|
? posMaster.orgChild1.orgChild1ShortName
|
||||||
// ? posMaster.orgChild1.orgChild1ShortName
|
: body.type === 2
|
||||||
// : body.type === 2
|
? posMaster.orgChild2.orgChild2ShortName
|
||||||
// ? posMaster.orgChild2.orgChild2ShortName
|
: body.type === 3
|
||||||
// : body.type === 3
|
? posMaster.orgChild3.orgChild3ShortName
|
||||||
// ? posMaster.orgChild3.orgChild3ShortName
|
: body.type === 4
|
||||||
// : body.type === 4
|
? posMaster.orgChild4.orgChild4ShortName
|
||||||
// ? posMaster.orgChild4.orgChild4ShortName
|
: "-",
|
||||||
// : "-",
|
positions: positions.map((position) => ({
|
||||||
// profileIdCurrentHolder: posMaster.profileIdCurrentHolder,
|
id: position.id,
|
||||||
// profileIdNextHolder: posMaster.profileIdNextHolder,
|
positionName: position.positionName,
|
||||||
// positions: positions.map((position) => ({
|
positionField: position.positionField,
|
||||||
// id: position.id,
|
posTypeId: position.posTypeId,
|
||||||
// positionName: position.positionName,
|
posTypeName: position.posType == null ? null : position.posType.posTypeName,
|
||||||
// positionField: position.positionField,
|
posLevelId: position.posLevelId,
|
||||||
// posTypeId: position.posTypeId,
|
posLevelName: position.posLevel == null ? null : position.posLevel.posLevelName,
|
||||||
// posTypeName: position.posType == null ? null : position.posType.posTypeName,
|
posExecutiveId: position.posExecutiveId,
|
||||||
// posLevelId: position.posLevelId,
|
posExecutiveName:
|
||||||
// posLevelName: position.posLevel == null ? null : position.posLevel.posLevelName,
|
position.posExecutive == null ? null : position.posExecutive.posExecutiveName,
|
||||||
// posExecutiveId: position.posExecutiveId,
|
positionExecutiveField: position.positionExecutiveField,
|
||||||
// posExecutiveName:
|
positionArea: position.positionArea,
|
||||||
// position.posExecutive == null ? null : position.posExecutive.posExecutiveName,
|
positionIsSelected: position.positionIsSelected,
|
||||||
// positionExecutiveField: position.positionExecutiveField,
|
})),
|
||||||
// positionArea: position.positionArea,
|
};
|
||||||
// positionIsSelected: position.positionIsSelected,
|
}),
|
||||||
// })),
|
);
|
||||||
// };
|
return new HttpSuccess({ data: formattedData, total });
|
||||||
// }),
|
|
||||||
// );
|
|
||||||
// return new HttpSuccess({ data: formattedData, total });
|
|
||||||
//******** จบของมอส *********//
|
|
||||||
let data = AppDataSource.getRepository(PosMaster)
|
|
||||||
.createQueryBuilder("posMaster")
|
|
||||||
.leftJoin("posMaster.positions", "position")
|
|
||||||
.leftJoin("position.posType", "posType")
|
|
||||||
.leftJoin("position.posLevel", "posLevel")
|
|
||||||
.andWhere("posMaster.posMasterNoPrefix LIKE :keyword", { keyword: `%${body.keyword}%` })
|
|
||||||
.orWhere("position.positionName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
|
||||||
.orWhere("posType.posTypeName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
|
||||||
.orWhere("posLevel.posLevelName LIKE :keyword", { keyword: `%${body.keyword}%` })
|
|
||||||
.orderBy("posMaster.posMasterOrder", "ASC")
|
|
||||||
.skip((body.page - 1) * body.pageSize)
|
|
||||||
.take(body.pageSize);
|
|
||||||
|
|
||||||
if (body.type === 0) {
|
|
||||||
data = data.andWhere("posMaster.orgRootId = :orgRootId", { orgRootId: body.id });
|
|
||||||
if (!body.isAll) {
|
|
||||||
data = data.andWhere("posMaster.orgChild1Id IS NULL");
|
|
||||||
}
|
|
||||||
} else if (body.type === 1) {
|
|
||||||
data = data.andWhere("posMaster.orgChild1Id = :orgChild1Id", { orgChild1Id: body.id });
|
|
||||||
if (!body.isAll) {
|
|
||||||
data = data.andWhere("posMaster.orgChild2Id IS NULL");
|
|
||||||
}
|
|
||||||
} else if (body.type === 2) {
|
|
||||||
data = data.andWhere("posMaster.orgChild2Id = :orgChild2Id", { orgChild2Id: body.id });
|
|
||||||
if (!body.isAll) {
|
|
||||||
data = data.andWhere("posMaster.orgChild3Id IS NULL");
|
|
||||||
}
|
|
||||||
} else if (body.type === 3) {
|
|
||||||
data = data.andWhere("posMaster.orgChild3Id = :orgChild3Id", { orgChild3Id: body.id });
|
|
||||||
if (!body.isAll) {
|
|
||||||
data = data.andWhere("posMaster.orgChild4Id IS NULL");
|
|
||||||
}
|
|
||||||
} else if (body.type === 4) {
|
|
||||||
data = data.andWhere("posMaster.orgChild4Id = :orgChild4Id", { orgChild4Id: body.id });
|
|
||||||
}
|
|
||||||
|
|
||||||
const [posMaster, total] = await data.getManyAndCount();
|
|
||||||
|
|
||||||
// const posMaster = await this.posMasterRepository.find({
|
|
||||||
// where: {
|
|
||||||
// ...typeCondition,
|
|
||||||
// ...checkChildConditions,
|
|
||||||
// },
|
|
||||||
// order: { posMasterOrder: "ASC" },
|
|
||||||
// skip: (body.page - 1) * body.pageSize,
|
|
||||||
// take: body.pageSize,
|
|
||||||
// });
|
|
||||||
// const total = posMaster.length;
|
|
||||||
|
|
||||||
const formattedData = await Promise.all(
|
|
||||||
posMaster.map(async (posMaster) => {
|
|
||||||
const positions = await this.positionRepository.find({
|
|
||||||
where: {
|
|
||||||
posMasterId: posMaster.id,
|
|
||||||
},
|
|
||||||
relations: ["posLevel", "posType", "posExecutive"],
|
|
||||||
});
|
|
||||||
|
|
||||||
return {
|
|
||||||
id: posMaster.id,
|
|
||||||
posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
|
||||||
posMasterNo: posMaster.posMasterNo,
|
|
||||||
posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
|
||||||
positions: positions.map((position) => ({
|
|
||||||
id: position.id,
|
|
||||||
positionName: position.positionName,
|
|
||||||
positionField: position.positionField,
|
|
||||||
posTypeId: position.posTypeId,
|
|
||||||
posTypeName: position.posType == null ? null : position.posType.posTypeName,
|
|
||||||
posLevelId: position.posLevelId,
|
|
||||||
posLevelName: position.posLevel == null ? null : position.posLevel.posLevelName,
|
|
||||||
posExecutiveId: position.posExecutiveId,
|
|
||||||
posExecutiveName:
|
|
||||||
position.posExecutive == null ? null : position.posExecutive.posExecutiveName,
|
|
||||||
positionExecutiveField: position.positionExecutiveField,
|
|
||||||
positionArea: position.positionArea,
|
|
||||||
positionIsSelected: position.positionIsSelected,
|
|
||||||
})),
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
return new HttpSuccess({ data: formattedData, total });
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
@ -1156,4 +1114,136 @@ export class PositionController extends Controller {
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ดูประวัติอัตรากำลัง
|
||||||
|
*
|
||||||
|
* @summary ORG_054 - ดูประวัติอัตรากำลัง (ADMIN) #58
|
||||||
|
*
|
||||||
|
* @param {string} id Id อัตรากำลัง
|
||||||
|
*/
|
||||||
|
@Get("history/{id}")
|
||||||
|
async getHistoryPosMater(@Path() id: string) {
|
||||||
|
const posMaster = await this.posMasterRepository.findOne({
|
||||||
|
where: { id },
|
||||||
|
});
|
||||||
|
if (!posMaster) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลตำแหน่งตามไอดีนี้ : " + id);
|
||||||
|
}
|
||||||
|
const posMasters = await this.posMasterRepository.find({
|
||||||
|
where: { ancestorDNA: posMaster.ancestorDNA },
|
||||||
|
order: { lastUpdatedAt: "DESC" },
|
||||||
|
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3", "orgChild4"],
|
||||||
|
});
|
||||||
|
const _data = posMasters.map((item) => ({
|
||||||
|
id: item.id,
|
||||||
|
orgShortName:
|
||||||
|
item.orgRoot == null
|
||||||
|
? "-"
|
||||||
|
: item.orgChild1 == null
|
||||||
|
? item.orgRoot
|
||||||
|
: item.orgChild2 == null
|
||||||
|
? item.orgChild1.orgChild1ShortName
|
||||||
|
: item.orgChild3 == null
|
||||||
|
? item.orgChild2.orgChild2ShortName
|
||||||
|
: item.orgChild4 == null
|
||||||
|
? item.orgChild3.orgChild3ShortName
|
||||||
|
: item.orgChild4.orgChild4ShortName,
|
||||||
|
lastUpdatedAt: item.lastUpdatedAt,
|
||||||
|
posMasterNoPrefix: item.posMasterNoPrefix,
|
||||||
|
posMasterNo: item.posMasterNo,
|
||||||
|
posMasterNoSuffix: item.posMasterNoSuffix,
|
||||||
|
}));
|
||||||
|
return new HttpSuccess(_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API ย้ายอัตรากำลัง
|
||||||
|
*
|
||||||
|
* @summary ORG_054 - ย้ายอัตรากำลัง (ADMIN) #59
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Post("move")
|
||||||
|
async movePosMaster(
|
||||||
|
@Body() requestBody: { id: string; type: number; positionMaster: string[] },
|
||||||
|
@Request() request: { user: Record<string, any> },
|
||||||
|
) {
|
||||||
|
try {
|
||||||
|
const posMasters = await this.posMasterRepository.find({
|
||||||
|
where: { id: In(requestBody.positionMaster) },
|
||||||
|
});
|
||||||
|
|
||||||
|
posMasters.forEach(async (posMaster: any) => {
|
||||||
|
posMaster.orgRootId = null;
|
||||||
|
posMaster.orgChild1Id = null;
|
||||||
|
posMaster.orgChild2Id = null;
|
||||||
|
posMaster.orgChild3Id = null;
|
||||||
|
posMaster.orgChild4Id = null;
|
||||||
|
|
||||||
|
if (requestBody.type == 0) {
|
||||||
|
const org = await this.orgRootRepository.findOne({
|
||||||
|
where: { id: requestBody.id },
|
||||||
|
});
|
||||||
|
if (org != null) {
|
||||||
|
posMaster.orgRootId = org.id;
|
||||||
|
posMaster.orgRevisionId = org.orgRevisionId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (requestBody.type == 1) {
|
||||||
|
const org = await this.child1Repository.findOne({
|
||||||
|
where: { id: requestBody.id },
|
||||||
|
});
|
||||||
|
if (org != null) {
|
||||||
|
posMaster.orgRootId = org.orgRootId;
|
||||||
|
posMaster.orgChild1Id = org.id;
|
||||||
|
posMaster.orgRevisionId = org.orgRevisionId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (requestBody.type == 2) {
|
||||||
|
const org = await this.child2Repository.findOne({
|
||||||
|
where: { id: requestBody.id },
|
||||||
|
});
|
||||||
|
if (org != null) {
|
||||||
|
posMaster.orgRootId = org.orgRootId;
|
||||||
|
posMaster.orgChild1Id = org.orgChild1Id;
|
||||||
|
posMaster.orgChild2Id = org.id;
|
||||||
|
posMaster.orgRevisionId = org.orgRevisionId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (requestBody.type == 3) {
|
||||||
|
const org = await this.child3Repository.findOne({
|
||||||
|
where: { id: requestBody.id },
|
||||||
|
});
|
||||||
|
if (org != null) {
|
||||||
|
posMaster.orgRootId = org.orgRootId;
|
||||||
|
posMaster.orgChild1Id = org.orgChild1Id;
|
||||||
|
posMaster.orgChild2Id = org.orgChild2Id;
|
||||||
|
posMaster.orgChild3Id = org.id;
|
||||||
|
posMaster.orgRevisionId = org.orgRevisionId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (requestBody.type == 4) {
|
||||||
|
const org = await this.child4Repository.findOne({
|
||||||
|
where: { id: requestBody.id },
|
||||||
|
});
|
||||||
|
if (org != null) {
|
||||||
|
posMaster.orgRootId = org.orgRootId;
|
||||||
|
posMaster.orgChild1Id = org.orgChild1Id;
|
||||||
|
posMaster.orgChild2Id = org.orgChild2Id;
|
||||||
|
posMaster.orgChild3Id = org.orgChild3Id;
|
||||||
|
posMaster.orgChild4Id = org.id;
|
||||||
|
posMaster.orgRevisionId = org.orgRevisionId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
posMaster.createdUserId = request.user.sub;
|
||||||
|
posMaster.createdFullName = request.user.name;
|
||||||
|
posMaster.lastUpdateUserId = request.user.sub;
|
||||||
|
posMaster.lastUpdateFullName = request.user.name;
|
||||||
|
await this.posMasterRepository.save(posMaster);
|
||||||
|
});
|
||||||
|
return new HttpSuccess();
|
||||||
|
} catch (error) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ export class PosMaster extends EntityBase {
|
||||||
comment: "คีย์นอก(FK)ของตาราง orgRoot",
|
comment: "คีย์นอก(FK)ของตาราง orgRoot",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
orgRootId?: string;
|
orgRootId?: string | null;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
|
@ -93,7 +93,7 @@ export class PosMaster extends EntityBase {
|
||||||
comment: "คีย์นอก(FK)ของตาราง orgChild1",
|
comment: "คีย์นอก(FK)ของตาราง orgChild1",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
orgChild1Id?: string;
|
orgChild1Id?: string | null;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
|
@ -101,7 +101,7 @@ export class PosMaster extends EntityBase {
|
||||||
comment: "คีย์นอก(FK)ของตาราง orgChild2",
|
comment: "คีย์นอก(FK)ของตาราง orgChild2",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
orgChild2Id?: string;
|
orgChild2Id?: string | null;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
|
@ -109,7 +109,7 @@ export class PosMaster extends EntityBase {
|
||||||
comment: "คีย์นอก(FK)ของตาราง orgChild3",
|
comment: "คีย์นอก(FK)ของตาราง orgChild3",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
orgChild3Id?: string;
|
orgChild3Id?: string | null;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
|
@ -117,7 +117,7 @@ export class PosMaster extends EntityBase {
|
||||||
comment: "คีย์นอก(FK)ของตาราง orgChild4",
|
comment: "คีย์นอก(FK)ของตาราง orgChild4",
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
orgChild4Id?: string;
|
orgChild4Id?: string | null;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue