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")
|
||||
async GetKpiCapacityTypeGROUP(@Query("positionName") positionName: string) {
|
||||
let position = await this.positionRepository.findOne({
|
||||
where: {
|
||||
where: {
|
||||
name: Like(`${positionName}`),
|
||||
kpiLink: Not(IsNull()) || Not("")
|
||||
kpiLink: Not(IsNull()) || Not(""),
|
||||
},
|
||||
relations: ["kpiLink", "kpiLink.kpiCapacitys"],
|
||||
});
|
||||
|
||||
if (position == null) {
|
||||
position = await this.positionRepository.findOne({
|
||||
where: {
|
||||
name: "นักจัดการงานทั่วไป",
|
||||
kpiLink: Not(IsNull()) || Not("")
|
||||
where: {
|
||||
name: "นักจัดการงานทั่วไป",
|
||||
kpiLink: Not(IsNull()) || Not(""),
|
||||
},
|
||||
relations: ["kpiLink", "kpiLink.kpiCapacitys"],
|
||||
});
|
||||
|
|
@ -310,7 +310,8 @@ export class kpiCapacityController extends Controller {
|
|||
],
|
||||
})
|
||||
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({
|
||||
where: { id: id },
|
||||
select: ["type", "name", "description"],
|
||||
|
|
|
|||
|
|
@ -118,7 +118,8 @@ export class kpiGroupController extends Controller {
|
|||
nameGroupKPI: "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({
|
||||
where: { id: id },
|
||||
select: ["nameGroupKPI"],
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ export class kpiLinkController extends Controller {
|
|||
...requestBody,
|
||||
kpiCapacitys: [],
|
||||
});
|
||||
|
||||
|
||||
const chkCapacity = await this.kpiCapacityRepository.find({
|
||||
where: {
|
||||
id: In(requestBody.kpiCapacityIds),
|
||||
|
|
@ -181,7 +181,8 @@ export class kpiLinkController extends Controller {
|
|||
*/
|
||||
@Get("edit/{id}")
|
||||
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({
|
||||
where: { id: id },
|
||||
relations: ["positions", "kpiCapacitys", "kpiGroup"],
|
||||
|
|
|
|||
|
|
@ -175,7 +175,8 @@ export class kpiPeriodController extends Controller {
|
|||
endDate: "datetime", //วันสิ้นสุด
|
||||
})
|
||||
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({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -310,7 +310,8 @@ export class kpiPlanController extends Controller {
|
|||
*/
|
||||
@Get("edit/{id}")
|
||||
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({
|
||||
where: { id: id },
|
||||
relations: { kpiPeriod: true },
|
||||
|
|
|
|||
|
|
@ -286,7 +286,8 @@ export class kpiRoleController extends Controller {
|
|||
*/
|
||||
@Get("edit/{id}")
|
||||
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({
|
||||
where: { id: id },
|
||||
relations: { kpiPeriod: true },
|
||||
|
|
|
|||
|
|
@ -126,7 +126,8 @@ export class kpiSpecialController extends Controller {
|
|||
*/
|
||||
@Get("edit/{id}")
|
||||
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({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -177,7 +177,6 @@ export class KpiUserCapacityController extends Controller {
|
|||
*/
|
||||
@Get("{id}")
|
||||
async GetKpiUserCapacityById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||
const kpiUserCapacity = await this.kpiUserCapacityRepository.findOne({
|
||||
where: { id: id },
|
||||
relations: ["kpiCapacity"],
|
||||
|
|
@ -212,7 +211,6 @@ export class KpiUserCapacityController extends Controller {
|
|||
@Query("id") id: string, //kpiUserEvaluationId
|
||||
@Query("type") type: string,
|
||||
) {
|
||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||
const [kpiUserCapacity, total] = await AppDataSource.getRepository(KpiUserCapacity)
|
||||
.createQueryBuilder("kpiUserCapacity")
|
||||
.leftJoinAndSelect("kpiUserCapacity.kpiCapacity", "kpiCapacity")
|
||||
|
|
|
|||
|
|
@ -240,7 +240,6 @@ export class KpiUserDevelopmentController extends Controller {
|
|||
*/
|
||||
@Get("{id}")
|
||||
async GetKpiUserDevelopmentDetail(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||
const getKpiUserDevelopment = await this.kpiUserDevelopmentRepository.findOne({
|
||||
relations: ["kpiUserEvaluation", "developmentProjects"],
|
||||
where: { id: id },
|
||||
|
|
@ -282,7 +281,6 @@ export class KpiUserDevelopmentController extends Controller {
|
|||
*/
|
||||
@Get()
|
||||
async GetKpiUserDevelopment(@Request() request: RequestWithUser, @Query("id") id: string) {
|
||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");//USER
|
||||
const kpiUserDevelopment = await this.kpiUserDevelopmentRepository.find({
|
||||
where: {
|
||||
kpiUserEvaluationId: id,
|
||||
|
|
@ -452,7 +450,8 @@ export class KpiUserDevelopmentController extends Controller {
|
|||
@Request() request: RequestWithUser,
|
||||
@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({
|
||||
relations: [
|
||||
"kpiUserEvaluation",
|
||||
|
|
@ -514,23 +513,29 @@ export class KpiUserDevelopmentController extends Controller {
|
|||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลพัฒนาตนเองนี้");
|
||||
}
|
||||
if (type.trim().toLocaleUpperCase() == "OFFICER") {
|
||||
await new permission().PermissionOrgUserGet(
|
||||
request,
|
||||
"SYS_REGISTRY_OFFICER",
|
||||
getKpiUserDevelopment.kpiUserEvaluation.profileId,
|
||||
);
|
||||
let _workflow = await new permission().Workflow(request, id, "SYS_REGISTRY_OFFICER");
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionOrgUserGet(
|
||||
request,
|
||||
"SYS_REGISTRY_OFFICER",
|
||||
getKpiUserDevelopment.kpiUserEvaluation.profileId,
|
||||
);
|
||||
} else if (type.trim().toLocaleUpperCase() == "EMPLOYEE") {
|
||||
await new permission().PermissionOrgUserGet(
|
||||
request,
|
||||
"SYS_REGISTRY_EMP",
|
||||
getKpiUserDevelopment.kpiUserEvaluation.profileId,
|
||||
);
|
||||
let _workflow = await new permission().Workflow(request, id, "SYS_REGISTRY_EMP");
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionOrgUserGet(
|
||||
request,
|
||||
"SYS_REGISTRY_EMP",
|
||||
getKpiUserDevelopment.kpiUserEvaluation.profileId,
|
||||
);
|
||||
} else if (type.trim().toLocaleUpperCase() == "TEMP") {
|
||||
await new permission().PermissionOrgUserGet(
|
||||
request,
|
||||
"SYS_REGISTRY_TEMP",
|
||||
getKpiUserDevelopment.kpiUserEvaluation.profileId,
|
||||
);
|
||||
let _workflow = await new permission().Workflow(request, id, "SYS_REGISTRY_TEMP");
|
||||
if (_workflow == false)
|
||||
await new permission().PermissionOrgUserGet(
|
||||
request,
|
||||
"SYS_REGISTRY_TEMP",
|
||||
getKpiUserDevelopment.kpiUserEvaluation.profileId,
|
||||
);
|
||||
} else if (type.trim().toLocaleUpperCase() == "USER") {
|
||||
} else {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่สามารถเข้าถึงข้อมูลนี้ได้");
|
||||
|
|
|
|||
|
|
@ -1327,7 +1327,8 @@ export class KpiUserEvaluationController extends Controller {
|
|||
*/
|
||||
@Get("admin/{id}")
|
||||
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({
|
||||
relations: ["kpiPeriod"],
|
||||
where: { id: id },
|
||||
|
|
@ -1631,7 +1632,7 @@ export class KpiUserEvaluationController extends Controller {
|
|||
})
|
||||
.then(async () => {})
|
||||
.catch((error) => {
|
||||
console.error('Error details:', error.response.data);
|
||||
console.error("Error details:", error.response.data);
|
||||
});
|
||||
|
||||
kpiUserEvaluation.kpiUserDevelopments.map(async (kpiUserDevelopment) => {
|
||||
|
|
@ -1652,12 +1653,13 @@ export class KpiUserEvaluationController extends Controller {
|
|||
isDevelopment20: kpiUserDevelopment.isDevelopment20,
|
||||
isDevelopment10: kpiUserDevelopment.isDevelopment10,
|
||||
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),
|
||||
})
|
||||
.then(async () => {})
|
||||
.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 () => {})
|
||||
.catch((error) => {
|
||||
console.error('Error details:', error.response.data);
|
||||
console.error("Error details:", error.response.data);
|
||||
});
|
||||
const before = null;
|
||||
kpiUserEvaluation.lastUpdateUserId = request.user.sub;
|
||||
|
|
|
|||
|
|
@ -190,7 +190,6 @@ export class KpiUserPlannedController extends Controller {
|
|||
*/
|
||||
@Get("{id}")
|
||||
async GetKpiUserPlannedDetail(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||
const getKpiUserPlanned = await this.kpiUserPlannedRepository.findOne({
|
||||
relations: ["kpiPlan", "kpiUserEvaluation"],
|
||||
where: { id: id },
|
||||
|
|
@ -233,7 +232,6 @@ export class KpiUserPlannedController extends Controller {
|
|||
*/
|
||||
@Get()
|
||||
async GetKpiUserPlanned(@Request() request: RequestWithUser, @Query("id") id: string) {
|
||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");//USER
|
||||
const kpiUserPlanned = await this.kpiUserPlannedRepository.find({
|
||||
where: {
|
||||
kpiUserEvaluationId: id,
|
||||
|
|
|
|||
|
|
@ -194,7 +194,6 @@ export class KpiUserRoleController extends Controller {
|
|||
*/
|
||||
@Get("{id}")
|
||||
async GetKpiUserRoleDetail(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||
const getKpiUserRole = await this.kpiUserRoleRepository.findOne({
|
||||
relations: ["kpiRole", "kpiUserEvaluation"],
|
||||
where: { id: id },
|
||||
|
|
@ -237,7 +236,6 @@ export class KpiUserRoleController extends Controller {
|
|||
*/
|
||||
@Get()
|
||||
async GetKpiUserRole(@Request() request: RequestWithUser, @Query("id") id: string) {
|
||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");//USER
|
||||
const kpiUserRole = await this.kpiUserRoleRepository.find({
|
||||
where: {
|
||||
kpiUserEvaluationId: id,
|
||||
|
|
|
|||
|
|
@ -280,7 +280,6 @@ export class KpiUserSpecialController extends Controller {
|
|||
*/
|
||||
@Get()
|
||||
async GetKpiUserSpecial(@Request() request: RequestWithUser, @Query("id") id: string) {
|
||||
// await new permission().PermissionGet(request, "SYS_KPI_LIST");
|
||||
const kpiUserSpecial = await this.kpiUserSpecialRepository.find({
|
||||
where: {
|
||||
kpiUserEvaluationId: id,
|
||||
|
|
|
|||
|
|
@ -53,18 +53,7 @@ class CheckAuth {
|
|||
return await new CallAPI()
|
||||
.GetData(req, `/org/permission/org/${system}/${action}`)
|
||||
.then(async (x) => {
|
||||
console.log(x);
|
||||
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 = {
|
||||
root: [null],
|
||||
|
|
@ -72,6 +61,7 @@ class CheckAuth {
|
|||
child2: [null],
|
||||
child3: [null],
|
||||
child4: [null],
|
||||
privilege: [null],
|
||||
};
|
||||
let node = 4;
|
||||
if (x.orgChild1Id == null) {
|
||||
|
|
@ -83,13 +73,23 @@ class CheckAuth {
|
|||
} else if (x.orgChild4Id == null) {
|
||||
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 = {
|
||||
root: [x.orgRootId],
|
||||
child1: null,
|
||||
child2: null,
|
||||
child3: null,
|
||||
child4: null,
|
||||
privilege: "ROOT",
|
||||
};
|
||||
} else if (privilege == "CHILD") {
|
||||
data = {
|
||||
|
|
@ -98,6 +98,7 @@ class CheckAuth {
|
|||
child2: node >= 2 ? [x.orgChild2Id] : null,
|
||||
child3: node >= 3 ? [x.orgChild3Id] : null,
|
||||
child4: node >= 4 ? [x.orgChild4Id] : null,
|
||||
privilege: "CHILD",
|
||||
};
|
||||
} else if (privilege == "NORMAL") {
|
||||
data = {
|
||||
|
|
@ -106,16 +107,9 @@ class CheckAuth {
|
|||
child2: [x.orgChild2Id],
|
||||
child3: [x.orgChild3Id],
|
||||
child4: [x.orgChild4Id],
|
||||
privilege: "NORMAL",
|
||||
};
|
||||
} else if (privilege == "SPECIFIC") {
|
||||
} else if (privilege == "OWNER") {
|
||||
data = {
|
||||
root: null,
|
||||
child1: null,
|
||||
child2: null,
|
||||
child3: null,
|
||||
child4: null,
|
||||
};
|
||||
}
|
||||
|
||||
return data;
|
||||
|
|
@ -145,16 +139,6 @@ class CheckAuth {
|
|||
.GetData(req, `/org/permission/user/${system}/${action}/${profileId}`)
|
||||
.then(async (x) => {
|
||||
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.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) {
|
||||
return await this.Permission(req, system, "CREATE");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue