Merge branch 'develop' into adiDev
This commit is contained in:
commit
45b460a095
2 changed files with 58 additions and 6 deletions
|
|
@ -25,6 +25,7 @@ import {
|
||||||
} from "../entities/kpiUserSpecial";
|
} from "../entities/kpiUserSpecial";
|
||||||
import HttpError from "../interfaces/http-error";
|
import HttpError from "../interfaces/http-error";
|
||||||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||||
|
import { KpiSpecial } from "../entities/kpiSpecial";
|
||||||
import { Not } from "typeorm";
|
import { Not } from "typeorm";
|
||||||
|
|
||||||
@Route("api/v1/kpi/user/achievement/special")
|
@Route("api/v1/kpi/user/achievement/special")
|
||||||
|
|
@ -38,6 +39,7 @@ import { Not } from "typeorm";
|
||||||
export class KpiUserSpecialController extends Controller {
|
export class KpiUserSpecialController extends Controller {
|
||||||
private kpiUserSpecialRepository = AppDataSource.getRepository(KpiUserSpecial);
|
private kpiUserSpecialRepository = AppDataSource.getRepository(KpiUserSpecial);
|
||||||
private kpiUserEvaluationRepository = AppDataSource.getRepository(KpiUserEvaluation);
|
private kpiUserEvaluationRepository = AppDataSource.getRepository(KpiUserEvaluation);
|
||||||
|
private kpiSpecialRepository = AppDataSource.getRepository(KpiSpecial);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* API เพิ่มงานที่ได้รับมอบหมายพิเศษ
|
* API เพิ่มงานที่ได้รับมอบหมายพิเศษ
|
||||||
|
|
@ -66,18 +68,39 @@ export class KpiUserSpecialController extends Controller {
|
||||||
const chk_indicator = await this.kpiUserSpecialRepository.findOne({
|
const chk_indicator = await this.kpiUserSpecialRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
kpiUserEvaluationId: requestBody.kpiUserEvaluationId,
|
kpiUserEvaluationId: requestBody.kpiUserEvaluationId,
|
||||||
|
including: String(requestBody.including),
|
||||||
|
includingName: String(requestBody.includingName),
|
||||||
|
period: requestBody.period,
|
||||||
|
year: requestBody.year,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (
|
if (
|
||||||
(chk_indicator && chk_indicator.including == requestBody.including) ||
|
// (chk_indicator && chk_indicator.including == requestBody.including) ||
|
||||||
(chk_indicator && chk_indicator.includingName == requestBody.includingName)
|
// (chk_indicator && chk_indicator.includingName == requestBody.includingName)
|
||||||
|
chk_indicator
|
||||||
) {
|
) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
HttpStatusCode.CONFLICT,
|
HttpStatusCode.CONFLICT,
|
||||||
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const chk_kpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||||
|
where: {
|
||||||
|
including: String(requestBody.including),
|
||||||
|
includingName: String(requestBody.includingName)
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if(!chk_kpiSpecial){
|
||||||
|
const kpiSpecial = Object.assign(new KpiSpecial(), requestBody);
|
||||||
|
if (!kpiSpecial) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
}
|
||||||
|
kpiSpecial.createdUserId = request.user.sub;
|
||||||
|
kpiSpecial.createdFullName = request.user.name;
|
||||||
|
kpiSpecial.lastUpdateUserId = request.user.sub;
|
||||||
|
kpiSpecial.lastUpdateFullName = request.user.name;
|
||||||
|
await this.kpiSpecialRepository.save(kpiSpecial);
|
||||||
|
}
|
||||||
kpiUserSpecial.createdUserId = request.user.sub;
|
kpiUserSpecial.createdUserId = request.user.sub;
|
||||||
kpiUserSpecial.createdFullName = request.user.name;
|
kpiUserSpecial.createdFullName = request.user.name;
|
||||||
kpiUserSpecial.lastUpdateUserId = request.user.sub;
|
kpiUserSpecial.lastUpdateUserId = request.user.sub;
|
||||||
|
|
@ -117,18 +140,39 @@ export class KpiUserSpecialController extends Controller {
|
||||||
where: {
|
where: {
|
||||||
id: Not(id),
|
id: Not(id),
|
||||||
kpiUserEvaluationId: requestBody.kpiUserEvaluationId,
|
kpiUserEvaluationId: requestBody.kpiUserEvaluationId,
|
||||||
|
including: String(requestBody.including),
|
||||||
|
includingName: String(requestBody.includingName),
|
||||||
|
period: requestBody.period,
|
||||||
|
year: requestBody.year,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
if (
|
if (
|
||||||
(chk_indicator && chk_indicator.including == requestBody.including) ||
|
// (chk_indicator && chk_indicator.including == requestBody.including) ||
|
||||||
(chk_indicator && chk_indicator.includingName == requestBody.includingName)
|
// (chk_indicator && chk_indicator.includingName == requestBody.includingName)
|
||||||
|
chk_indicator
|
||||||
) {
|
) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
HttpStatusCode.CONFLICT,
|
HttpStatusCode.CONFLICT,
|
||||||
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
"ไม่สามารถเพิ่มข้อมูลได้เนื่องจากข้อมูลตัวชี้วัดซ้ำ",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
const chk_kpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||||
|
where: {
|
||||||
|
including: String(requestBody.including),
|
||||||
|
includingName: String(requestBody.includingName)
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if(!chk_kpiSpecial){
|
||||||
|
const kpiSpecial = Object.assign(new KpiSpecial(), requestBody);
|
||||||
|
if (!kpiSpecial) {
|
||||||
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูล");
|
||||||
|
}
|
||||||
|
kpiSpecial.createdUserId = request.user.sub;
|
||||||
|
kpiSpecial.createdFullName = request.user.name;
|
||||||
|
kpiSpecial.lastUpdateUserId = request.user.sub;
|
||||||
|
kpiSpecial.lastUpdateFullName = request.user.name;
|
||||||
|
await this.kpiSpecialRepository.save(kpiSpecial);
|
||||||
|
}
|
||||||
kpiUserSpecial.lastUpdateUserId = request.user.sub;
|
kpiUserSpecial.lastUpdateUserId = request.user.sub;
|
||||||
kpiUserSpecial.lastUpdateFullName = request.user.name;
|
kpiUserSpecial.lastUpdateFullName = request.user.name;
|
||||||
kpiUserSpecial.documentInfoEvidence = request.user.documentInfoEvidence;
|
kpiUserSpecial.documentInfoEvidence = request.user.documentInfoEvidence;
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,10 @@ export class CreateKpiUserSpecial {
|
||||||
startDate: Date;
|
startDate: Date;
|
||||||
@Column()
|
@Column()
|
||||||
endDate: Date;
|
endDate: Date;
|
||||||
|
@Column()
|
||||||
|
period: string;
|
||||||
|
@Column()
|
||||||
|
year: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class UpdateKpiUserSpecial {
|
export class UpdateKpiUserSpecial {
|
||||||
|
|
@ -228,6 +232,10 @@ export class UpdateKpiUserSpecial {
|
||||||
startDate: Date;
|
startDate: Date;
|
||||||
@Column()
|
@Column()
|
||||||
endDate: Date;
|
endDate: Date;
|
||||||
|
@Column()
|
||||||
|
period: string;
|
||||||
|
@Column()
|
||||||
|
year: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class KpiUserSpecialDataPoint {
|
export class KpiUserSpecialDataPoint {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue