This commit is contained in:
Kittapath 2024-05-13 15:38:56 +07:00
parent a9f0458f1b
commit 9a7adc4eb5
2 changed files with 37 additions and 5 deletions

View file

@ -256,12 +256,12 @@ export class ProfileEmployeeController extends Controller {
: "1=1",
)
.andWhere(
type !== undefined && type !== null && type !== ""
? "profileEmployee.employeeClass LIKE :type"
type !== undefined && type !== null && type !== ""
? "profileEmployee.employeeClass LIKE :type"
: "1=1",
{
type: `%${type}%`,
}
type: type == null || type == undefined ? null : `${type.trim().toUpperCase()}`,
},
)
.skip((page - 1) * pageSize)
.take(pageSize)
@ -296,7 +296,7 @@ export class ProfileEmployeeController extends Controller {
posTypeId: _data.posType == null ? null : _data.posType.id,
position: _data.position,
posNo: shortName,
employeeClass: _data.employeeClass == null ? null : _data.employeeClass
employeeClass: _data.employeeClass == null ? null : _data.employeeClass,
};
}),
);

View file

@ -0,0 +1,32 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableProfileemployeeAddPk1715589320290 implements MigrationInterface {
name = 'UpdateTableProfileemployeeAddPk1715589320290'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileCertificate\` ADD \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee'`);
await queryRunner.query(`ALTER TABLE \`profileTraining\` ADD \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee'`);
await queryRunner.query(`ALTER TABLE \`profileInsignia\` ADD \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee'`);
await queryRunner.query(`ALTER TABLE \`profileHonor\` ADD \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee'`);
await queryRunner.query(`ALTER TABLE \`profileAssessment\` ADD \`profileEmployeeId\` varchar(40) NULL COMMENT 'คีย์นอก(FK)ของตาราง ProfileEmployee'`);
await queryRunner.query(`ALTER TABLE \`profileCertificate\` ADD CONSTRAINT \`FK_7ae014c31077ea18d731735ec2a\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`profileTraining\` ADD CONSTRAINT \`FK_888dd3a5637446912458a7e17ca\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`profileInsignia\` ADD CONSTRAINT \`FK_a1652104fa8e8d9c3231bf32dfe\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`profileHonor\` ADD CONSTRAINT \`FK_d5f2346dd8ccebf9a26178ed9b3\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
await queryRunner.query(`ALTER TABLE \`profileAssessment\` ADD CONSTRAINT \`FK_47feb44a370ff188acb938c7bca\` FOREIGN KEY (\`profileEmployeeId\`) REFERENCES \`profileEmployee\`(\`id\`) ON DELETE NO ACTION ON UPDATE NO ACTION`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`profileAssessment\` DROP FOREIGN KEY \`FK_47feb44a370ff188acb938c7bca\``);
await queryRunner.query(`ALTER TABLE \`profileHonor\` DROP FOREIGN KEY \`FK_d5f2346dd8ccebf9a26178ed9b3\``);
await queryRunner.query(`ALTER TABLE \`profileInsignia\` DROP FOREIGN KEY \`FK_a1652104fa8e8d9c3231bf32dfe\``);
await queryRunner.query(`ALTER TABLE \`profileTraining\` DROP FOREIGN KEY \`FK_888dd3a5637446912458a7e17ca\``);
await queryRunner.query(`ALTER TABLE \`profileCertificate\` DROP FOREIGN KEY \`FK_7ae014c31077ea18d731735ec2a\``);
await queryRunner.query(`ALTER TABLE \`profileAssessment\` DROP COLUMN \`profileEmployeeId\``);
await queryRunner.query(`ALTER TABLE \`profileHonor\` DROP COLUMN \`profileEmployeeId\``);
await queryRunner.query(`ALTER TABLE \`profileInsignia\` DROP COLUMN \`profileEmployeeId\``);
await queryRunner.query(`ALTER TABLE \`profileTraining\` DROP COLUMN \`profileEmployeeId\``);
await queryRunner.query(`ALTER TABLE \`profileCertificate\` DROP COLUMN \`profileEmployeeId\``);
}
}