From 5fc5b1bb0658fefc28f09d4f2fc8fe3270f616be Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 13 Mar 2024 11:25:07 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=81=E0=B8=81=E0=B9=89=E0=B8=8A=E0=B8=B7?= =?UTF-8?q?=E0=B9=88=E0=B8=AD=E0=B8=9F=E0=B8=B4=E0=B8=A7=E0=B8=9C=E0=B8=B1?= =?UTF-8?q?=E0=B8=87=E0=B9=80=E0=B8=87=E0=B8=B4=E0=B8=99=E0=B9=80=E0=B8=94?= =?UTF-8?q?=E0=B8=B7=E0=B8=AD=E0=B8=99=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88?= =?UTF-8?q?=E0=B9=89=E0=B8=B2=E0=B8=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SalaryRankEmployeeController.ts | 4 ++-- src/entities/SalaryEmployees.ts | 14 ++++++------- src/entities/SalaryRankEmployees.ts | 9 ++++----- src/entities/SalaryRanks.ts | 2 +- src/entities/Salarys.ts | 2 +- ...-update_type_step_table_SalaryEmployees.ts | 20 +++++++++++++++++++ ...update_type_step_table_SalaryEmployees1.ts | 14 +++++++++++++ 7 files changed, 48 insertions(+), 17 deletions(-) create mode 100644 src/migration/1710302516943-update_type_step_table_SalaryEmployees.ts create mode 100644 src/migration/1710302798280-update_type_step_table_SalaryEmployees1.ts diff --git a/src/controllers/SalaryRankEmployeeController.ts b/src/controllers/SalaryRankEmployeeController.ts index 6cfa146..829bfd7 100644 --- a/src/controllers/SalaryRankEmployeeController.ts +++ b/src/controllers/SalaryRankEmployeeController.ts @@ -127,7 +127,7 @@ export class SalaryRankEmployeesController extends Controller { where: { salaryEmployeeId: id, }, - select: ["id", "step", "salaryMounth", "salaryDay"], + select: ["id", "step", "salaryMonth", "salaryDay"], order: { step: "ASC", }, @@ -137,7 +137,7 @@ export class SalaryRankEmployeesController extends Controller { const filteredSalaryRankEmployee = salaryRankEmployee.filter( (x) => x.step?.toString().includes(keyword) || - x.salaryMounth?.toString().includes(keyword) || + x.salaryMonth?.toString().includes(keyword) || x.salaryDay?.toString().includes(keyword), ); const slicedData = filteredSalaryRankEmployee.slice((page - 1) * pageSize, page * pageSize); diff --git a/src/entities/SalaryEmployees.ts b/src/entities/SalaryEmployees.ts index 1bfa7db..7e0bd1a 100644 --- a/src/entities/SalaryEmployees.ts +++ b/src/entities/SalaryEmployees.ts @@ -1,8 +1,5 @@ -import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm"; +import { Entity, Column, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; -import { SalaryRanks } from "./SalaryRanks"; -import { PosType } from "./PosType"; -import { PosLevel } from "./PosLevel"; import { SalaryRankEmployees } from "./SalaryRankEmployees"; @Entity("salaryEmployees") @@ -14,10 +11,11 @@ export class SalaryEmployees extends EntityBase { name: string; @Column({ - length: 40, + nullable: true, comment: "กลุ่มบัญชีการจ้าง", + default: null, }) - group: string; + group: number; @Column({ comment: "สถานะการใช้งาน", @@ -68,7 +66,7 @@ export class CreateSalaryEmployee { name: string; @Column() - group: string; + group: number; @Column() isActive: boolean; @@ -91,7 +89,7 @@ export class UpdateSalaryEmployee { name: string; @Column() - group: string; + group: number; @Column() isActive: boolean; diff --git a/src/entities/SalaryRankEmployees.ts b/src/entities/SalaryRankEmployees.ts index d51c68e..0dbdcd0 100644 --- a/src/entities/SalaryRankEmployees.ts +++ b/src/entities/SalaryRankEmployees.ts @@ -1,6 +1,5 @@ -import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm"; +import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; -import { Salarys } from "./Salarys"; import { SalaryEmployees } from "./SalaryEmployees"; @Entity("salaryRankEmployees") @@ -23,7 +22,7 @@ export class SalaryRankEmployees extends EntityBase { comment: "ค่าจ้างรายเดือน", default: null, }) - salaryMounth: number | null; + salaryMonth: number | null; @Column({ nullable: true, @@ -46,7 +45,7 @@ export class CreateSalaryRankEmployee { step: number; @Column() - salaryMounth?: number | null; + salaryMonth?: number | null; @Column() salaryDay?: number | null; @@ -57,7 +56,7 @@ export class UpdateSalaryRankEmployee { step: number; @Column() - salaryMounth?: number | null; + salaryMonth?: number | null; @Column() salaryDay?: number | null; diff --git a/src/entities/SalaryRanks.ts b/src/entities/SalaryRanks.ts index 41998fa..f8ae6ed 100644 --- a/src/entities/SalaryRanks.ts +++ b/src/entities/SalaryRanks.ts @@ -1,4 +1,4 @@ -import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm"; +import { Entity, Column, ManyToOne, JoinColumn } from "typeorm"; import { EntityBase } from "./base/Base"; import { Salarys } from "./Salarys"; diff --git a/src/entities/Salarys.ts b/src/entities/Salarys.ts index b8a3588..c1bb48f 100644 --- a/src/entities/Salarys.ts +++ b/src/entities/Salarys.ts @@ -1,4 +1,4 @@ -import { Entity, Column, ManyToOne, JoinColumn, OneToOne, OneToMany } from "typeorm"; +import { Entity, Column, ManyToOne, JoinColumn, OneToMany } from "typeorm"; import { EntityBase } from "./base/Base"; import { SalaryRanks } from "./SalaryRanks"; import { PosType } from "./PosType"; diff --git a/src/migration/1710302516943-update_type_step_table_SalaryEmployees.ts b/src/migration/1710302516943-update_type_step_table_SalaryEmployees.ts new file mode 100644 index 0000000..1f280d6 --- /dev/null +++ b/src/migration/1710302516943-update_type_step_table_SalaryEmployees.ts @@ -0,0 +1,20 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTypeStepTableSalaryEmployees1710302516943 implements MigrationInterface { + name = 'UpdateTypeStepTableSalaryEmployees1710302516943' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`salaryEmployees\` CHANGE \`group\` \`step\` varchar(40) NOT NULL COMMENT 'กลุ่มบัญชีการจ้าง'`); + await queryRunner.query(`ALTER TABLE \`salaryRankEmployees\` CHANGE \`salaryMounth\` \`salaryMonth\` double NULL COMMENT 'ค่าจ้างรายเดือน'`); + await queryRunner.query(`ALTER TABLE \`salaryEmployees\` DROP COLUMN \`step\``); + await queryRunner.query(`ALTER TABLE \`salaryEmployees\` ADD \`step\` int NULL COMMENT 'กลุ่มบัญชีการจ้าง'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`salaryEmployees\` DROP COLUMN \`step\``); + await queryRunner.query(`ALTER TABLE \`salaryEmployees\` ADD \`step\` varchar(40) NOT NULL COMMENT 'กลุ่มบัญชีการจ้าง'`); + await queryRunner.query(`ALTER TABLE \`salaryRankEmployees\` CHANGE \`salaryMonth\` \`salaryMounth\` double NULL COMMENT 'ค่าจ้างรายเดือน'`); + await queryRunner.query(`ALTER TABLE \`salaryEmployees\` CHANGE \`step\` \`group\` varchar(40) NOT NULL COMMENT 'กลุ่มบัญชีการจ้าง'`); + } + +} diff --git a/src/migration/1710302798280-update_type_step_table_SalaryEmployees1.ts b/src/migration/1710302798280-update_type_step_table_SalaryEmployees1.ts new file mode 100644 index 0000000..a2eb874 --- /dev/null +++ b/src/migration/1710302798280-update_type_step_table_SalaryEmployees1.ts @@ -0,0 +1,14 @@ +import { MigrationInterface, QueryRunner } from "typeorm"; + +export class UpdateTypeStepTableSalaryEmployees11710302798280 implements MigrationInterface { + name = 'UpdateTypeStepTableSalaryEmployees11710302798280' + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`salaryEmployees\` CHANGE \`step\` \`group\` int NULL COMMENT 'กลุ่มบัญชีการจ้าง'`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE \`salaryEmployees\` CHANGE \`group\` \`step\` int NULL COMMENT 'กลุ่มบัญชีการจ้าง'`); + } + +}