เพิ่มlink relation
This commit is contained in:
parent
a41e33c0d4
commit
d74c3140fa
16 changed files with 416 additions and 139 deletions
|
|
@ -683,9 +683,9 @@ export class OrganizationController extends Controller {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API สำหรับแสดงรายการการประชุม
|
* API ประวัติหน่วยงาน
|
||||||
*
|
*
|
||||||
* @summary EV4_006 - รายการการประชุม (ADMIN)
|
* @summary ORG_039 - ประวัติหน่วยงาน (ADMIN) #42
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("/history/publish")
|
@Get("/history/publish")
|
||||||
|
|
@ -700,20 +700,16 @@ export class OrganizationController extends Controller {
|
||||||
}
|
}
|
||||||
const datas = await this.child1Repository.find({
|
const datas = await this.child1Repository.find({
|
||||||
where: { isAncestorDNA: orgChild1.isAncestorDNA },
|
where: { isAncestorDNA: orgChild1.isAncestorDNA },
|
||||||
select: ["id", "orgRevisionId", "orgChild1Name", "lastUpdatedAt"],
|
relations: ["orgRevision"],
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
for (let data of datas) {
|
const _data = datas.map((item) => ({
|
||||||
const revision = await this.orgRevisionRepository.findOne({
|
id: item.id,
|
||||||
where: { id: data.orgRevisionId },
|
orgRevisionName: item.orgRevision == null ? null : item.orgRevision.orgRevisionName,
|
||||||
});
|
name: item.orgChild1Name,
|
||||||
_data.push({
|
lastUpdatedAt: item.lastUpdatedAt,
|
||||||
id: data.id,
|
}));
|
||||||
orgRevisionName: revision?.orgRevisionName,
|
return new HttpSuccess(_data);
|
||||||
orgChild1Name: data.orgChild1Name,
|
|
||||||
lastUpdatedAt: data.lastUpdatedAt,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (type == 2) {
|
} else if (type == 2) {
|
||||||
const orgChild2 = await this.child2Repository.findOne({
|
const orgChild2 = await this.child2Repository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -723,20 +719,16 @@ export class OrganizationController extends Controller {
|
||||||
}
|
}
|
||||||
const datas = await this.child2Repository.find({
|
const datas = await this.child2Repository.find({
|
||||||
where: { isAncestorDNA: orgChild2.isAncestorDNA },
|
where: { isAncestorDNA: orgChild2.isAncestorDNA },
|
||||||
select: ["id", "orgRevisionId", "orgChild2Name", "lastUpdatedAt"],
|
relations: ["orgRevision"],
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
for (let data of datas) {
|
const _data = datas.map((item) => ({
|
||||||
const revision = await this.orgRevisionRepository.findOne({
|
id: item.id,
|
||||||
where: { id: data.orgRevisionId },
|
orgRevisionName: item.orgRevision == null ? null : item.orgRevision.orgRevisionName,
|
||||||
});
|
name: item.orgChild2Name,
|
||||||
_data.push({
|
lastUpdatedAt: item.lastUpdatedAt,
|
||||||
id: data.id,
|
}));
|
||||||
orgRevisionName: revision?.orgRevisionName,
|
return new HttpSuccess(_data);
|
||||||
name: data.orgChild2Name,
|
|
||||||
lastUpdatedAt: data.lastUpdatedAt,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (type == 3) {
|
} else if (type == 3) {
|
||||||
const orgChild3 = await this.child3Repository.findOne({
|
const orgChild3 = await this.child3Repository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -746,20 +738,16 @@ export class OrganizationController extends Controller {
|
||||||
}
|
}
|
||||||
const datas = await this.child3Repository.find({
|
const datas = await this.child3Repository.find({
|
||||||
where: { isAncestorDNA: orgChild3.isAncestorDNA },
|
where: { isAncestorDNA: orgChild3.isAncestorDNA },
|
||||||
select: ["id", "orgRevisionId", "orgChild3Name", "lastUpdatedAt"],
|
relations: ["orgRevision"],
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
for (let data of datas) {
|
const _data = datas.map((item) => ({
|
||||||
const revision = await this.orgRevisionRepository.findOne({
|
id: item.id,
|
||||||
where: { id: data.orgRevisionId },
|
orgRevisionName: item.orgRevision == null ? null : item.orgRevision.orgRevisionName,
|
||||||
});
|
name: item.orgChild3Name,
|
||||||
_data.push({
|
lastUpdatedAt: item.lastUpdatedAt,
|
||||||
id: data.id,
|
}));
|
||||||
orgRevisionName: revision?.orgRevisionName,
|
return new HttpSuccess(_data);
|
||||||
name: data.orgChild3Name,
|
|
||||||
lastUpdatedAt: data.lastUpdatedAt,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else if (type == 4) {
|
} else if (type == 4) {
|
||||||
const orgChild4 = await this.child4Repository.findOne({
|
const orgChild4 = await this.child4Repository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -769,20 +757,16 @@ export class OrganizationController extends Controller {
|
||||||
}
|
}
|
||||||
const datas = await this.child4Repository.find({
|
const datas = await this.child4Repository.find({
|
||||||
where: { isAncestorDNA: orgChild4.isAncestorDNA },
|
where: { isAncestorDNA: orgChild4.isAncestorDNA },
|
||||||
select: ["id", "orgRevisionId", "orgChild4Name", "lastUpdatedAt"],
|
relations: ["orgRevision"],
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
for (let data of datas) {
|
const _data = datas.map((item) => ({
|
||||||
const revision = await this.orgRevisionRepository.findOne({
|
id: item.id,
|
||||||
where: { id: data.orgRevisionId },
|
orgRevisionName: item.orgRevision == null ? null : item.orgRevision.orgRevisionName,
|
||||||
});
|
name: item.orgChild4Name,
|
||||||
_data.push({
|
lastUpdatedAt: item.lastUpdatedAt,
|
||||||
id: data.id,
|
}));
|
||||||
orgRevisionName: revision?.orgRevisionName,
|
return new HttpSuccess(_data);
|
||||||
name: data.orgChild4Name,
|
|
||||||
lastUpdatedAt: data.lastUpdatedAt,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
const orgRoot = await this.orgRootRepository.findOne({
|
const orgRoot = await this.orgRootRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -792,20 +776,16 @@ export class OrganizationController extends Controller {
|
||||||
}
|
}
|
||||||
const datas = await this.orgRootRepository.find({
|
const datas = await this.orgRootRepository.find({
|
||||||
where: { isAncestorDNA: orgRoot.isAncestorDNA },
|
where: { isAncestorDNA: orgRoot.isAncestorDNA },
|
||||||
select: ["id", "orgRevisionId", "orgRootName", "lastUpdatedAt"],
|
relations: ["orgRevision"],
|
||||||
order: { lastUpdatedAt: "DESC" },
|
order: { lastUpdatedAt: "DESC" },
|
||||||
});
|
});
|
||||||
for (let data of datas) {
|
const _data = datas.map((item) => ({
|
||||||
const revision = await this.orgRevisionRepository.findOne({
|
id: item.id,
|
||||||
where: { id: data.orgRevisionId },
|
orgRevisionName: item.orgRevision == null ? null : item.orgRevision.orgRevisionName,
|
||||||
});
|
name: item.orgRootName,
|
||||||
_data.push({
|
lastUpdatedAt: item.lastUpdatedAt,
|
||||||
id: data.id,
|
}));
|
||||||
orgRevisionName: revision?.orgRevisionName,
|
return new HttpSuccess(_data);
|
||||||
name: data.orgRootName,
|
|
||||||
lastUpdatedAt: data.lastUpdatedAt,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return new HttpSuccess(_data);
|
return new HttpSuccess(_data);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -267,76 +267,98 @@ export class PositionController extends Controller {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Get("position")
|
@Get("position")
|
||||||
async findPosition(@Query("keyword") keyword: string, @Query("type") type: string){
|
async findPosition(@Query("keyword") keyword: string, @Query("type") type: string) {
|
||||||
try {
|
try {
|
||||||
let findPosDict: any;
|
let findPosDict: any;
|
||||||
switch(type){
|
switch (type) {
|
||||||
case "positionName":
|
case "positionName":
|
||||||
findPosDict = await this.posDictRepository.find({ where: { posDictName: Like(`%${keyword}%`) } });
|
findPosDict = await this.posDictRepository.find({
|
||||||
|
where: { posDictName: Like(`%${keyword}%`) },
|
||||||
|
});
|
||||||
if (!findPosDict) {
|
if (!findPosDict) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "positionField":
|
case "positionField":
|
||||||
findPosDict = await this.posDictRepository.find({ where: { posDictField: Like(`%${keyword}%`) } });
|
findPosDict = await this.posDictRepository.find({
|
||||||
|
where: { posDictField: Like(`%${keyword}%`) },
|
||||||
|
});
|
||||||
if (!findPosDict) {
|
if (!findPosDict) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "positionType":
|
case "positionType":
|
||||||
const findTypes: PosType[] = await this.posTypeRepository.find({ where: { posTypeName: Like(`%${keyword}%`) } });
|
const findTypes: PosType[] = await this.posTypeRepository.find({
|
||||||
if(!findTypes){
|
where: { posTypeName: Like(`%${keyword}%`) },
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword + " ใน posType");
|
});
|
||||||
|
if (!findTypes) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword + " ใน posType");
|
||||||
}
|
}
|
||||||
for (const types of findTypes) {
|
for (const types of findTypes) {
|
||||||
findPosDict = await this.posDictRepository.find({ where: { posTypeId: types.id } });
|
findPosDict = await this.posDictRepository.find({ where: { posTypeId: types.id } });
|
||||||
if (!findPosDict) {
|
if (!findPosDict) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "positionLevel":
|
case "positionLevel":
|
||||||
const findLevel: PosLevel[] = await this.posLevelRepository.find({ where: { posLevelName: Like(`%${keyword}%`) } })
|
const findLevel: PosLevel[] = await this.posLevelRepository.find({
|
||||||
if(!findLevel){
|
where: { posLevelName: Like(`%${keyword}%`) },
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword + " ใน posLevel");
|
});
|
||||||
|
if (!findLevel) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่พบข้อมูล " + keyword + " ใน posLevel",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const types of findLevel) {
|
for (const types of findLevel) {
|
||||||
findPosDict = await this.posDictRepository.find({ where: { posLevelId: types.id } });
|
findPosDict = await this.posDictRepository.find({ where: { posLevelId: types.id } });
|
||||||
if (!findPosDict) {
|
if (!findPosDict) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "positionExecutive":
|
case "positionExecutive":
|
||||||
const findExecutive: PosExecutive[] = await this.posExecutiveRepository.find({ where: { posExecutiveName: Like(`%${keyword}%`) } })
|
const findExecutive: PosExecutive[] = await this.posExecutiveRepository.find({
|
||||||
if(!findExecutive){
|
where: { posExecutiveName: Like(`%${keyword}%`) },
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword + " ใน posExecutive");
|
});
|
||||||
|
if (!findExecutive) {
|
||||||
|
throw new HttpError(
|
||||||
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
"ไม่พบข้อมูล " + keyword + " ใน posExecutive",
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const types of findExecutive) {
|
for (const types of findExecutive) {
|
||||||
findPosDict = await this.posDictRepository.find({ where: { posExecutiveId: types.id } });
|
findPosDict = await this.posDictRepository.find({
|
||||||
|
where: { posExecutiveId: types.id },
|
||||||
|
});
|
||||||
if (!findPosDict) {
|
if (!findPosDict) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "positionExecutiveField":
|
case "positionExecutiveField":
|
||||||
findPosDict = await this.posDictRepository.find({ where: { posDictExecutiveField: Like(`%${keyword}%`) } });
|
findPosDict = await this.posDictRepository.find({
|
||||||
|
where: { posDictExecutiveField: Like(`%${keyword}%`) },
|
||||||
|
});
|
||||||
if (!findPosDict) {
|
if (!findPosDict) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "positionArea":
|
case "positionArea":
|
||||||
findPosDict = await this.posDictRepository.find({ where: { posDictArea: Like(`%${keyword}%`) } });
|
findPosDict = await this.posDictRepository.find({
|
||||||
|
where: { posDictArea: Like(`%${keyword}%`) },
|
||||||
|
});
|
||||||
if (!findPosDict) {
|
if (!findPosDict) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
@ -348,34 +370,44 @@ export class PositionController extends Controller {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!findPosDict){
|
if (!findPosDict) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||||
}
|
}
|
||||||
|
|
||||||
const mapDataPosDict = await Promise.all(findPosDict.map(async (item: any) => {
|
const mapDataPosDict = await Promise.all(
|
||||||
const posTypeName = await this.posTypeRepository.findOne({ where: { id: item.posTypeId }, select: ["posTypeName"] });
|
findPosDict.map(async (item: any) => {
|
||||||
const posLevelName = await this.posLevelRepository.findOne({ where: { id: item.posLevelId }, select: ["posLevelName"] });
|
const posTypeName = await this.posTypeRepository.findOne({
|
||||||
const posExecutiveName = await this.posExecutiveRepository.findOne({ where: { id: item.posExecutiveId }, select: ["posExecutiveName"] });
|
where: { id: item.posTypeId },
|
||||||
|
select: ["posTypeName"],
|
||||||
|
});
|
||||||
|
const posLevelName = await this.posLevelRepository.findOne({
|
||||||
|
where: { id: item.posLevelId },
|
||||||
|
select: ["posLevelName"],
|
||||||
|
});
|
||||||
|
const posExecutiveName = await this.posExecutiveRepository.findOne({
|
||||||
|
where: { id: item.posExecutiveId },
|
||||||
|
select: ["posExecutiveName"],
|
||||||
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: item.id,
|
id: item.id,
|
||||||
positionName: item.posDictName,
|
positionName: item.posDictName,
|
||||||
positionField: item.posDictField,
|
positionField: item.posDictField,
|
||||||
posTypeId: item.posTypeId,
|
posTypeId: item.posTypeId,
|
||||||
posTypeName: posTypeName ? posTypeName.posTypeName : null,
|
posTypeName: posTypeName ? posTypeName.posTypeName : null,
|
||||||
posLevelId: item.posLevelId,
|
posLevelId: item.posLevelId,
|
||||||
posLevelName: posLevelName ? posLevelName.posLevelName : null,
|
posLevelName: posLevelName ? posLevelName.posLevelName : null,
|
||||||
posExecutiveId: item.posExecutiveId,
|
posExecutiveId: item.posExecutiveId,
|
||||||
posExecutiveName: posExecutiveName ? posExecutiveName.posExecutiveName : null,
|
posExecutiveName: posExecutiveName ? posExecutiveName.posExecutiveName : null,
|
||||||
positionExecutiveField: item.posDictExecutiveField,
|
positionExecutiveField: item.posDictExecutiveField,
|
||||||
positionArea: item.posDictArea,
|
positionArea: item.posDictArea,
|
||||||
positionIsSelected: false
|
positionIsSelected: false,
|
||||||
};
|
};
|
||||||
}));
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
return new HttpSuccess(mapDataPosDict);
|
return new HttpSuccess(mapDataPosDict);
|
||||||
}
|
} catch (error) {
|
||||||
catch (error) {
|
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -620,4 +652,50 @@ export class PositionController extends Controller {
|
||||||
});
|
});
|
||||||
return new HttpSuccess(posMaster.id);
|
return new HttpSuccess(posMaster.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* API รายละเอียดอัตรากำลัง
|
||||||
|
*
|
||||||
|
* @summary ORG_037 - รายละเอียดอัตรากำลัง (ADMIN) #36
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Get("master/{id}")
|
||||||
|
async detail(@Path() id: string) {
|
||||||
|
try {
|
||||||
|
const posMaster = await this.posMasterRepository.findOne({
|
||||||
|
where: { id },
|
||||||
|
relations: ["posType", "posLevel", "posExecutive"],
|
||||||
|
});
|
||||||
|
if (!posMaster) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
}
|
||||||
|
const positions = await this.posPositionRepository.find({
|
||||||
|
where: { posMasterId: posMaster.id },
|
||||||
|
});
|
||||||
|
const formattedData = {
|
||||||
|
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(formattedData);
|
||||||
|
} catch (error) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToMany, PrimaryGeneratedColum
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { OrgRoot } from "./OrgRoot";
|
import { OrgRoot } from "./OrgRoot";
|
||||||
import { OrgChild2 } from "./OrgChild2";
|
import { OrgChild2 } from "./OrgChild2";
|
||||||
|
import { OrgRevision } from "./OrgRevision";
|
||||||
|
import { OrgChild3 } from "./OrgChild3";
|
||||||
|
import { OrgChild4 } from "./OrgChild4";
|
||||||
|
|
||||||
enum OrgChild1Rank {
|
enum OrgChild1Rank {
|
||||||
DEPARTMENT = "DEPARTMENT",
|
DEPARTMENT = "DEPARTMENT",
|
||||||
|
|
@ -89,12 +92,22 @@ export class OrgChild1 extends EntityBase {
|
||||||
})
|
})
|
||||||
isAncestorDNA: string;
|
isAncestorDNA: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild1s)
|
||||||
|
@JoinColumn({ name: "orgRevisionId" })
|
||||||
|
orgRevision: OrgRevision;
|
||||||
|
|
||||||
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.orgChild1s)
|
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.orgChild1s)
|
||||||
@JoinColumn({ name: "orgRootId" })
|
@JoinColumn({ name: "orgRootId" })
|
||||||
orgRoot: OrgRoot;
|
orgRoot: OrgRoot;
|
||||||
|
|
||||||
@OneToMany(() => OrgChild2, (orgChild2) => orgChild2.orgChild1)
|
@OneToMany(() => OrgChild2, (orgChild2) => orgChild2.orgChild1)
|
||||||
orgChild2s: OrgChild2[];
|
orgChild2s: OrgChild2[];
|
||||||
|
|
||||||
|
@OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgChild1)
|
||||||
|
orgChild3s: OrgChild3[];
|
||||||
|
|
||||||
|
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild1)
|
||||||
|
orgChild4s: OrgChild4[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateOrgChild1 {
|
export class CreateOrgChild1 {
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { OrgRoot } from "./OrgRoot";
|
||||||
import { OrgChild1 } from "./OrgChild1";
|
import { OrgChild1 } from "./OrgChild1";
|
||||||
import { OrgChild3 } from "./OrgChild3";
|
import { OrgChild3 } from "./OrgChild3";
|
||||||
import { OrgChild4 } from "./OrgChild4";
|
import { OrgChild4 } from "./OrgChild4";
|
||||||
|
import { OrgRevision } from "./OrgRevision";
|
||||||
|
|
||||||
// ENUM orgChild2Rank
|
// ENUM orgChild2Rank
|
||||||
enum OrgChild2Rank {
|
enum OrgChild2Rank {
|
||||||
|
|
@ -105,12 +106,23 @@ export class OrgChild2 extends EntityBase {
|
||||||
})
|
})
|
||||||
isAncestorDNA: string;
|
isAncestorDNA: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild2s)
|
||||||
|
@JoinColumn({ name: "orgRevisionId" })
|
||||||
|
orgRevision: OrgRevision;
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.orgChild2s)
|
||||||
|
@JoinColumn({ name: "orgRootId" })
|
||||||
|
orgRoot: OrgRoot;
|
||||||
|
|
||||||
@ManyToOne(() => OrgChild1, (orgChild1) => orgChild1.orgChild2s)
|
@ManyToOne(() => OrgChild1, (orgChild1) => orgChild1.orgChild2s)
|
||||||
@JoinColumn({ name: "orgChild1Id" })
|
@JoinColumn({ name: "orgChild1Id" })
|
||||||
orgChild1: OrgChild1;
|
orgChild1: OrgChild1;
|
||||||
|
|
||||||
@OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgChild2)
|
@OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgChild2)
|
||||||
orgChild3s: OrgChild3[];
|
orgChild3s: OrgChild3[];
|
||||||
|
|
||||||
|
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild2)
|
||||||
|
orgChild4s: OrgChild4[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateOrgChild2 {
|
export class CreateOrgChild2 {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { OrgChild2 } from "./OrgChild2";
|
import { OrgChild2 } from "./OrgChild2";
|
||||||
import { OrgChild4 } from "./OrgChild4";
|
import { OrgChild4 } from "./OrgChild4";
|
||||||
|
import { OrgRevision } from "./OrgRevision";
|
||||||
|
import { OrgChild1 } from "./OrgChild1";
|
||||||
|
import { OrgRoot } from "./OrgRoot";
|
||||||
|
|
||||||
enum OrgChild3Rank {
|
enum OrgChild3Rank {
|
||||||
DEPARTMENT = "DEPARTMENT",
|
DEPARTMENT = "DEPARTMENT",
|
||||||
|
|
@ -101,6 +104,18 @@ export class OrgChild3 extends EntityBase {
|
||||||
})
|
})
|
||||||
isAncestorDNA: string;
|
isAncestorDNA: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild3s)
|
||||||
|
@JoinColumn({ name: "orgRevisionId" })
|
||||||
|
orgRevision: OrgRevision;
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.orgChild3s)
|
||||||
|
@JoinColumn({ name: "orgRootId" })
|
||||||
|
orgRoot: OrgRoot;
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgChild1, (orgChild1) => orgChild1.orgChild3s)
|
||||||
|
@JoinColumn({ name: "orgChild1Id" })
|
||||||
|
orgChild1: OrgChild1;
|
||||||
|
|
||||||
@ManyToOne(() => OrgChild2, (orgChild2) => orgChild2.orgChild3s)
|
@ManyToOne(() => OrgChild2, (orgChild2) => orgChild2.orgChild3s)
|
||||||
@JoinColumn({ name: "orgChild2Id" })
|
@JoinColumn({ name: "orgChild2Id" })
|
||||||
orgChild2: OrgChild2;
|
orgChild2: OrgChild2;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ import { OrgRoot } from "./OrgRoot";
|
||||||
import { OrgChild1 } from "./OrgChild1";
|
import { OrgChild1 } from "./OrgChild1";
|
||||||
import { OrgChild2 } from "./OrgChild2";
|
import { OrgChild2 } from "./OrgChild2";
|
||||||
import { OrgChild3 } from "./OrgChild3";
|
import { OrgChild3 } from "./OrgChild3";
|
||||||
|
import { OrgRevision } from "./OrgRevision";
|
||||||
// ENUM orgChild4Rank
|
// ENUM orgChild4Rank
|
||||||
enum OrgChild4Rank {
|
enum OrgChild4Rank {
|
||||||
DEPARTMENT = "DEPARTMENT",
|
DEPARTMENT = "DEPARTMENT",
|
||||||
|
|
@ -116,6 +117,22 @@ export class OrgChild4 extends EntityBase {
|
||||||
})
|
})
|
||||||
isAncestorDNA: string;
|
isAncestorDNA: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild4s)
|
||||||
|
@JoinColumn({ name: "orgRevisionId" })
|
||||||
|
orgRevision: OrgRevision;
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.orgChild4s)
|
||||||
|
@JoinColumn({ name: "orgRootId" })
|
||||||
|
orgRoot: OrgRoot;
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgChild1, (orgChild1) => orgChild1.orgChild4s)
|
||||||
|
@JoinColumn({ name: "orgChild1Id" })
|
||||||
|
orgChild1: OrgChild1;
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgChild2, (orgChild2) => orgChild2.orgChild4s)
|
||||||
|
@JoinColumn({ name: "orgChild2Id" })
|
||||||
|
orgChild2: OrgChild2;
|
||||||
|
|
||||||
@ManyToOne(() => OrgChild3, (orgChild3) => orgChild3.orgChild4s)
|
@ManyToOne(() => OrgChild3, (orgChild3) => orgChild3.orgChild4s)
|
||||||
@JoinColumn({ name: "orgChild3Id" })
|
@JoinColumn({ name: "orgChild3Id" })
|
||||||
orgChild3: OrgChild3;
|
orgChild3: OrgChild3;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,11 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { OrgRoot } from "./OrgRoot";
|
import { OrgRoot } from "./OrgRoot";
|
||||||
|
import { PosMaster } from "./PosMaster";
|
||||||
|
import { OrgChild1 } from "./OrgChild1";
|
||||||
|
import { OrgChild2 } from "./OrgChild2";
|
||||||
|
import { OrgChild3 } from "./OrgChild3";
|
||||||
|
import { OrgChild4 } from "./OrgChild4";
|
||||||
|
|
||||||
@Entity("orgRevision")
|
@Entity("orgRevision")
|
||||||
export class OrgRevision extends EntityBase {
|
export class OrgRevision extends EntityBase {
|
||||||
|
|
@ -46,8 +51,23 @@ export class OrgRevision extends EntityBase {
|
||||||
})
|
})
|
||||||
orgRevisionIsDraft: boolean;
|
orgRevisionIsDraft: boolean;
|
||||||
|
|
||||||
|
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgRevision)
|
||||||
|
posMasters: PosMaster[];
|
||||||
|
|
||||||
@OneToMany(() => OrgRoot, (orgRoot) => orgRoot.orgRevision)
|
@OneToMany(() => OrgRoot, (orgRoot) => orgRoot.orgRevision)
|
||||||
orgRoots: OrgRoot[];
|
orgRoots: OrgRoot[];
|
||||||
|
|
||||||
|
@OneToMany(() => OrgChild1, (orgChild1) => orgChild1.orgRevision)
|
||||||
|
orgChild1s: OrgChild1[];
|
||||||
|
|
||||||
|
@OneToMany(() => OrgChild2, (orgChild2) => orgChild2.orgRevision)
|
||||||
|
orgChild2s: OrgChild2[];
|
||||||
|
|
||||||
|
@OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgRevision)
|
||||||
|
orgChild3s: OrgChild3[];
|
||||||
|
|
||||||
|
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgRevision)
|
||||||
|
orgChild4s: OrgChild4[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateOrgRevision {
|
export class CreateOrgRevision {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "type
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { OrgChild1 } from "./OrgChild1";
|
import { OrgChild1 } from "./OrgChild1";
|
||||||
import { OrgRevision } from "./OrgRevision";
|
import { OrgRevision } from "./OrgRevision";
|
||||||
|
import { OrgChild2 } from "./OrgChild2";
|
||||||
|
import { OrgChild3 } from "./OrgChild3";
|
||||||
|
import { OrgChild4 } from "./OrgChild4";
|
||||||
|
|
||||||
// ENUM orgRootRank
|
// ENUM orgRootRank
|
||||||
enum OrgRootRank {
|
enum OrgRootRank {
|
||||||
|
|
@ -91,6 +94,15 @@ export class OrgRoot extends EntityBase {
|
||||||
|
|
||||||
@OneToMany(() => OrgChild1, (orgChild1) => orgChild1.orgRoot)
|
@OneToMany(() => OrgChild1, (orgChild1) => orgChild1.orgRoot)
|
||||||
orgChild1s: OrgChild1[];
|
orgChild1s: OrgChild1[];
|
||||||
|
|
||||||
|
@OneToMany(() => OrgChild2, (orgChild2) => orgChild2.orgChild1)
|
||||||
|
orgChild2s: OrgChild2[];
|
||||||
|
|
||||||
|
@OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgChild1)
|
||||||
|
orgChild3s: OrgChild3[];
|
||||||
|
|
||||||
|
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild1)
|
||||||
|
orgChild4s: OrgChild4[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateOrgRoot {
|
export class CreateOrgRoot {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,8 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
|
import { PosExecutive } from "./PosExecutive";
|
||||||
|
import { PosType } from "./PosType";
|
||||||
|
import { PosLevel } from "./PosLevel";
|
||||||
|
|
||||||
@Entity("posDict")
|
@Entity("posDict")
|
||||||
export class PosDict extends EntityBase {
|
export class PosDict extends EntityBase {
|
||||||
|
|
@ -24,7 +27,6 @@ export class PosDict extends EntityBase {
|
||||||
comment: "ตำแหน่งประเภท",
|
comment: "ตำแหน่งประเภท",
|
||||||
default: "00000000-0000-0000-0000-000000000000",
|
default: "00000000-0000-0000-0000-000000000000",
|
||||||
})
|
})
|
||||||
|
|
||||||
posTypeId: string;
|
posTypeId: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
|
|
@ -58,6 +60,17 @@ export class PosDict extends EntityBase {
|
||||||
})
|
})
|
||||||
posDictArea: string;
|
posDictArea: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => PosExecutive, (posExecutive) => posExecutive)
|
||||||
|
@JoinColumn({ name: "posExecutiveId" })
|
||||||
|
posExecutive: PosExecutive;
|
||||||
|
|
||||||
|
@ManyToOne(() => PosType, (posType) => posType)
|
||||||
|
@JoinColumn({ name: "posTypeId" })
|
||||||
|
posType: PosType;
|
||||||
|
|
||||||
|
@ManyToOne(() => PosLevel, (posLevel) => posLevel)
|
||||||
|
@JoinColumn({ name: "posLevelId" })
|
||||||
|
posLevel: PosLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreatePosDict {
|
export class CreatePosDict {
|
||||||
|
|
@ -84,4 +97,3 @@ export class CreatePosDict {
|
||||||
}
|
}
|
||||||
|
|
||||||
export type UpdatePosDict = Partial<CreatePosDict>;
|
export type UpdatePosDict = Partial<CreatePosDict>;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,27 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
|
import { Position } from "./Position";
|
||||||
|
import { PosDict } from "./PosDict";
|
||||||
|
|
||||||
@Entity("posExecutive")
|
@Entity("posExecutive")
|
||||||
export class PosExecutive extends EntityBase {
|
export class PosExecutive extends EntityBase {
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ชื่อตำแหน่งทางการบริหาร",
|
comment: "ชื่อตำแหน่งทางการบริหาร",
|
||||||
length: 255,
|
length: 255,
|
||||||
default: "string",
|
default: "string",
|
||||||
})
|
})
|
||||||
posExecutiveName: string;
|
posExecutiveName: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ลำดับความสำคัญ",
|
comment: "ลำดับความสำคัญ",
|
||||||
})
|
})
|
||||||
posExecutivePriority: number;
|
posExecutivePriority: number;
|
||||||
|
|
||||||
|
@OneToMany(() => Position, (position) => position.posExecutive)
|
||||||
|
positions: Position[];
|
||||||
|
|
||||||
|
@OneToMany(() => PosDict, (posDict) => posDict.posExecutive)
|
||||||
|
posDicts: PosDict[];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { PosType } from "./PosType";
|
import { PosType } from "./PosType";
|
||||||
|
import { Position } from "./Position";
|
||||||
|
import { PosDict } from "./PosDict";
|
||||||
// ENUM PosLevelAuthority
|
// ENUM PosLevelAuthority
|
||||||
enum PosLevelAuthority {
|
enum PosLevelAuthority {
|
||||||
HEAD = "HEAD",
|
HEAD = "HEAD",
|
||||||
|
|
@ -43,4 +45,9 @@ export class PosLevel extends EntityBase {
|
||||||
@JoinColumn({ name: "posTypeId" })
|
@JoinColumn({ name: "posTypeId" })
|
||||||
posType: PosType;
|
posType: PosType;
|
||||||
|
|
||||||
|
@OneToMany(() => Position, (position) => position.posLevel)
|
||||||
|
positions: Position[];
|
||||||
|
|
||||||
|
@OneToMany(() => PosDict, (posDict) => posDict.posLevel)
|
||||||
|
posDicts: PosDict[];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { CreatePosDict } from "./PosDict";
|
import { CreatePosDict } from "./PosDict";
|
||||||
|
import { OrgRevision } from "./OrgRevision";
|
||||||
|
import { Position } from "./Position";
|
||||||
|
|
||||||
enum PosMasterLine {
|
enum PosMasterLine {
|
||||||
MAIN = "MAIN",
|
MAIN = "MAIN",
|
||||||
|
|
@ -127,6 +129,13 @@ export class PosMaster extends EntityBase {
|
||||||
default: "00000000-0000-0000-0000-000000000000",
|
default: "00000000-0000-0000-0000-000000000000",
|
||||||
})
|
})
|
||||||
orgRevisionId: string; //fk
|
orgRevisionId: string; //fk
|
||||||
|
|
||||||
|
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgRoots)
|
||||||
|
@JoinColumn({ name: "orgRevisionId" })
|
||||||
|
orgRevision: OrgRevision;
|
||||||
|
|
||||||
|
@OneToMany(() => Position, (position) => position.posMaster)
|
||||||
|
positions: Position[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreatePosMaster {
|
export class CreatePosMaster {
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,32 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { PosLevel } from "./PosLevel";
|
import { PosLevel } from "./PosLevel";
|
||||||
|
import { Position } from "./Position";
|
||||||
|
import { PosDict } from "./PosDict";
|
||||||
|
|
||||||
@Entity("posType")
|
@Entity("posType")
|
||||||
export class PosType extends EntityBase {
|
export class PosType extends EntityBase {
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ชื่อประเภทตำแหน่ง (ทั่วไป วิชาการ อำนวยการ บริหาร)",
|
comment: "ชื่อประเภทตำแหน่ง (ทั่วไป วิชาการ อำนวยการ บริหาร)",
|
||||||
length: 255,
|
length: 255,
|
||||||
default: "string",
|
default: "string",
|
||||||
})
|
})
|
||||||
posTypeName: string;
|
posTypeName: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
nullable: true,
|
nullable: true,
|
||||||
comment: "ระดับของประเภทตำแหน่ง ไว้ใช้ระบุว่าประเภทตำแหน่งนี้อยู่ระดับสูงหรือต่ำกว่ากัน โดย 1 = ต่ำกว่า , มากกว่า 1 = สูงกว่า ทั่วไป = 1 วิชาการ = 2 อำนวยการ = 3 บริหาร = 4",
|
comment:
|
||||||
})
|
"ระดับของประเภทตำแหน่ง ไว้ใช้ระบุว่าประเภทตำแหน่งนี้อยู่ระดับสูงหรือต่ำกว่ากัน โดย 1 = ต่ำกว่า , มากกว่า 1 = สูงกว่า ทั่วไป = 1 วิชาการ = 2 อำนวยการ = 3 บริหาร = 4",
|
||||||
posTypeRank: number;
|
})
|
||||||
|
posTypeRank: number;
|
||||||
|
|
||||||
@OneToMany(() => PosLevel, (posLevel) => posLevel.posType)
|
@OneToMany(() => PosLevel, (posLevel) => posLevel.posType)
|
||||||
posLevels: PosLevel[];
|
posLevels: PosLevel[];
|
||||||
|
|
||||||
|
@OneToMany(() => Position, (position) => position.posType)
|
||||||
|
positions: Position[];
|
||||||
|
|
||||||
|
@OneToMany(() => PosDict, (posDict) => posDict.posType)
|
||||||
|
posDicts: PosDict[];
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,9 @@
|
||||||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
|
import { PosMaster } from "./PosMaster";
|
||||||
|
import { PosLevel } from "./PosLevel";
|
||||||
|
import { PosType } from "./PosType";
|
||||||
|
import { PosExecutive } from "./PosExecutive";
|
||||||
|
|
||||||
@Entity("position")
|
@Entity("position")
|
||||||
export class Position extends EntityBase {
|
export class Position extends EntityBase {
|
||||||
|
|
@ -69,6 +73,22 @@ export class Position extends EntityBase {
|
||||||
default: "00000000-0000-0000-0000-000000000000",
|
default: "00000000-0000-0000-0000-000000000000",
|
||||||
})
|
})
|
||||||
posMasterId: string;
|
posMasterId: string;
|
||||||
|
|
||||||
|
@ManyToOne(() => PosMaster, (posMaster) => posMaster)
|
||||||
|
@JoinColumn({ name: "posMasterId" })
|
||||||
|
posMaster: PosMaster;
|
||||||
|
|
||||||
|
@ManyToOne(() => PosExecutive, (posExecutive) => posExecutive)
|
||||||
|
@JoinColumn({ name: "posExecutiveId" })
|
||||||
|
posExecutive: PosExecutive;
|
||||||
|
|
||||||
|
@ManyToOne(() => PosType, (posType) => posType)
|
||||||
|
@JoinColumn({ name: "posTypeId" })
|
||||||
|
posType: PosType;
|
||||||
|
|
||||||
|
@ManyToOne(() => PosLevel, (posLevel) => posLevel)
|
||||||
|
@JoinColumn({ name: "posLevelId" })
|
||||||
|
posLevel: PosLevel;
|
||||||
}
|
}
|
||||||
export class CreatePosition {
|
export class CreatePosition {
|
||||||
@Column()
|
@Column()
|
||||||
|
|
|
||||||
18
src/migration/1706684320055-add_table_posMaster.ts
Normal file
18
src/migration/1706684320055-add_table_posMaster.ts
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class AddTablePosMaster1706684320055 implements MigrationInterface {
|
||||||
|
name = 'AddTablePosMaster1706684320055'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`CREATE TABLE \`posMaster\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`posMasterNoPrefix\` varchar(16) NULL COMMENT 'Prefix นำหน้าเลขที่ตำแหน่ง เป็น Optional (ไม่ใช่อักษรย่อของหน่วยงาน/ส่วนราชการ)' DEFAULT 'string', \`posMasterNo\` varchar(16) NULL COMMENT 'เลขที่ตำแหน่ง เป็นตัวเลข' DEFAULT 'string', \`posMasterNoSuffix\` varchar(16) NULL COMMENT 'Suffix หลังเลขที่ตำแหน่ง เช่น ช.' DEFAULT 'string', \`posMasterCreatedAt\` datetime NULL COMMENT 'วัน-เวลาที่สร้าง', \`ancestorDNA\` varchar(40) NULL COMMENT 'รหัส DNA ใช้ในกรณีที่มีการทำสำเนาโครงสร้างและตำแหน่ง ตำแหน่งที่ทำสำเนามากับตำแหน่งเก่าจะต้องมี DNA เดียวกัน เพื่อให้ track ประวัติการแก้ไขตำแหน่งย้อนหลังได้' DEFAULT 'string', \`posMasterOrder\` int NULL COMMENT 'ลำดับที่แสดงผล', \`posMasterPriority\` int NULL COMMENT 'ลำดับความสำคัญ', \`posMasterLine\` enum ('MAIN', 'SUPPORT') NULL COMMENT 'สายงานในอัตรากำลัง (หลัก / สนับสนุน) คนละฟิลด์กับสายงานของตำแหน่ง', \`orgRootId\` varchar(40) NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`orgChild1Id\` varchar(40) NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`orgChild2Id\` varchar(40) NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`orgChild3Id\` varchar(40) NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`orgChild4Id\` varchar(40) NULL DEFAULT '00000000-0000-0000-0000-000000000000', \`profileIdCurrentHolder\` varchar(40) NULL COMMENT 'คนครองปัจจุบัน เมื่อทำสำเนาโครงสร้างและตำแหน่งพร้อมกับคนครองมา คนครองจะอยู่ในฟิลด์นี้' DEFAULT 'string', \`profileIdNextHolder\` varchar(40) NULL COMMENT 'คนที่กำลังจะมาครอง ตอนปรับโครงสร้าง ถ้าเลือกให้ใครมาครอง ProfileId ของคนนั้นจะมาอยู่ในช่องนี้ รวมทั้งตอนเลือกตำแหน่งเพื่อบรรจุ แต่งตั้ง เลื่อน ย้าย ในระบบบรรจุแต่งตั้งด้วย' DEFAULT 'string', \`orgRevisionId\` varchar(40) NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||||
|
await queryRunner.query(`CREATE TABLE \`position\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`positionName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งในสายงาน (ชื่อตำแหน่ง)' DEFAULT 'string', \`positionField\` varchar(45) NULL COMMENT 'สายงาน' DEFAULT 'string', \`posTypeId\` varchar(40) NOT NULL COMMENT 'ประเภทตำแหน่ง' DEFAULT '00000000-0000-0000-0000-000000000000', \`posLevelId\` varchar(40) NOT NULL COMMENT 'ระดับตำแหน่ง' DEFAULT '00000000-0000-0000-0000-000000000000', \`posExecutiveId\` varchar(40) NULL COMMENT 'ตำแหน่งทางการบริหาร' DEFAULT '00000000-0000-0000-0000-000000000000', \`positionExecutiveField\` varchar(255) NULL COMMENT 'ด้านทางการบริหาร' DEFAULT 'string', \`positionArea\` varchar(255) NULL COMMENT 'ด้าน/สาขา' DEFAULT 'string', \`positionIsSelected\` tinyint NULL COMMENT 'เป็นตำแหน่งที่ถูกเลือกในรอบนั้นๆ หรือไม่?', \`posMasterId\` varchar(40) NOT NULL COMMENT 'เชื่อมโยงกับตารางเลขที่ตำแหน่ง' DEFAULT '00000000-0000-0000-0000-000000000000', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||||
|
await queryRunner.query(`CREATE TABLE \`posDict\` (\`id\` varchar(36) NOT NULL, \`createdAt\` datetime(6) NOT NULL COMMENT 'สร้างข้อมูลเมื่อ' DEFAULT CURRENT_TIMESTAMP(6), \`createdUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่สร้างข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`lastUpdatedAt\` datetime(6) NOT NULL COMMENT 'แก้ไขข้อมูลล่าสุดเมื่อ' DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6), \`lastUpdateUserId\` varchar(40) NOT NULL COMMENT 'User Id ที่แก้ไขข้อมูล' DEFAULT '00000000-0000-0000-0000-000000000000', \`createdFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่สร้างข้อมูล' DEFAULT 'string', \`lastUpdateFullName\` varchar(200) NOT NULL COMMENT 'ชื่อ User ที่แก้ไขข้อมูลล่าสุด' DEFAULT 'string', \`posDictName\` varchar(255) NULL COMMENT 'ชื่อตำแหน่งในสายงาน (ชื่อตำแหน่ง)' DEFAULT 'string', \`posDictField\` varchar(255) NULL COMMENT 'สายงาน' DEFAULT 'string', \`posTypeId\` varchar(40) NOT NULL COMMENT 'ตำแหน่งประเภท' DEFAULT '00000000-0000-0000-0000-000000000000', \`posLevelId\` varchar(40) NOT NULL COMMENT 'ระดับตำแหน่ง' DEFAULT '00000000-0000-0000-0000-000000000000', \`posExecutiveId\` varchar(40) NULL COMMENT 'ตำแหน่งทางการบริหาร' DEFAULT '00000000-0000-0000-0000-000000000000', \`posDictExecutiveField\` varchar(255) NULL COMMENT 'ด้านทางการบริหาร' DEFAULT 'string', \`posDictArea\` varchar(255) NULL COMMENT 'ด้าน/สาขา' DEFAULT 'string', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`DROP TABLE \`posDict\``);
|
||||||
|
await queryRunner.query(`DROP TABLE \`position\``);
|
||||||
|
await queryRunner.query(`DROP TABLE \`posMaster\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
48
src/migration/1706685942091-add_table_posMaster1.ts
Normal file
48
src/migration/1706685942091-add_table_posMaster1.ts
Normal file
|
|
@ -0,0 +1,48 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class AddTablePosMaster11706685942091 implements MigrationInterface {
|
||||||
|
name = 'AddTablePosMaster11706685942091'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_cdefa5d1dc0141102324ed4bfc2\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_82aff1cb1e02d1640b5cb384420\` FOREIGN KEY (\`orgRootId\`) REFERENCES \`orgRoot\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_3848be44d5d26ff438c893c662e\` FOREIGN KEY (\`orgChild1Id\`) REFERENCES \`orgChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild4\` ADD CONSTRAINT \`FK_4bb600399098cb8596babcc9b12\` FOREIGN KEY (\`orgChild2Id\`) REFERENCES \`orgChild2\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD CONSTRAINT \`FK_897d37984d8749690da88b538a4\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD CONSTRAINT \`FK_1f1f5214555b0e653c40924c453\` FOREIGN KEY (\`orgRootId\`) REFERENCES \`orgRoot\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild3\` ADD CONSTRAINT \`FK_85c7a51d4ba358817c2187ba0c0\` FOREIGN KEY (\`orgChild1Id\`) REFERENCES \`orgChild1\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild2\` ADD CONSTRAINT \`FK_7826c78069b4cdf5b5656460f90\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild2\` ADD CONSTRAINT \`FK_298491a199687ab46c830db5675\` FOREIGN KEY (\`orgRootId\`) REFERENCES \`orgRoot\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild1\` ADD CONSTRAINT \`FK_4f53766362a9ee2b19969343513\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` ADD CONSTRAINT \`FK_f601e38caafa049c60b4eac6f06\` FOREIGN KEY (\`orgRevisionId\`) REFERENCES \`orgRevision\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posDict\` ADD CONSTRAINT \`FK_e3827e0630023124de4e6a9063f\` FOREIGN KEY (\`posExecutiveId\`) REFERENCES \`posExecutive\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posDict\` ADD CONSTRAINT \`FK_9abc42b86d67e0f30ed64683936\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posDict\` ADD CONSTRAINT \`FK_f73c785c0db2d5178d63f3b6c46\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`position\` ADD CONSTRAINT \`FK_bfcf6ec9f1e08c2a351be8df46a\` FOREIGN KEY (\`posMasterId\`) REFERENCES \`posMaster\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`position\` ADD CONSTRAINT \`FK_dc2d0309e4642e0599f27b22271\` FOREIGN KEY (\`posExecutiveId\`) REFERENCES \`posExecutive\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`position\` ADD CONSTRAINT \`FK_663dce303cab0a73190d2b55a52\` FOREIGN KEY (\`posTypeId\`) REFERENCES \`posType\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`position\` ADD CONSTRAINT \`FK_6dcc1bd887c6b4a660391ab2dc5\` FOREIGN KEY (\`posLevelId\`) REFERENCES \`posLevel\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`position\` DROP FOREIGN KEY \`FK_6dcc1bd887c6b4a660391ab2dc5\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`position\` DROP FOREIGN KEY \`FK_663dce303cab0a73190d2b55a52\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`position\` DROP FOREIGN KEY \`FK_dc2d0309e4642e0599f27b22271\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`position\` DROP FOREIGN KEY \`FK_bfcf6ec9f1e08c2a351be8df46a\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posDict\` DROP FOREIGN KEY \`FK_f73c785c0db2d5178d63f3b6c46\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posDict\` DROP FOREIGN KEY \`FK_9abc42b86d67e0f30ed64683936\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posDict\` DROP FOREIGN KEY \`FK_e3827e0630023124de4e6a9063f\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` DROP FOREIGN KEY \`FK_f601e38caafa049c60b4eac6f06\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild1\` DROP FOREIGN KEY \`FK_4f53766362a9ee2b19969343513\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild2\` DROP FOREIGN KEY \`FK_298491a199687ab46c830db5675\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild2\` DROP FOREIGN KEY \`FK_7826c78069b4cdf5b5656460f90\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP FOREIGN KEY \`FK_85c7a51d4ba358817c2187ba0c0\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP FOREIGN KEY \`FK_1f1f5214555b0e653c40924c453\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild3\` DROP FOREIGN KEY \`FK_897d37984d8749690da88b538a4\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_4bb600399098cb8596babcc9b12\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_3848be44d5d26ff438c893c662e\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_82aff1cb1e02d1640b5cb384420\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild4\` DROP FOREIGN KEY \`FK_cdefa5d1dc0141102324ed4bfc2\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue