คำสั่งวินัย

This commit is contained in:
Kittapath 2024-06-30 20:51:04 +07:00
parent 40f45b01e6
commit d6f0f583c3
2 changed files with 241 additions and 115 deletions

View file

@ -77,7 +77,6 @@ export class kpiReasonController extends Controller {
where: { id: id },
relations: ["kpiUserEvaluation"],
});
let kpiUserEvaluationReason = Object.assign(new KpiUserEvaluationReasonPlan(), requestBody);
kpiUserEvaluationReason.type = type.trim().toUpperCase();
if (type.trim().toUpperCase() == "PROBLEM") {
@ -204,10 +203,39 @@ export class kpiReasonController extends Controller {
@Get("{type}/plan/{user}/{id}")
async listKpiUserPlanReason(@Path() id: string, @Path() type: string, @Path() user: string) {
if (type.trim().toUpperCase() == "PROBLEM") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonPlan.find({
where: { kpiUserPlannedId: id, type: type.trim().toUpperCase() },
});
return new HttpSuccess(kpiUserEvaluationReason);
if (user.trim().toUpperCase() == "USER") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonPlan.find({
where: { kpiUserPlannedId: id, type: type.trim().toUpperCase() },
});
return new HttpSuccess(kpiUserEvaluationReason);
} else if (user.trim().toUpperCase() == "EVALUATOR") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonPlan.find({
where: {
kpiUserPlannedId: id,
type: type.trim().toUpperCase(),
status: In(["EVALUATOR", "COMMANDER", "COMMANDERHIGH", "DONE"]),
},
});
return new HttpSuccess(kpiUserEvaluationReason);
} else if (user.trim().toUpperCase() == "COMMANDER") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonPlan.find({
where: {
kpiUserPlannedId: id,
type: type.trim().toUpperCase(),
status: In(["COMMANDER", "COMMANDERHIGH", "DONE"]),
},
});
return new HttpSuccess(kpiUserEvaluationReason);
} else if (user.trim().toUpperCase() == "COMMANDERHIGH") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonPlan.find({
where: {
kpiUserPlannedId: id,
type: type.trim().toUpperCase(),
status: In(["COMMANDERHIGH", "DONE"]),
},
});
return new HttpSuccess(kpiUserEvaluationReason);
}
} else {
if (user.trim().toUpperCase() == "USER") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonPlan.find({
@ -392,10 +420,39 @@ export class kpiReasonController extends Controller {
@Get("{type}/role/{user}/{id}")
async listKpiUserRoleReason(@Path() id: string, @Path() type: string, @Path() user: string) {
if (type.trim().toUpperCase() == "PROBLEM") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonRole.find({
where: { kpiUserRoleId: id, type: type.trim().toUpperCase() },
});
return new HttpSuccess(kpiUserEvaluationReason);
if (user.trim().toUpperCase() == "USER") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonRole.find({
where: { kpiUserRoleId: id, type: type.trim().toUpperCase() },
});
return new HttpSuccess(kpiUserEvaluationReason);
} else if (user.trim().toUpperCase() == "EVALUATOR") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonRole.find({
where: {
kpiUserRoleId: id,
type: type.trim().toUpperCase(),
status: In(["EVALUATOR", "COMMANDER", "COMMANDERHIGH", "DONE"]),
},
});
return new HttpSuccess(kpiUserEvaluationReason);
} else if (user.trim().toUpperCase() == "COMMANDER") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonRole.find({
where: {
kpiUserRoleId: id,
type: type.trim().toUpperCase(),
status: In(["COMMANDER", "COMMANDERHIGH", "DONE"]),
},
});
return new HttpSuccess(kpiUserEvaluationReason);
} else if (user.trim().toUpperCase() == "COMMANDERHIGH") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonRole.find({
where: {
kpiUserRoleId: id,
type: type.trim().toUpperCase(),
status: In(["COMMANDERHIGH", "DONE"]),
},
});
return new HttpSuccess(kpiUserEvaluationReason);
}
} else {
if (user.trim().toUpperCase() == "USER") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonRole.find({
@ -582,10 +639,39 @@ export class kpiReasonController extends Controller {
@Get("{type}/special/{user}/{id}")
async listKpiUserSpecialReason(@Path() id: string, @Path() type: string, @Path() user: string) {
if (type.trim().toUpperCase() == "PROBLEM") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonSpecial.find({
where: { kpiUserSpecialId: id, type: type.trim().toUpperCase() },
});
return new HttpSuccess(kpiUserEvaluationReason);
if (user.trim().toUpperCase() == "USER") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonSpecial.find({
where: { kpiUserSpecialId: id, type: type.trim().toUpperCase() },
});
return new HttpSuccess(kpiUserEvaluationReason);
} else if (user.trim().toUpperCase() == "EVALUATOR") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonSpecial.find({
where: {
kpiUserSpecialId: id,
type: type.trim().toUpperCase(),
status: In(["EVALUATOR", "COMMANDER", "COMMANDERHIGH", "DONE"]),
},
});
return new HttpSuccess(kpiUserEvaluationReason);
} else if (user.trim().toUpperCase() == "COMMANDER") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonSpecial.find({
where: {
kpiUserSpecialId: id,
type: type.trim().toUpperCase(),
status: In(["COMMANDER", "COMMANDERHIGH", "DONE"]),
},
});
return new HttpSuccess(kpiUserEvaluationReason);
} else if (user.trim().toUpperCase() == "COMMANDERHIGH") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonSpecial.find({
where: {
kpiUserSpecialId: id,
type: type.trim().toUpperCase(),
status: In(["COMMANDERHIGH", "DONE"]),
},
});
return new HttpSuccess(kpiUserEvaluationReason);
}
} else {
if (user.trim().toUpperCase() == "USER") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonSpecial.find({
@ -772,10 +858,39 @@ export class kpiReasonController extends Controller {
@Path() user: string,
) {
if (type.trim().toUpperCase() == "PROBLEM") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonDevelopment.find({
where: { kpiUserDevelopmentId: id, type: type.trim().toUpperCase() },
});
return new HttpSuccess(kpiUserEvaluationReason);
if (user.trim().toUpperCase() == "USER") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonDevelopment.find({
where: { kpiUserDevelopmentId: id, type: type.trim().toUpperCase() },
});
return new HttpSuccess(kpiUserEvaluationReason);
} else if (user.trim().toUpperCase() == "EVALUATOR") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonDevelopment.find({
where: {
kpiUserDevelopmentId: id,
type: type.trim().toUpperCase(),
status: In(["EVALUATOR", "COMMANDER", "COMMANDERHIGH", "DONE"]),
},
});
return new HttpSuccess(kpiUserEvaluationReason);
} else if (user.trim().toUpperCase() == "COMMANDER") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonDevelopment.find({
where: {
kpiUserDevelopmentId: id,
type: type.trim().toUpperCase(),
status: In(["COMMANDER", "COMMANDERHIGH", "DONE"]),
},
});
return new HttpSuccess(kpiUserEvaluationReason);
} else if (user.trim().toUpperCase() == "COMMANDERHIGH") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonDevelopment.find({
where: {
kpiUserDevelopmentId: id,
type: type.trim().toUpperCase(),
status: In(["COMMANDERHIGH", "DONE"]),
},
});
return new HttpSuccess(kpiUserEvaluationReason);
}
} else {
if (user.trim().toUpperCase() == "USER") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonDevelopment.find({
@ -958,10 +1073,39 @@ export class kpiReasonController extends Controller {
@Get("{type}/capacity/{user}/{id}")
async listKpiUserCapacityReason(@Path() id: string, @Path() type: string, @Path() user: string) {
if (type.trim().toUpperCase() == "PROBLEM") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonCapacity.find({
where: { kpiUserCapacityId: id, type: type.trim().toUpperCase() },
});
return new HttpSuccess(kpiUserEvaluationReason);
if (user.trim().toUpperCase() == "USER") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonCapacity.find({
where: { kpiUserCapacityId: id, type: type.trim().toUpperCase() },
});
return new HttpSuccess(kpiUserEvaluationReason);
} else if (user.trim().toUpperCase() == "EVALUATOR") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonCapacity.find({
where: {
kpiUserCapacityId: id,
type: type.trim().toUpperCase(),
status: In(["EVALUATOR", "COMMANDER", "COMMANDERHIGH", "DONE"]),
},
});
return new HttpSuccess(kpiUserEvaluationReason);
} else if (user.trim().toUpperCase() == "COMMANDER") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonCapacity.find({
where: {
kpiUserCapacityId: id,
type: type.trim().toUpperCase(),
status: In(["COMMANDER", "COMMANDERHIGH", "DONE"]),
},
});
return new HttpSuccess(kpiUserEvaluationReason);
} else if (user.trim().toUpperCase() == "COMMANDERHIGH") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonCapacity.find({
where: {
kpiUserCapacityId: id,
type: type.trim().toUpperCase(),
status: In(["COMMANDERHIGH", "DONE"]),
},
});
return new HttpSuccess(kpiUserEvaluationReason);
}
} else {
if (user.trim().toUpperCase() == "USER") {
const kpiUserEvaluationReason = await this.kpiUserEvaluationReasonCapacity.find({