add isCommission
This commit is contained in:
parent
b0d6e50cf1
commit
85ca3a9b0a
6 changed files with 116 additions and 0 deletions
|
|
@ -67,6 +67,7 @@ export class OrgChild1Controller {
|
||||||
orgChild1Fax: orgChild1.orgChild1Fax,
|
orgChild1Fax: orgChild1.orgChild1Fax,
|
||||||
orgRevisionId: orgChild1.orgRevisionId,
|
orgRevisionId: orgChild1.orgRevisionId,
|
||||||
isOfficer: orgChild1.isOfficer,
|
isOfficer: orgChild1.isOfficer,
|
||||||
|
isInformation: orgChild1.isInformation,
|
||||||
misId: orgChild1.misId,
|
misId: orgChild1.misId,
|
||||||
orgCode: orgChild1.orgRoot.orgRootCode + orgChild1.orgChild1Code,
|
orgCode: orgChild1.orgRoot.orgRootCode + orgChild1.orgChild1Code,
|
||||||
};
|
};
|
||||||
|
|
@ -107,6 +108,23 @@ export class OrgChild1Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (requestBody.isInformation == true) {
|
||||||
|
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||||
|
where: { id: rootIdExits.orgRevisionId },
|
||||||
|
relations: ["orgChild1s"],
|
||||||
|
});
|
||||||
|
if (orgRevision != null) {
|
||||||
|
await Promise.all(
|
||||||
|
orgRevision.orgChild1s
|
||||||
|
.filter((x: OrgChild1) => x.isInformation == true)
|
||||||
|
.map(async (item: OrgChild1) => {
|
||||||
|
item.isInformation = false;
|
||||||
|
await this.child1Repository.save(item);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const revisionIdExits = await this.orgRevisionRepository.findOne({
|
const revisionIdExits = await this.orgRevisionRepository.findOne({
|
||||||
where: { id: rootIdExits.orgRevisionId },
|
where: { id: rootIdExits.orgRevisionId },
|
||||||
});
|
});
|
||||||
|
|
@ -224,6 +242,23 @@ export class OrgChild1Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (requestBody.isInformation == true) {
|
||||||
|
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||||
|
where: { id: rootIdExits.orgRevisionId },
|
||||||
|
relations: ["orgChild1s"],
|
||||||
|
});
|
||||||
|
if (orgRevision != null) {
|
||||||
|
await Promise.all(
|
||||||
|
orgRevision.orgChild1s
|
||||||
|
.filter((x: OrgChild1) => x.isInformation == true)
|
||||||
|
.map(async (item: OrgChild1) => {
|
||||||
|
item.isInformation = false;
|
||||||
|
await this.child1Repository.save(item);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const revisionIdExits = await this.orgRevisionRepository.findOne({
|
const revisionIdExits = await this.orgRevisionRepository.findOne({
|
||||||
where: { id: rootIdExits.orgRevisionId },
|
where: { id: rootIdExits.orgRevisionId },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,7 @@ export class OrgRootController extends Controller {
|
||||||
orgRootFax: orgRoot.orgRootFax,
|
orgRootFax: orgRoot.orgRootFax,
|
||||||
orgRevisionId: orgRoot.orgRevisionId,
|
orgRevisionId: orgRoot.orgRevisionId,
|
||||||
isDeputy: orgRoot.isDeputy,
|
isDeputy: orgRoot.isDeputy,
|
||||||
|
isCommission: orgRoot.isCommission,
|
||||||
misId: orgRoot.misId,
|
misId: orgRoot.misId,
|
||||||
orgCode: orgRoot.orgRootCode + "00",
|
orgCode: orgRoot.orgRootCode + "00",
|
||||||
};
|
};
|
||||||
|
|
@ -122,6 +123,23 @@ export class OrgRootController extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (requestBody.isCommission == true) {
|
||||||
|
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||||
|
where: { id: requestBody.orgRevisionId },
|
||||||
|
relations: ["orgRoots"],
|
||||||
|
});
|
||||||
|
if (orgRevision != null) {
|
||||||
|
await Promise.all(
|
||||||
|
orgRevision.orgRoots
|
||||||
|
.filter((x: OrgRoot) => x.isCommission == true)
|
||||||
|
.map(async (item: OrgRoot) => {
|
||||||
|
item.isCommission = false;
|
||||||
|
await this.orgRootRepository.save(item);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const validOrgRootRanks = ["DEPARTMENT", "OFFICE", "DIVISION", "SECTION"];
|
const validOrgRootRanks = ["DEPARTMENT", "OFFICE", "DIVISION", "SECTION"];
|
||||||
if (!validOrgRootRanks.includes(requestBody.orgRootRank.toUpperCase())) {
|
if (!validOrgRootRanks.includes(requestBody.orgRootRank.toUpperCase())) {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. orgRootRank");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "not found. orgRootRank");
|
||||||
|
|
@ -230,6 +248,23 @@ export class OrgRootController extends Controller {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (requestBody.isCommission == true) {
|
||||||
|
const orgRevision = await this.orgRevisionRepository.findOne({
|
||||||
|
where: { id: requestBody.orgRevisionId },
|
||||||
|
relations: ["orgRoots"],
|
||||||
|
});
|
||||||
|
if (orgRevision != null) {
|
||||||
|
await Promise.all(
|
||||||
|
orgRevision.orgRoots
|
||||||
|
.filter((x: OrgRoot) => x.isCommission == true)
|
||||||
|
.map(async (item: OrgRoot) => {
|
||||||
|
item.isCommission = false;
|
||||||
|
await this.orgRootRepository.save(item);
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const revisionIdExits = await this.orgRevisionRepository.findOne({
|
const revisionIdExits = await this.orgRevisionRepository.findOne({
|
||||||
where: { id: requestBody.orgRevisionId },
|
where: { id: requestBody.orgRevisionId },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -783,6 +783,7 @@ export class OrganizationController extends Controller {
|
||||||
.select([
|
.select([
|
||||||
"orgRoot.id",
|
"orgRoot.id",
|
||||||
"orgRoot.isDeputy",
|
"orgRoot.isDeputy",
|
||||||
|
"orgRoot.isCommission",
|
||||||
"orgRoot.orgRootName",
|
"orgRoot.orgRootName",
|
||||||
"orgRoot.orgRootShortName",
|
"orgRoot.orgRootShortName",
|
||||||
"orgRoot.orgRootCode",
|
"orgRoot.orgRootCode",
|
||||||
|
|
@ -816,6 +817,7 @@ export class OrganizationController extends Controller {
|
||||||
.select([
|
.select([
|
||||||
"orgChild1.id",
|
"orgChild1.id",
|
||||||
"orgChild1.isOfficer",
|
"orgChild1.isOfficer",
|
||||||
|
"orgChild1.isInformation",
|
||||||
"orgChild1.orgChild1Name",
|
"orgChild1.orgChild1Name",
|
||||||
"orgChild1.orgChild1ShortName",
|
"orgChild1.orgChild1ShortName",
|
||||||
"orgChild1.orgChild1Code",
|
"orgChild1.orgChild1Code",
|
||||||
|
|
@ -958,6 +960,7 @@ export class OrganizationController extends Controller {
|
||||||
responsibility: orgRoot.responsibility,
|
responsibility: orgRoot.responsibility,
|
||||||
isOfficer: false,
|
isOfficer: false,
|
||||||
isDeputy: orgRoot.isDeputy,
|
isDeputy: orgRoot.isDeputy,
|
||||||
|
isCommission: orgRoot.isCommission,
|
||||||
labelName:
|
labelName:
|
||||||
orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName,
|
orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName,
|
||||||
totalPosition: await this.posMasterRepository.count({
|
totalPosition: await this.posMasterRepository.count({
|
||||||
|
|
@ -1069,6 +1072,7 @@ export class OrganizationController extends Controller {
|
||||||
orgRootName: orgRoot.orgRootName,
|
orgRootName: orgRoot.orgRootName,
|
||||||
responsibility: orgChild1.responsibility,
|
responsibility: orgChild1.responsibility,
|
||||||
isOfficer: orgChild1.isOfficer,
|
isOfficer: orgChild1.isOfficer,
|
||||||
|
isInformation: orgChild1.isInformation,
|
||||||
labelName:
|
labelName:
|
||||||
orgChild1.orgChild1Name +
|
orgChild1.orgChild1Name +
|
||||||
" " +
|
" " +
|
||||||
|
|
@ -1605,6 +1609,7 @@ export class OrganizationController extends Controller {
|
||||||
.select([
|
.select([
|
||||||
"orgRoot.id",
|
"orgRoot.id",
|
||||||
"orgRoot.isDeputy",
|
"orgRoot.isDeputy",
|
||||||
|
"orgRoot.isCommission",
|
||||||
"orgRoot.orgRootName",
|
"orgRoot.orgRootName",
|
||||||
"orgRoot.orgRootShortName",
|
"orgRoot.orgRootShortName",
|
||||||
"orgRoot.orgRootCode",
|
"orgRoot.orgRootCode",
|
||||||
|
|
@ -1628,6 +1633,7 @@ export class OrganizationController extends Controller {
|
||||||
.select([
|
.select([
|
||||||
"orgChild1.id",
|
"orgChild1.id",
|
||||||
"orgChild1.isOfficer",
|
"orgChild1.isOfficer",
|
||||||
|
"orgChild1.isInformation",
|
||||||
"orgChild1.orgChild1Name",
|
"orgChild1.orgChild1Name",
|
||||||
"orgChild1.orgChild1ShortName",
|
"orgChild1.orgChild1ShortName",
|
||||||
"orgChild1.orgChild1Code",
|
"orgChild1.orgChild1Code",
|
||||||
|
|
@ -1739,6 +1745,7 @@ export class OrganizationController extends Controller {
|
||||||
orgRevisionId: orgRoot.orgRevisionId,
|
orgRevisionId: orgRoot.orgRevisionId,
|
||||||
orgRootName: orgRoot.orgRootName,
|
orgRootName: orgRoot.orgRootName,
|
||||||
isDeputy: orgRoot.isDeputy,
|
isDeputy: orgRoot.isDeputy,
|
||||||
|
isCommission: orgRoot.isCommission,
|
||||||
responsibility: orgRoot.responsibility,
|
responsibility: orgRoot.responsibility,
|
||||||
labelName:
|
labelName:
|
||||||
orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName,
|
orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName,
|
||||||
|
|
@ -1851,6 +1858,7 @@ export class OrganizationController extends Controller {
|
||||||
orgRootName: orgRoot.orgRootName,
|
orgRootName: orgRoot.orgRootName,
|
||||||
responsibility: orgChild1.responsibility,
|
responsibility: orgChild1.responsibility,
|
||||||
isOfficer: orgChild1.isOfficer,
|
isOfficer: orgChild1.isOfficer,
|
||||||
|
isInformation: orgChild1.isInformation,
|
||||||
labelName:
|
labelName:
|
||||||
orgChild1.orgChild1Name +
|
orgChild1.orgChild1Name +
|
||||||
" " +
|
" " +
|
||||||
|
|
@ -2383,6 +2391,7 @@ export class OrganizationController extends Controller {
|
||||||
"orgRoot.id",
|
"orgRoot.id",
|
||||||
"orgRoot.misId",
|
"orgRoot.misId",
|
||||||
"orgRoot.isDeputy",
|
"orgRoot.isDeputy",
|
||||||
|
"orgRoot.isCommission",
|
||||||
"orgRoot.orgRootName",
|
"orgRoot.orgRootName",
|
||||||
"orgRoot.orgRootShortName",
|
"orgRoot.orgRootShortName",
|
||||||
"orgRoot.orgRootCode",
|
"orgRoot.orgRootCode",
|
||||||
|
|
@ -2417,6 +2426,7 @@ export class OrganizationController extends Controller {
|
||||||
"orgChild1.id",
|
"orgChild1.id",
|
||||||
"orgChild1.misId",
|
"orgChild1.misId",
|
||||||
"orgChild1.isOfficer",
|
"orgChild1.isOfficer",
|
||||||
|
"orgChild1.isInformation",
|
||||||
"orgChild1.orgChild1Name",
|
"orgChild1.orgChild1Name",
|
||||||
"orgChild1.orgChild1ShortName",
|
"orgChild1.orgChild1ShortName",
|
||||||
"orgChild1.orgChild1Code",
|
"orgChild1.orgChild1Code",
|
||||||
|
|
@ -2562,6 +2572,7 @@ export class OrganizationController extends Controller {
|
||||||
orgRevisionId: orgRoot.orgRevisionId,
|
orgRevisionId: orgRoot.orgRevisionId,
|
||||||
orgRootName: orgRoot.orgRootName,
|
orgRootName: orgRoot.orgRootName,
|
||||||
isDeputy: orgRoot.isDeputy,
|
isDeputy: orgRoot.isDeputy,
|
||||||
|
isCommission: orgRoot.isCommission,
|
||||||
responsibility: orgRoot.responsibility,
|
responsibility: orgRoot.responsibility,
|
||||||
labelName:
|
labelName:
|
||||||
orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName,
|
orgRoot.orgRootName + " " + orgRoot.orgRootCode + "00" + " " + orgRoot.orgRootShortName,
|
||||||
|
|
@ -2675,6 +2686,7 @@ export class OrganizationController extends Controller {
|
||||||
orgRootName: orgRoot.orgRootName,
|
orgRootName: orgRoot.orgRootName,
|
||||||
responsibility: orgChild1.responsibility,
|
responsibility: orgChild1.responsibility,
|
||||||
isOfficer: orgChild1.isOfficer,
|
isOfficer: orgChild1.isOfficer,
|
||||||
|
isInformation: orgChild1.isInformation,
|
||||||
labelName:
|
labelName:
|
||||||
orgChild1.orgChild1Name +
|
orgChild1.orgChild1Name +
|
||||||
" " +
|
" " +
|
||||||
|
|
|
||||||
|
|
@ -130,6 +130,12 @@ export class OrgChild1 extends EntityBase {
|
||||||
})
|
})
|
||||||
isOfficer: boolean;
|
isOfficer: boolean;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
comment: "ศูนย์สารสนเทศทรัพยากรบุคคล",
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
isInformation: boolean;
|
||||||
|
|
||||||
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild1s)
|
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.orgChild1s)
|
||||||
@JoinColumn({ name: "orgRevisionId" })
|
@JoinColumn({ name: "orgRevisionId" })
|
||||||
orgRevision: OrgRevision;
|
orgRevision: OrgRevision;
|
||||||
|
|
@ -185,6 +191,9 @@ export class CreateOrgChild1 {
|
||||||
@Column()
|
@Column()
|
||||||
isOfficer: boolean;
|
isOfficer: boolean;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
isInformation: boolean;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
misId?: string;
|
misId?: string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -119,6 +119,12 @@ export class OrgRoot extends EntityBase {
|
||||||
})
|
})
|
||||||
isDeputy: boolean;
|
isDeputy: boolean;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
comment: "สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร",
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
isCommission: boolean;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
length: 40,
|
length: 40,
|
||||||
comment: "คีย์นอก(FK)ของตาราง orgRevision",
|
comment: "คีย์นอก(FK)ของตาราง orgRevision",
|
||||||
|
|
@ -182,6 +188,9 @@ export class CreateOrgRoot {
|
||||||
@Column()
|
@Column()
|
||||||
isDeputy: boolean;
|
isDeputy: boolean;
|
||||||
|
|
||||||
|
@Column()
|
||||||
|
isCommission: boolean;
|
||||||
|
|
||||||
@Column()
|
@Column()
|
||||||
misId?: string;
|
misId?: string;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
16
src/migration/1737360654848-update_table_add_isCommission.ts
Normal file
16
src/migration/1737360654848-update_table_add_isCommission.ts
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class UpdateTableAddIsCommission1737360654848 implements MigrationInterface {
|
||||||
|
name = 'UpdateTableAddIsCommission1737360654848'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild1\` ADD \`isInformation\` tinyint NOT NULL COMMENT 'ศูนย์สารสนเทศทรัพยากรบุคคล' DEFAULT 0`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgRoot\` ADD \`isCommission\` tinyint NOT NULL COMMENT 'สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร' DEFAULT 0`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgRoot\` DROP COLUMN \`isCommission\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`orgChild1\` DROP COLUMN \`isInformation\``);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue