ประวัติการแก้โครงสร่าง
This commit is contained in:
parent
9166faf102
commit
14eb068a18
3 changed files with 144 additions and 9 deletions
|
|
@ -14,6 +14,7 @@ import {
|
|||
Example,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Query,
|
||||
} from "tsoa";
|
||||
import { CreateOrgRevision, OrgRevision } from "../entities/OrgRevision";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
|
|
@ -545,6 +546,7 @@ export class OrganizationController extends Controller {
|
|||
return {
|
||||
orgTreeId: orgRoot.id,
|
||||
orgLevel: 0,
|
||||
orgName: orgRoot.orgRootName,
|
||||
orgTreeName: orgRoot.orgRootName,
|
||||
orgTreeShortName: orgRoot.orgRootShortName,
|
||||
orgTreeCode: orgRoot.orgRootCode,
|
||||
|
|
@ -562,7 +564,7 @@ export class OrganizationController extends Controller {
|
|||
orgTreeId: orgChild1.id,
|
||||
orgRootId: orgRoot.id,
|
||||
orgLevel: 1,
|
||||
orgName: orgChild1.orgChild1Name,
|
||||
orgName: `${orgChild1.orgChild1Name}/${orgRoot.orgRootName}`,
|
||||
orgTreeName: orgChild1.orgChild1Name,
|
||||
orgTreeShortName: orgChild1.orgChild1ShortName,
|
||||
orgTreeCode: orgChild1.orgChild1Code,
|
||||
|
|
@ -581,7 +583,7 @@ export class OrganizationController extends Controller {
|
|||
orgTreeId: orgChild2.id,
|
||||
orgRootId: orgChild1.id,
|
||||
orgLevel: 2,
|
||||
orgName: `${orgChild1.orgChild1Name}/${orgChild2.orgChild2Name}`,
|
||||
orgName: `${orgChild2.orgChild2Name}/${orgChild1.orgChild1Name}/${orgRoot.orgRootName}`,
|
||||
orgTreeName: orgChild2.orgChild2Name,
|
||||
orgTreeShortName: orgChild2.orgChild2ShortName,
|
||||
orgTreeCode: orgChild2.orgChild2Code,
|
||||
|
|
@ -599,7 +601,7 @@ export class OrganizationController extends Controller {
|
|||
orgTreeId: orgChild3.id,
|
||||
orgRootId: orgChild2.id,
|
||||
orgLevel: 3,
|
||||
orgName: `${orgChild1.orgChild1Name}/${orgChild2.orgChild2Name}/${orgChild3.orgChild3Name}`,
|
||||
orgName: `${orgChild3.orgChild3Name}/${orgChild2.orgChild2Name}/${orgChild1.orgChild1Name}/${orgRoot.orgRootName}`,
|
||||
orgTreeName: orgChild3.orgChild3Name,
|
||||
orgTreeShortName: orgChild3.orgChild3ShortName,
|
||||
orgTreeCode: orgChild3.orgChild3Code,
|
||||
|
|
@ -618,7 +620,7 @@ export class OrganizationController extends Controller {
|
|||
orgTreeId: orgChild4.id,
|
||||
orgRootId: orgChild3.id,
|
||||
orgLevel: 4,
|
||||
orgName: `${orgChild1.orgChild1Name}/${orgChild2.orgChild2Name}/${orgChild3.orgChild3Name}/${orgChild4.orgChild4Name}`,
|
||||
orgName: `${orgChild4.orgChild4Name}/${orgChild3.orgChild3Name}/${orgChild2.orgChild2Name}/${orgChild1.orgChild1Name}/${orgRoot.orgRootName}`,
|
||||
orgTreeName: orgChild4.orgChild4Name,
|
||||
orgTreeShortName: orgChild4.orgChild4ShortName,
|
||||
orgTreeCode: orgChild4.orgChild4Code,
|
||||
|
|
@ -679,4 +681,132 @@ export class OrganizationController extends Controller {
|
|||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* API สำหรับแสดงรายการการประชุม
|
||||
*
|
||||
* @summary EV4_006 - รายการการประชุม (ADMIN)
|
||||
*
|
||||
*/
|
||||
@Get("/history/publish")
|
||||
async GetHistoryPublish(@Query("id") id: string, @Query("type") type: number = 1) {
|
||||
const _data = new Array();
|
||||
if (type == 1) {
|
||||
const orgChild1 = await this.child1Repository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!orgChild1) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Child1");
|
||||
}
|
||||
const datas = await this.child1Repository.find({
|
||||
where: { isAncestorDNA: orgChild1.isAncestorDNA },
|
||||
select: ["id", "orgRevisionId", "orgChild1Name", "lastUpdatedAt"],
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
for (let data of datas) {
|
||||
const revision = await this.orgRevisionRepository.findOne({
|
||||
where: { id: data.orgRevisionId },
|
||||
});
|
||||
_data.push({
|
||||
id: data.id,
|
||||
orgRevisionId: revision?.orgRevisionName,
|
||||
orgChild1Name: data.orgChild1Name,
|
||||
lastUpdatedAt: data.lastUpdatedAt,
|
||||
});
|
||||
}
|
||||
} else if (type == 2) {
|
||||
const orgChild2 = await this.child2Repository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!orgChild2) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Child2");
|
||||
}
|
||||
const datas = await this.child2Repository.find({
|
||||
where: { isAncestorDNA: orgChild2.isAncestorDNA },
|
||||
select: ["id", "orgRevisionId", "orgChild2Name", "lastUpdatedAt"],
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
for (let data of datas) {
|
||||
const revision = await this.orgRevisionRepository.findOne({
|
||||
where: { id: data.orgRevisionId },
|
||||
});
|
||||
_data.push({
|
||||
id: data.id,
|
||||
orgRevisionId: revision?.orgRevisionName,
|
||||
name: data.orgChild2Name,
|
||||
lastUpdatedAt: data.lastUpdatedAt,
|
||||
});
|
||||
}
|
||||
} else if (type == 3) {
|
||||
const orgChild3 = await this.child3Repository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!orgChild3) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Child3");
|
||||
}
|
||||
const datas = await this.child3Repository.find({
|
||||
where: { isAncestorDNA: orgChild3.isAncestorDNA },
|
||||
select: ["id", "orgRevisionId", "orgChild3Name", "lastUpdatedAt"],
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
for (let data of datas) {
|
||||
const revision = await this.orgRevisionRepository.findOne({
|
||||
where: { id: data.orgRevisionId },
|
||||
});
|
||||
_data.push({
|
||||
id: data.id,
|
||||
orgRevisionId: revision?.orgRevisionName,
|
||||
name: data.orgChild3Name,
|
||||
lastUpdatedAt: data.lastUpdatedAt,
|
||||
});
|
||||
}
|
||||
} else if (type == 4) {
|
||||
const orgChild4 = await this.child4Repository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!orgChild4) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Child4");
|
||||
}
|
||||
const datas = await this.child4Repository.find({
|
||||
where: { isAncestorDNA: orgChild4.isAncestorDNA },
|
||||
select: ["id", "orgRevisionId", "orgChild4Name", "lastUpdatedAt"],
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
for (let data of datas) {
|
||||
const revision = await this.orgRevisionRepository.findOne({
|
||||
where: { id: data.orgRevisionId },
|
||||
});
|
||||
_data.push({
|
||||
id: data.id,
|
||||
orgRevisionId: revision?.orgRevisionName,
|
||||
name: data.orgChild4Name,
|
||||
lastUpdatedAt: data.lastUpdatedAt,
|
||||
});
|
||||
}
|
||||
} else {
|
||||
const orgRoot = await this.orgRootRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!orgRoot) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. Root");
|
||||
}
|
||||
const datas = await this.orgRootRepository.find({
|
||||
where: { isAncestorDNA: orgRoot.isAncestorDNA },
|
||||
select: ["id", "orgRevisionId", "orgRootName", "lastUpdatedAt"],
|
||||
order: { lastUpdatedAt: "DESC" },
|
||||
});
|
||||
for (let data of datas) {
|
||||
const revision = await this.orgRevisionRepository.findOne({
|
||||
where: { id: data.orgRevisionId },
|
||||
});
|
||||
_data.push({
|
||||
id: data.id,
|
||||
orgRevisionId: revision?.orgRevisionName,
|
||||
name: data.orgRootName,
|
||||
lastUpdatedAt: data.lastUpdatedAt,
|
||||
});
|
||||
}
|
||||
}
|
||||
return new HttpSuccess(_data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -494,6 +494,11 @@ export class PositionController extends Controller {
|
|||
if (!posMaster) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลอัตรากำลัง");
|
||||
}
|
||||
posMaster.orgRootId = "";
|
||||
posMaster.orgChild1Id = "";
|
||||
posMaster.orgChild2Id = "";
|
||||
posMaster.orgChild3Id = "";
|
||||
posMaster.orgChild4Id = "";
|
||||
|
||||
const orgRoot = await this.orgRootRepository.findOne({
|
||||
where: { id: requestBody.orgRootId },
|
||||
|
|
|
|||
|
|
@ -143,19 +143,19 @@ export class CreatePosMaster {
|
|||
positions: CreatePosDict[];
|
||||
|
||||
@Column("uuid")
|
||||
orgRootId: string;
|
||||
orgRootId?: string;
|
||||
|
||||
@Column("uuid")
|
||||
orgChild1Id: string;
|
||||
orgChild1Id?: string;
|
||||
|
||||
@Column("uuid")
|
||||
orgChild2Id: string;
|
||||
orgChild2Id?: string;
|
||||
|
||||
@Column("uuid")
|
||||
orgChild3Id: string;
|
||||
orgChild3Id?: string;
|
||||
|
||||
@Column("uuid")
|
||||
orgChild4Id: string;
|
||||
orgChild4Id?: string;
|
||||
}
|
||||
|
||||
export type UpdatePosMaster = Partial<PosMaster>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue