หมายเหตุ ผู้ประเมิน

This commit is contained in:
Kittapath 2024-06-26 12:41:38 +07:00
parent 468d8d8865
commit ae87b678d1
3 changed files with 302 additions and 0 deletions

View file

@ -987,4 +987,207 @@ export class KpiUserEvaluationController extends Controller {
return new HttpSuccess();
}
/**
*
*
* @param {string} id Guid, *Id (USER)
*/
@Get("open/{id}")
async openKpiUserEvaluation(
@Path() id: string,
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
kpiUserEvaluation.isOpen = true;
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name;
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
return new HttpSuccess(kpiUserEvaluation.id);
}
/**
* API (USER)
*
* @summary (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Put("reason/user/{id}")
async updateReasonKpiUserEvaluation(
@Path() id: string,
@Body()
requestBody: {
topicEvaluator?: string | null;
developEvaluator?: string | null;
timeEvaluator?: string | null;
reasonEvaluator?: string | null;
},
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
const _null: any = null;
kpiUserEvaluation.topicEvaluator =
requestBody.topicEvaluator == null ? _null : requestBody.topicEvaluator;
kpiUserEvaluation.developEvaluator =
requestBody.developEvaluator == null ? _null : requestBody.developEvaluator;
kpiUserEvaluation.timeEvaluator =
requestBody.timeEvaluator == null ? _null : requestBody.timeEvaluator;
kpiUserEvaluation.reasonEvaluator =
requestBody.reasonEvaluator == null ? _null : requestBody.reasonEvaluator;
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name;
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
return new HttpSuccess(kpiUserEvaluation.id);
}
/**
* API (USER)
*
* @summary (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Put("reason/commander/{id}")
async updateReasonKpiCommanderEvaluation(
@Path() id: string,
@Body()
requestBody: {
isReason: boolean;
reason?: string | null;
},
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
const _null: any = null;
kpiUserEvaluation.isReasonCommander = requestBody.isReason;
kpiUserEvaluation.reasonCommander = requestBody.reason == null ? _null : requestBody.reason;
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name;
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
return new HttpSuccess(kpiUserEvaluation.id);
}
/**
* API (USER)
*
* @summary (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Put("reason/commanderHigh/{id}")
async updateReasonKpiCommanderHighEvaluation(
@Path() id: string,
@Body()
requestBody: {
isReason: boolean;
reason?: string | null;
},
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
const _null: any = null;
kpiUserEvaluation.isReasonCommanderHigh = requestBody.isReason;
kpiUserEvaluation.reasonCommanderHigh = requestBody.reason == null ? _null : requestBody.reason;
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name;
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
return new HttpSuccess(kpiUserEvaluation.id);
}
/**
* API (USER)
*
* @summary (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Get("reason/{id}")
async getReasonKpiEvaluation(
@Path() id: string,
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
select: [
"topicEvaluator",
"developEvaluator",
"timeEvaluator",
"reasonEvaluator",
"isReasonCommander",
"reasonCommander",
"isReasonCommanderHigh",
"reasonCommanderHigh",
"isOpen",
],
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
return new HttpSuccess(kpiUserEvaluation);
}
/**
* API (USER)
*
* @summary (USER)
*
* @param {string} id Guid, *Id (USER)
*/
@Get("summary/{id}")
async getSummaryKpiEvaluation(
@Path() id: string,
@Request() request: { user: Record<string, any> },
) {
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
where: { id: id },
select: ["id", "evaluationStatus", "lastUpdateUserId", "lastUpdateFullName"],
});
if (!kpiUserEvaluation) {
throw new HttpError(
HttpStatusCode.NOT_FOUND,
"ไม่พบข้อมูลรายการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
);
}
kpiUserEvaluation.evaluationStatus = "SUMMARY";
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
kpiUserEvaluation.lastUpdateFullName = request.user.name;
await this.kpiUserEvalutionRepository.save(kpiUserEvaluation);
return new HttpSuccess(kpiUserEvaluation);
}
}

View file

@ -188,6 +188,75 @@ export class KpiUserEvaluation extends EntityBase {
})
summaryPoint: number;
@Column({
nullable: true,
comment: "ชื่อเรื่อง/เนื้อหา/หัวข้อการพัฒนา",
length: 255,
default: null,
})
topicEvaluator: string;
@Column({
nullable: true,
comment: "วิธีการพัฒนา",
length: 255,
default: null,
})
developEvaluator: string;
@Column({
nullable: true,
comment: "ช่วงเวลาการพัฒนา",
length: 255,
default: null,
})
timeEvaluator: string;
@Column({
nullable: true,
comment: "ความเห็นของผู้ประเมิน",
length: 255,
default: null,
})
reasonEvaluator: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป",
default: false,
})
isReasonCommander: boolean;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป",
length: 255,
default: null,
})
reasonCommander: string;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง",
default: false,
})
isReasonCommanderHigh: boolean;
@Column({
nullable: true,
comment: "หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง",
length: 255,
default: null,
})
reasonCommanderHigh: string;
@Column({
nullable: true,
comment: "การรับทราบผลการประเมิน",
default: false,
})
isOpen: boolean;
@Column({
nullable: true,
length: 40,

View file

@ -0,0 +1,30 @@
import { MigrationInterface, QueryRunner } from "typeorm";
export class UpdateTableKpiUserEvalutionAddReason1719376307198 implements MigrationInterface {
name = 'UpdateTableKpiUserEvalutionAddReason1719376307198'
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`topicEvaluator\` varchar(255) NULL COMMENT 'ชื่อเรื่อง/เนื้อหา/หัวข้อการพัฒนา'`);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`developEvaluator\` varchar(255) NULL COMMENT 'วิธีการพัฒนา'`);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`timeEvaluator\` varchar(255) NULL COMMENT 'ช่วงเวลาการพัฒนา'`);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`reasonEvaluator\` varchar(255) NULL COMMENT 'ความเห็นของผู้ประเมิน'`);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`isReasonCommander\` tinyint NULL COMMENT 'หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`reasonCommander\` varchar(255) NULL COMMENT 'หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไป'`);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`isReasonCommanderHigh\` tinyint NULL COMMENT 'หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง' DEFAULT 0`);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`reasonCommanderHigh\` varchar(255) NULL COMMENT 'หมายเหตุ ผู้บังคับบัญชาเหนือขึ้นไปอีกชั้นหนึ่ง'`);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` ADD \`isOpen\` tinyint NULL COMMENT 'การรับทราบผลการประเมิน' DEFAULT 0`);
}
public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`isOpen\``);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`reasonCommanderHigh\``);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`isReasonCommanderHigh\``);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`reasonCommander\``);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`isReasonCommander\``);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`reasonEvaluator\``);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`timeEvaluator\``);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`developEvaluator\``);
await queryRunner.query(`ALTER TABLE \`kpiUserEvaluation\` DROP COLUMN \`topicEvaluator\``);
}
}