เปิดปิดรอบประเมิน
This commit is contained in:
parent
50f0e205f6
commit
f75bd88f6b
3 changed files with 79 additions and 1 deletions
|
|
@ -88,6 +88,56 @@ export class kpiController extends Controller {
|
|||
return new HttpSuccess(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* API ปิดรอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
||||
* @param id Guid, *Id ปิดรอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
||||
*/
|
||||
@Get("close/{id}")
|
||||
@Example({
|
||||
durationKPI: "string", //รอบเดือนที่สร้าง
|
||||
startDate: "datetime", //วันเริ่มต้น
|
||||
endDate: "datetime", //วันสิ้นสุด
|
||||
})
|
||||
async CloseSalaryById(@Path() id: string) {
|
||||
const kpi = await this.kpiRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!kpi) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลรอบการประเมินผลการปฏิบัติหน้าที่ราชการนี้",
|
||||
);
|
||||
}
|
||||
kpi.isActive = false;
|
||||
await this.kpiRepository.save(kpi);
|
||||
return new HttpSuccess(kpi);
|
||||
}
|
||||
|
||||
/**
|
||||
* API เปิดรอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
||||
* @param id Guid, *Id เปิดรอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
||||
*/
|
||||
@Get("open/{id}")
|
||||
@Example({
|
||||
durationKPI: "string", //รอบเดือนที่สร้าง
|
||||
startDate: "datetime", //วันเริ่มต้น
|
||||
endDate: "datetime", //วันสิ้นสุด
|
||||
})
|
||||
async OpenSalaryById(@Path() id: string) {
|
||||
const kpi = await this.kpiRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
if (!kpi) {
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่พบข้อมูลรอบการประเมินผลการปฏิบัติหน้าที่ราชการนี้",
|
||||
);
|
||||
}
|
||||
kpi.isActive = true;
|
||||
await this.kpiRepository.save(kpi);
|
||||
return new HttpSuccess(kpi);
|
||||
}
|
||||
|
||||
/**
|
||||
* API รอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
||||
* @param id Guid, *Id รอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
||||
|
|
@ -101,7 +151,7 @@ export class kpiController extends Controller {
|
|||
async GetSalaryById(@Path() id: string) {
|
||||
const kpi = await this.kpiRepository.findOne({
|
||||
where: { id: id },
|
||||
select: ["durationKPI", "startDate", "endDate"],
|
||||
select: ["durationKPI", "startDate", "endDate", "isActive"],
|
||||
});
|
||||
if (!kpi) {
|
||||
throw new HttpError(
|
||||
|
|
@ -122,9 +172,13 @@ export class kpiController extends Controller {
|
|||
async listKpiPeriod(
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("year") year?: string,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
const [kpiPeriod, total] = await this.kpiRepository.findAndCount({
|
||||
// where: {
|
||||
// name: Like(`%${keyword}%`),
|
||||
// },
|
||||
...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }),
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,12 @@ export class KpiPeriod extends EntityBase {
|
|||
default: null,
|
||||
})
|
||||
endDate: Date;
|
||||
|
||||
@Column({
|
||||
comment: "รอบ",
|
||||
default: false,
|
||||
})
|
||||
isActive: boolean;
|
||||
}
|
||||
export class createKpi {
|
||||
@Column()
|
||||
|
|
@ -33,6 +39,8 @@ export class createKpi {
|
|||
startDate: Date;
|
||||
@Column()
|
||||
endDate: Date;
|
||||
@Column()
|
||||
isActive: boolean;
|
||||
}
|
||||
|
||||
export class updateKpi {
|
||||
|
|
@ -42,4 +50,6 @@ export class updateKpi {
|
|||
startDate: Date;
|
||||
@Column()
|
||||
endDate: Date;
|
||||
@Column()
|
||||
isActive: boolean;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
import { MigrationInterface, QueryRunner } from "typeorm";
|
||||
|
||||
export class UpdateTableKpiperiodAddIsactive1713223298389 implements MigrationInterface {
|
||||
name = 'UpdateTableKpiperiodAddIsactive1713223298389'
|
||||
|
||||
public async up(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`kpiPeriod\` ADD \`isActive\` tinyint NOT NULL COMMENT 'รอบ' DEFAULT 0`);
|
||||
}
|
||||
|
||||
public async down(queryRunner: QueryRunner): Promise<void> {
|
||||
await queryRunner.query(`ALTER TABLE \`kpiPeriod\` DROP COLUMN \`isActive\``);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue