check workflow
This commit is contained in:
parent
e3e6a1df36
commit
a4647e102a
14 changed files with 84 additions and 73 deletions
|
|
@ -230,18 +230,18 @@ export class kpiCapacityController extends Controller {
|
||||||
@Get("group")
|
@Get("group")
|
||||||
async GetKpiCapacityTypeGROUP(@Query("positionName") positionName: string) {
|
async GetKpiCapacityTypeGROUP(@Query("positionName") positionName: string) {
|
||||||
let position = await this.positionRepository.findOne({
|
let position = await this.positionRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
name: Like(`${positionName}`),
|
name: Like(`${positionName}`),
|
||||||
kpiLink: Not(IsNull()) || Not("")
|
kpiLink: Not(IsNull()) || Not(""),
|
||||||
},
|
},
|
||||||
relations: ["kpiLink", "kpiLink.kpiCapacitys"],
|
relations: ["kpiLink", "kpiLink.kpiCapacitys"],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (position == null) {
|
if (position == null) {
|
||||||
position = await this.positionRepository.findOne({
|
position = await this.positionRepository.findOne({
|
||||||
where: {
|
where: {
|
||||||
name: "นักจัดการงานทั่วไป",
|
name: "นักจัดการงานทั่วไป",
|
||||||
kpiLink: Not(IsNull()) || Not("")
|
kpiLink: Not(IsNull()) || Not(""),
|
||||||
},
|
},
|
||||||
relations: ["kpiLink", "kpiLink.kpiCapacitys"],
|
relations: ["kpiLink", "kpiLink.kpiCapacitys"],
|
||||||
});
|
});
|
||||||
|
|
@ -310,7 +310,8 @@ export class kpiCapacityController extends Controller {
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
async GetKpiCapacityByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
|
async GetKpiCapacityByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
let _data = await new permission().PermissionGet(request, "SYS_EVA_COMPETENCY");
|
let _workflow = await new permission().Workflow(request, id, "SYS_EVA_COMPETENCY");
|
||||||
|
if (_workflow == false) await new permission().PermissionGet(request, "SYS_EVA_COMPETENCY");
|
||||||
const kpiCapacity = await this.kpiCapacityRepository.findOne({
|
const kpiCapacity = await this.kpiCapacityRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
select: ["type", "name", "description"],
|
select: ["type", "name", "description"],
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,8 @@ export class kpiGroupController extends Controller {
|
||||||
nameGroupKPI: "string", //ชื่อกลุ่มงาน
|
nameGroupKPI: "string", //ชื่อกลุ่มงาน
|
||||||
})
|
})
|
||||||
async KpiGroupByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
|
async KpiGroupByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
let _data = await new permission().PermissionGet(request, "SYS_EVA_COMPETENCY");
|
let _workflow = await new permission().Workflow(request, id, "SYS_EVA_COMPETENCY");
|
||||||
|
if (_workflow == false) await new permission().PermissionGet(request, "SYS_EVA_COMPETENCY");
|
||||||
const kpiGroup = await this.kpiGroupRepository.findOne({
|
const kpiGroup = await this.kpiGroupRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
select: ["nameGroupKPI"],
|
select: ["nameGroupKPI"],
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ export class kpiLinkController extends Controller {
|
||||||
...requestBody,
|
...requestBody,
|
||||||
kpiCapacitys: [],
|
kpiCapacitys: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const chkCapacity = await this.kpiCapacityRepository.find({
|
const chkCapacity = await this.kpiCapacityRepository.find({
|
||||||
where: {
|
where: {
|
||||||
id: In(requestBody.kpiCapacityIds),
|
id: In(requestBody.kpiCapacityIds),
|
||||||
|
|
@ -181,7 +181,8 @@ export class kpiLinkController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("edit/{id}")
|
@Get("edit/{id}")
|
||||||
async KpiLinkByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
|
async KpiLinkByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
let _data = await new permission().PermissionGet(request, "SYS_EVA_COMPETENCY");
|
let _workflow = await new permission().Workflow(request, id, "SYS_EVA_COMPETENCY");
|
||||||
|
if (_workflow == false) await new permission().PermissionGet(request, "SYS_EVA_COMPETENCY");
|
||||||
const kpiLink = await this.kpiLinkRepository.findOne({
|
const kpiLink = await this.kpiLinkRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
relations: ["positions", "kpiCapacitys", "kpiGroup"],
|
relations: ["positions", "kpiCapacitys", "kpiGroup"],
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,8 @@ export class kpiPeriodController extends Controller {
|
||||||
endDate: "datetime", //วันสิ้นสุด
|
endDate: "datetime", //วันสิ้นสุด
|
||||||
})
|
})
|
||||||
async OpenKpiPeriodById(@Path() id: string, @Request() request: RequestWithUser) {
|
async OpenKpiPeriodById(@Path() id: string, @Request() request: RequestWithUser) {
|
||||||
await new permission().PermissionGet(request, "SYS_KPI_ROUND");
|
let _workflow = await new permission().Workflow(request, id, "SYS_KPI_ROUND");
|
||||||
|
if (_workflow == false) await new permission().PermissionGet(request, "SYS_KPI_ROUND");
|
||||||
const kpiPeriod = await this.kpiPeriodRepository.findOne({
|
const kpiPeriod = await this.kpiPeriodRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -310,7 +310,8 @@ export class kpiPlanController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("edit/{id}")
|
@Get("edit/{id}")
|
||||||
async GetKpiPlanByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
|
async GetKpiPlanByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
let _data = await new permission().PermissionGet(request, "SYS_EVA_INDICATOR");
|
let _workflow = await new permission().Workflow(request, id, "SYS_EVA_INDICATOR");
|
||||||
|
if (_workflow == false) await new permission().PermissionGet(request, "SYS_EVA_INDICATOR");
|
||||||
const kpiPlan = await this.kpiPlanRepository.findOne({
|
const kpiPlan = await this.kpiPlanRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
relations: { kpiPeriod: true },
|
relations: { kpiPeriod: true },
|
||||||
|
|
|
||||||
|
|
@ -286,7 +286,8 @@ export class kpiRoleController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("edit/{id}")
|
@Get("edit/{id}")
|
||||||
async GetKpiRoleByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
|
async GetKpiRoleByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
let _data = await new permission().PermissionGet(request, "SYS_EVA_INDICATOR");
|
let _workflow = await new permission().Workflow(request, id, "SYS_EVA_INDICATOR");
|
||||||
|
if (_workflow == false) await new permission().PermissionGet(request, "SYS_EVA_INDICATOR");
|
||||||
const kpiRole = await this.kpiRoleRepository.findOne({
|
const kpiRole = await this.kpiRoleRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
relations: { kpiPeriod: true },
|
relations: { kpiPeriod: true },
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,8 @@ export class kpiSpecialController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("edit/{id}")
|
@Get("edit/{id}")
|
||||||
async GetKpiSpecialByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
|
async GetKpiSpecialByIdEdit(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
let _data = await new permission().PermissionGet(request, "SYS_EVA_INDICATOR");
|
let _workflow = await new permission().Workflow(request, id, "SYS_EVA_INDICATOR");
|
||||||
|
if (_workflow == false) await new permission().PermissionGet(request, "SYS_EVA_INDICATOR");
|
||||||
const KpiSpecial = await this.kpiSpecialRepository.findOne({
|
const KpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -177,7 +177,6 @@ export class KpiUserCapacityController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetKpiUserCapacityById(@Request() request: RequestWithUser, @Path() id: string) {
|
async GetKpiUserCapacityById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
|
||||||
const kpiUserCapacity = await this.kpiUserCapacityRepository.findOne({
|
const kpiUserCapacity = await this.kpiUserCapacityRepository.findOne({
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
relations: ["kpiCapacity"],
|
relations: ["kpiCapacity"],
|
||||||
|
|
@ -212,7 +211,6 @@ export class KpiUserCapacityController extends Controller {
|
||||||
@Query("id") id: string, //kpiUserEvaluationId
|
@Query("id") id: string, //kpiUserEvaluationId
|
||||||
@Query("type") type: string,
|
@Query("type") type: string,
|
||||||
) {
|
) {
|
||||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
|
||||||
const [kpiUserCapacity, total] = await AppDataSource.getRepository(KpiUserCapacity)
|
const [kpiUserCapacity, total] = await AppDataSource.getRepository(KpiUserCapacity)
|
||||||
.createQueryBuilder("kpiUserCapacity")
|
.createQueryBuilder("kpiUserCapacity")
|
||||||
.leftJoinAndSelect("kpiUserCapacity.kpiCapacity", "kpiCapacity")
|
.leftJoinAndSelect("kpiUserCapacity.kpiCapacity", "kpiCapacity")
|
||||||
|
|
|
||||||
|
|
@ -240,7 +240,6 @@ export class KpiUserDevelopmentController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetKpiUserDevelopmentDetail(@Request() request: RequestWithUser, @Path() id: string) {
|
async GetKpiUserDevelopmentDetail(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
|
||||||
const getKpiUserDevelopment = await this.kpiUserDevelopmentRepository.findOne({
|
const getKpiUserDevelopment = await this.kpiUserDevelopmentRepository.findOne({
|
||||||
relations: ["kpiUserEvaluation", "developmentProjects"],
|
relations: ["kpiUserEvaluation", "developmentProjects"],
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -282,7 +281,6 @@ export class KpiUserDevelopmentController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async GetKpiUserDevelopment(@Request() request: RequestWithUser, @Query("id") id: string) {
|
async GetKpiUserDevelopment(@Request() request: RequestWithUser, @Query("id") id: string) {
|
||||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");//USER
|
|
||||||
const kpiUserDevelopment = await this.kpiUserDevelopmentRepository.find({
|
const kpiUserDevelopment = await this.kpiUserDevelopmentRepository.find({
|
||||||
where: {
|
where: {
|
||||||
kpiUserEvaluationId: id,
|
kpiUserEvaluationId: id,
|
||||||
|
|
@ -452,7 +450,8 @@ export class KpiUserDevelopmentController extends Controller {
|
||||||
@Request() request: RequestWithUser,
|
@Request() request: RequestWithUser,
|
||||||
@Path("id") id: string,
|
@Path("id") id: string,
|
||||||
) {
|
) {
|
||||||
await new permission().PermissionGet(request, "SYS_RESULT");
|
let _workflow = await new permission().Workflow(request, id, "SYS_RESULT");
|
||||||
|
if (_workflow == false) await new permission().PermissionGet(request, "SYS_RESULT");
|
||||||
const kpiUserDevelopment = await this.kpiUserDevelopmentRepository.findOne({
|
const kpiUserDevelopment = await this.kpiUserDevelopmentRepository.findOne({
|
||||||
relations: [
|
relations: [
|
||||||
"kpiUserEvaluation",
|
"kpiUserEvaluation",
|
||||||
|
|
@ -514,23 +513,29 @@ export class KpiUserDevelopmentController extends Controller {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลพัฒนาตนเองนี้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลพัฒนาตนเองนี้");
|
||||||
}
|
}
|
||||||
if (type.trim().toLocaleUpperCase() == "OFFICER") {
|
if (type.trim().toLocaleUpperCase() == "OFFICER") {
|
||||||
await new permission().PermissionOrgUserGet(
|
let _workflow = await new permission().Workflow(request, id, "SYS_REGISTRY_OFFICER");
|
||||||
request,
|
if (_workflow == false)
|
||||||
"SYS_REGISTRY_OFFICER",
|
await new permission().PermissionOrgUserGet(
|
||||||
getKpiUserDevelopment.kpiUserEvaluation.profileId,
|
request,
|
||||||
);
|
"SYS_REGISTRY_OFFICER",
|
||||||
|
getKpiUserDevelopment.kpiUserEvaluation.profileId,
|
||||||
|
);
|
||||||
} else if (type.trim().toLocaleUpperCase() == "EMPLOYEE") {
|
} else if (type.trim().toLocaleUpperCase() == "EMPLOYEE") {
|
||||||
await new permission().PermissionOrgUserGet(
|
let _workflow = await new permission().Workflow(request, id, "SYS_REGISTRY_EMP");
|
||||||
request,
|
if (_workflow == false)
|
||||||
"SYS_REGISTRY_EMP",
|
await new permission().PermissionOrgUserGet(
|
||||||
getKpiUserDevelopment.kpiUserEvaluation.profileId,
|
request,
|
||||||
);
|
"SYS_REGISTRY_EMP",
|
||||||
|
getKpiUserDevelopment.kpiUserEvaluation.profileId,
|
||||||
|
);
|
||||||
} else if (type.trim().toLocaleUpperCase() == "TEMP") {
|
} else if (type.trim().toLocaleUpperCase() == "TEMP") {
|
||||||
await new permission().PermissionOrgUserGet(
|
let _workflow = await new permission().Workflow(request, id, "SYS_REGISTRY_TEMP");
|
||||||
request,
|
if (_workflow == false)
|
||||||
"SYS_REGISTRY_TEMP",
|
await new permission().PermissionOrgUserGet(
|
||||||
getKpiUserDevelopment.kpiUserEvaluation.profileId,
|
request,
|
||||||
);
|
"SYS_REGISTRY_TEMP",
|
||||||
|
getKpiUserDevelopment.kpiUserEvaluation.profileId,
|
||||||
|
);
|
||||||
} else if (type.trim().toLocaleUpperCase() == "USER") {
|
} else if (type.trim().toLocaleUpperCase() == "USER") {
|
||||||
} else {
|
} else {
|
||||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถเข้าถึงข้อมูลนี้ได้");
|
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถเข้าถึงข้อมูลนี้ได้");
|
||||||
|
|
|
||||||
|
|
@ -1327,7 +1327,8 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("admin/{id}")
|
@Get("admin/{id}")
|
||||||
async GetKpiAdminEvaluationById(@Path() id: string, @Request() req: RequestWithUser) {
|
async GetKpiAdminEvaluationById(@Path() id: string, @Request() req: RequestWithUser) {
|
||||||
await new permission().PermissionGet(req, "SYS_KPI_LIST");
|
let _workflow = await new permission().Workflow(req, id, "SYS_KPI_LIST");
|
||||||
|
if (_workflow == false) await new permission().PermissionGet(req, "SYS_KPI_LIST");
|
||||||
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
const kpiUserEvaluation = await this.kpiUserEvalutionRepository.findOne({
|
||||||
relations: ["kpiPeriod"],
|
relations: ["kpiPeriod"],
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -1631,7 +1632,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
})
|
})
|
||||||
.then(async () => {})
|
.then(async () => {})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error details:', error.response.data);
|
console.error("Error details:", error.response.data);
|
||||||
});
|
});
|
||||||
|
|
||||||
kpiUserEvaluation.kpiUserDevelopments.map(async (kpiUserDevelopment) => {
|
kpiUserEvaluation.kpiUserDevelopments.map(async (kpiUserDevelopment) => {
|
||||||
|
|
@ -1652,12 +1653,13 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
isDevelopment20: kpiUserDevelopment.isDevelopment20,
|
isDevelopment20: kpiUserDevelopment.isDevelopment20,
|
||||||
isDevelopment10: kpiUserDevelopment.isDevelopment10,
|
isDevelopment10: kpiUserDevelopment.isDevelopment10,
|
||||||
developmentResults: `${kpiUserDevelopment.achievement10}(10), ${kpiUserDevelopment.achievement5}(5), ${kpiUserDevelopment.achievement0}(0)`,
|
developmentResults: `${kpiUserDevelopment.achievement10}(10), ${kpiUserDevelopment.achievement5}(5), ${kpiUserDevelopment.achievement0}(0)`,
|
||||||
developmentReport: kpiUserDevelopment.point != null ?kpiUserDevelopment.point.toString():null,
|
developmentReport:
|
||||||
|
kpiUserDevelopment.point != null ? kpiUserDevelopment.point.toString() : null,
|
||||||
developmentProjects: kpiUserDevelopment.developmentProjects.map((x) => x.name),
|
developmentProjects: kpiUserDevelopment.developmentProjects.map((x) => x.name),
|
||||||
})
|
})
|
||||||
.then(async () => {})
|
.then(async () => {})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error details:', error.response.data);
|
console.error("Error details:", error.response.data);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -1673,7 +1675,7 @@ export class KpiUserEvaluationController extends Controller {
|
||||||
})
|
})
|
||||||
.then(async () => {})
|
.then(async () => {})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
console.error('Error details:', error.response.data);
|
console.error("Error details:", error.response.data);
|
||||||
});
|
});
|
||||||
const before = null;
|
const before = null;
|
||||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||||
|
|
|
||||||
|
|
@ -190,7 +190,6 @@ export class KpiUserPlannedController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetKpiUserPlannedDetail(@Request() request: RequestWithUser, @Path() id: string) {
|
async GetKpiUserPlannedDetail(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
|
||||||
const getKpiUserPlanned = await this.kpiUserPlannedRepository.findOne({
|
const getKpiUserPlanned = await this.kpiUserPlannedRepository.findOne({
|
||||||
relations: ["kpiPlan", "kpiUserEvaluation"],
|
relations: ["kpiPlan", "kpiUserEvaluation"],
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -233,7 +232,6 @@ export class KpiUserPlannedController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async GetKpiUserPlanned(@Request() request: RequestWithUser, @Query("id") id: string) {
|
async GetKpiUserPlanned(@Request() request: RequestWithUser, @Query("id") id: string) {
|
||||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");//USER
|
|
||||||
const kpiUserPlanned = await this.kpiUserPlannedRepository.find({
|
const kpiUserPlanned = await this.kpiUserPlannedRepository.find({
|
||||||
where: {
|
where: {
|
||||||
kpiUserEvaluationId: id,
|
kpiUserEvaluationId: id,
|
||||||
|
|
|
||||||
|
|
@ -194,7 +194,6 @@ export class KpiUserRoleController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get("{id}")
|
@Get("{id}")
|
||||||
async GetKpiUserRoleDetail(@Request() request: RequestWithUser, @Path() id: string) {
|
async GetKpiUserRoleDetail(@Request() request: RequestWithUser, @Path() id: string) {
|
||||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
|
||||||
const getKpiUserRole = await this.kpiUserRoleRepository.findOne({
|
const getKpiUserRole = await this.kpiUserRoleRepository.findOne({
|
||||||
relations: ["kpiRole", "kpiUserEvaluation"],
|
relations: ["kpiRole", "kpiUserEvaluation"],
|
||||||
where: { id: id },
|
where: { id: id },
|
||||||
|
|
@ -237,7 +236,6 @@ export class KpiUserRoleController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async GetKpiUserRole(@Request() request: RequestWithUser, @Query("id") id: string) {
|
async GetKpiUserRole(@Request() request: RequestWithUser, @Query("id") id: string) {
|
||||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");//USER
|
|
||||||
const kpiUserRole = await this.kpiUserRoleRepository.find({
|
const kpiUserRole = await this.kpiUserRoleRepository.find({
|
||||||
where: {
|
where: {
|
||||||
kpiUserEvaluationId: id,
|
kpiUserEvaluationId: id,
|
||||||
|
|
|
||||||
|
|
@ -280,7 +280,6 @@ export class KpiUserSpecialController extends Controller {
|
||||||
*/
|
*/
|
||||||
@Get()
|
@Get()
|
||||||
async GetKpiUserSpecial(@Request() request: RequestWithUser, @Query("id") id: string) {
|
async GetKpiUserSpecial(@Request() request: RequestWithUser, @Query("id") id: string) {
|
||||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
|
||||||
const kpiUserSpecial = await this.kpiUserSpecialRepository.find({
|
const kpiUserSpecial = await this.kpiUserSpecialRepository.find({
|
||||||
where: {
|
where: {
|
||||||
kpiUserEvaluationId: id,
|
kpiUserEvaluationId: id,
|
||||||
|
|
|
||||||
|
|
@ -53,18 +53,7 @@ class CheckAuth {
|
||||||
return await new CallAPI()
|
return await new CallAPI()
|
||||||
.GetData(req, `/org/permission/org/${system}/${action}`)
|
.GetData(req, `/org/permission/org/${system}/${action}`)
|
||||||
.then(async (x) => {
|
.then(async (x) => {
|
||||||
console.log(x);
|
|
||||||
let privilege = x.privilege;
|
let privilege = x.privilege;
|
||||||
// if (action.trim().toLocaleUpperCase() == "CREATE")
|
|
||||||
// privilege = await this.PermissionCreate(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "DELETE")
|
|
||||||
// privilege = await this.PermissionDelete(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "GET")
|
|
||||||
// privilege = await this.PermissionGet(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "LIST")
|
|
||||||
// privilege = await this.PermissionList(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "UPDATE")
|
|
||||||
// privilege = await this.PermissionUpdate(req, system);
|
|
||||||
|
|
||||||
let data: any = {
|
let data: any = {
|
||||||
root: [null],
|
root: [null],
|
||||||
|
|
@ -72,6 +61,7 @@ class CheckAuth {
|
||||||
child2: [null],
|
child2: [null],
|
||||||
child3: [null],
|
child3: [null],
|
||||||
child4: [null],
|
child4: [null],
|
||||||
|
privilege: [null],
|
||||||
};
|
};
|
||||||
let node = 4;
|
let node = 4;
|
||||||
if (x.orgChild1Id == null) {
|
if (x.orgChild1Id == null) {
|
||||||
|
|
@ -83,13 +73,23 @@ class CheckAuth {
|
||||||
} else if (x.orgChild4Id == null) {
|
} else if (x.orgChild4Id == null) {
|
||||||
node = 3;
|
node = 3;
|
||||||
}
|
}
|
||||||
if (privilege == "ROOT") {
|
if (privilege == "OWNER") {
|
||||||
|
data = {
|
||||||
|
root: null,
|
||||||
|
child1: null,
|
||||||
|
child2: null,
|
||||||
|
child3: null,
|
||||||
|
child4: null,
|
||||||
|
privilege: "OWNER",
|
||||||
|
};
|
||||||
|
} else if (privilege == "ROOT") {
|
||||||
data = {
|
data = {
|
||||||
root: [x.orgRootId],
|
root: [x.orgRootId],
|
||||||
child1: null,
|
child1: null,
|
||||||
child2: null,
|
child2: null,
|
||||||
child3: null,
|
child3: null,
|
||||||
child4: null,
|
child4: null,
|
||||||
|
privilege: "ROOT",
|
||||||
};
|
};
|
||||||
} else if (privilege == "CHILD") {
|
} else if (privilege == "CHILD") {
|
||||||
data = {
|
data = {
|
||||||
|
|
@ -98,6 +98,7 @@ class CheckAuth {
|
||||||
child2: node >= 2 ? [x.orgChild2Id] : null,
|
child2: node >= 2 ? [x.orgChild2Id] : null,
|
||||||
child3: node >= 3 ? [x.orgChild3Id] : null,
|
child3: node >= 3 ? [x.orgChild3Id] : null,
|
||||||
child4: node >= 4 ? [x.orgChild4Id] : null,
|
child4: node >= 4 ? [x.orgChild4Id] : null,
|
||||||
|
privilege: "CHILD",
|
||||||
};
|
};
|
||||||
} else if (privilege == "NORMAL") {
|
} else if (privilege == "NORMAL") {
|
||||||
data = {
|
data = {
|
||||||
|
|
@ -106,16 +107,9 @@ class CheckAuth {
|
||||||
child2: [x.orgChild2Id],
|
child2: [x.orgChild2Id],
|
||||||
child3: [x.orgChild3Id],
|
child3: [x.orgChild3Id],
|
||||||
child4: [x.orgChild4Id],
|
child4: [x.orgChild4Id],
|
||||||
|
privilege: "NORMAL",
|
||||||
};
|
};
|
||||||
} else if (privilege == "SPECIFIC") {
|
} else if (privilege == "SPECIFIC") {
|
||||||
} else if (privilege == "OWNER") {
|
|
||||||
data = {
|
|
||||||
root: null,
|
|
||||||
child1: null,
|
|
||||||
child2: null,
|
|
||||||
child3: null,
|
|
||||||
child4: null,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
|
|
@ -145,16 +139,6 @@ class CheckAuth {
|
||||||
.GetData(req, `/org/permission/user/${system}/${action}/${profileId}`)
|
.GetData(req, `/org/permission/user/${system}/${action}/${profileId}`)
|
||||||
.then(async (x) => {
|
.then(async (x) => {
|
||||||
let org = x.org;
|
let org = x.org;
|
||||||
// if (action.trim().toLocaleUpperCase() == "CREATE")
|
|
||||||
// org = await this.PermissionOrgCreate(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "DELETE")
|
|
||||||
// org = await this.PermissionOrgDelete(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "GET")
|
|
||||||
// org = await this.PermissionOrgGet(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "LIST")
|
|
||||||
// org = await this.PermissionOrgList(req, system);
|
|
||||||
// if (action.trim().toLocaleUpperCase() == "UPDATE")
|
|
||||||
// org = await this.PermissionOrgUpdate(req, system);
|
|
||||||
|
|
||||||
if (org.root != null) if (x.orgRootId != org.root[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
|
if (org.root != null) if (x.orgRootId != org.root[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
|
||||||
if (org.child1 != null)
|
if (org.child1 != null)
|
||||||
|
|
@ -176,6 +160,26 @@ class CheckAuth {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
public async Workflow(req: RequestWithUser, id: string, sysName: string) {
|
||||||
|
if (
|
||||||
|
req.headers.hasOwnProperty("api_key") &&
|
||||||
|
req.headers["api_key"] &&
|
||||||
|
req.headers["api_key"] == process.env.API_KEY
|
||||||
|
) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return await new CallAPI()
|
||||||
|
.PostData(req, "/org/workflow/keycloak/isofficer", {
|
||||||
|
refId: id,
|
||||||
|
sysName: sysName,
|
||||||
|
})
|
||||||
|
.then((x) => {
|
||||||
|
return true;
|
||||||
|
})
|
||||||
|
.catch((x) => {
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
public async PermissionCreate(req: RequestWithUser, system: string) {
|
public async PermissionCreate(req: RequestWithUser, system: string) {
|
||||||
return await this.Permission(req, system, "CREATE");
|
return await this.Permission(req, system, "CREATE");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue