fix: delete kpi row
This commit is contained in:
parent
1ccde3f38d
commit
fe37dc82be
1 changed files with 65 additions and 58 deletions
|
|
@ -41,10 +41,11 @@ import { resolveNodeId, resolveNodeLevel, setLogDataDiff } from "../interfaces/u
|
||||||
import { KpiUserRejectAgreement } from "../entities/kpiUserRejectAgreement";
|
import { KpiUserRejectAgreement } from "../entities/kpiUserRejectAgreement";
|
||||||
import { KpiUserRejectResult } from "../entities/kpiUserRejectResult";
|
import { KpiUserRejectResult } from "../entities/kpiUserRejectResult";
|
||||||
import { KpiUserCapacity } from "../entities/kpiUserCapacity";
|
import { KpiUserCapacity } from "../entities/kpiUserCapacity";
|
||||||
import { KpiUserPlanned } from "../entities/kpiUserPlanned"
|
import { KpiUserPlanned } from "../entities/kpiUserPlanned";
|
||||||
import { KpiUserRole } from "../entities/kpiUserRole";
|
import { KpiUserRole } from "../entities/kpiUserRole";
|
||||||
import { KpiUserSpecial } from "../entities/kpiUserSpecial";
|
import { KpiUserSpecial } from "../entities/kpiUserSpecial";
|
||||||
import { KpiUserDevelopment } from "../entities/kpiUserDevelopment";
|
import { KpiUserDevelopment } from "../entities/kpiUserDevelopment";
|
||||||
|
import { KpiUserEvaluationReasonPlan } from "../entities/kpiUserEvaluationReasonPlan";
|
||||||
|
|
||||||
@Route("api/v1/kpi/user/evaluation")
|
@Route("api/v1/kpi/user/evaluation")
|
||||||
@Tags("kpiUserEvaluation")
|
@Tags("kpiUserEvaluation")
|
||||||
|
|
@ -255,7 +256,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
"CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword";
|
"CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword";
|
||||||
let _data = await new permission().PermissionOrgList(request, "SYS_RESULT");
|
let _data = await new permission().PermissionOrgList(request, "SYS_RESULT");
|
||||||
|
|
||||||
const orgDna = await new permission().checkDna(request, request.user.sub)
|
const orgDna = await new permission().checkDna(request, request.user.sub);
|
||||||
|
|
||||||
let typeCondition: {
|
let typeCondition: {
|
||||||
query?: string;
|
query?: string;
|
||||||
|
|
@ -266,9 +267,11 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
let conditions: string[] = [];
|
let conditions: string[] = [];
|
||||||
let params: any = {};
|
let params: any = {};
|
||||||
|
|
||||||
if (_data.privilege === "CHILD" || /*_data.privilege === "PARENT" ||*/ _data.privilege === "BROTHER") {
|
if (
|
||||||
|
_data.privilege === "CHILD" ||
|
||||||
|
/*_data.privilege === "PARENT" ||*/ _data.privilege === "BROTHER"
|
||||||
|
) {
|
||||||
if (_data.privilege === "CHILD") {
|
if (_data.privilege === "CHILD") {
|
||||||
|
|
||||||
if (level === 0 && orgDna.rootDnaId) {
|
if (level === 0 && orgDna.rootDnaId) {
|
||||||
conditions.push("kpiUserEvaluation.orgDnaId = :root");
|
conditions.push("kpiUserEvaluation.orgDnaId = :root");
|
||||||
params.root = orgDna.rootDnaId;
|
params.root = orgDna.rootDnaId;
|
||||||
|
|
@ -300,8 +303,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
params,
|
params,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
} else if (_data.privilege === "BROTHER") {
|
||||||
else if (_data.privilege === "BROTHER") {
|
|
||||||
const parentLevel = level !== null ? level - 1 : null;
|
const parentLevel = level !== null ? level - 1 : null;
|
||||||
if (parentLevel != null && parentLevel === 0 && orgDna.rootDnaId) {
|
if (parentLevel != null && parentLevel === 0 && orgDna.rootDnaId) {
|
||||||
conditions.push("kpiUserEvaluation.orgDnaId = :root");
|
conditions.push("kpiUserEvaluation.orgDnaId = :root");
|
||||||
|
|
@ -359,7 +361,11 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
// };
|
// };
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
} else if (_data.privilege === "OWNER" || _data.privilege === "ROOT" || _data.privilege === "PARENT") {
|
} else if (
|
||||||
|
_data.privilege === "OWNER" ||
|
||||||
|
_data.privilege === "ROOT" ||
|
||||||
|
_data.privilege === "PARENT"
|
||||||
|
) {
|
||||||
if (orgDna.rootDnaId) {
|
if (orgDna.rootDnaId) {
|
||||||
conditions.push("kpiUserEvaluation.orgDnaId = :root");
|
conditions.push("kpiUserEvaluation.orgDnaId = :root");
|
||||||
params.root = orgDna.rootDnaId;
|
params.root = orgDna.rootDnaId;
|
||||||
|
|
@ -593,7 +599,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
let _data = await new permission().PermissionOrgList(request, "SYS_KPI_LIST");
|
let _data = await new permission().PermissionOrgList(request, "SYS_KPI_LIST");
|
||||||
const orgDna = await new permission().checkDna(request, request.user.sub)
|
const orgDna = await new permission().checkDna(request, request.user.sub);
|
||||||
|
|
||||||
let conditionFullName =
|
let conditionFullName =
|
||||||
"CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword";
|
"CONCAT(kpiUserEvaluation.prefix, kpiUserEvaluation.firstName, ' ', kpiUserEvaluation.lastName) LIKE :keyword";
|
||||||
|
|
@ -606,9 +612,11 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
let nodeId = resolveNodeId(orgDna);
|
let nodeId = resolveNodeId(orgDna);
|
||||||
let conditions: string[] = [];
|
let conditions: string[] = [];
|
||||||
let params: any = {};
|
let params: any = {};
|
||||||
if (_data.privilege === "CHILD" || /*_data.privilege === "PARENT" ||*/ _data.privilege === "BROTHER") {
|
if (
|
||||||
|
_data.privilege === "CHILD" ||
|
||||||
|
/*_data.privilege === "PARENT" ||*/ _data.privilege === "BROTHER"
|
||||||
|
) {
|
||||||
if (_data.privilege === "CHILD") {
|
if (_data.privilege === "CHILD") {
|
||||||
|
|
||||||
if (level === 0 && orgDna.rootDnaId) {
|
if (level === 0 && orgDna.rootDnaId) {
|
||||||
conditions.push("kpiUserEvaluation.orgDnaId = :root");
|
conditions.push("kpiUserEvaluation.orgDnaId = :root");
|
||||||
params.root = orgDna.rootDnaId;
|
params.root = orgDna.rootDnaId;
|
||||||
|
|
@ -640,8 +648,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
params,
|
params,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
} else if (_data.privilege === "BROTHER") {
|
||||||
else if (_data.privilege === "BROTHER") {
|
|
||||||
const parentLevel = level !== null ? level - 1 : null;
|
const parentLevel = level !== null ? level - 1 : null;
|
||||||
if (parentLevel != null && parentLevel === 0 && orgDna.rootDnaId) {
|
if (parentLevel != null && parentLevel === 0 && orgDna.rootDnaId) {
|
||||||
conditions.push("kpiUserEvaluation.orgDnaId = :root");
|
conditions.push("kpiUserEvaluation.orgDnaId = :root");
|
||||||
|
|
@ -827,7 +834,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
keyword: `%${requestBody.keyword}%`,
|
keyword: `%${requestBody.keyword}%`,
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
)
|
);
|
||||||
|
|
||||||
if (typeCondition.query) {
|
if (typeCondition.query) {
|
||||||
query.andWhere(typeCondition.query, typeCondition.params);
|
query.andWhere(typeCondition.query, typeCondition.params);
|
||||||
|
|
@ -906,9 +913,9 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
) {
|
) {
|
||||||
if (
|
if (
|
||||||
requestBody.evaluatorId != null && requestBody.evaluatorId == requestBody.commanderId ||
|
(requestBody.evaluatorId != null && requestBody.evaluatorId == requestBody.commanderId) ||
|
||||||
requestBody.evaluatorId != null && requestBody.evaluatorId == requestBody.commanderHighId ||
|
(requestBody.evaluatorId != null && requestBody.evaluatorId == requestBody.commanderHighId) ||
|
||||||
requestBody.commanderId != null && requestBody.commanderId == requestBody.commanderHighId
|
(requestBody.commanderId != null && requestBody.commanderId == requestBody.commanderHighId)
|
||||||
) {
|
) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
HttpStatusCode.NOT_FOUND,
|
HttpStatusCode.NOT_FOUND,
|
||||||
|
|
@ -1880,8 +1887,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
* @param {string} id Guid, *Id รายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER)
|
* @param {string} id Guid, *Id รายการประเมินผลการปฏิบัติราชการระดับบุคคล (USER)
|
||||||
*/
|
*/
|
||||||
@Delete("{id}")
|
@Delete("{id}")
|
||||||
async deleteKpiUserEvaluation(@Path() id: string, @Request() request: RequestWithUser
|
async deleteKpiUserEvaluation(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
) {
|
|
||||||
const queryRunner = AppDataSource.createQueryRunner();
|
const queryRunner = AppDataSource.createQueryRunner();
|
||||||
await queryRunner.connect();
|
await queryRunner.connect();
|
||||||
await queryRunner.startTransaction();
|
await queryRunner.startTransaction();
|
||||||
|
|
@ -1894,10 +1900,11 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
if (!kpiUserEvaluation) {
|
if (!kpiUserEvaluation) {
|
||||||
throw new HttpError(
|
throw new HttpError(
|
||||||
HttpStatusCode.NOT_FOUND,
|
HttpStatusCode.NOT_FOUND,
|
||||||
"ไม่พบข้อมูลการประเมินผลการปฏิบัติราชการระดับบุคคลนี้"
|
"ไม่พบข้อมูลการประเมินผลการปฏิบัติราชการระดับบุคคลนี้",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await queryRunner.manager.delete(KpiUserCapacity, { kpiUserEvaluationId: id });
|
await queryRunner.manager.delete(KpiUserCapacity, { kpiUserEvaluationId: id });
|
||||||
|
await queryRunner.manager.delete(KpiUserEvaluationReasonPlan, { kpiUserEvaluationId: id });
|
||||||
await queryRunner.manager.delete(KpiUserPlanned, { kpiUserEvaluationId: id });
|
await queryRunner.manager.delete(KpiUserPlanned, { kpiUserEvaluationId: id });
|
||||||
await queryRunner.manager.delete(KpiUserRole, { kpiUserEvaluationId: id });
|
await queryRunner.manager.delete(KpiUserRole, { kpiUserEvaluationId: id });
|
||||||
await queryRunner.manager.delete(KpiUserSpecial, { kpiUserEvaluationId: id });
|
await queryRunner.manager.delete(KpiUserSpecial, { kpiUserEvaluationId: id });
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue