แก้ค่า default

This commit is contained in:
Kittapath 2024-05-09 11:25:08 +07:00
parent 5d9e731947
commit 3bfd309ae8
3 changed files with 24 additions and 6 deletions

View file

@ -240,7 +240,7 @@ export class KpiUserEvaluationController extends Controller {
@Get("{id}") @Get("{id}")
async GetKpiUserEvaluationById(@Path() id: string) { async GetKpiUserEvaluationById(@Path() id: string) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({ const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
relations:["kpiPeriod"], relations: ["kpiPeriod"],
where: { id: id }, where: { id: id },
}); });
if (!kpiUserEvaluation) { if (!kpiUserEvaluation) {
@ -257,6 +257,7 @@ export class KpiUserEvaluationController extends Controller {
lastName: kpiUserEvaluation.lastName, lastName: kpiUserEvaluation.lastName,
evaluationStatus: kpiUserEvaluation.evaluationStatus, evaluationStatus: kpiUserEvaluation.evaluationStatus,
evaluationResults: kpiUserEvaluation.evaluationResults, evaluationResults: kpiUserEvaluation.evaluationResults,
evaluationReqEdit: kpiUserEvaluation.evaluationReqEdit,
createdAt: kpiUserEvaluation.createdAt, createdAt: kpiUserEvaluation.createdAt,
evaluatorId: kpiUserEvaluation.evaluatorId, evaluatorId: kpiUserEvaluation.evaluatorId,
commanderId: kpiUserEvaluation.commanderId, commanderId: kpiUserEvaluation.commanderId,
@ -267,8 +268,9 @@ export class KpiUserEvaluationController extends Controller {
capacityPoint: kpiUserEvaluation.capacityPoint, capacityPoint: kpiUserEvaluation.capacityPoint,
kpiPeriodId: kpiUserEvaluation.kpiPeriodId, kpiPeriodId: kpiUserEvaluation.kpiPeriodId,
year: kpiUserEvaluation.kpiPeriod == null ? null : kpiUserEvaluation.kpiPeriod.year, year: kpiUserEvaluation.kpiPeriod == null ? null : kpiUserEvaluation.kpiPeriod.year,
durationKPI: kpiUserEvaluation.kpiPeriod == null ? null : kpiUserEvaluation.kpiPeriod.durationKPI, durationKPI:
} kpiUserEvaluation.kpiPeriod == null ? null : kpiUserEvaluation.kpiPeriod.durationKPI,
};
return new HttpSuccess(mapData); return new HttpSuccess(mapData);
} }

View file

@ -80,7 +80,7 @@ export class KpiUserEvaluation extends EntityBase {
length: 40, length: 40,
comment: comment:
"ผลการประเมิน ดังนี้ PENDING = รอดำเนินการ, PASSED = ผ่านการประเมิน, NOTPASSED = ไม่ผ่านการประเมิน", "ผลการประเมิน ดังนี้ PENDING = รอดำเนินการ, PASSED = ผ่านการประเมิน, NOTPASSED = ไม่ผ่านการประเมิน",
default: null, default: "PENDING",
}) })
evaluationResults: string; evaluationResults: string;
@ -88,7 +88,7 @@ export class KpiUserEvaluation extends EntityBase {
nullable: true, nullable: true,
length: 40, length: 40,
comment: "คำขอแก้ไข", comment: "คำขอแก้ไข",
default: null, default: "NEW",
}) })
evaluationReqEdit: string; evaluationReqEdit: string;

View file

@ -0,0 +1,16 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableKpiUserEvaluationAddEvaluationReqEdit11715228658780 implements MigrationInterface {
name = 'UpdateTableKpiUserEvaluationAddEvaluationReqEdit11715228658780'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationResults\` \`evaluationResults\` varchar(40) NULL COMMENT 'ผลการประเมิน ดังนี้ PENDING = รอดำเนินการ, PASSED = ผ่านการประเมิน, NOTPASSED = ไม่ผ่านการประเมิน' DEFAULT 'PENDING'`);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationReqEdit\` \`evaluationReqEdit\` varchar(40) NULL COMMENT 'คำขอแก้ไข' DEFAULT 'NEW'`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationReqEdit\` \`evaluationReqEdit\` varchar(40) NULL COMMENT 'คำขอแก้ไข'`);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` CHANGE \`evaluationResults\` \`evaluationResults\` varchar(40) NULL COMMENT 'ผลการประเมิน ดังนี้ PENDING = รอดำเนินการ, PASSED = ผ่านการประเมิน, NOTPASSED = ไม่ผ่านการประเมิน'`);
}
}