unit to string

This commit is contained in:
Kittapath 2024-05-09 15:57:43 +07:00
parent 9a85609e93
commit 6e07eaacba
8 changed files with 33 additions and 13 deletions

View file

@ -102,7 +102,7 @@ export class kpiSpecialController extends Controller {
}
kpiSpecial.lastUpdateUserId = request.user.sub;
kpiSpecial.lastUpdateFullName = request.user.name;
this.kpiSpecialRepository.merge(kpiSpecial, requestBody);
Object.assign(kpiSpecial, requestBody);
await this.kpiSpecialRepository.save(kpiSpecial);
return new HttpSuccess(id);
}

View file

@ -148,7 +148,7 @@ export class KpiUserPlannedController extends Controller {
// kpiUserPlanned.achievement4 = request.user.achievement4;
// kpiUserPlanned.achievement5 = request.user.achievement5;
this.kpiUserPlannedRepository.merge(kpiUserPlanned, requestBody);
Object.assign(kpiUserPlanned, requestBody);
kpiUserPlanned.startDate = requestBody.startDate == undefined ? null : requestBody.startDate;
kpiUserPlanned.endDate = requestBody.endDate == undefined ? null : requestBody.endDate;
await this.kpiUserPlannedRepository.save(kpiUserPlanned);

View file

@ -150,7 +150,7 @@ export class KpiUserRoleController extends Controller {
kpiUserRole.lastUpdateUserId = request.user.sub;
kpiUserRole.lastUpdateFullName = request.user.name;
this.kpiUserRoleRepository.merge(kpiUserRole, requestBody);
Object.assign(kpiUserRole, requestBody);
kpiUserRole.startDate = requestBody.startDate == undefined ? null : requestBody.startDate;
kpiUserRole.endDate = requestBody.endDate == undefined ? null : requestBody.endDate;
await this.kpiUserRoleRepository.save(kpiUserRole);

View file

@ -166,7 +166,7 @@ export class CreateKpiSpecial {
@Column()
target: string;
@Column()
unit: string;
unit: string | null;
@Column()
weight: number;
@Column()
@ -199,7 +199,7 @@ export class UpdateKpiSpecial {
@Column()
target: string;
@Column()
unit: string;
unit: string | null;
@Column()
weight: number;
@Column()

View file

@ -18,7 +18,7 @@ export class KpiUserPlanned extends EntityBase {
comment: "หน่วยนับ",
default: null,
})
unit: number;
unit: string;
@Column({
nullable: true,
@ -149,7 +149,7 @@ export class CreateKpiUserPlanned {
@Column()
target: string;
@Column()
unit: number;
unit: string | null;
@Column()
weight: number;
@Column()
@ -182,7 +182,7 @@ export class UpdateKpiUserPlanned {
@Column()
target: string;
@Column()
unit: number;
unit: string | null;
@Column()
weight: number;
@Column()

View file

@ -19,7 +19,7 @@ export class KpiUserRole extends EntityBase {
comment: "หน่วยนับ",
default: null,
})
unit: number;
unit: string;
@Column({
nullable: true,
@ -150,7 +150,7 @@ export class CreateKpiUserRole {
@Column()
target: string;
@Column()
unit: number;
unit: string | null;
@Column()
weight: number;
@Column()
@ -183,7 +183,7 @@ export class UpdateKpiUserRole {
@Column()
target: string;
@Column()
unit: number;
unit: string | null;
@Column()
weight: number;
@Column()

View file

@ -185,7 +185,7 @@ export class CreateKpiUserSpecial {
@Column()
target: string;
@Column()
unit: string;
unit: string | null;
@Column()
weight: number;
@Column()
@ -224,7 +224,7 @@ export class UpdateKpiUserSpecial {
@Column()
target: string;
@Column()
unit: string;
unit: string | null;
@Column()
weight: number;
@Column()

View file

@ -0,0 +1,20 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableKpiSpecialUnitToString1715244414852 implements MigrationInterface {
name = 'UpdateTableKpiSpecialUnitToString1715244414852'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` DROP COLUMN \`unit\``);
await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` ADD \`unit\` varchar(255) NULL COMMENT 'หน่วยนับ'`);
await queryRunner.query(`ALTER TABLE \`kpiUserRole\` DROP COLUMN \`unit\``);
await queryRunner.query(`ALTER TABLE \`kpiUserRole\` ADD \`unit\` varchar(255) NULL COMMENT 'หน่วยนับ'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`kpiUserRole\` DROP COLUMN \`unit\``);
await queryRunner.query(`ALTER TABLE \`kpiUserRole\` ADD \`unit\` int NULL COMMENT 'หน่วยนับ'`);
await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` DROP COLUMN \`unit\``);
await queryRunner.query(`ALTER TABLE \`kpiUserPlanned\` ADD \`unit\` int NULL COMMENT 'หน่วยนับ'`);
}
}