เช็คสมรรถนะซ้ำ
This commit is contained in:
parent
c4950703fc
commit
7f46b85809
1 changed files with 26 additions and 1 deletions
|
|
@ -23,7 +23,7 @@ import HttpStatusCode from "../interfaces/http-status";
|
|||
import { KpiCapacity } from "../entities/kpiCapacity";
|
||||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||
import { KpiUserCapacity, KpiUserCapacityDataPoint} from "../entities/kpiUserCapacity";
|
||||
import { Like, In } from "typeorm";
|
||||
import { Like, In, Not } from "typeorm";
|
||||
import { Double } from "typeorm/browser";
|
||||
|
||||
@Route("api/v1/kpi/user/capacity")
|
||||
|
|
@ -76,6 +76,18 @@ export class KpiUserCapacityController extends Controller {
|
|||
"ไม่พบข้อมูลรายการสมรรถนะนี้",
|
||||
);
|
||||
}
|
||||
const chkRepleat = await this.kpiUserCapacityRepository.find({
|
||||
where: {
|
||||
kpiUserEvaluationId: requestBody.kpiUserEvaluationId,
|
||||
kpiCapacityId: requestBody.kpiCapacityId
|
||||
}
|
||||
})
|
||||
if(chkRepleat.length > 0){
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากรายการสมรรถนะซ้ำ",
|
||||
);
|
||||
}
|
||||
const kpiUserCapacity = Object.assign(new KpiUserCapacity(), requestBody);
|
||||
kpiUserCapacity.createdUserId = request.user.sub;
|
||||
kpiUserCapacity.createdFullName = request.user.name;
|
||||
|
|
@ -134,6 +146,19 @@ export class KpiUserCapacityController extends Controller {
|
|||
"ไม่พบข้อมูลองค์ประกอบที่ 2 พฤติกรรมการปฎิบัติราชการ (สมรรถนะ) นี้",
|
||||
);
|
||||
}
|
||||
const chkRepleat = await this.kpiUserCapacityRepository.find({
|
||||
where: {
|
||||
kpiUserEvaluationId: requestBody.kpiUserEvaluationId,
|
||||
kpiCapacityId: requestBody.kpiCapacityId,
|
||||
id: Not(id)
|
||||
}
|
||||
})
|
||||
if(chkRepleat.length > 0){
|
||||
throw new HttpError(
|
||||
HttpStatusCode.NOT_FOUND,
|
||||
"ไม่สามารถแก้ไขข้อมูลได้เนื่องจากรายการสมรรถนะซ้ำ",
|
||||
);
|
||||
}
|
||||
const _kpiUserCapacity = Object.assign(new KpiUserCapacity(), requestBody);
|
||||
kpiUserCapacity.lastUpdateUserId = request.user.sub;
|
||||
kpiUserCapacity.lastUpdateFullName = request.user.name;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue