เปิดปิดรอบประเมิน
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);
|
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 รอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
* API รอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
||||||
* @param id Guid, *Id รอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
* @param id Guid, *Id รอบการประเมินผลการปฏิบัติหน้าที่ราชการ
|
||||||
|
|
@ -101,7 +151,7 @@ export class kpiController extends Controller {
|
||||||
async GetSalaryById(@Path() id: string) {
|
async GetSalaryById(@Path() id: string) {
|
||||||
const kpi = await this.kpiRepository.findOne({
|
const kpi = await this.kpiRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
select: ["durationKPI", "startDate", "endDate"],
|
select: ["durationKPI", "startDate", "endDate", "isActive"],
|
||||||
});
|
});
|
||||||
if (!kpi) {
|
if (!kpi) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
|
|
@ -122,9 +172,13 @@ export class kpiController extends Controller {
|
||||||
async listKpiPeriod(
|
async listKpiPeriod(
|
||||||
@Query("page") page: number = 1,
|
@Query("page") page: number = 1,
|
||||||
@Query("pageSize") pageSize: number = 10,
|
@Query("pageSize") pageSize: number = 10,
|
||||||
|
@Query("year") year?: string,
|
||||||
@Query("keyword") keyword?: string,
|
@Query("keyword") keyword?: string,
|
||||||
) {
|
) {
|
||||||
const [kpiPeriod, total] = await this.kpiRepository.findAndCount({
|
const [kpiPeriod, total] = await this.kpiRepository.findAndCount({
|
||||||
|
// where: {
|
||||||
|
// name: Like(`%${keyword}%`),
|
||||||
|
// },
|
||||||
...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }),
|
...(keyword ? {} : { skip: (page - 1) * pageSize, take: pageSize }),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,12 @@ export class KpiPeriod extends EntityBase {
|
||||||
default: null,
|
default: null,
|
||||||
})
|
})
|
||||||
endDate: Date;
|
endDate: Date;
|
||||||
|
|
||||||
|
@Column({
|
||||||
|
comment: "รอบ",
|
||||||
|
default: false,
|
||||||
|
})
|
||||||
|
isActive: boolean;
|
||||||
}
|
}
|
||||||
export class createKpi {
|
export class createKpi {
|
||||||
@Column()
|
@Column()
|
||||||
|
|
@ -33,6 +39,8 @@ export class createKpi {
|
||||||
startDate: Date;
|
startDate: Date;
|
||||||
@Column()
|
@Column()
|
||||||
endDate: Date;
|
endDate: Date;
|
||||||
|
@Column()
|
||||||
|
isActive: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class updateKpi {
|
export class updateKpi {
|
||||||
|
|
@ -42,4 +50,6 @@ export class updateKpi {
|
||||||
startDate: Date;
|
startDate: Date;
|
||||||
@Column()
|
@Column()
|
||||||
endDate: Date;
|
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