Merge branch 'develop' of github.com:Frappet/bma-ehr-organization into develop
This commit is contained in:
commit
53621bbef1
4 changed files with 84 additions and 14 deletions
|
|
@ -712,7 +712,15 @@ export class PositionController extends Controller {
|
||||||
const [posMaster, total] = await this.posMasterRepository.findAndCount({
|
const [posMaster, total] = await this.posMasterRepository.findAndCount({
|
||||||
where: keywordConditions,
|
where: keywordConditions,
|
||||||
order: { posMasterOrder: "ASC" },
|
order: { posMasterOrder: "ASC" },
|
||||||
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3", "orgChild4"],
|
relations: [
|
||||||
|
"orgRoot",
|
||||||
|
"orgChild1",
|
||||||
|
"orgChild2",
|
||||||
|
"orgChild3",
|
||||||
|
"orgChild4",
|
||||||
|
"current_holder",
|
||||||
|
"next_holder",
|
||||||
|
],
|
||||||
skip: (body.page - 1) * body.pageSize,
|
skip: (body.page - 1) * body.pageSize,
|
||||||
take: body.pageSize,
|
take: body.pageSize,
|
||||||
});
|
});
|
||||||
|
|
@ -736,6 +744,16 @@ export class PositionController extends Controller {
|
||||||
posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
posMasterNoPrefix: posMaster.posMasterNoPrefix,
|
||||||
posMasterNo: posMaster.posMasterNo,
|
posMasterNo: posMaster.posMasterNo,
|
||||||
posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
posMasterNoSuffix: posMaster.posMasterNoSuffix,
|
||||||
|
fullNameNextHolder:
|
||||||
|
posMaster.current_holder.prefix +
|
||||||
|
posMaster.current_holder.firstName +
|
||||||
|
" " +
|
||||||
|
posMaster.current_holder.lastName,
|
||||||
|
fullNameCurrentHolder:
|
||||||
|
posMaster.next_holder.prefix +
|
||||||
|
posMaster.next_holder.firstName +
|
||||||
|
" " +
|
||||||
|
posMaster.next_holder.lastName,
|
||||||
orgShortname:
|
orgShortname:
|
||||||
body.type === 0
|
body.type === 0
|
||||||
? posMaster.orgRoot.orgRootShortName
|
? posMaster.orgRoot.orgRootShortName
|
||||||
|
|
|
||||||
|
|
@ -137,15 +137,13 @@ export class PosMaster extends EntityBase {
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
profileIdNextHolder: string;
|
profileIdNextHolder: string;
|
||||||
|
|
||||||
@Column({
|
@Column({
|
||||||
length: 40,
|
length: 40,
|
||||||
comment: "คีย์นอก(FK)ของตาราง orgRevision",
|
comment: "คีย์นอก(FK)ของตาราง orgRevision",
|
||||||
})
|
})
|
||||||
orgRevisionId: string; //fk
|
orgRevisionId: string; //fk
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.posMasters)
|
@ManyToOne(() => OrgRevision, (orgRevision) => orgRevision.posMasters)
|
||||||
@JoinColumn({ name: "orgRevisionId" })
|
@JoinColumn({ name: "orgRevisionId" })
|
||||||
orgRevision: OrgRevision;
|
orgRevision: OrgRevision;
|
||||||
|
|
@ -170,12 +168,12 @@ export class PosMaster extends EntityBase {
|
||||||
@JoinColumn({ name: "orgChild4Id" })
|
@JoinColumn({ name: "orgChild4Id" })
|
||||||
orgChild4: OrgChild4;
|
orgChild4: OrgChild4;
|
||||||
|
|
||||||
@ManyToOne(() => Profile, (profile) => profile.posMasters)
|
@OneToOne(() => Profile)
|
||||||
@JoinColumn({ name: "profileIdCurrentHolder" })
|
@JoinColumn()
|
||||||
profile: Profile;
|
current_holder: Profile;
|
||||||
|
|
||||||
@ManyToOne(() => Profile, (profile) => profile.next_holder_posMasters)
|
@OneToOne(() => Profile)
|
||||||
@JoinColumn({ name: "profileIdNextHolder" })
|
@JoinColumn()
|
||||||
next_holder: Profile;
|
next_holder: Profile;
|
||||||
|
|
||||||
@OneToMany(() => Position, (position) => position.posMaster)
|
@OneToMany(() => Position, (position) => position.posMaster)
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
import { Entity, Column, OneToMany} from "typeorm";
|
import { Entity, Column, OneToMany, OneToOne, JoinColumn} from "typeorm";
|
||||||
import { EntityBase } from "./base/Base";
|
import { EntityBase } from "./base/Base";
|
||||||
import { PosMaster } from "./PosMaster";
|
import { PosMaster } from "./PosMaster";
|
||||||
|
|
||||||
|
|
@ -36,11 +36,13 @@ export class Profile extends EntityBase {
|
||||||
})
|
})
|
||||||
citizenId: string;
|
citizenId: string;
|
||||||
|
|
||||||
@OneToMany(() => PosMaster, (posMaster) => posMaster.profile)
|
@OneToOne(() => PosMaster)
|
||||||
posMasters: PosMaster[];
|
@JoinColumn()
|
||||||
|
current_holder: PosMaster;
|
||||||
|
|
||||||
@OneToMany(() => PosMaster, (posMaster) => posMaster.next_holder)
|
@OneToOne(() => PosMaster)
|
||||||
next_holder_posMasters: PosMaster[];
|
@JoinColumn()
|
||||||
|
next_holder: PosMaster;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CreateProfile {
|
export class CreateProfile {
|
||||||
|
|
|
||||||
52
src/migration/1707194386583-add_table_profile1.ts
Normal file
52
src/migration/1707194386583-add_table_profile1.ts
Normal file
|
|
@ -0,0 +1,52 @@
|
||||||
|
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||||
|
|
||||||
|
export class AddTableProfile11707194386583 implements MigrationInterface {
|
||||||
|
name = 'AddTableProfile11707194386583'
|
||||||
|
|
||||||
|
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` DROP FOREIGN KEY \`FK_1acc4ba5b4af308f0d8a1b7b249\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` DROP FOREIGN KEY \`FK_9d29f52dcf499db3a5e8209b6dc\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`currentHolderId\` varchar(36) NULL`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` ADD UNIQUE INDEX \`IDX_b5bfc34771c02a8078b9bf8944\` (\`currentHolderId\`)`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`nextHolderId\` varchar(36) NULL`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` ADD UNIQUE INDEX \`IDX_49d2dcf6c8bd789ca99df7dc0d\` (\`nextHolderId\`)`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` ADD \`currentHolderId\` varchar(36) NULL`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` ADD UNIQUE INDEX \`IDX_dca00872043f09a74af1d5172f\` (\`currentHolderId\`)`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` ADD \`nextHolderId\` varchar(36) NULL`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` ADD UNIQUE INDEX \`IDX_d15696d0e541ead772db817b36\` (\`nextHolderId\`)`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`citizenId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`citizenId\` varchar(13) NULL COMMENT 'เลขประจำตัวประชาชน'`);
|
||||||
|
await queryRunner.query(`CREATE UNIQUE INDEX \`REL_b5bfc34771c02a8078b9bf8944\` ON \`profile\` (\`currentHolderId\`)`);
|
||||||
|
await queryRunner.query(`CREATE UNIQUE INDEX \`REL_49d2dcf6c8bd789ca99df7dc0d\` ON \`profile\` (\`nextHolderId\`)`);
|
||||||
|
await queryRunner.query(`CREATE UNIQUE INDEX \`REL_dca00872043f09a74af1d5172f\` ON \`posMaster\` (\`currentHolderId\`)`);
|
||||||
|
await queryRunner.query(`CREATE UNIQUE INDEX \`REL_d15696d0e541ead772db817b36\` ON \`posMaster\` (\`nextHolderId\`)`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` ADD CONSTRAINT \`FK_b5bfc34771c02a8078b9bf89445\` FOREIGN KEY (\`currentHolderId\`) REFERENCES \`posMaster\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` ADD CONSTRAINT \`FK_49d2dcf6c8bd789ca99df7dc0d4\` FOREIGN KEY (\`nextHolderId\`) REFERENCES \`posMaster\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` ADD CONSTRAINT \`FK_dca00872043f09a74af1d5172f3\` FOREIGN KEY (\`currentHolderId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` ADD CONSTRAINT \`FK_d15696d0e541ead772db817b36a\` FOREIGN KEY (\`nextHolderId\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` DROP FOREIGN KEY \`FK_d15696d0e541ead772db817b36a\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` DROP FOREIGN KEY \`FK_dca00872043f09a74af1d5172f3\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` DROP FOREIGN KEY \`FK_49d2dcf6c8bd789ca99df7dc0d4\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` DROP FOREIGN KEY \`FK_b5bfc34771c02a8078b9bf89445\``);
|
||||||
|
await queryRunner.query(`DROP INDEX \`REL_d15696d0e541ead772db817b36\` ON \`posMaster\``);
|
||||||
|
await queryRunner.query(`DROP INDEX \`REL_dca00872043f09a74af1d5172f\` ON \`posMaster\``);
|
||||||
|
await queryRunner.query(`DROP INDEX \`REL_49d2dcf6c8bd789ca99df7dc0d\` ON \`profile\``);
|
||||||
|
await queryRunner.query(`DROP INDEX \`REL_b5bfc34771c02a8078b9bf8944\` ON \`profile\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`citizenId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` ADD \`citizenId\` int NULL COMMENT 'เลขประจำตัวประชาชน'`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` DROP INDEX \`IDX_d15696d0e541ead772db817b36\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` DROP COLUMN \`nextHolderId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` DROP INDEX \`IDX_dca00872043f09a74af1d5172f\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` DROP COLUMN \`currentHolderId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` DROP INDEX \`IDX_49d2dcf6c8bd789ca99df7dc0d\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`nextHolderId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` DROP INDEX \`IDX_b5bfc34771c02a8078b9bf8944\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`profile\` DROP COLUMN \`currentHolderId\``);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` ADD CONSTRAINT \`FK_9d29f52dcf499db3a5e8209b6dc\` FOREIGN KEY (\`profileIdNextHolder\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
await queryRunner.query(`ALTER TABLE \`posMaster\` ADD CONSTRAINT \`FK_1acc4ba5b4af308f0d8a1b7b249\` FOREIGN KEY (\`profileIdCurrentHolder\`) REFERENCES \`profile\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue