เพิ่ม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")
|
||||
|
|
@ -700,20 +700,16 @@ export class OrganizationController extends Controller {
|
|||
}
|
||||
const datas = await this.child1Repository.find({
|
||||
where: { isAncestorDNA: orgChild1.isAncestorDNA },
|
||||
select: ["id", "orgRevisionId", "orgChild1Name", "lastUpdatedAt"],
|
||||
relations: ["orgRevision"],
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
for (let data of datas) {
|
||||
const revision = await this.orgRevisionRepository.findOne({
|
||||
where: { id: data.orgRevisionId },
|
||||
});
|
||||
_data.push({
|
||||
id: data.id,
|
||||
orgRevisionName: revision?.orgRevisionName,
|
||||
orgChild1Name: data.orgChild1Name,
|
||||
lastUpdatedAt: data.lastUpdatedAt,
|
||||
});
|
||||
}
|
||||
const _data = datas.map((item) => ({
|
||||
id: item.id,
|
||||
orgRevisionName: item.orgRevision == null ? null : item.orgRevision.orgRevisionName,
|
||||
name: item.orgChild1Name,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
}));
|
||||
return new HttpSuccess(_data);
|
||||
} else if (type == 2) {
|
||||
const orgChild2 = await this.child2Repository.findOne({
|
||||
where: { id: id },
|
||||
|
|
@ -723,20 +719,16 @@ export class OrganizationController extends Controller {
|
|||
}
|
||||
const datas = await this.child2Repository.find({
|
||||
where: { isAncestorDNA: orgChild2.isAncestorDNA },
|
||||
select: ["id", "orgRevisionId", "orgChild2Name", "lastUpdatedAt"],
|
||||
relations: ["orgRevision"],
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
for (let data of datas) {
|
||||
const revision = await this.orgRevisionRepository.findOne({
|
||||
where: { id: data.orgRevisionId },
|
||||
});
|
||||
_data.push({
|
||||
id: data.id,
|
||||
orgRevisionName: revision?.orgRevisionName,
|
||||
name: data.orgChild2Name,
|
||||
lastUpdatedAt: data.lastUpdatedAt,
|
||||
});
|
||||
}
|
||||
const _data = datas.map((item) => ({
|
||||
id: item.id,
|
||||
orgRevisionName: item.orgRevision == null ? null : item.orgRevision.orgRevisionName,
|
||||
name: item.orgChild2Name,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
}));
|
||||
return new HttpSuccess(_data);
|
||||
} else if (type == 3) {
|
||||
const orgChild3 = await this.child3Repository.findOne({
|
||||
where: { id: id },
|
||||
|
|
@ -746,20 +738,16 @@ export class OrganizationController extends Controller {
|
|||
}
|
||||
const datas = await this.child3Repository.find({
|
||||
where: { isAncestorDNA: orgChild3.isAncestorDNA },
|
||||
select: ["id", "orgRevisionId", "orgChild3Name", "lastUpdatedAt"],
|
||||
relations: ["orgRevision"],
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
for (let data of datas) {
|
||||
const revision = await this.orgRevisionRepository.findOne({
|
||||
where: { id: data.orgRevisionId },
|
||||
});
|
||||
_data.push({
|
||||
id: data.id,
|
||||
orgRevisionName: revision?.orgRevisionName,
|
||||
name: data.orgChild3Name,
|
||||
lastUpdatedAt: data.lastUpdatedAt,
|
||||
});
|
||||
}
|
||||
const _data = datas.map((item) => ({
|
||||
id: item.id,
|
||||
orgRevisionName: item.orgRevision == null ? null : item.orgRevision.orgRevisionName,
|
||||
name: item.orgChild3Name,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
}));
|
||||
return new HttpSuccess(_data);
|
||||
} else if (type == 4) {
|
||||
const orgChild4 = await this.child4Repository.findOne({
|
||||
where: { id: id },
|
||||
|
|
@ -769,20 +757,16 @@ export class OrganizationController extends Controller {
|
|||
}
|
||||
const datas = await this.child4Repository.find({
|
||||
where: { isAncestorDNA: orgChild4.isAncestorDNA },
|
||||
select: ["id", "orgRevisionId", "orgChild4Name", "lastUpdatedAt"],
|
||||
relations: ["orgRevision"],
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
for (let data of datas) {
|
||||
const revision = await this.orgRevisionRepository.findOne({
|
||||
where: { id: data.orgRevisionId },
|
||||
});
|
||||
_data.push({
|
||||
id: data.id,
|
||||
orgRevisionName: revision?.orgRevisionName,
|
||||
name: data.orgChild4Name,
|
||||
lastUpdatedAt: data.lastUpdatedAt,
|
||||
});
|
||||
}
|
||||
const _data = datas.map((item) => ({
|
||||
id: item.id,
|
||||
orgRevisionName: item.orgRevision == null ? null : item.orgRevision.orgRevisionName,
|
||||
name: item.orgChild4Name,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
}));
|
||||
return new HttpSuccess(_data);
|
||||
} else {
|
||||
const orgRoot = await this.orgRootRepository.findOne({
|
||||
where: { id: id },
|
||||
|
|
@ -792,20 +776,16 @@ export class OrganizationController extends Controller {
|
|||
}
|
||||
const datas = await this.orgRootRepository.find({
|
||||
where: { isAncestorDNA: orgRoot.isAncestorDNA },
|
||||
select: ["id", "orgRevisionId", "orgRootName", "lastUpdatedAt"],
|
||||
relations: ["orgRevision"],
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
for (let data of datas) {
|
||||
const revision = await this.orgRevisionRepository.findOne({
|
||||
where: { id: data.orgRevisionId },
|
||||
});
|
||||
_data.push({
|
||||
id: data.id,
|
||||
orgRevisionName: revision?.orgRevisionName,
|
||||
name: data.orgRootName,
|
||||
lastUpdatedAt: data.lastUpdatedAt,
|
||||
});
|
||||
}
|
||||
const _data = datas.map((item) => ({
|
||||
id: item.id,
|
||||
orgRevisionName: item.orgRevision == null ? null : item.orgRevision.orgRevisionName,
|
||||
name: item.orgRootName,
|
||||
lastUpdatedAt: item.lastUpdatedAt,
|
||||
}));
|
||||
return new HttpSuccess(_data);
|
||||
}
|
||||
return new HttpSuccess(_data);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -267,76 +267,98 @@ export class PositionController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Get("position")
|
||||
async findPosition(@Query("keyword") keyword: string, @Query("type") type: string){
|
||||
async findPosition(@Query("keyword") keyword: string, @Query("type") type: string) {
|
||||
try {
|
||||
let findPosDict: any;
|
||||
switch(type){
|
||||
switch (type) {
|
||||
case "positionName":
|
||||
findPosDict = await this.posDictRepository.find({ where: { posDictName: Like(`%${keyword}%`) } });
|
||||
findPosDict = await this.posDictRepository.find({
|
||||
where: { posDictName: Like(`%${keyword}%`) },
|
||||
});
|
||||
if (!findPosDict) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||
}
|
||||
break;
|
||||
|
||||
case "positionField":
|
||||
findPosDict = await this.posDictRepository.find({ where: { posDictField: Like(`%${keyword}%`) } });
|
||||
findPosDict = await this.posDictRepository.find({
|
||||
where: { posDictField: Like(`%${keyword}%`) },
|
||||
});
|
||||
if (!findPosDict) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||
}
|
||||
break;
|
||||
|
||||
case "positionType":
|
||||
const findTypes: PosType[] = await this.posTypeRepository.find({ where: { posTypeName: Like(`%${keyword}%`) } });
|
||||
if(!findTypes){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword + " ใน posType");
|
||||
const findTypes: PosType[] = await this.posTypeRepository.find({
|
||||
where: { posTypeName: Like(`%${keyword}%`) },
|
||||
});
|
||||
if (!findTypes) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword + " ใน posType");
|
||||
}
|
||||
for (const types of findTypes) {
|
||||
findPosDict = await this.posDictRepository.find({ where: { posTypeId: types.id } });
|
||||
if (!findPosDict) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "positionLevel":
|
||||
const findLevel: PosLevel[] = await this.posLevelRepository.find({ where: { posLevelName: Like(`%${keyword}%`) } })
|
||||
if(!findLevel){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword + " ใน posLevel");
|
||||
const findLevel: PosLevel[] = await this.posLevelRepository.find({
|
||||
where: { posLevelName: Like(`%${keyword}%`) },
|
||||
});
|
||||
if (!findLevel) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูล " + keyword + " ใน posLevel",
|
||||
);
|
||||
}
|
||||
|
||||
for (const types of findLevel) {
|
||||
findPosDict = await this.posDictRepository.find({ where: { posLevelId: types.id } });
|
||||
if (!findPosDict) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "positionExecutive":
|
||||
const findExecutive: PosExecutive[] = await this.posExecutiveRepository.find({ where: { posExecutiveName: Like(`%${keyword}%`) } })
|
||||
if(!findExecutive){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword + " ใน posExecutive");
|
||||
const findExecutive: PosExecutive[] = await this.posExecutiveRepository.find({
|
||||
where: { posExecutiveName: Like(`%${keyword}%`) },
|
||||
});
|
||||
if (!findExecutive) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูล " + keyword + " ใน posExecutive",
|
||||
);
|
||||
}
|
||||
|
||||
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) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case "positionExecutiveField":
|
||||
findPosDict = await this.posDictRepository.find({ where: { posDictExecutiveField: Like(`%${keyword}%`) } });
|
||||
findPosDict = await this.posDictRepository.find({
|
||||
where: { posDictExecutiveField: Like(`%${keyword}%`) },
|
||||
});
|
||||
if (!findPosDict) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||
}
|
||||
break;
|
||||
|
||||
case "positionArea":
|
||||
findPosDict = await this.posDictRepository.find({ where: { posDictArea: Like(`%${keyword}%`) } });
|
||||
findPosDict = await this.posDictRepository.find({
|
||||
where: { posDictArea: Like(`%${keyword}%`) },
|
||||
});
|
||||
if (!findPosDict) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
@ -348,34 +370,44 @@ export class PositionController extends Controller {
|
|||
break;
|
||||
}
|
||||
|
||||
if(!findPosDict){
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล "+ keyword);
|
||||
if (!findPosDict) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล " + keyword);
|
||||
}
|
||||
|
||||
const mapDataPosDict = await Promise.all(findPosDict.map(async (item: any) => {
|
||||
const posTypeName = await this.posTypeRepository.findOne({ 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"] });
|
||||
const mapDataPosDict = await Promise.all(
|
||||
findPosDict.map(async (item: any) => {
|
||||
const posTypeName = await this.posTypeRepository.findOne({
|
||||
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 {
|
||||
id: item.id,
|
||||
positionName: item.posDictName,
|
||||
positionField: item.posDictField,
|
||||
posTypeId: item.posTypeId,
|
||||
posTypeName: posTypeName ? posTypeName.posTypeName : null,
|
||||
posLevelId: item.posLevelId,
|
||||
posLevelName: posLevelName ? posLevelName.posLevelName : null,
|
||||
posExecutiveId: item.posExecutiveId,
|
||||
posExecutiveName: posExecutiveName ? posExecutiveName.posExecutiveName : null,
|
||||
positionExecutiveField: item.posDictExecutiveField,
|
||||
positionArea: item.posDictArea,
|
||||
positionIsSelected: false
|
||||
};
|
||||
}));
|
||||
return {
|
||||
id: item.id,
|
||||
positionName: item.posDictName,
|
||||
positionField: item.posDictField,
|
||||
posTypeId: item.posTypeId,
|
||||
posTypeName: posTypeName ? posTypeName.posTypeName : null,
|
||||
posLevelId: item.posLevelId,
|
||||
posLevelName: posLevelName ? posLevelName.posLevelName : null,
|
||||
posExecutiveId: item.posExecutiveId,
|
||||
posExecutiveName: posExecutiveName ? posExecutiveName.posExecutiveName : null,
|
||||
positionExecutiveField: item.posDictExecutiveField,
|
||||
positionArea: item.posDictArea,
|
||||
positionIsSelected: false,
|
||||
};
|
||||
}),
|
||||
);
|
||||
|
||||
return new HttpSuccess(mapDataPosDict);
|
||||
}
|
||||
catch (error) {
|
||||
} catch (error) {
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
|
@ -620,4 +652,50 @@ export class PositionController extends Controller {
|
|||
});
|
||||
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 { OrgRoot } from "./OrgRoot";
|
||||
import { OrgChild2 } from "./OrgChild2";
|
||||
import { OrgRevision } from "./OrgRevision";
|
||||
import { OrgChild3 } from "./OrgChild3";
|
||||
import { OrgChild4 } from "./OrgChild4";
|
||||
|
||||
enum OrgChild1Rank {
|
||||
DEPARTMENT = "DEPARTMENT",
|
||||
|
|
@ -89,12 +92,22 @@ export class OrgChild1 extends EntityBase {
|
|||
})
|
||||
isAncestorDNA: string;
|
||||
|
||||
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild1s)
|
||||
@JoinColumn({ name: "orgRevisionId" })
|
||||
orgRevision: OrgRevision;
|
||||
|
||||
@ManyToOne(() => OrgRoot, (orgRoot) => orgRoot.orgChild1s)
|
||||
@JoinColumn({ name: "orgRootId" })
|
||||
orgRoot: OrgRoot;
|
||||
|
||||
@OneToMany(() => OrgChild2, (orgChild2) => orgChild2.orgChild1)
|
||||
orgChild2s: OrgChild2[];
|
||||
|
||||
@OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgChild1)
|
||||
orgChild3s: OrgChild3[];
|
||||
|
||||
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild1)
|
||||
orgChild4s: OrgChild4[];
|
||||
}
|
||||
|
||||
export class CreateOrgChild1 {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { OrgRoot } from "./OrgRoot";
|
|||
import { OrgChild1 } from "./OrgChild1";
|
||||
import { OrgChild3 } from "./OrgChild3";
|
||||
import { OrgChild4 } from "./OrgChild4";
|
||||
import { OrgRevision } from "./OrgRevision";
|
||||
|
||||
// ENUM orgChild2Rank
|
||||
enum OrgChild2Rank {
|
||||
|
|
@ -105,12 +106,23 @@ export class OrgChild2 extends EntityBase {
|
|||
})
|
||||
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)
|
||||
@JoinColumn({ name: "orgChild1Id" })
|
||||
orgChild1: OrgChild1;
|
||||
|
||||
@OneToMany(() => OrgChild3, (orgChild3) => orgChild3.orgChild2)
|
||||
orgChild3s: OrgChild3[];
|
||||
|
||||
@OneToMany(() => OrgChild4, (orgChild4) => orgChild4.orgChild2)
|
||||
orgChild4s: OrgChild4[];
|
||||
}
|
||||
|
||||
export class CreateOrgChild2 {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm";
|
|||
import { EntityBase } from "./base/Base";
|
||||
import { OrgChild2 } from "./OrgChild2";
|
||||
import { OrgChild4 } from "./OrgChild4";
|
||||
import { OrgRevision } from "./OrgRevision";
|
||||
import { OrgChild1 } from "./OrgChild1";
|
||||
import { OrgRoot } from "./OrgRoot";
|
||||
|
||||
enum OrgChild3Rank {
|
||||
DEPARTMENT = "DEPARTMENT",
|
||||
|
|
@ -101,6 +104,18 @@ export class OrgChild3 extends EntityBase {
|
|||
})
|
||||
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)
|
||||
@JoinColumn({ name: "orgChild2Id" })
|
||||
orgChild2: OrgChild2;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import { OrgRoot } from "./OrgRoot";
|
|||
import { OrgChild1 } from "./OrgChild1";
|
||||
import { OrgChild2 } from "./OrgChild2";
|
||||
import { OrgChild3 } from "./OrgChild3";
|
||||
import { OrgRevision } from "./OrgRevision";
|
||||
// ENUM orgChild4Rank
|
||||
enum OrgChild4Rank {
|
||||
DEPARTMENT = "DEPARTMENT",
|
||||
|
|
@ -116,6 +117,22 @@ export class OrgChild4 extends EntityBase {
|
|||
})
|
||||
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)
|
||||
@JoinColumn({ name: "orgChild3Id" })
|
||||
orgChild3: OrgChild3;
|
||||
|
|
|
|||
|
|
@ -1,6 +1,11 @@
|
|||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
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")
|
||||
export class OrgRevision extends EntityBase {
|
||||
|
|
@ -46,8 +51,23 @@ export class OrgRevision extends EntityBase {
|
|||
})
|
||||
orgRevisionIsDraft: boolean;
|
||||
|
||||
@OneToMany(() => PosMaster, (posMaster) => posMaster.orgRevision)
|
||||
posMasters: PosMaster[];
|
||||
|
||||
@OneToMany(() => OrgRoot, (orgRoot) => orgRoot.orgRevision)
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "type
|
|||
import { EntityBase } from "./base/Base";
|
||||
import { OrgChild1 } from "./OrgChild1";
|
||||
import { OrgRevision } from "./OrgRevision";
|
||||
import { OrgChild2 } from "./OrgChild2";
|
||||
import { OrgChild3 } from "./OrgChild3";
|
||||
import { OrgChild4 } from "./OrgChild4";
|
||||
|
||||
// ENUM orgRootRank
|
||||
enum OrgRootRank {
|
||||
|
|
@ -91,6 +94,15 @@ export class OrgRoot extends EntityBase {
|
|||
|
||||
@OneToMany(() => OrgChild1, (orgChild1) => orgChild1.orgRoot)
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { PosExecutive } from "./PosExecutive";
|
||||
import { PosType } from "./PosType";
|
||||
import { PosLevel } from "./PosLevel";
|
||||
|
||||
@Entity("posDict")
|
||||
export class PosDict extends EntityBase {
|
||||
|
|
@ -24,7 +27,6 @@ export class PosDict extends EntityBase {
|
|||
comment: "ตำแหน่งประเภท",
|
||||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
|
||||
posTypeId: string;
|
||||
|
||||
@Column({
|
||||
|
|
@ -58,6 +60,17 @@ export class PosDict extends EntityBase {
|
|||
})
|
||||
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 {
|
||||
|
|
@ -84,4 +97,3 @@ export class CreatePosDict {
|
|||
}
|
||||
|
||||
export type UpdatePosDict = Partial<CreatePosDict>;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,27 @@
|
|||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { Position } from "./Position";
|
||||
import { PosDict } from "./PosDict";
|
||||
|
||||
@Entity("posExecutive")
|
||||
export class PosExecutive extends EntityBase {
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อตำแหน่งทางการบริหาร",
|
||||
length: 255,
|
||||
default: "string",
|
||||
})
|
||||
posExecutiveName: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ลำดับความสำคัญ",
|
||||
})
|
||||
posExecutivePriority: number;
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อตำแหน่งทางการบริหาร",
|
||||
length: 255,
|
||||
default: "string",
|
||||
})
|
||||
posExecutiveName: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ลำดับความสำคัญ",
|
||||
})
|
||||
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 { EntityBase } from "./base/Base";
|
||||
import { PosType } from "./PosType";
|
||||
import { Position } from "./Position";
|
||||
import { PosDict } from "./PosDict";
|
||||
// ENUM PosLevelAuthority
|
||||
enum PosLevelAuthority {
|
||||
HEAD = "HEAD",
|
||||
|
|
@ -43,4 +45,9 @@ export class PosLevel extends EntityBase {
|
|||
@JoinColumn({ name: "posTypeId" })
|
||||
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 { EntityBase } from "./base/Base";
|
||||
import { CreatePosDict } from "./PosDict";
|
||||
import { OrgRevision } from "./OrgRevision";
|
||||
import { Position } from "./Position";
|
||||
|
||||
enum PosMasterLine {
|
||||
MAIN = "MAIN",
|
||||
|
|
@ -127,6 +129,13 @@ export class PosMaster extends EntityBase {
|
|||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
orgRevisionId: string; //fk
|
||||
|
||||
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgRoots)
|
||||
@JoinColumn({ name: "orgRevisionId" })
|
||||
orgRevision: OrgRevision;
|
||||
|
||||
@OneToMany(() => Position, (position) => position.posMaster)
|
||||
positions: Position[];
|
||||
}
|
||||
|
||||
export class CreatePosMaster {
|
||||
|
|
|
|||
|
|
@ -1,24 +1,32 @@
|
|||
import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm";
|
||||
import { EntityBase } from "./base/Base";
|
||||
import { PosLevel } from "./PosLevel";
|
||||
import { Position } from "./Position";
|
||||
import { PosDict } from "./PosDict";
|
||||
|
||||
@Entity("posType")
|
||||
export class PosType extends EntityBase {
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อประเภทตำแหน่ง (ทั่วไป วิชาการ อำนวยการ บริหาร)",
|
||||
length: 255,
|
||||
default: "string",
|
||||
})
|
||||
posTypeName: string;
|
||||
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ระดับของประเภทตำแหน่ง ไว้ใช้ระบุว่าประเภทตำแหน่งนี้อยู่ระดับสูงหรือต่ำกว่ากัน โดย 1 = ต่ำกว่า , มากกว่า 1 = สูงกว่า ทั่วไป = 1 วิชาการ = 2 อำนวยการ = 3 บริหาร = 4",
|
||||
})
|
||||
posTypeRank: number;
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment: "ชื่อประเภทตำแหน่ง (ทั่วไป วิชาการ อำนวยการ บริหาร)",
|
||||
length: 255,
|
||||
default: "string",
|
||||
})
|
||||
posTypeName: string;
|
||||
|
||||
@OneToMany(() => PosLevel, (posLevel) => posLevel.posType)
|
||||
posLevels: PosLevel[];
|
||||
@Column({
|
||||
nullable: true,
|
||||
comment:
|
||||
"ระดับของประเภทตำแหน่ง ไว้ใช้ระบุว่าประเภทตำแหน่งนี้อยู่ระดับสูงหรือต่ำกว่ากัน โดย 1 = ต่ำกว่า , มากกว่า 1 = สูงกว่า ทั่วไป = 1 วิชาการ = 2 อำนวยการ = 3 บริหาร = 4",
|
||||
})
|
||||
posTypeRank: number;
|
||||
|
||||
@OneToMany(() => PosLevel, (posLevel) => posLevel.posType)
|
||||
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 { EntityBase } from "./base/Base";
|
||||
import { PosMaster } from "./PosMaster";
|
||||
import { PosLevel } from "./PosLevel";
|
||||
import { PosType } from "./PosType";
|
||||
import { PosExecutive } from "./PosExecutive";
|
||||
|
||||
@Entity("position")
|
||||
export class Position extends EntityBase {
|
||||
|
|
@ -69,6 +73,22 @@ export class Position extends EntityBase {
|
|||
default: "00000000-0000-0000-0000-000000000000",
|
||||
})
|
||||
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 {
|
||||
@Column()
|
||||
|
|
@ -93,4 +113,4 @@ export class CreatePosition {
|
|||
positionArea: string;
|
||||
}
|
||||
|
||||
export type UpdatePosition = Partial<CreatePosition>;
|
||||
export type UpdatePosition = Partial<CreatePosition>;
|
||||
|
|
|
|||
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