From 5bba5822ea7735df9485c3898ebfba88c92d8731 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 13 Nov 2024 11:32:45 +0700 Subject: [PATCH 1/8] =?UTF-8?q?api=20=E0=B9=80=E0=B8=8A=E0=B9=87=E0=B8=84?= =?UTF-8?q?=E0=B8=AA=E0=B8=96=E0=B8=B2=E0=B8=99=E0=B8=B0=E0=B9=82=E0=B8=84?= =?UTF-8?q?=E0=B8=A3=E0=B8=87=E0=B8=AA=E0=B8=A3=E0=B9=89=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/CommandController.ts | 23 ++ src/controllers/OrganizationController.ts | 22 ++ src/controllers/PositionController.ts | 2 + src/entities/OrgRevision.ts | 6 + ...25-update_table_profie_add_rolekeycloak.ts | 304 ------------------ ...6-update_table_profie_add_rolekeycloak2.ts | 136 -------- ...23400-update_table_revision_add_islock.ts} | 12 +- 7 files changed, 57 insertions(+), 448 deletions(-) delete mode 100644 src/migration/1731311003025-update_table_profie_add_rolekeycloak.ts delete mode 100644 src/migration/1731319350256-update_table_profie_add_rolekeycloak2.ts rename src/migration/{1731316103019-update_table_profie_add_rolekeycloak1.ts => 1731471323400-update_table_revision_add_islock.ts} (93%) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 914bef96..537236ce 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -3037,6 +3037,16 @@ export class CommandController extends Controller { statusReport: "REPORT", })); await this.posMasterRepository.save(data); + if (posMasters && posMasters.length > 0) { + const orgRevision = await this.orgRevisionRepo.findOne({ + where: { id: posMasters[0].orgRevisionId } + }); + if (orgRevision != null) { + await this.orgRevisionRepo.update(orgRevision.id, { + isLock: true, + }); + } + } return new HttpSuccess(); } @@ -3531,6 +3541,19 @@ export class CommandController extends Controller { statusReport: "PENDING", })); await this.posMasterRepository.save(data); + if (data && data.length > 0) { + const revisionId = data[0].orgRevisionId; + const orgRevision = await this.orgRevisionRepo.findOne({ + where: { id: revisionId }, + relations: ["posMasters"] + }); + if (orgRevision != null && !orgRevision?.posMasters.filter(x => x.statusReport === "REPORT") + ) { + await this.orgRevisionRepo.update(orgRevision.id, { + isLock: false, + }); + } + } return new HttpSuccess(); } diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index e1d78f9e..718ae907 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -668,6 +668,28 @@ export class OrganizationController extends Controller { return new HttpSuccess(revision); } + /** + * API เช็คสถานะโครงสร้างว่าส่งคนไปออกคำสั่งหรือไม่ + * + * @summary API เช็คสถานะโครงสร้างว่าส่งคนไปออกคำสั่งหรือไม่ + * + * @param {string} id Id OrgRevison + */ + @Get("lock/{id}") + async GetById( + @Request() request: RequestWithUser, + @Path() id: string, + ) { + //add check permission + const orgRevision = await this.orgRevisionRepository.findOne({ + where: { id: id } + }); + if (!orgRevision) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลโครงสร้าง"); + } + return new HttpSuccess(orgRevision.isLock); + } + /** * API รายละเอียดโครงสร้าง * diff --git a/src/controllers/PositionController.ts b/src/controllers/PositionController.ts index 981810e3..683641b5 100644 --- a/src/controllers/PositionController.ts +++ b/src/controllers/PositionController.ts @@ -3112,6 +3112,8 @@ export class PositionController extends Controller { await this.posMasterRepository.update(id, { isSit: false, next_holderId: null, + current_holderId: null, + statusReport: "PENDING", }); dataMaster.positions.forEach(async (position) => { diff --git a/src/entities/OrgRevision.ts b/src/entities/OrgRevision.ts index b0a290f5..3f65c7df 100644 --- a/src/entities/OrgRevision.ts +++ b/src/entities/OrgRevision.ts @@ -45,6 +45,12 @@ export class OrgRevision extends EntityBase { }) orgRevisionIsDraft: boolean; + @Column({ + comment: "สถานะเช็คโครงสร้างส่งคนไปออกคำสั่งหรือไม่", + default: false, + }) + isLock: boolean; + @OneToMany(() => PosMaster, (posMaster) => posMaster.orgRevision) posMasters: PosMaster[]; diff --git a/src/migration/1731311003025-update_table_profie_add_rolekeycloak.ts b/src/migration/1731311003025-update_table_profie_add_rolekeycloak.ts deleted file mode 100644 index a4a392b0..00000000 --- a/src/migration/1731311003025-update_table_profie_add_rolekeycloak.ts +++ /dev/null @@ -1,304 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableProfieAddRolekeycloak1731311003025 implements MigrationInterface { - name = 'UpdateTableProfieAddRolekeycloak1731311003025' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director_acting","bma_ehr_organization_demo"]); - await queryRunner.query(`DROP VIEW \`view_director_acting\``); - await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director","bma_ehr_organization_demo"]); - await queryRunner.query(`DROP VIEW \`view_director\``); - await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director","bma_ehr_organization_demo"]); - await queryRunner.query(`DROP VIEW \`view_director\``); - await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director_acting","bma_ehr_organization_demo"]); - await queryRunner.query(`DROP VIEW \`view_director_acting\``); - await queryRunner.query(`CREATE TABLE \`roleKeycloak\` (\`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', \`name\` varchar(255) NULL COMMENT 'ชื่อ role', PRIMARY KEY (\`id\`)) ENGINE=InnoDB`); - await queryRunner.query(`ALTER TABLE \`profileEmployee\` ADD \`isActive\` tinyint NOT NULL COMMENT 'สถานะการใช้งาน' DEFAULT 1`); - await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`isActive\` tinyint NOT NULL COMMENT 'สถานะการใช้งาน' DEFAULT 1`); - await queryRunner.query(`ALTER TABLE \`profile\` ADD \`isActive\` tinyint NOT NULL COMMENT 'สถานะการใช้งาน' DEFAULT 1`); - await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`isActive\` tinyint NOT NULL COMMENT 'สถานะการใช้งาน' DEFAULT 1`); - await queryRunner.query(`CREATE VIEW \`view_director_acting\` AS SELECT - \`profileChild\`.\`id\` AS \`Id\`, - \`profileChild\`.\`prefix\` AS \`prefix\`, - \`profileChild\`.\`firstName\` AS \`firstName\`, - \`profileChild\`.\`lastName\` AS \`lastName\`, - \`profileChild\`.\`citizenId\` AS \`citizenId\`, - \`profileChild\`.\`position\` AS \`position\`, - CONCAT((CASE - WHEN (\`posMaster\`.\`orgChild1Id\` IS NULL) THEN \`orgRootChild\`.\`orgRootShortName\` - WHEN (\`posMaster\`.\`orgChild2Id\` IS NULL) THEN \`orgChild1Child\`.\`orgChild1ShortName\` - WHEN (\`posMaster\`.\`orgChild3Id\` IS NULL) THEN \`orgChild2Child\`.\`orgChild2ShortName\` - WHEN (\`posMaster\`.\`orgChild4Id\` IS NULL) THEN \`orgChild3Child\`.\`orgChild3ShortName\` - ELSE \`orgChild4Child\`.\`orgChild4ShortName\` - END), - \`posMaster\`.\`posMasterNo\`) AS \`posNo\`, - \`posMasterChild\`.\`isDirector\` AS \`isDirectorChild\`, - \`posMaster\`.\`isDirector\` AS \`isDirector\`, - \`posLevel\`.\`posLevelName\` AS \`posLevel\`, - \`posType\`.\`posTypeName\` AS \`posType\`, - \`posExecutive\`.\`posExecutiveName\` AS \`posExecutiveName\`, - \`orgRoot\`.\`isDeputy\` AS \`isDeputy\`, - \`posMaster\`.\`orgRootId\` AS \`orgRootId\`, - \`posMaster\`.\`orgChild1Id\` AS \`orgChild1Id\`, - \`posMaster\`.\`orgChild2Id\` AS \`orgChild2Id\`, - \`posMaster\`.\`orgChild3Id\` AS \`orgChild3Id\`, - \`posMaster\`.\`orgChild4Id\` AS \`orgChild4Id\`, - CONCAT(\`posMaster\`.\`id\`, \`profileChild\`.\`id\`) AS \`key\`, - \`profile\`.\`id\` AS \`actFullNameId\`, - CONCAT(\`profile\`.\`prefix\`, - \`profile\`.\`firstName\`, - ' ', - \`profile\`.\`lastName\`) AS \`actFullName\` - FROM - ((((((((((((((\`posMasterAct\` - JOIN \`posMaster\` \`posMasterChild\` ON ((\`posMasterAct\`.\`posMasterChildId\` = \`posMasterChild\`.\`id\`))) - JOIN \`profile\` \`profileChild\` ON ((\`posMasterChild\`.\`current_holderId\` = \`profileChild\`.\`id\`))) - LEFT JOIN \`orgRoot\` \`orgRootChild\` ON ((\`posMasterChild\`.\`orgRootId\` = \`orgRootChild\`.\`id\`))) - LEFT JOIN \`orgChild1\` \`orgChild1Child\` ON ((\`posMasterChild\`.\`orgChild1Id\` = \`orgChild1Child\`.\`id\`))) - LEFT JOIN \`orgChild2\` \`orgChild2Child\` ON ((\`posMasterChild\`.\`orgChild2Id\` = \`orgChild2Child\`.\`id\`))) - LEFT JOIN \`orgChild3\` \`orgChild3Child\` ON ((\`posMasterChild\`.\`orgChild3Id\` = \`orgChild3Child\`.\`id\`))) - LEFT JOIN \`orgChild4\` \`orgChild4Child\` ON ((\`posMasterChild\`.\`orgChild4Id\` = \`orgChild4Child\`.\`id\`))) - JOIN \`posLevel\` ON ((\`profileChild\`.\`posLevelId\` = \`posLevel\`.\`id\`))) - JOIN \`posType\` ON ((\`profileChild\`.\`posTypeId\` = \`posType\`.\`id\`))) - JOIN \`posMaster\` ON ((\`posMasterAct\`.\`posMasterId\` = \`posMaster\`.\`id\`))) - LEFT JOIN \`orgRoot\` ON ((\`posMaster\`.\`orgRootId\` = \`orgRoot\`.\`id\`))) - JOIN \`profile\` ON ((\`posMaster\`.\`current_holderId\` = \`profile\`.\`id\`))) - LEFT JOIN \`position\` ON ((\`posMasterChild\`.\`id\` = \`position\`.\`posMasterId\`))) - LEFT JOIN \`posExecutive\` ON ((\`position\`.\`posExecutiveId\` = \`posExecutive\`.\`id\`))) - WHERE - (\`position\`.\`positionIsSelected\` = TRUE)`); - await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_director_acting","SELECT \n `profileChild`.`id` AS `Id`,\n `profileChild`.`prefix` AS `prefix`,\n `profileChild`.`firstName` AS `firstName`,\n `profileChild`.`lastName` AS `lastName`,\n `profileChild`.`citizenId` AS `citizenId`,\n `profileChild`.`position` AS `position`,\n CONCAT((CASE\n WHEN (`posMaster`.`orgChild1Id` IS NULL) THEN `orgRootChild`.`orgRootShortName`\n WHEN (`posMaster`.`orgChild2Id` IS NULL) THEN `orgChild1Child`.`orgChild1ShortName`\n WHEN (`posMaster`.`orgChild3Id` IS NULL) THEN `orgChild2Child`.`orgChild2ShortName`\n WHEN (`posMaster`.`orgChild4Id` IS NULL) THEN `orgChild3Child`.`orgChild3ShortName`\n ELSE `orgChild4Child`.`orgChild4ShortName`\n END),\n `posMaster`.`posMasterNo`) AS `posNo`,\n `posMasterChild`.`isDirector` AS `isDirectorChild`,\n `posMaster`.`isDirector` AS `isDirector`,\n `posLevel`.`posLevelName` AS `posLevel`,\n `posType`.`posTypeName` AS `posType`,\n `posExecutive`.`posExecutiveName` AS `posExecutiveName`,\n `orgRoot`.`isDeputy` AS `isDeputy`,\n `posMaster`.`orgRootId` AS `orgRootId`,\n `posMaster`.`orgChild1Id` AS `orgChild1Id`,\n `posMaster`.`orgChild2Id` AS `orgChild2Id`,\n `posMaster`.`orgChild3Id` AS `orgChild3Id`,\n `posMaster`.`orgChild4Id` AS `orgChild4Id`,\n CONCAT(`posMaster`.`id`, `profileChild`.`id`) AS `key`,\n `profile`.`id` AS `actFullNameId`,\n CONCAT(`profile`.`prefix`,\n `profile`.`firstName`,\n ' ',\n `profile`.`lastName`) AS `actFullName`\n FROM\n ((((((((((((((`posMasterAct`\n JOIN `posMaster` `posMasterChild` ON ((`posMasterAct`.`posMasterChildId` = `posMasterChild`.`id`)))\n JOIN `profile` `profileChild` ON ((`posMasterChild`.`current_holderId` = `profileChild`.`id`)))\n LEFT JOIN `orgRoot` `orgRootChild` ON ((`posMasterChild`.`orgRootId` = `orgRootChild`.`id`)))\n LEFT JOIN `orgChild1` `orgChild1Child` ON ((`posMasterChild`.`orgChild1Id` = `orgChild1Child`.`id`)))\n LEFT JOIN `orgChild2` `orgChild2Child` ON ((`posMasterChild`.`orgChild2Id` = `orgChild2Child`.`id`)))\n LEFT JOIN `orgChild3` `orgChild3Child` ON ((`posMasterChild`.`orgChild3Id` = `orgChild3Child`.`id`)))\n LEFT JOIN `orgChild4` `orgChild4Child` ON ((`posMasterChild`.`orgChild4Id` = `orgChild4Child`.`id`)))\n JOIN `posLevel` ON ((`profileChild`.`posLevelId` = `posLevel`.`id`)))\n JOIN `posType` ON ((`profileChild`.`posTypeId` = `posType`.`id`)))\n JOIN `posMaster` ON ((`posMasterAct`.`posMasterId` = `posMaster`.`id`)))\n LEFT JOIN `orgRoot` ON ((`posMaster`.`orgRootId` = `orgRoot`.`id`)))\n JOIN `profile` ON ((`posMaster`.`current_holderId` = `profile`.`id`)))\n LEFT JOIN `position` ON ((`posMasterChild`.`id` = `position`.`posMasterId`)))\n LEFT JOIN `posExecutive` ON ((`position`.`posExecutiveId` = `posExecutive`.`id`)))\n WHERE\n (`position`.`positionIsSelected` = TRUE)"]); - await queryRunner.query(`CREATE VIEW \`view_director\` AS SELECT - \`profile\`.\`id\` AS \`Id\`, - \`profile\`.\`prefix\` AS \`prefix\`, - \`profile\`.\`firstName\` AS \`firstName\`, - \`profile\`.\`lastName\` AS \`lastName\`, - \`profile\`.\`citizenId\` AS \`citizenId\`, - \`profile\`.\`position\` AS \`position\`, - CONCAT((CASE - WHEN (\`posMaster\`.\`orgChild1Id\` IS NULL) THEN \`orgRoot\`.\`orgRootShortName\` - WHEN (\`posMaster\`.\`orgChild2Id\` IS NULL) THEN \`orgChild1\`.\`orgChild1ShortName\` - WHEN (\`posMaster\`.\`orgChild3Id\` IS NULL) THEN \`orgChild2\`.\`orgChild2ShortName\` - WHEN (\`posMaster\`.\`orgChild4Id\` IS NULL) THEN \`orgChild3\`.\`orgChild3ShortName\` - ELSE \`orgChild4\`.\`orgChild4ShortName\` - END), - \`posMaster\`.\`posMasterNo\`) AS \`posNo\`, - \`posMaster\`.\`isDirector\` AS \`isDirector\`, - \`posLevel\`.\`posLevelName\` AS \`posLevel\`, - \`posType\`.\`posTypeName\` AS \`posType\`, - \`posExecutive\`.\`posExecutiveName\` AS \`posExecutiveName\`, - \`orgRoot\`.\`isDeputy\` AS \`isDeputy\`, - \`posMaster\`.\`orgRootId\` AS \`orgRootId\`, - \`posMaster\`.\`orgChild1Id\` AS \`orgChild1Id\`, - \`posMaster\`.\`orgChild2Id\` AS \`orgChild2Id\`, - \`posMaster\`.\`orgChild3Id\` AS \`orgChild3Id\`, - \`posMaster\`.\`orgChild4Id\` AS \`orgChild4Id\`, - CONCAT(\`posMaster\`.\`id\`, \`profile\`.\`id\`) AS \`key\`, - NULL AS \`actFullNameId\`, - NULL AS \`actFullName\` - FROM - ((((((((((\`posMaster\` - JOIN \`profile\` ON ((\`posMaster\`.\`current_holderId\` = \`profile\`.\`id\`))) - LEFT JOIN \`orgRoot\` ON ((\`posMaster\`.\`orgRootId\` = \`orgRoot\`.\`id\`))) - LEFT JOIN \`orgChild1\` ON ((\`posMaster\`.\`orgChild1Id\` = \`orgChild1\`.\`id\`))) - LEFT JOIN \`orgChild2\` ON ((\`posMaster\`.\`orgChild2Id\` = \`orgChild2\`.\`id\`))) - LEFT JOIN \`orgChild3\` ON ((\`posMaster\`.\`orgChild3Id\` = \`orgChild3\`.\`id\`))) - LEFT JOIN \`orgChild4\` ON ((\`posMaster\`.\`orgChild4Id\` = \`orgChild4\`.\`id\`))) - JOIN \`posLevel\` ON ((\`profile\`.\`posLevelId\` = \`posLevel\`.\`id\`))) - JOIN \`posType\` ON ((\`profile\`.\`posTypeId\` = \`posType\`.\`id\`))) - LEFT JOIN \`position\` ON ((\`posMaster\`.\`id\` = \`position\`.\`posMasterId\`))) - LEFT JOIN \`posExecutive\` ON ((\`position\`.\`posExecutiveId\` = \`posExecutive\`.\`id\`))) - WHERE - (\`position\`.\`positionIsSelected\` = TRUE)`); - await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_director","SELECT \n `profile`.`id` AS `Id`,\n `profile`.`prefix` AS `prefix`,\n `profile`.`firstName` AS `firstName`,\n `profile`.`lastName` AS `lastName`,\n `profile`.`citizenId` AS `citizenId`,\n `profile`.`position` AS `position`,\n CONCAT((CASE\n WHEN (`posMaster`.`orgChild1Id` IS NULL) THEN `orgRoot`.`orgRootShortName`\n WHEN (`posMaster`.`orgChild2Id` IS NULL) THEN `orgChild1`.`orgChild1ShortName`\n WHEN (`posMaster`.`orgChild3Id` IS NULL) THEN `orgChild2`.`orgChild2ShortName`\n WHEN (`posMaster`.`orgChild4Id` IS NULL) THEN `orgChild3`.`orgChild3ShortName`\n ELSE `orgChild4`.`orgChild4ShortName`\n END),\n `posMaster`.`posMasterNo`) AS `posNo`,\n `posMaster`.`isDirector` AS `isDirector`,\n `posLevel`.`posLevelName` AS `posLevel`,\n `posType`.`posTypeName` AS `posType`,\n `posExecutive`.`posExecutiveName` AS `posExecutiveName`,\n `orgRoot`.`isDeputy` AS `isDeputy`,\n `posMaster`.`orgRootId` AS `orgRootId`,\n `posMaster`.`orgChild1Id` AS `orgChild1Id`,\n `posMaster`.`orgChild2Id` AS `orgChild2Id`,\n `posMaster`.`orgChild3Id` AS `orgChild3Id`,\n `posMaster`.`orgChild4Id` AS `orgChild4Id`,\n CONCAT(`posMaster`.`id`, `profile`.`id`) AS `key`,\n NULL AS `actFullNameId`,\n NULL AS `actFullName`\n FROM\n ((((((((((`posMaster`\n JOIN `profile` ON ((`posMaster`.`current_holderId` = `profile`.`id`)))\n LEFT JOIN `orgRoot` ON ((`posMaster`.`orgRootId` = `orgRoot`.`id`)))\n LEFT JOIN `orgChild1` ON ((`posMaster`.`orgChild1Id` = `orgChild1`.`id`)))\n LEFT JOIN `orgChild2` ON ((`posMaster`.`orgChild2Id` = `orgChild2`.`id`)))\n LEFT JOIN `orgChild3` ON ((`posMaster`.`orgChild3Id` = `orgChild3`.`id`)))\n LEFT JOIN `orgChild4` ON ((`posMaster`.`orgChild4Id` = `orgChild4`.`id`)))\n JOIN `posLevel` ON ((`profile`.`posLevelId` = `posLevel`.`id`)))\n JOIN `posType` ON ((`profile`.`posTypeId` = `posType`.`id`)))\n LEFT JOIN `position` ON ((`posMaster`.`id` = `position`.`posMasterId`)))\n LEFT JOIN `posExecutive` ON ((`position`.`posExecutiveId` = `posExecutive`.`id`)))\n WHERE\n (`position`.`positionIsSelected` = TRUE)"]); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director","bma_ehr_organization_demo"]); - await queryRunner.query(`DROP VIEW \`view_director\``); - await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director_acting","bma_ehr_organization_demo"]); - await queryRunner.query(`DROP VIEW \`view_director_acting\``); - await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`isActive\``); - await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`isActive\``); - await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`isActive\``); - await queryRunner.query(`ALTER TABLE \`profileEmployee\` DROP COLUMN \`isActive\``); - await queryRunner.query(`DROP TABLE \`roleKeycloak\``); - await queryRunner.query(`CREATE VIEW \`view_director_acting\` AS SELECT - \`profileChild\`.\`id\` AS \`Id\`, - \`profileChild\`.\`prefix\` AS \`prefix\`, - \`profileChild\`.\`firstName\` AS \`firstName\`, - \`profileChild\`.\`lastName\` AS \`lastName\`, - \`profileChild\`.\`citizenId\` AS \`citizenId\`, - \`profileChild\`.\`position\` AS \`position\`, - CONCAT((CASE - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` IS NULL) THEN \`orgRootChild\`.\`orgRootShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` IS NULL) THEN \`orgChild1Child\`.\`orgChild1ShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` IS NULL) THEN \`orgChild2Child\`.\`orgChild2ShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` IS NULL) THEN \`orgChild3Child\`.\`orgChild3ShortName\` - ELSE \`orgChild4Child\`.\`orgChild4ShortName\` - END), - \`bma_ehr_organization_demo\`.\`posMaster\`.\`posMasterNo\`) AS \`posNo\`, - \`posMasterChild\`.\`isDirector\` AS \`isDirectorChild\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`isDirector\` AS \`isDirector\`, - \`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`, - \`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`, - NULL AS \`posExecutiveName\`, - \`bma_ehr_organization_demo\`.\`orgRoot\`.\`isDeputy\` AS \`isDeputy\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` AS \`orgChild1Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` AS \`orgChild2Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` AS \`orgChild3Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` AS \`orgChild4Id\`, - CONCAT(\`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`, - \`profileChild\`.\`id\`) AS \`key\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`id\` AS \`actFullNameId\`, - CONCAT(\`bma_ehr_organization_demo\`.\`profile\`.\`prefix\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`firstName\`, - ' ', - \`bma_ehr_organization_demo\`.\`profile\`.\`lastName\`) AS \`actFullName\` - FROM - ((((((((((((\`bma_ehr_organization_demo\`.\`posMasterAct\` - JOIN \`bma_ehr_organization_demo\`.\`posMaster\` \`posMasterChild\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterChildId\` = \`posMasterChild\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`profile\` \`profileChild\` ON ((\`posMasterChild\`.\`current_holderId\` = \`profileChild\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgRoot\` \`orgRootChild\` ON ((\`posMasterChild\`.\`orgRootId\` = \`orgRootChild\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild1\` \`orgChild1Child\` ON ((\`posMasterChild\`.\`orgChild1Id\` = \`orgChild1Child\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild2\` \`orgChild2Child\` ON ((\`posMasterChild\`.\`orgChild2Id\` = \`orgChild2Child\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild3\` \`orgChild3Child\` ON ((\`posMasterChild\`.\`orgChild3Id\` = \`orgChild3Child\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild4\` \`orgChild4Child\` ON ((\`posMasterChild\`.\`orgChild4Id\` = \`orgChild4Child\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`posLevel\` ON ((\`profileChild\`.\`posLevelId\` = \`bma_ehr_organization_demo\`.\`posLevel\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`posType\` ON ((\`profileChild\`.\`posTypeId\` = \`bma_ehr_organization_demo\`.\`posType\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`posMaster\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterId\` = \`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgRoot\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` = \`bma_ehr_organization_demo\`.\`orgRoot\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`)))`); - await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_director_acting","SELECT \n `profileChild`.`id` AS `Id`,\n `profileChild`.`prefix` AS `prefix`,\n `profileChild`.`firstName` AS `firstName`,\n `profileChild`.`lastName` AS `lastName`,\n `profileChild`.`citizenId` AS `citizenId`,\n `profileChild`.`position` AS `position`,\n CONCAT((CASE\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` IS NULL) THEN `orgRootChild`.`orgRootShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` IS NULL) THEN `orgChild1Child`.`orgChild1ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` IS NULL) THEN `orgChild2Child`.`orgChild2ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` IS NULL) THEN `orgChild3Child`.`orgChild3ShortName`\n ELSE `orgChild4Child`.`orgChild4ShortName`\n END),\n `bma_ehr_organization_demo`.`posMaster`.`posMasterNo`) AS `posNo`,\n `posMasterChild`.`isDirector` AS `isDirectorChild`,\n `bma_ehr_organization_demo`.`posMaster`.`isDirector` AS `isDirector`,\n `bma_ehr_organization_demo`.`posLevel`.`posLevelName` AS `posLevel`,\n `bma_ehr_organization_demo`.`posType`.`posTypeName` AS `posType`,\n NULL AS `posExecutiveName`,\n `bma_ehr_organization_demo`.`orgRoot`.`isDeputy` AS `isDeputy`,\n `bma_ehr_organization_demo`.`posMaster`.`orgRootId` AS `orgRootId`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` AS `orgChild1Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` AS `orgChild2Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` AS `orgChild3Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` AS `orgChild4Id`,\n CONCAT(`bma_ehr_organization_demo`.`posMaster`.`id`,\n `profileChild`.`id`) AS `key`,\n `bma_ehr_organization_demo`.`profile`.`id` AS `actFullNameId`,\n CONCAT(`bma_ehr_organization_demo`.`profile`.`prefix`,\n `bma_ehr_organization_demo`.`profile`.`firstName`,\n ' ',\n `bma_ehr_organization_demo`.`profile`.`lastName`) AS `actFullName`\n FROM\n ((((((((((((`bma_ehr_organization_demo`.`posMasterAct`\n JOIN `bma_ehr_organization_demo`.`posMaster` `posMasterChild` ON ((`bma_ehr_organization_demo`.`posMasterAct`.`posMasterChildId` = `posMasterChild`.`id`)))\n JOIN `bma_ehr_organization_demo`.`profile` `profileChild` ON ((`posMasterChild`.`current_holderId` = `profileChild`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgRoot` `orgRootChild` ON ((`posMasterChild`.`orgRootId` = `orgRootChild`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild1` `orgChild1Child` ON ((`posMasterChild`.`orgChild1Id` = `orgChild1Child`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild2` `orgChild2Child` ON ((`posMasterChild`.`orgChild2Id` = `orgChild2Child`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild3` `orgChild3Child` ON ((`posMasterChild`.`orgChild3Id` = `orgChild3Child`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild4` `orgChild4Child` ON ((`posMasterChild`.`orgChild4Id` = `orgChild4Child`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posLevel` ON ((`profileChild`.`posLevelId` = `bma_ehr_organization_demo`.`posLevel`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posType` ON ((`profileChild`.`posTypeId` = `bma_ehr_organization_demo`.`posType`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posMaster` ON ((`bma_ehr_organization_demo`.`posMasterAct`.`posMasterId` = `bma_ehr_organization_demo`.`posMaster`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgRoot` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgRootId` = `bma_ehr_organization_demo`.`orgRoot`.`id`)))\n JOIN `bma_ehr_organization_demo`.`profile` ON ((`bma_ehr_organization_demo`.`posMaster`.`current_holderId` = `bma_ehr_organization_demo`.`profile`.`id`)))"]); - await queryRunner.query(`CREATE VIEW \`view_director\` AS SELECT - \`bma_ehr_organization_demo\`.\`profile\`.\`id\` AS \`Id\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`prefix\` AS \`prefix\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`firstName\` AS \`firstName\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`lastName\` AS \`lastName\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`citizenId\` AS \`citizenId\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`position\` AS \`position\`, - CONCAT((CASE - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgRoot\`.\`orgRootShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgChild1\`.\`orgChild1ShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgChild2\`.\`orgChild2ShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgChild3\`.\`orgChild3ShortName\` - ELSE \`bma_ehr_organization_demo\`.\`orgChild4\`.\`orgChild4ShortName\` - END), - \`bma_ehr_organization_demo\`.\`posMaster\`.\`posMasterNo\`) AS \`posNo\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`isDirector\` AS \`isDirector\`, - \`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`, - \`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`, - NULL AS \`posExecutiveName\`, - \`bma_ehr_organization_demo\`.\`orgRoot\`.\`isDeputy\` AS \`isDeputy\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` AS \`orgChild1Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` AS \`orgChild2Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` AS \`orgChild3Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` AS \`orgChild4Id\`, - CONCAT(\`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`id\`) AS \`key\`, - NULL AS \`actFullNameId\`, - NULL AS \`actFullName\` - FROM - ((((((((\`bma_ehr_organization_demo\`.\`posMaster\` - JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgRoot\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` = \`bma_ehr_organization_demo\`.\`orgRoot\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild1\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` = \`bma_ehr_organization_demo\`.\`orgChild1\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild2\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` = \`bma_ehr_organization_demo\`.\`orgChild2\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild3\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` = \`bma_ehr_organization_demo\`.\`orgChild3\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild4\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` = \`bma_ehr_organization_demo\`.\`orgChild4\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`posLevel\` ON ((\`bma_ehr_organization_demo\`.\`profile\`.\`posLevelId\` = \`bma_ehr_organization_demo\`.\`posLevel\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`posType\` ON ((\`bma_ehr_organization_demo\`.\`profile\`.\`posTypeId\` = \`bma_ehr_organization_demo\`.\`posType\`.\`id\`)))`); - await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_director","SELECT \n `bma_ehr_organization_demo`.`profile`.`id` AS `Id`,\n `bma_ehr_organization_demo`.`profile`.`prefix` AS `prefix`,\n `bma_ehr_organization_demo`.`profile`.`firstName` AS `firstName`,\n `bma_ehr_organization_demo`.`profile`.`lastName` AS `lastName`,\n `bma_ehr_organization_demo`.`profile`.`citizenId` AS `citizenId`,\n `bma_ehr_organization_demo`.`profile`.`position` AS `position`,\n CONCAT((CASE\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgRoot`.`orgRootShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgChild1`.`orgChild1ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgChild2`.`orgChild2ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgChild3`.`orgChild3ShortName`\n ELSE `bma_ehr_organization_demo`.`orgChild4`.`orgChild4ShortName`\n END),\n `bma_ehr_organization_demo`.`posMaster`.`posMasterNo`) AS `posNo`,\n `bma_ehr_organization_demo`.`posMaster`.`isDirector` AS `isDirector`,\n `bma_ehr_organization_demo`.`posLevel`.`posLevelName` AS `posLevel`,\n `bma_ehr_organization_demo`.`posType`.`posTypeName` AS `posType`,\n NULL AS `posExecutiveName`,\n `bma_ehr_organization_demo`.`orgRoot`.`isDeputy` AS `isDeputy`,\n `bma_ehr_organization_demo`.`posMaster`.`orgRootId` AS `orgRootId`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` AS `orgChild1Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` AS `orgChild2Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` AS `orgChild3Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` AS `orgChild4Id`,\n CONCAT(`bma_ehr_organization_demo`.`posMaster`.`id`,\n `bma_ehr_organization_demo`.`profile`.`id`) AS `key`,\n NULL AS `actFullNameId`,\n NULL AS `actFullName`\n FROM\n ((((((((`bma_ehr_organization_demo`.`posMaster`\n JOIN `bma_ehr_organization_demo`.`profile` ON ((`bma_ehr_organization_demo`.`posMaster`.`current_holderId` = `bma_ehr_organization_demo`.`profile`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgRoot` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgRootId` = `bma_ehr_organization_demo`.`orgRoot`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild1` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` = `bma_ehr_organization_demo`.`orgChild1`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild2` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` = `bma_ehr_organization_demo`.`orgChild2`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild3` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` = `bma_ehr_organization_demo`.`orgChild3`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild4` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` = `bma_ehr_organization_demo`.`orgChild4`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posLevel` ON ((`bma_ehr_organization_demo`.`profile`.`posLevelId` = `bma_ehr_organization_demo`.`posLevel`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posType` ON ((`bma_ehr_organization_demo`.`profile`.`posTypeId` = `bma_ehr_organization_demo`.`posType`.`id`)))"]); - await queryRunner.query(`CREATE VIEW \`view_director\` AS SELECT - \`bma_ehr_organization_demo\`.\`profile\`.\`id\` AS \`Id\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`prefix\` AS \`prefix\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`firstName\` AS \`firstName\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`lastName\` AS \`lastName\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`citizenId\` AS \`citizenId\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`position\` AS \`position\`, - CONCAT((CASE - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgRoot\`.\`orgRootShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgChild1\`.\`orgChild1ShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgChild2\`.\`orgChild2ShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgChild3\`.\`orgChild3ShortName\` - ELSE \`bma_ehr_organization_demo\`.\`orgChild4\`.\`orgChild4ShortName\` - END), - \`bma_ehr_organization_demo\`.\`posMaster\`.\`posMasterNo\`) AS \`posNo\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`isDirector\` AS \`isDirector\`, - \`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`, - \`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`, - NULL AS \`posExecutiveName\`, - \`bma_ehr_organization_demo\`.\`orgRoot\`.\`isDeputy\` AS \`isDeputy\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` AS \`orgChild1Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` AS \`orgChild2Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` AS \`orgChild3Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` AS \`orgChild4Id\`, - CONCAT(\`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`id\`) AS \`key\`, - NULL AS \`actFullNameId\`, - NULL AS \`actFullName\` - FROM - ((((((((\`bma_ehr_organization_demo\`.\`posMaster\` - JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgRoot\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` = \`bma_ehr_organization_demo\`.\`orgRoot\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild1\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` = \`bma_ehr_organization_demo\`.\`orgChild1\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild2\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` = \`bma_ehr_organization_demo\`.\`orgChild2\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild3\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` = \`bma_ehr_organization_demo\`.\`orgChild3\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild4\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` = \`bma_ehr_organization_demo\`.\`orgChild4\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`posLevel\` ON ((\`bma_ehr_organization_demo\`.\`profile\`.\`posLevelId\` = \`bma_ehr_organization_demo\`.\`posLevel\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`posType\` ON ((\`bma_ehr_organization_demo\`.\`profile\`.\`posTypeId\` = \`bma_ehr_organization_demo\`.\`posType\`.\`id\`)))`); - await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_director","SELECT \n `bma_ehr_organization_demo`.`profile`.`id` AS `Id`,\n `bma_ehr_organization_demo`.`profile`.`prefix` AS `prefix`,\n `bma_ehr_organization_demo`.`profile`.`firstName` AS `firstName`,\n `bma_ehr_organization_demo`.`profile`.`lastName` AS `lastName`,\n `bma_ehr_organization_demo`.`profile`.`citizenId` AS `citizenId`,\n `bma_ehr_organization_demo`.`profile`.`position` AS `position`,\n CONCAT((CASE\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgRoot`.`orgRootShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgChild1`.`orgChild1ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgChild2`.`orgChild2ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgChild3`.`orgChild3ShortName`\n ELSE `bma_ehr_organization_demo`.`orgChild4`.`orgChild4ShortName`\n END),\n `bma_ehr_organization_demo`.`posMaster`.`posMasterNo`) AS `posNo`,\n `bma_ehr_organization_demo`.`posMaster`.`isDirector` AS `isDirector`,\n `bma_ehr_organization_demo`.`posLevel`.`posLevelName` AS `posLevel`,\n `bma_ehr_organization_demo`.`posType`.`posTypeName` AS `posType`,\n NULL AS `posExecutiveName`,\n `bma_ehr_organization_demo`.`orgRoot`.`isDeputy` AS `isDeputy`,\n `bma_ehr_organization_demo`.`posMaster`.`orgRootId` AS `orgRootId`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` AS `orgChild1Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` AS `orgChild2Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` AS `orgChild3Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` AS `orgChild4Id`,\n CONCAT(`bma_ehr_organization_demo`.`posMaster`.`id`,\n `bma_ehr_organization_demo`.`profile`.`id`) AS `key`,\n NULL AS `actFullNameId`,\n NULL AS `actFullName`\n FROM\n ((((((((`bma_ehr_organization_demo`.`posMaster`\n JOIN `bma_ehr_organization_demo`.`profile` ON ((`bma_ehr_organization_demo`.`posMaster`.`current_holderId` = `bma_ehr_organization_demo`.`profile`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgRoot` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgRootId` = `bma_ehr_organization_demo`.`orgRoot`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild1` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` = `bma_ehr_organization_demo`.`orgChild1`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild2` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` = `bma_ehr_organization_demo`.`orgChild2`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild3` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` = `bma_ehr_organization_demo`.`orgChild3`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild4` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` = `bma_ehr_organization_demo`.`orgChild4`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posLevel` ON ((`bma_ehr_organization_demo`.`profile`.`posLevelId` = `bma_ehr_organization_demo`.`posLevel`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posType` ON ((`bma_ehr_organization_demo`.`profile`.`posTypeId` = `bma_ehr_organization_demo`.`posType`.`id`)))"]); - await queryRunner.query(`CREATE VIEW \`view_director_acting\` AS SELECT - \`profileChild\`.\`id\` AS \`Id\`, - \`profileChild\`.\`prefix\` AS \`prefix\`, - \`profileChild\`.\`firstName\` AS \`firstName\`, - \`profileChild\`.\`lastName\` AS \`lastName\`, - \`profileChild\`.\`citizenId\` AS \`citizenId\`, - \`profileChild\`.\`position\` AS \`position\`, - CONCAT((CASE - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` IS NULL) THEN \`orgRootChild\`.\`orgRootShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` IS NULL) THEN \`orgChild1Child\`.\`orgChild1ShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` IS NULL) THEN \`orgChild2Child\`.\`orgChild2ShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` IS NULL) THEN \`orgChild3Child\`.\`orgChild3ShortName\` - ELSE \`orgChild4Child\`.\`orgChild4ShortName\` - END), - \`bma_ehr_organization_demo\`.\`posMaster\`.\`posMasterNo\`) AS \`posNo\`, - \`posMasterChild\`.\`isDirector\` AS \`isDirectorChild\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`isDirector\` AS \`isDirector\`, - \`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`, - \`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`, - NULL AS \`posExecutiveName\`, - \`bma_ehr_organization_demo\`.\`orgRoot\`.\`isDeputy\` AS \`isDeputy\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` AS \`orgChild1Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` AS \`orgChild2Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` AS \`orgChild3Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` AS \`orgChild4Id\`, - CONCAT(\`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`, - \`profileChild\`.\`id\`) AS \`key\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`id\` AS \`actFullNameId\`, - CONCAT(\`bma_ehr_organization_demo\`.\`profile\`.\`prefix\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`firstName\`, - ' ', - \`bma_ehr_organization_demo\`.\`profile\`.\`lastName\`) AS \`actFullName\` - FROM - ((((((((((((\`bma_ehr_organization_demo\`.\`posMasterAct\` - JOIN \`bma_ehr_organization_demo\`.\`posMaster\` \`posMasterChild\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterChildId\` = \`posMasterChild\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`profile\` \`profileChild\` ON ((\`posMasterChild\`.\`current_holderId\` = \`profileChild\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgRoot\` \`orgRootChild\` ON ((\`posMasterChild\`.\`orgRootId\` = \`orgRootChild\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild1\` \`orgChild1Child\` ON ((\`posMasterChild\`.\`orgChild1Id\` = \`orgChild1Child\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild2\` \`orgChild2Child\` ON ((\`posMasterChild\`.\`orgChild2Id\` = \`orgChild2Child\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild3\` \`orgChild3Child\` ON ((\`posMasterChild\`.\`orgChild3Id\` = \`orgChild3Child\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild4\` \`orgChild4Child\` ON ((\`posMasterChild\`.\`orgChild4Id\` = \`orgChild4Child\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`posLevel\` ON ((\`profileChild\`.\`posLevelId\` = \`bma_ehr_organization_demo\`.\`posLevel\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`posType\` ON ((\`profileChild\`.\`posTypeId\` = \`bma_ehr_organization_demo\`.\`posType\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`posMaster\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterId\` = \`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgRoot\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` = \`bma_ehr_organization_demo\`.\`orgRoot\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`)))`); - await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_director_acting","SELECT \n `profileChild`.`id` AS `Id`,\n `profileChild`.`prefix` AS `prefix`,\n `profileChild`.`firstName` AS `firstName`,\n `profileChild`.`lastName` AS `lastName`,\n `profileChild`.`citizenId` AS `citizenId`,\n `profileChild`.`position` AS `position`,\n CONCAT((CASE\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` IS NULL) THEN `orgRootChild`.`orgRootShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` IS NULL) THEN `orgChild1Child`.`orgChild1ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` IS NULL) THEN `orgChild2Child`.`orgChild2ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` IS NULL) THEN `orgChild3Child`.`orgChild3ShortName`\n ELSE `orgChild4Child`.`orgChild4ShortName`\n END),\n `bma_ehr_organization_demo`.`posMaster`.`posMasterNo`) AS `posNo`,\n `posMasterChild`.`isDirector` AS `isDirectorChild`,\n `bma_ehr_organization_demo`.`posMaster`.`isDirector` AS `isDirector`,\n `bma_ehr_organization_demo`.`posLevel`.`posLevelName` AS `posLevel`,\n `bma_ehr_organization_demo`.`posType`.`posTypeName` AS `posType`,\n NULL AS `posExecutiveName`,\n `bma_ehr_organization_demo`.`orgRoot`.`isDeputy` AS `isDeputy`,\n `bma_ehr_organization_demo`.`posMaster`.`orgRootId` AS `orgRootId`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` AS `orgChild1Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` AS `orgChild2Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` AS `orgChild3Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` AS `orgChild4Id`,\n CONCAT(`bma_ehr_organization_demo`.`posMaster`.`id`,\n `profileChild`.`id`) AS `key`,\n `bma_ehr_organization_demo`.`profile`.`id` AS `actFullNameId`,\n CONCAT(`bma_ehr_organization_demo`.`profile`.`prefix`,\n `bma_ehr_organization_demo`.`profile`.`firstName`,\n ' ',\n `bma_ehr_organization_demo`.`profile`.`lastName`) AS `actFullName`\n FROM\n ((((((((((((`bma_ehr_organization_demo`.`posMasterAct`\n JOIN `bma_ehr_organization_demo`.`posMaster` `posMasterChild` ON ((`bma_ehr_organization_demo`.`posMasterAct`.`posMasterChildId` = `posMasterChild`.`id`)))\n JOIN `bma_ehr_organization_demo`.`profile` `profileChild` ON ((`posMasterChild`.`current_holderId` = `profileChild`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgRoot` `orgRootChild` ON ((`posMasterChild`.`orgRootId` = `orgRootChild`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild1` `orgChild1Child` ON ((`posMasterChild`.`orgChild1Id` = `orgChild1Child`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild2` `orgChild2Child` ON ((`posMasterChild`.`orgChild2Id` = `orgChild2Child`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild3` `orgChild3Child` ON ((`posMasterChild`.`orgChild3Id` = `orgChild3Child`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild4` `orgChild4Child` ON ((`posMasterChild`.`orgChild4Id` = `orgChild4Child`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posLevel` ON ((`profileChild`.`posLevelId` = `bma_ehr_organization_demo`.`posLevel`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posType` ON ((`profileChild`.`posTypeId` = `bma_ehr_organization_demo`.`posType`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posMaster` ON ((`bma_ehr_organization_demo`.`posMasterAct`.`posMasterId` = `bma_ehr_organization_demo`.`posMaster`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgRoot` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgRootId` = `bma_ehr_organization_demo`.`orgRoot`.`id`)))\n JOIN `bma_ehr_organization_demo`.`profile` ON ((`bma_ehr_organization_demo`.`posMaster`.`current_holderId` = `bma_ehr_organization_demo`.`profile`.`id`)))"]); - } - -} diff --git a/src/migration/1731319350256-update_table_profie_add_rolekeycloak2.ts b/src/migration/1731319350256-update_table_profie_add_rolekeycloak2.ts deleted file mode 100644 index a665e669..00000000 --- a/src/migration/1731319350256-update_table_profie_add_rolekeycloak2.ts +++ /dev/null @@ -1,136 +0,0 @@ -import { MigrationInterface, QueryRunner } from "typeorm"; - -export class UpdateTableProfieAddRolekeycloak21731319350256 implements MigrationInterface { - name = 'UpdateTableProfieAddRolekeycloak21731319350256' - - public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director","bma_ehr_organization_demo"]); - await queryRunner.query(`DROP VIEW \`view_director\``); - await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director_acting","bma_ehr_organization_demo"]); - await queryRunner.query(`DROP VIEW \`view_director_acting\``); - await queryRunner.query(`CREATE TABLE \`profile_employee_role_keycloaks_role_keycloak\` (\`profileEmployeeId\` varchar(36) NOT NULL, \`roleKeycloakId\` varchar(36) NOT NULL, INDEX \`IDX_c9ae1b82e09fc11b0d60c464d6\` (\`profileEmployeeId\`), INDEX \`IDX_08e8507d999f006695d8300104\` (\`roleKeycloakId\`), PRIMARY KEY (\`profileEmployeeId\`, \`roleKeycloakId\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`profile_employee_history_role_keycloaks_role_keycloak\` (\`profileEmployeeHistoryId\` varchar(36) NOT NULL, \`roleKeycloakId\` varchar(36) NOT NULL, INDEX \`IDX_1f7b9e3cc938ec88d88c6feb93\` (\`profileEmployeeHistoryId\`), INDEX \`IDX_3ec130b8cd68bbe5c28d0a2441\` (\`roleKeycloakId\`), PRIMARY KEY (\`profileEmployeeHistoryId\`, \`roleKeycloakId\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`profile_role_keycloaks_role_keycloak\` (\`profileId\` varchar(36) NOT NULL, \`roleKeycloakId\` varchar(36) NOT NULL, INDEX \`IDX_0b2ac4419b663f589d76569ae7\` (\`profileId\`), INDEX \`IDX_74825f66b686ca55adb0ebb18a\` (\`roleKeycloakId\`), PRIMARY KEY (\`profileId\`, \`roleKeycloakId\`)) ENGINE=InnoDB`); - await queryRunner.query(`CREATE TABLE \`profile_history_role_keycloaks_role_keycloak\` (\`profileHistoryId\` varchar(36) NOT NULL, \`roleKeycloakId\` varchar(36) NOT NULL, INDEX \`IDX_128a31820671a34001638e7d16\` (\`profileHistoryId\`), INDEX \`IDX_f2a24cce7f4d5f899f10d2ccdd\` (\`roleKeycloakId\`), PRIMARY KEY (\`profileHistoryId\`, \`roleKeycloakId\`)) ENGINE=InnoDB`); - await queryRunner.query(`ALTER TABLE \`profile_employee_role_keycloaks_role_keycloak\` ADD CONSTRAINT \`FK_c9ae1b82e09fc11b0d60c464d63\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE \`profile_employee_role_keycloaks_role_keycloak\` ADD CONSTRAINT \`FK_08e8507d999f006695d83001040\` FOREIGN KEY (\`roleKeycloakId\`) REFERENCES \`roleKeycloak\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`profile_employee_history_role_keycloaks_role_keycloak\` ADD CONSTRAINT \`FK_1f7b9e3cc938ec88d88c6feb939\` FOREIGN KEY (\`profileEmployeeHistoryId\`) REFERENCES \`profileEmployeeHistory\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE \`profile_employee_history_role_keycloaks_role_keycloak\` ADD CONSTRAINT \`FK_3ec130b8cd68bbe5c28d0a24411\` FOREIGN KEY (\`roleKeycloakId\`) REFERENCES \`roleKeycloak\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`profile_role_keycloaks_role_keycloak\` ADD CONSTRAINT \`FK_0b2ac4419b663f589d76569ae70\` FOREIGN KEY (\`profileId\`) REFERENCES \`profile\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE \`profile_role_keycloaks_role_keycloak\` ADD CONSTRAINT \`FK_74825f66b686ca55adb0ebb18a6\` FOREIGN KEY (\`roleKeycloakId\`) REFERENCES \`roleKeycloak\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - await queryRunner.query(`ALTER TABLE \`profile_history_role_keycloaks_role_keycloak\` ADD CONSTRAINT \`FK_128a31820671a34001638e7d16a\` FOREIGN KEY (\`profileHistoryId\`) REFERENCES \`profileHistory\`(\`id\`) ON DELETE CASCADE ON UPDATE CASCADE`); - await queryRunner.query(`ALTER TABLE \`profile_history_role_keycloaks_role_keycloak\` ADD CONSTRAINT \`FK_f2a24cce7f4d5f899f10d2ccdd9\` FOREIGN KEY (\`roleKeycloakId\`) REFERENCES \`roleKeycloak\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`); - } - - public async down(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`profile_history_role_keycloaks_role_keycloak\` DROP FOREIGN KEY \`FK_f2a24cce7f4d5f899f10d2ccdd9\``); - await queryRunner.query(`ALTER TABLE \`profile_history_role_keycloaks_role_keycloak\` DROP FOREIGN KEY \`FK_128a31820671a34001638e7d16a\``); - await queryRunner.query(`ALTER TABLE \`profile_role_keycloaks_role_keycloak\` DROP FOREIGN KEY \`FK_74825f66b686ca55adb0ebb18a6\``); - await queryRunner.query(`ALTER TABLE \`profile_role_keycloaks_role_keycloak\` DROP FOREIGN KEY \`FK_0b2ac4419b663f589d76569ae70\``); - await queryRunner.query(`ALTER TABLE \`profile_employee_history_role_keycloaks_role_keycloak\` DROP FOREIGN KEY \`FK_3ec130b8cd68bbe5c28d0a24411\``); - await queryRunner.query(`ALTER TABLE \`profile_employee_history_role_keycloaks_role_keycloak\` DROP FOREIGN KEY \`FK_1f7b9e3cc938ec88d88c6feb939\``); - await queryRunner.query(`ALTER TABLE \`profile_employee_role_keycloaks_role_keycloak\` DROP FOREIGN KEY \`FK_08e8507d999f006695d83001040\``); - await queryRunner.query(`ALTER TABLE \`profile_employee_role_keycloaks_role_keycloak\` DROP FOREIGN KEY \`FK_c9ae1b82e09fc11b0d60c464d63\``); - await queryRunner.query(`DROP INDEX \`IDX_f2a24cce7f4d5f899f10d2ccdd\` ON \`profile_history_role_keycloaks_role_keycloak\``); - await queryRunner.query(`DROP INDEX \`IDX_128a31820671a34001638e7d16\` ON \`profile_history_role_keycloaks_role_keycloak\``); - await queryRunner.query(`DROP TABLE \`profile_history_role_keycloaks_role_keycloak\``); - await queryRunner.query(`DROP INDEX \`IDX_74825f66b686ca55adb0ebb18a\` ON \`profile_role_keycloaks_role_keycloak\``); - await queryRunner.query(`DROP INDEX \`IDX_0b2ac4419b663f589d76569ae7\` ON \`profile_role_keycloaks_role_keycloak\``); - await queryRunner.query(`DROP TABLE \`profile_role_keycloaks_role_keycloak\``); - await queryRunner.query(`DROP INDEX \`IDX_3ec130b8cd68bbe5c28d0a2441\` ON \`profile_employee_history_role_keycloaks_role_keycloak\``); - await queryRunner.query(`DROP INDEX \`IDX_1f7b9e3cc938ec88d88c6feb93\` ON \`profile_employee_history_role_keycloaks_role_keycloak\``); - await queryRunner.query(`DROP TABLE \`profile_employee_history_role_keycloaks_role_keycloak\``); - await queryRunner.query(`DROP INDEX \`IDX_08e8507d999f006695d8300104\` ON \`profile_employee_role_keycloaks_role_keycloak\``); - await queryRunner.query(`DROP INDEX \`IDX_c9ae1b82e09fc11b0d60c464d6\` ON \`profile_employee_role_keycloaks_role_keycloak\``); - await queryRunner.query(`DROP TABLE \`profile_employee_role_keycloaks_role_keycloak\``); - await queryRunner.query(`CREATE VIEW \`view_director_acting\` AS SELECT - \`profileChild\`.\`id\` AS \`Id\`, - \`profileChild\`.\`prefix\` AS \`prefix\`, - \`profileChild\`.\`firstName\` AS \`firstName\`, - \`profileChild\`.\`lastName\` AS \`lastName\`, - \`profileChild\`.\`citizenId\` AS \`citizenId\`, - \`profileChild\`.\`position\` AS \`position\`, - CONCAT((CASE - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` IS NULL) THEN \`orgRootChild\`.\`orgRootShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` IS NULL) THEN \`orgChild1Child\`.\`orgChild1ShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` IS NULL) THEN \`orgChild2Child\`.\`orgChild2ShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` IS NULL) THEN \`orgChild3Child\`.\`orgChild3ShortName\` - ELSE \`orgChild4Child\`.\`orgChild4ShortName\` - END), - \`bma_ehr_organization_demo\`.\`posMaster\`.\`posMasterNo\`) AS \`posNo\`, - \`posMasterChild\`.\`isDirector\` AS \`isDirectorChild\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`isDirector\` AS \`isDirector\`, - \`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`, - \`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`, - NULL AS \`posExecutiveName\`, - \`bma_ehr_organization_demo\`.\`orgRoot\`.\`isDeputy\` AS \`isDeputy\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` AS \`orgChild1Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` AS \`orgChild2Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` AS \`orgChild3Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` AS \`orgChild4Id\`, - CONCAT(\`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`, - \`profileChild\`.\`id\`) AS \`key\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`id\` AS \`actFullNameId\`, - CONCAT(\`bma_ehr_organization_demo\`.\`profile\`.\`prefix\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`firstName\`, - ' ', - \`bma_ehr_organization_demo\`.\`profile\`.\`lastName\`) AS \`actFullName\` - FROM - ((((((((((((\`bma_ehr_organization_demo\`.\`posMasterAct\` - JOIN \`bma_ehr_organization_demo\`.\`posMaster\` \`posMasterChild\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterChildId\` = \`posMasterChild\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`profile\` \`profileChild\` ON ((\`posMasterChild\`.\`current_holderId\` = \`profileChild\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgRoot\` \`orgRootChild\` ON ((\`posMasterChild\`.\`orgRootId\` = \`orgRootChild\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild1\` \`orgChild1Child\` ON ((\`posMasterChild\`.\`orgChild1Id\` = \`orgChild1Child\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild2\` \`orgChild2Child\` ON ((\`posMasterChild\`.\`orgChild2Id\` = \`orgChild2Child\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild3\` \`orgChild3Child\` ON ((\`posMasterChild\`.\`orgChild3Id\` = \`orgChild3Child\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild4\` \`orgChild4Child\` ON ((\`posMasterChild\`.\`orgChild4Id\` = \`orgChild4Child\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`posLevel\` ON ((\`profileChild\`.\`posLevelId\` = \`bma_ehr_organization_demo\`.\`posLevel\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`posType\` ON ((\`profileChild\`.\`posTypeId\` = \`bma_ehr_organization_demo\`.\`posType\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`posMaster\` ON ((\`bma_ehr_organization_demo\`.\`posMasterAct\`.\`posMasterId\` = \`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgRoot\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` = \`bma_ehr_organization_demo\`.\`orgRoot\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`)))`); - await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_director_acting","SELECT \n `profileChild`.`id` AS `Id`,\n `profileChild`.`prefix` AS `prefix`,\n `profileChild`.`firstName` AS `firstName`,\n `profileChild`.`lastName` AS `lastName`,\n `profileChild`.`citizenId` AS `citizenId`,\n `profileChild`.`position` AS `position`,\n CONCAT((CASE\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` IS NULL) THEN `orgRootChild`.`orgRootShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` IS NULL) THEN `orgChild1Child`.`orgChild1ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` IS NULL) THEN `orgChild2Child`.`orgChild2ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` IS NULL) THEN `orgChild3Child`.`orgChild3ShortName`\n ELSE `orgChild4Child`.`orgChild4ShortName`\n END),\n `bma_ehr_organization_demo`.`posMaster`.`posMasterNo`) AS `posNo`,\n `posMasterChild`.`isDirector` AS `isDirectorChild`,\n `bma_ehr_organization_demo`.`posMaster`.`isDirector` AS `isDirector`,\n `bma_ehr_organization_demo`.`posLevel`.`posLevelName` AS `posLevel`,\n `bma_ehr_organization_demo`.`posType`.`posTypeName` AS `posType`,\n NULL AS `posExecutiveName`,\n `bma_ehr_organization_demo`.`orgRoot`.`isDeputy` AS `isDeputy`,\n `bma_ehr_organization_demo`.`posMaster`.`orgRootId` AS `orgRootId`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` AS `orgChild1Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` AS `orgChild2Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` AS `orgChild3Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` AS `orgChild4Id`,\n CONCAT(`bma_ehr_organization_demo`.`posMaster`.`id`,\n `profileChild`.`id`) AS `key`,\n `bma_ehr_organization_demo`.`profile`.`id` AS `actFullNameId`,\n CONCAT(`bma_ehr_organization_demo`.`profile`.`prefix`,\n `bma_ehr_organization_demo`.`profile`.`firstName`,\n ' ',\n `bma_ehr_organization_demo`.`profile`.`lastName`) AS `actFullName`\n FROM\n ((((((((((((`bma_ehr_organization_demo`.`posMasterAct`\n JOIN `bma_ehr_organization_demo`.`posMaster` `posMasterChild` ON ((`bma_ehr_organization_demo`.`posMasterAct`.`posMasterChildId` = `posMasterChild`.`id`)))\n JOIN `bma_ehr_organization_demo`.`profile` `profileChild` ON ((`posMasterChild`.`current_holderId` = `profileChild`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgRoot` `orgRootChild` ON ((`posMasterChild`.`orgRootId` = `orgRootChild`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild1` `orgChild1Child` ON ((`posMasterChild`.`orgChild1Id` = `orgChild1Child`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild2` `orgChild2Child` ON ((`posMasterChild`.`orgChild2Id` = `orgChild2Child`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild3` `orgChild3Child` ON ((`posMasterChild`.`orgChild3Id` = `orgChild3Child`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild4` `orgChild4Child` ON ((`posMasterChild`.`orgChild4Id` = `orgChild4Child`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posLevel` ON ((`profileChild`.`posLevelId` = `bma_ehr_organization_demo`.`posLevel`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posType` ON ((`profileChild`.`posTypeId` = `bma_ehr_organization_demo`.`posType`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posMaster` ON ((`bma_ehr_organization_demo`.`posMasterAct`.`posMasterId` = `bma_ehr_organization_demo`.`posMaster`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgRoot` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgRootId` = `bma_ehr_organization_demo`.`orgRoot`.`id`)))\n JOIN `bma_ehr_organization_demo`.`profile` ON ((`bma_ehr_organization_demo`.`posMaster`.`current_holderId` = `bma_ehr_organization_demo`.`profile`.`id`)))"]); - await queryRunner.query(`CREATE VIEW \`view_director\` AS SELECT - \`bma_ehr_organization_demo\`.\`profile\`.\`id\` AS \`Id\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`prefix\` AS \`prefix\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`firstName\` AS \`firstName\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`lastName\` AS \`lastName\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`citizenId\` AS \`citizenId\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`position\` AS \`position\`, - CONCAT((CASE - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgRoot\`.\`orgRootShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgChild1\`.\`orgChild1ShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgChild2\`.\`orgChild2ShortName\` - WHEN (\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` IS NULL) THEN \`bma_ehr_organization_demo\`.\`orgChild3\`.\`orgChild3ShortName\` - ELSE \`bma_ehr_organization_demo\`.\`orgChild4\`.\`orgChild4ShortName\` - END), - \`bma_ehr_organization_demo\`.\`posMaster\`.\`posMasterNo\`) AS \`posNo\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`isDirector\` AS \`isDirector\`, - \`bma_ehr_organization_demo\`.\`posLevel\`.\`posLevelName\` AS \`posLevel\`, - \`bma_ehr_organization_demo\`.\`posType\`.\`posTypeName\` AS \`posType\`, - NULL AS \`posExecutiveName\`, - \`bma_ehr_organization_demo\`.\`orgRoot\`.\`isDeputy\` AS \`isDeputy\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` AS \`orgRootId\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` AS \`orgChild1Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` AS \`orgChild2Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` AS \`orgChild3Id\`, - \`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` AS \`orgChild4Id\`, - CONCAT(\`bma_ehr_organization_demo\`.\`posMaster\`.\`id\`, - \`bma_ehr_organization_demo\`.\`profile\`.\`id\`) AS \`key\`, - NULL AS \`actFullNameId\`, - NULL AS \`actFullName\` - FROM - ((((((((\`bma_ehr_organization_demo\`.\`posMaster\` - JOIN \`bma_ehr_organization_demo\`.\`profile\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`current_holderId\` = \`bma_ehr_organization_demo\`.\`profile\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgRoot\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgRootId\` = \`bma_ehr_organization_demo\`.\`orgRoot\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild1\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild1Id\` = \`bma_ehr_organization_demo\`.\`orgChild1\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild2\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild2Id\` = \`bma_ehr_organization_demo\`.\`orgChild2\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild3\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild3Id\` = \`bma_ehr_organization_demo\`.\`orgChild3\`.\`id\`))) - LEFT JOIN \`bma_ehr_organization_demo\`.\`orgChild4\` ON ((\`bma_ehr_organization_demo\`.\`posMaster\`.\`orgChild4Id\` = \`bma_ehr_organization_demo\`.\`orgChild4\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`posLevel\` ON ((\`bma_ehr_organization_demo\`.\`profile\`.\`posLevelId\` = \`bma_ehr_organization_demo\`.\`posLevel\`.\`id\`))) - JOIN \`bma_ehr_organization_demo\`.\`posType\` ON ((\`bma_ehr_organization_demo\`.\`profile\`.\`posTypeId\` = \`bma_ehr_organization_demo\`.\`posType\`.\`id\`)))`); - await queryRunner.query(`INSERT INTO \`bma_ehr_organization_demo\`.\`typeorm_metadata\`(\`database\`, \`schema\`, \`table\`, \`type\`, \`name\`, \`value\`) VALUES (DEFAULT, ?, DEFAULT, ?, ?, ?)`, ["bma_ehr_organization_demo","VIEW","view_director","SELECT \n `bma_ehr_organization_demo`.`profile`.`id` AS `Id`,\n `bma_ehr_organization_demo`.`profile`.`prefix` AS `prefix`,\n `bma_ehr_organization_demo`.`profile`.`firstName` AS `firstName`,\n `bma_ehr_organization_demo`.`profile`.`lastName` AS `lastName`,\n `bma_ehr_organization_demo`.`profile`.`citizenId` AS `citizenId`,\n `bma_ehr_organization_demo`.`profile`.`position` AS `position`,\n CONCAT((CASE\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgRoot`.`orgRootShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgChild1`.`orgChild1ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgChild2`.`orgChild2ShortName`\n WHEN (`bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` IS NULL) THEN `bma_ehr_organization_demo`.`orgChild3`.`orgChild3ShortName`\n ELSE `bma_ehr_organization_demo`.`orgChild4`.`orgChild4ShortName`\n END),\n `bma_ehr_organization_demo`.`posMaster`.`posMasterNo`) AS `posNo`,\n `bma_ehr_organization_demo`.`posMaster`.`isDirector` AS `isDirector`,\n `bma_ehr_organization_demo`.`posLevel`.`posLevelName` AS `posLevel`,\n `bma_ehr_organization_demo`.`posType`.`posTypeName` AS `posType`,\n NULL AS `posExecutiveName`,\n `bma_ehr_organization_demo`.`orgRoot`.`isDeputy` AS `isDeputy`,\n `bma_ehr_organization_demo`.`posMaster`.`orgRootId` AS `orgRootId`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` AS `orgChild1Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` AS `orgChild2Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` AS `orgChild3Id`,\n `bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` AS `orgChild4Id`,\n CONCAT(`bma_ehr_organization_demo`.`posMaster`.`id`,\n `bma_ehr_organization_demo`.`profile`.`id`) AS `key`,\n NULL AS `actFullNameId`,\n NULL AS `actFullName`\n FROM\n ((((((((`bma_ehr_organization_demo`.`posMaster`\n JOIN `bma_ehr_organization_demo`.`profile` ON ((`bma_ehr_organization_demo`.`posMaster`.`current_holderId` = `bma_ehr_organization_demo`.`profile`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgRoot` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgRootId` = `bma_ehr_organization_demo`.`orgRoot`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild1` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild1Id` = `bma_ehr_organization_demo`.`orgChild1`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild2` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild2Id` = `bma_ehr_organization_demo`.`orgChild2`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild3` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild3Id` = `bma_ehr_organization_demo`.`orgChild3`.`id`)))\n LEFT JOIN `bma_ehr_organization_demo`.`orgChild4` ON ((`bma_ehr_organization_demo`.`posMaster`.`orgChild4Id` = `bma_ehr_organization_demo`.`orgChild4`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posLevel` ON ((`bma_ehr_organization_demo`.`profile`.`posLevelId` = `bma_ehr_organization_demo`.`posLevel`.`id`)))\n JOIN `bma_ehr_organization_demo`.`posType` ON ((`bma_ehr_organization_demo`.`profile`.`posTypeId` = `bma_ehr_organization_demo`.`posType`.`id`)))"]); - } - -} diff --git a/src/migration/1731316103019-update_table_profie_add_rolekeycloak1.ts b/src/migration/1731471323400-update_table_revision_add_islock.ts similarity index 93% rename from src/migration/1731316103019-update_table_profie_add_rolekeycloak1.ts rename to src/migration/1731471323400-update_table_revision_add_islock.ts index e2133f81..a0c20cbe 100644 --- a/src/migration/1731316103019-update_table_profie_add_rolekeycloak1.ts +++ b/src/migration/1731471323400-update_table_revision_add_islock.ts @@ -1,12 +1,10 @@ import { MigrationInterface, QueryRunner } from "typeorm"; -export class UpdateTableProfieAddRolekeycloak11731316103019 implements MigrationInterface { - name = 'UpdateTableProfieAddRolekeycloak11731316103019' +export class UpdateTableRevisionAddIslock1731471323400 implements MigrationInterface { + name = 'UpdateTableRevisionAddIslock1731471323400' public async up(queryRunner: QueryRunner): Promise { - await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` ADD \`isActive\` tinyint NOT NULL COMMENT 'สถานะการใช้งาน' DEFAULT 1`); - await queryRunner.query(`ALTER TABLE \`profile\` ADD \`isActive\` tinyint NOT NULL COMMENT 'สถานะการใช้งาน' DEFAULT 1`); - await queryRunner.query(`ALTER TABLE \`profileHistory\` ADD \`isActive\` tinyint NOT NULL COMMENT 'สถานะการใช้งาน' DEFAULT 1`); + await queryRunner.query(`ALTER TABLE \`orgRevision\` ADD \`isLock\` tinyint NOT NULL COMMENT 'สถานะเช็คโครงสร้างส่งคนไปออกคำสั่งหรือไม่' DEFAULT 0`); await queryRunner.query(`CREATE VIEW \`view_director\` AS SELECT \`profile\`.\`id\` AS \`Id\`, \`profile\`.\`prefix\` AS \`prefix\`, @@ -108,9 +106,7 @@ export class UpdateTableProfieAddRolekeycloak11731316103019 implements Migration await queryRunner.query(`DROP VIEW \`view_director_acting\``); await queryRunner.query(`DELETE FROM \`bma_ehr_organization_demo\`.\`typeorm_metadata\` WHERE \`type\` = ? AND \`name\` = ? AND \`schema\` = ?`, ["VIEW","view_director","bma_ehr_organization_demo"]); await queryRunner.query(`DROP VIEW \`view_director\``); - await queryRunner.query(`ALTER TABLE \`profileHistory\` DROP COLUMN \`isActive\``); - await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`isActive\``); - await queryRunner.query(`ALTER TABLE \`profileEmployeeHistory\` DROP COLUMN \`isActive\``); + await queryRunner.query(`ALTER TABLE \`orgRevision\` DROP COLUMN \`isLock\``); } } From c38eae7498e44164d497204118938ea65063dec9 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 13 Nov 2024 11:56:22 +0700 Subject: [PATCH 2/8] =?UTF-8?q?=E0=B8=AB=E0=B8=B2=20root?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/OrganizationController.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/controllers/OrganizationController.ts b/src/controllers/OrganizationController.ts index e1d78f9e..642bdee5 100644 --- a/src/controllers/OrganizationController.ts +++ b/src/controllers/OrganizationController.ts @@ -5520,6 +5520,27 @@ export class OrganizationController extends Controller { return new HttpSuccess(data.map((x) => x.id)); } + /** + * API หาสำนักทั้งหมด + * + * @summary หาสำนักทั้งหมด + * + */ + @Get("active/root/all") + async GetActiveRootAll() { + const orgRevisionActive = await this.orgRevisionRepository.findOne({ + where: { orgRevisionIsCurrent: true, orgRevisionIsDraft: false }, + }); + if (!orgRevisionActive) { + throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบโครงสร้างที่เผยแพร่อยู่ตอนนี้"); + } + + const data = await this.orgRootRepository.find({ + where: { orgRevisionId: orgRevisionActive.id }, + }); + return new HttpSuccess(data); + } + /** * API * From 174be3a53abde98ae4e77c9146c34237f6af75e3 Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 13 Nov 2024 13:31:41 +0700 Subject: [PATCH 3/8] fix --- src/controllers/CommandController.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 537236ce..dbe5c5db 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -3041,7 +3041,7 @@ export class CommandController extends Controller { const orgRevision = await this.orgRevisionRepo.findOne({ where: { id: posMasters[0].orgRevisionId } }); - if (orgRevision != null) { + if (orgRevision != null && orgRevision.isLock == false) { await this.orgRevisionRepo.update(orgRevision.id, { isLock: true, }); @@ -3547,7 +3547,8 @@ export class CommandController extends Controller { where: { id: revisionId }, relations: ["posMasters"] }); - if (orgRevision != null && !orgRevision?.posMasters.filter(x => x.statusReport === "REPORT") + if (orgRevision != null && !["REPORT"].includes( + orgRevision.posMasters.find(x => x.statusReport === "REPORT")?.statusReport || "") ) { await this.orgRevisionRepo.update(orgRevision.id, { isLock: false, From f953ba6d270bd7e50cb4e5d3b9cbf7cb25660f7d Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 13 Nov 2024 14:47:27 +0700 Subject: [PATCH 4/8] =?UTF-8?q?fix=20=E0=B8=AA=E0=B9=88=E0=B8=A7=E0=B8=99?= =?UTF-8?q?=E0=B8=A3=E0=B8=B2=E0=B8=8A=E0=B8=81=E0=B8=B2=E0=B8=A3=E0=B8=A0?= =?UTF-8?q?=E0=B8=B2=E0=B8=A2=E0=B9=83=E0=B8=95=E0=B9=89=E0=B8=AB=E0=B8=99?= =?UTF-8?q?=E0=B9=88=E0=B8=A7=E0=B8=A2=E0=B8=87=E0=B8=B2=E0=B8=99=E0=B9=84?= =?UTF-8?q?=E0=B8=A1=E0=B9=88=E0=B9=81=E0=B8=AA=E0=B8=94=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/controllers/ProfileController.ts | 23 +++++++++++++++- src/controllers/ProfileEmployeeController.ts | 19 ++++++++++++- .../ProfileEmployeeTempController.ts | 27 +++++++++++++++++-- 3 files changed, 65 insertions(+), 4 deletions(-) diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 38634422..83559285 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -4428,6 +4428,10 @@ export class ProfileController extends Controller { "posType", "current_holders", "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", "profileSalary", ], order: { @@ -4444,6 +4448,10 @@ export class ProfileController extends Controller { "posType", "current_holders", "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", "profileSalary", ], order: { @@ -5287,6 +5295,10 @@ export class ProfileController extends Controller { "posType", "current_holders", "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", "profileSalary", "profileEducations", ], @@ -7000,7 +7012,16 @@ export class ProfileController extends Controller { ) { const profile = await this.profileRepo.findOne({ where: { keycloak: request.user.sub }, - relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"], + relations: [ + "posLevel", + "posType", + "current_holders", + "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", + ], }); if (!profile) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); diff --git a/src/controllers/ProfileEmployeeController.ts b/src/controllers/ProfileEmployeeController.ts index 97b21044..20014907 100644 --- a/src/controllers/ProfileEmployeeController.ts +++ b/src/controllers/ProfileEmployeeController.ts @@ -1856,6 +1856,10 @@ export class ProfileEmployeeController extends Controller { "posType", "current_holders", "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", "profileSalary", ], order: { @@ -2983,7 +2987,16 @@ export class ProfileEmployeeController extends Controller { ) { const profile = await this.profileRepo.findOne({ where: { keycloak: request.user.sub }, - relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"], + relations: [ + "posLevel", + "posType", + "current_holders", + "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", + ], }); if (!profile) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); @@ -3838,6 +3851,10 @@ export class ProfileEmployeeController extends Controller { "posType", "current_holders", "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", "profileSalary", "profileEducations" ], diff --git a/src/controllers/ProfileEmployeeTempController.ts b/src/controllers/ProfileEmployeeTempController.ts index a676e793..2ad44993 100644 --- a/src/controllers/ProfileEmployeeTempController.ts +++ b/src/controllers/ProfileEmployeeTempController.ts @@ -1563,6 +1563,10 @@ export class ProfileEmployeeTempController extends Controller { "posType", "current_holders", "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", "profileSalary", ], order: { @@ -2614,7 +2618,16 @@ export class ProfileEmployeeTempController extends Controller { ) { const profile = await this.profileRepo.findOne({ where: { keycloak: request.user.sub }, - relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"], + relations: [ + "posLevel", + "posType", + "current_holders", + "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", + ], }); if (!profile) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); @@ -3431,7 +3444,17 @@ export class ProfileEmployeeTempController extends Controller { // await new permission().PermissionGet(req, "SYS_REGISTRY_TEMP");//ไม่แน่ใจTEMPปิดไว้ก่อน const profile = await this.profileRepo.findOne({ where: { id: id }, - relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot", "profileEducations"], + relations: [ + "posLevel", + "posType", + "current_holders", + "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", + "profileEducations" + ], order: { profileEducations: { createdAt: "DESC" From a354fe74fe6d52b98ed5b523f9bb0a79f5ee8000 Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 13 Nov 2024 15:59:08 +0700 Subject: [PATCH 5/8] bug create user --- src/controllers/UserController.ts | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/src/controllers/UserController.ts b/src/controllers/UserController.ts index 8fd455e4..aa1a902b 100644 --- a/src/controllers/UserController.ts +++ b/src/controllers/UserController.ts @@ -143,10 +143,6 @@ export class KeycloakController extends Controller { // }); // io.getInstance()?.emit("FolderCreate", folderData); - const _roles = { - role: body.roles || [], - }; - const addRole = await this.addRole(userId, _roles); const profile = await this.profileRepo.findOne({ where: { @@ -157,6 +153,21 @@ export class KeycloakController extends Controller { if (profile) { profile.keycloak = userId; await this.profileRepo.save(profile); + if (body.roles != null && body.roles.length > 0) { + const roleKeycloak = await this.roleKeycloakRepo.find({ + where: { id: In(body.roles) }, + }); + const _profile = await this.profileRepo.findOne({ + where: { keycloak: userId }, + relations: ["roleKeycloaks"], + }); + if (_profile) { + _profile.roleKeycloaks = Array.from( + new Set([..._profile.roleKeycloaks, ...roleKeycloak]), + ); + this.profileRepo.save(_profile); + } + } } return userId; } @@ -183,7 +194,6 @@ export class KeycloakController extends Controller { // const _rolesUpdate = { // role: body.roles || [], // }; - // const addRole = await this.addRole(userId, _rolesUpdate); return chkUpdate; } @@ -498,13 +508,14 @@ export class KeycloakController extends Controller { const result = await createGroup(body.name); if (!result) throw new Error("Failed. Cannot create group."); } - + @Post("log/sso") async addLogSSO( @Request() req: RequestWithUser, - @Body() body: { - text: string, - } + @Body() + body: { + text: string; + }, ) { try { addLogSequence(req, { From 04928bb83a7f927410142eb5858cc7a51133fd5d Mon Sep 17 00:00:00 2001 From: kittapath Date: Wed, 13 Nov 2024 16:07:37 +0700 Subject: [PATCH 6/8] no message --- src/controllers/UserController.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/controllers/UserController.ts b/src/controllers/UserController.ts index aa1a902b..43c04b32 100644 --- a/src/controllers/UserController.ts +++ b/src/controllers/UserController.ts @@ -151,7 +151,9 @@ export class KeycloakController extends Controller { }); if (profile) { + let _null: any = null; profile.keycloak = userId; + profile.email = body.email == null ? _null : body.email; await this.profileRepo.save(profile); if (body.roles != null && body.roles.length > 0) { const roleKeycloak = await this.roleKeycloakRepo.find({ From eab9b79aa747071956ef77484851c37587718c5c Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 13 Nov 2024 17:04:28 +0700 Subject: [PATCH 7/8] no message --- src/controllers/CommandController.ts | 4 ++-- src/controllers/ProfileController.ts | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index dbe5c5db..d02a4945 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -876,9 +876,9 @@ export class CommandController extends Controller { } /** - * API ลบรายการคำสั่ง + * API ลบรายการคำสั่งถาวร * - * @summary API ลบรายการคำสั่ง + * @summary API ลบรายการคำสั่งถาวร * * @param {string} id Id คำสั่ง */ diff --git a/src/controllers/ProfileController.ts b/src/controllers/ProfileController.ts index 83559285..b6a2ed64 100644 --- a/src/controllers/ProfileController.ts +++ b/src/controllers/ProfileController.ts @@ -5684,7 +5684,16 @@ export class ProfileController extends Controller { //await new permission().PermissionOrgUserGet(request, "SYS_REGISTRY_OFFICER", id); //ไม่แน่ใจOFFปิดไว้ก่อน const profile = await this.profileEmpRepo.findOne({ where: { id: id }, - relations: ["posLevel", "posType", "current_holders", "current_holders.orgRoot"], + relations: [ + "posLevel", + "posType", + "current_holders", + "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", + ], }); if (!profile) { throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูลบุคคลนี้ในระบบ"); From 9a0348dadad2665c2b77bfc069951371b7d4ab8f Mon Sep 17 00:00:00 2001 From: Bright Date: Wed, 13 Nov 2024 18:39:16 +0700 Subject: [PATCH 8/8] fix issue #679 --- src/controllers/CommandController.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index d02a4945..1c921ae4 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -2561,7 +2561,17 @@ export class CommandController extends Controller { await Promise.all( body.data.map(async (item) => { const profile = await this.profileRepository.findOne({ - relations: ["profileSalary","posType","posLevel"], + relations: [ + "profileSalary", + "posType", + "posLevel", + "current_holders", + "current_holders.orgRoot", + "current_holders.orgChild1", + "current_holders.orgChild2", + "current_holders.orgChild3", + "current_holders.orgChild4", + ], where: { id: item.profileId }, order: { profileSalary: {