ผูกสิดข้อมูลหลัก
This commit is contained in:
parent
f9fce4ba25
commit
92b2291c4b
15 changed files with 702 additions and 514 deletions
|
|
@ -69,7 +69,7 @@ export class kpiCapacityController extends Controller {
|
|||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionCreate(request,"SYS_EVA_COMPETENCY");
|
||||
await new permission().PermissionCreate(request, "SYS_EVA_COMPETENCY");
|
||||
const kpiCapacity = Object.assign(new KpiCapacity(), {
|
||||
type: requestBody.type,
|
||||
name: requestBody.name,
|
||||
|
|
@ -134,7 +134,7 @@ export class kpiCapacityController extends Controller {
|
|||
},
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request,"SYS_EVA_COMPETENCY");
|
||||
await new permission().PermissionUpdate(request, "SYS_EVA_COMPETENCY");
|
||||
const kpiCapacity = await this.kpiCapacityRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -285,7 +285,8 @@ export class kpiCapacityController extends Controller {
|
|||
},
|
||||
],
|
||||
})
|
||||
async GetKpiCapacityById(@Path() id: string) {
|
||||
async GetKpiCapacityById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||
const kpiCapacity = await this.kpiCapacityRepository.findOne({
|
||||
where: { id: id },
|
||||
select: ["type", "name", "description"],
|
||||
|
|
@ -315,11 +316,13 @@ export class kpiCapacityController extends Controller {
|
|||
*/
|
||||
@Get()
|
||||
async listKpiCapacity(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("type") type?: string,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||
const [kpiCapacity, total] = await AppDataSource.getRepository(KpiCapacity)
|
||||
.createQueryBuilder("kpiCapacity")
|
||||
.leftJoinAndSelect("kpiCapacity.kpiCapacityDetails", "kpiCapacityDetail")
|
||||
|
|
@ -360,7 +363,7 @@ export class kpiCapacityController extends Controller {
|
|||
*/
|
||||
@Delete("{id}")
|
||||
async deleteKpiCapacity(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionDelete(request,"SYS_EVA_COMPETENCY");
|
||||
await new permission().PermissionDelete(request, "SYS_EVA_COMPETENCY");
|
||||
const kpiCapacity = await this.kpiCapacityRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Route,
|
||||
Security,
|
||||
Tags,
|
||||
Body,
|
||||
Path,
|
||||
Request,
|
||||
Example,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Query,
|
||||
|
|
@ -18,7 +14,7 @@ import {
|
|||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { Like, Not } from "typeorm";
|
||||
import { Like } from "typeorm";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { KpiEvaluation, updateKpiEvaluation } from "../entities/kpiEvaluation";
|
||||
import permission from "../interfaces/permission";
|
||||
|
|
@ -43,7 +39,7 @@ export class kpiEvaluationController extends Controller {
|
|||
@Body() requestBody: updateKpiEvaluation[],
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request,"SYS_EVA_COMPETENCY");
|
||||
await new permission().PermissionUpdate(request, "SYS_EVA_COMPETENCY");
|
||||
const updatedIds: string[] = [];
|
||||
|
||||
for (const item of requestBody) {
|
||||
|
|
@ -70,10 +66,12 @@ export class kpiEvaluationController extends Controller {
|
|||
*/
|
||||
@Get()
|
||||
async listKpiEvaluation(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||
let whereClause: any = {};
|
||||
|
||||
if (keyword !== undefined && keyword !== "") {
|
||||
|
|
|
|||
|
|
@ -43,11 +43,8 @@ export class kpiGroupController extends Controller {
|
|||
@Example({
|
||||
nameGroupKPI: "string", //ชื่อกลุ่มงาน
|
||||
})
|
||||
async createKpiGroup(
|
||||
@Body() requestBody: createKpiGroup,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionCreate(request,"SYS_EVA_COMPETENCY");
|
||||
async createKpiGroup(@Body() requestBody: createKpiGroup, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionCreate(request, "SYS_EVA_COMPETENCY");
|
||||
const kpiGroup = Object.assign(new KpiGroup(), requestBody);
|
||||
const chkkpinameGroup = await this.kpiGroupRepository.findOne({
|
||||
where: {
|
||||
|
|
@ -75,7 +72,7 @@ export class kpiGroupController extends Controller {
|
|||
@Body() requestBody: updateKpiGroup,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request,"SYS_EVA_COMPETENCY");
|
||||
await new permission().PermissionUpdate(request, "SYS_EVA_COMPETENCY");
|
||||
const kpiGroup = await this.kpiGroupRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -86,7 +83,7 @@ export class kpiGroupController extends Controller {
|
|||
const chkkpinameGroup = await this.kpiGroupRepository.findOne({
|
||||
where: {
|
||||
nameGroupKPI: requestBody.nameGroupKPI,
|
||||
id: Not(id)
|
||||
id: Not(id),
|
||||
},
|
||||
});
|
||||
if (chkkpinameGroup) {
|
||||
|
|
@ -107,7 +104,8 @@ export class kpiGroupController extends Controller {
|
|||
@Example({
|
||||
nameGroupKPI: "string", //ชื่อกลุ่มงาน
|
||||
})
|
||||
async KpiGroupById(@Path() id: string) {
|
||||
async KpiGroupById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||
const kpiGroup = await this.kpiGroupRepository.findOne({
|
||||
where: { id: id },
|
||||
select: ["nameGroupKPI"],
|
||||
|
|
@ -124,7 +122,7 @@ export class kpiGroupController extends Controller {
|
|||
*/
|
||||
@Delete("{id}")
|
||||
async deleteKpiGroup(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionDelete(request,"SYS_EVA_COMPETENCY");
|
||||
await new permission().PermissionDelete(request, "SYS_EVA_COMPETENCY");
|
||||
const kpiGroup = await this.kpiGroupRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -143,10 +141,12 @@ export class kpiGroupController extends Controller {
|
|||
*/
|
||||
@Get()
|
||||
async listKpiGroup(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||
let whereClause: any = {};
|
||||
|
||||
if (keyword !== undefined && keyword !== "") {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import {
|
|||
Body,
|
||||
Path,
|
||||
Request,
|
||||
Example,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Query,
|
||||
|
|
@ -18,9 +17,9 @@ import {
|
|||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { Like, Not, In, Brackets } from "typeorm";
|
||||
import { In, Brackets } from "typeorm";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { KpiLink, createKpiLink, updateKpiLink } from "../entities/kpiLink";
|
||||
import { KpiLink, createKpiLink } from "../entities/kpiLink";
|
||||
import { KpiGroup } from "../entities/kpiGroup";
|
||||
import { KpiCapacity } from "../entities/kpiCapacity";
|
||||
import { Position } from "../entities/position";
|
||||
|
|
@ -165,7 +164,8 @@ export class kpiLinkController extends Controller {
|
|||
* @param id
|
||||
*/
|
||||
@Get("{id}")
|
||||
async KpiLinkById(@Path() id: string) {
|
||||
async KpiLinkById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||
const kpiLink = await this.kpiLinkRepository.findOne({
|
||||
where: { id: id },
|
||||
relations: ["positions", "kpiCapacitys", "kpiGroup"],
|
||||
|
|
@ -224,10 +224,12 @@ export class kpiLinkController extends Controller {
|
|||
*/
|
||||
@Get()
|
||||
async listKpiLink(
|
||||
@Request() request: RequestWithUser,
|
||||
@Query("page") page: number = 1,
|
||||
@Query("pageSize") pageSize: number = 10,
|
||||
@Query("keyword") keyword?: string,
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_COMPETENCY");
|
||||
const [_kpiLink, _total] = await AppDataSource.getRepository(KpiLink)
|
||||
.createQueryBuilder("kpiLink")
|
||||
.leftJoinAndSelect("kpiLink.kpiGroup", "kpiGroup")
|
||||
|
|
|
|||
|
|
@ -10,10 +10,8 @@ import {
|
|||
Body,
|
||||
Path,
|
||||
Request,
|
||||
Example,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Query,
|
||||
} from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
|
|
@ -22,7 +20,7 @@ import HttpStatusCode from "../interfaces/http-status";
|
|||
import { KpiPlan, createKpiPlan, updateKpiPlan } from "../entities/kpiPlan";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import { KpiPeriod } from "../entities/kpiPeriod";
|
||||
import { Brackets, IsNull, Not } from "typeorm";
|
||||
import { Brackets, IsNull } from "typeorm";
|
||||
import { KpiPlanHistory } from "../entities/kpiPlanHistory";
|
||||
import { KpiSpecial } from "../entities/kpiSpecial";
|
||||
import { KpiRole } from "../entities/kpiRole";
|
||||
|
|
@ -48,11 +46,8 @@ export class kpiPlanController extends Controller {
|
|||
* @param request
|
||||
*/
|
||||
@Post()
|
||||
async createKpiPlan(
|
||||
@Body() requestBody: createKpiPlan,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionCreate(request,"SYS_EVA_INDICATOR");
|
||||
async createKpiPlan(@Body() requestBody: createKpiPlan, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionCreate(request, "SYS_EVA_INDICATOR");
|
||||
const kpiPlan = Object.assign(new KpiPlan(), requestBody);
|
||||
if (requestBody.year != null && requestBody.period != null) {
|
||||
const kpiPeriod = await this.kpiPeriodRepository
|
||||
|
|
@ -212,7 +207,7 @@ export class kpiPlanController extends Controller {
|
|||
@Body() requestBody: updateKpiPlan,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request,"SYS_EVA_INDICATOR");
|
||||
await new permission().PermissionUpdate(request, "SYS_EVA_INDICATOR");
|
||||
const kpiPlan = await this.kpiPlanRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -294,7 +289,8 @@ export class kpiPlanController extends Controller {
|
|||
* @param id Guid, *Id ตัวชี้วัดตามแผนฯ
|
||||
*/
|
||||
@Get("{id}")
|
||||
async GetKpiPlanById(@Path() id: string) {
|
||||
async GetKpiPlanById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||
const kpiPlan = await this.kpiPlanRepository.findOne({
|
||||
where: { id: id },
|
||||
relations: { kpiPeriod: true },
|
||||
|
|
@ -398,6 +394,7 @@ export class kpiPlanController extends Controller {
|
|||
*/
|
||||
@Post("search")
|
||||
async listKpiPlan(
|
||||
@Request() request: RequestWithUser,
|
||||
@Body()
|
||||
requestBody: {
|
||||
page: number;
|
||||
|
|
@ -411,6 +408,7 @@ export class kpiPlanController extends Controller {
|
|||
// isNull?: boolean | false;
|
||||
},
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||
let condition = "";
|
||||
let parameters: any = {};
|
||||
if (requestBody.isAll === false) {
|
||||
|
|
@ -506,7 +504,7 @@ export class kpiPlanController extends Controller {
|
|||
*/
|
||||
@Delete("{id}")
|
||||
async deleteKpiPlan(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionDelete(request,"SYS_EVA_INDICATOR");
|
||||
await new permission().PermissionDelete(request, "SYS_EVA_INDICATOR");
|
||||
const kpiPlan = await this.kpiPlanRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -592,7 +590,8 @@ export class kpiPlanController extends Controller {
|
|||
* @param id Guid, *Id ประวัดิตัวชี้วัดตามแผน
|
||||
*/
|
||||
@Get("history/{id}")
|
||||
async GetHistory(@Path() id: string) {
|
||||
async GetHistory(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||
const kpiPlanHistory = await this.kpiPlanHistoryRepository.find({
|
||||
where: { kpiPlanId: id },
|
||||
order: {
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import {
|
|||
updateKpiUserReasonEvaluation,
|
||||
} from "../entities/kpiUserEvaluationReasonCapacity";
|
||||
import { KpiUserEvaluationReasonDevelopment } from "../entities/kpiUserEvaluationReasonDevelopment";
|
||||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||
import { KpiUserRole } from "../entities/kpiUserRole";
|
||||
import { KpiUserSpecial } from "../entities/kpiUserSpecial";
|
||||
import { KpiUserCapacity } from "../entities/kpiUserCapacity";
|
||||
|
|
|
|||
|
|
@ -10,10 +10,8 @@ import {
|
|||
Body,
|
||||
Path,
|
||||
Request,
|
||||
Example,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Query,
|
||||
} from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
|
|
@ -44,11 +42,8 @@ export class kpiRoleController extends Controller {
|
|||
* @param request
|
||||
*/
|
||||
@Post()
|
||||
async createKpiRole(
|
||||
@Body() requestBody: createKpiRole,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionCreate(request,"SYS_EVA_INDICATOR");
|
||||
async createKpiRole(@Body() requestBody: createKpiRole, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionCreate(request, "SYS_EVA_INDICATOR");
|
||||
const kpiRole = Object.assign(new KpiRole(), requestBody);
|
||||
if (requestBody.year != null && requestBody.period != null) {
|
||||
const kpiPeriod = await this.kpiPeriodRepository
|
||||
|
|
@ -205,7 +200,7 @@ export class kpiRoleController extends Controller {
|
|||
@Body() requestBody: updateKpiRole,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request,"SYS_EVA_INDICATOR");
|
||||
await new permission().PermissionUpdate(request, "SYS_EVA_INDICATOR");
|
||||
const kpiRole = await this.kpiRoleRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -269,7 +264,8 @@ export class kpiRoleController extends Controller {
|
|||
* @param id Guid, *Id ตัวชี้วัดตามตำแหน่ง
|
||||
*/
|
||||
@Get("{id}")
|
||||
async GetKpiRoleById(@Path() id: string) {
|
||||
async GetKpiRoleById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||
const kpiRole = await this.kpiRoleRepository.findOne({
|
||||
where: { id: id },
|
||||
relations: { kpiPeriod: true },
|
||||
|
|
@ -343,6 +339,7 @@ export class kpiRoleController extends Controller {
|
|||
*/
|
||||
@Post("search")
|
||||
async listKpiRole(
|
||||
@Request() request: RequestWithUser,
|
||||
@Body()
|
||||
requestBody: {
|
||||
page: number;
|
||||
|
|
@ -357,6 +354,7 @@ export class kpiRoleController extends Controller {
|
|||
// isNull?: boolean | false;
|
||||
},
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||
let condition = "";
|
||||
let parameters: any = {};
|
||||
if (requestBody.isAll === false) {
|
||||
|
|
@ -468,8 +466,8 @@ export class kpiRoleController extends Controller {
|
|||
* @param id
|
||||
*/
|
||||
@Delete("{id}")
|
||||
async deleteKpiRole(@Path() id: string,@Request() request: RequestWithUser) {
|
||||
await new permission().PermissionDelete(request,"SYS_EVA_INDICATOR");
|
||||
async deleteKpiRole(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionDelete(request, "SYS_EVA_INDICATOR");
|
||||
const kpiRole = await this.kpiRoleRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -559,7 +557,8 @@ export class kpiRoleController extends Controller {
|
|||
* @param id Guid, *Id ประวัดิตัวชี้วัดตามตำแหน่ง
|
||||
*/
|
||||
@Get("history/{id}")
|
||||
async GetHistory(@Path() id: string) {
|
||||
async GetHistory(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||
const kpiRoleHistory = await this.kpiRoleHistoryRepository.find({
|
||||
where: { kpiRoleId: id },
|
||||
order: {
|
||||
|
|
|
|||
|
|
@ -10,18 +10,15 @@ import {
|
|||
Body,
|
||||
Path,
|
||||
Request,
|
||||
Example,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Query,
|
||||
} from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import HttpStatusCode from "../interfaces/http-status";
|
||||
import { KpiSpecial, CreateKpiSpecial, UpdateKpiSpecial } from "../entities/kpiSpecial";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import { Brackets, IsNull, Like, Not } from "typeorm";
|
||||
import { Brackets, Not } from "typeorm";
|
||||
import permission from "../interfaces/permission";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
@Route("api/v1/kpi/special")
|
||||
|
|
@ -45,7 +42,7 @@ export class kpiSpecialController extends Controller {
|
|||
@Body() requestBody: CreateKpiSpecial,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionCreate(request,"SYS_EVA_INDICATOR");
|
||||
await new permission().PermissionCreate(request, "SYS_EVA_INDICATOR");
|
||||
const chk_kpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||
where: {
|
||||
including: String(requestBody.including),
|
||||
|
|
@ -82,7 +79,7 @@ export class kpiSpecialController extends Controller {
|
|||
@Body() requestBody: UpdateKpiSpecial,
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request,"SYS_EVA_INDICATOR");
|
||||
await new permission().PermissionUpdate(request, "SYS_EVA_INDICATOR");
|
||||
const kpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -115,7 +112,8 @@ export class kpiSpecialController extends Controller {
|
|||
* @param id Guid, *Id ตัวชี้วัด Special
|
||||
*/
|
||||
@Get("{id}")
|
||||
async GetKpiSpecialById(@Path() id: string) {
|
||||
async GetKpiSpecialById(@Request() request: RequestWithUser, @Path() id: string) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||
const KpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
@ -156,6 +154,7 @@ export class kpiSpecialController extends Controller {
|
|||
*/
|
||||
@Post("search")
|
||||
async listKpiSpecial(
|
||||
@Request() request: RequestWithUser,
|
||||
@Body()
|
||||
requestBody: {
|
||||
page: number;
|
||||
|
|
@ -165,6 +164,7 @@ export class kpiSpecialController extends Controller {
|
|||
keyword?: string | null;
|
||||
},
|
||||
) {
|
||||
let _data = await new permission().PermissionList(request, "SYS_EVA_INDICATOR");
|
||||
// let condition: any = {};
|
||||
// if (requestBody.keyword !== undefined && requestBody.keyword !== "") {
|
||||
// condition = {
|
||||
|
|
@ -216,8 +216,8 @@ export class kpiSpecialController extends Controller {
|
|||
* @param id
|
||||
*/
|
||||
@Delete("{id}")
|
||||
async deleteKpiSpecial(@Path() id: string, @Request() request: RequestWithUser,) {
|
||||
await new permission().PermissionDelete(request,"SYS_EVA_INDICATOR");
|
||||
async deleteKpiSpecial(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionDelete(request, "SYS_EVA_INDICATOR");
|
||||
const kpiSpecial = await this.kpiSpecialRepository.findOne({
|
||||
where: { id: id },
|
||||
});
|
||||
|
|
|
|||
|
|
@ -10,11 +10,9 @@ import {
|
|||
Body,
|
||||
Path,
|
||||
Request,
|
||||
Example,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Query,
|
||||
ArrayValidator,
|
||||
} from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
|
|
@ -23,11 +21,9 @@ import HttpStatusCode from "../interfaces/http-status";
|
|||
import { KpiCapacity } from "../entities/kpiCapacity";
|
||||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||
import { KpiUserCapacity, KpiUserCapacityDataPoint } from "../entities/kpiUserCapacity";
|
||||
import { Like, In, Not } from "typeorm";
|
||||
import { Double } from "typeorm/browser";
|
||||
import { Not } from "typeorm";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import permission from "../interfaces/permission";
|
||||
import { request } from "axios";
|
||||
|
||||
@Route("api/v1/kpi/user/capacity")
|
||||
@Tags("kpiUserCapacity")
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ import {
|
|||
} from "../entities/kpiUserDevelopment";
|
||||
import HttpError from "../interfaces/http-error";
|
||||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||
import { Not, Like, Brackets } from "typeorm";
|
||||
import { Not, Brackets } from "typeorm";
|
||||
import { DevelopmentProject } from "../entities/developmentProject";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import permission from "../interfaces/permission";
|
||||
|
|
|
|||
|
|
@ -10,11 +10,9 @@ import {
|
|||
Body,
|
||||
Path,
|
||||
Request,
|
||||
Example,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Query,
|
||||
ArrayValidator,
|
||||
} from "tsoa";
|
||||
import { AppDataSource } from "../database/data-source";
|
||||
import HttpSuccess from "../interfaces/http-success";
|
||||
|
|
@ -31,7 +29,7 @@ import {
|
|||
updateKpiUserReqEditEvaluation,
|
||||
updateKpiUserResultEvaluation,
|
||||
} from "../entities/kpiUserEvaluation";
|
||||
import { Like, In, Brackets, IsNull, Not } from "typeorm";
|
||||
import { In, Brackets, IsNull, Not } from "typeorm";
|
||||
import CallAPI from "../interfaces/call-api";
|
||||
import { KpiCapacity } from "../entities/kpiCapacity";
|
||||
import { Position } from "../entities/position";
|
||||
|
|
@ -249,27 +247,27 @@ export class KpiUserEvaluationController extends Controller {
|
|||
qb.orWhere("kpiUserEvaluation.prefix LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.firstName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.lastName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.org LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.position LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.posTypeName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.posLevelName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere(conditionFullName, {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.firstName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.lastName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.org LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.position LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.posTypeName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere("kpiUserEvaluation.posLevelName LIKE :keyword", {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
})
|
||||
.orWhere(conditionFullName, {
|
||||
keyword: `%${requestBody.keyword}%`,
|
||||
});
|
||||
}),
|
||||
)
|
||||
.orderBy("kpiUserEvaluation.createdAt", "ASC")
|
||||
|
|
|
|||
|
|
@ -4,14 +4,12 @@ import {
|
|||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Patch,
|
||||
Route,
|
||||
Security,
|
||||
Tags,
|
||||
Body,
|
||||
Path,
|
||||
Request,
|
||||
Example,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Query,
|
||||
|
|
|
|||
|
|
@ -4,14 +4,12 @@ import {
|
|||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Patch,
|
||||
Route,
|
||||
Security,
|
||||
Tags,
|
||||
Body,
|
||||
Path,
|
||||
Request,
|
||||
Example,
|
||||
SuccessResponse,
|
||||
Response,
|
||||
Query,
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,16 +1,3 @@
|
|||
import {
|
||||
Controller,
|
||||
Request,
|
||||
Get,
|
||||
Post,
|
||||
Put,
|
||||
Delete,
|
||||
Patch,
|
||||
Route,
|
||||
Security,
|
||||
Tags,
|
||||
Path,
|
||||
} from "tsoa";
|
||||
import axios from "axios";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import CallAPI from "./call-api";
|
||||
|
|
@ -26,23 +13,166 @@ class CheckAuth {
|
|||
) {
|
||||
return null;
|
||||
}
|
||||
await new CallAPI()
|
||||
return await new CallAPI()
|
||||
.GetData(req, "/org/permission")
|
||||
.then((x) => {
|
||||
let permission = false;
|
||||
let role = x.roles.find((x: any) => x.authSysId == system);
|
||||
if (!role) throw "ไม่มีสิทธิ์เข้าระบบ";
|
||||
if (role.attrOwnership == "OWNER") return "OWNER";
|
||||
if (action.trim().toLocaleUpperCase() == "CREATE") permission = role.attrIsCreate;
|
||||
if (action.trim().toLocaleUpperCase() == "DELETE") permission = role.attrIsDelete;
|
||||
if (action.trim().toLocaleUpperCase() == "GET") permission = role.attrIsGet;
|
||||
if (action.trim().toLocaleUpperCase() == "LIST") permission = role.attrIsList;
|
||||
if (action.trim().toLocaleUpperCase() == "UPDATE") permission = role.attrIsUpdate;
|
||||
if (role.attrOwnership == "OWNER") permission = true;
|
||||
if (permission == false) throw "ไม่มีสิทธิ์ใช้งานระบบนี้";
|
||||
return role.attrPrivilege;
|
||||
})
|
||||
.catch((x) => {
|
||||
throw new HttpError(HttpStatus.FORBIDDEN, x);
|
||||
if (x.status != undefined) {
|
||||
throw new HttpError(x.status, x.message);
|
||||
} else {
|
||||
throw new HttpError(HttpStatus.FORBIDDEN, x);
|
||||
}
|
||||
});
|
||||
}
|
||||
public async PermissionOrg(req: RequestWithUser, system: string, action: 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()
|
||||
.GetData(req, "/org/permission/org")
|
||||
.then(async (x) => {
|
||||
let privilege = null;
|
||||
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],
|
||||
child1: [null],
|
||||
child2: [null],
|
||||
child3: [null],
|
||||
child4: [null],
|
||||
};
|
||||
let node = 4;
|
||||
if (x.orgChild1Id == null) {
|
||||
node = 0;
|
||||
} else if (x.orgChild2Id == null) {
|
||||
node = 1;
|
||||
} else if (x.orgChild3Id == null) {
|
||||
node = 2;
|
||||
} else if (x.orgChild4Id == null) {
|
||||
node = 3;
|
||||
}
|
||||
if (privilege == "ROOT") {
|
||||
data = {
|
||||
root: [x.orgRootId],
|
||||
child1: null,
|
||||
child2: null,
|
||||
child3: null,
|
||||
child4: null,
|
||||
};
|
||||
} else if (privilege == "CHILD") {
|
||||
data = {
|
||||
root: node >= 0 ? [x.orgRootId] : null,
|
||||
child1: node >= 1 ? [x.orgChild1Id] : null,
|
||||
child2: node >= 2 ? [x.orgChild2Id] : null,
|
||||
child3: node >= 3 ? [x.orgChild3Id] : null,
|
||||
child4: node >= 4 ? [x.orgChild4Id] : null,
|
||||
};
|
||||
} else if (privilege == "NORMAL") {
|
||||
data = {
|
||||
root: [x.orgRootId],
|
||||
child1: [x.orgChild1Id],
|
||||
child2: [x.orgChild2Id],
|
||||
child3: [x.orgChild3Id],
|
||||
child4: [x.orgChild4Id],
|
||||
};
|
||||
} else if (privilege == "SPECIFIC") {
|
||||
} else if (privilege == "OWNER") {
|
||||
data = {
|
||||
root: null,
|
||||
child1: null,
|
||||
child2: null,
|
||||
child3: null,
|
||||
child4: null,
|
||||
};
|
||||
}
|
||||
|
||||
return data;
|
||||
})
|
||||
.catch((x) => {
|
||||
if (x.status != undefined) {
|
||||
throw new HttpError(x.status, x.message);
|
||||
} else {
|
||||
throw new HttpError(HttpStatus.FORBIDDEN, x);
|
||||
}
|
||||
});
|
||||
}
|
||||
public async PermissionOrgByUser(
|
||||
req: RequestWithUser,
|
||||
system: string,
|
||||
action: string,
|
||||
profileId: string,
|
||||
) {
|
||||
if (
|
||||
req.headers.hasOwnProperty("api_key") &&
|
||||
req.headers["api_key"] &&
|
||||
req.headers["api_key"] == process.env.API_KEY
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return await new CallAPI()
|
||||
.GetData(req, `/org/permission/user/${profileId}`)
|
||||
.then(async (x) => {
|
||||
let org = {
|
||||
root: [null],
|
||||
child1: [null],
|
||||
child2: [null],
|
||||
child3: [null],
|
||||
child4: [null],
|
||||
};
|
||||
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)
|
||||
if (x.orgChild1Id != org.child1[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
|
||||
if (org.child2 != null)
|
||||
if (x.orgChild2Id != org.child2[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
|
||||
if (org.child3 != null)
|
||||
if (x.orgChild3Id != org.child3[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
|
||||
if (org.child4 != null)
|
||||
if (x.orgChild4Id != org.child4[0]) throw "ไม่มีสิทธิ์เข้าถึงข้อมูล";
|
||||
|
||||
return true;
|
||||
})
|
||||
.catch((x) => {
|
||||
if (x.status != undefined) {
|
||||
throw new HttpError(x.status, x.message);
|
||||
} else {
|
||||
throw new HttpError(HttpStatus.FORBIDDEN, x);
|
||||
}
|
||||
});
|
||||
}
|
||||
public async PermissionCreate(req: RequestWithUser, system: string) {
|
||||
|
|
@ -60,6 +190,38 @@ class CheckAuth {
|
|||
public async PermissionUpdate(req: RequestWithUser, system: string) {
|
||||
return await this.Permission(req, system, "UPDATE");
|
||||
}
|
||||
|
||||
public async PermissionOrgCreate(req: RequestWithUser, system: string) {
|
||||
return await this.PermissionOrg(req, system, "CREATE");
|
||||
}
|
||||
public async PermissionOrgDelete(req: RequestWithUser, system: string) {
|
||||
return await this.PermissionOrg(req, system, "DELETE");
|
||||
}
|
||||
public async PermissionOrgGet(req: RequestWithUser, system: string) {
|
||||
return await this.PermissionOrg(req, system, "GET");
|
||||
}
|
||||
public async PermissionOrgList(req: RequestWithUser, system: string) {
|
||||
return await this.PermissionOrg(req, system, "LIST");
|
||||
}
|
||||
public async PermissionOrgUpdate(req: RequestWithUser, system: string) {
|
||||
return await this.PermissionOrg(req, system, "UPDATE");
|
||||
}
|
||||
|
||||
public async PermissionOrgUserCreate(req: RequestWithUser, system: string, profileId: string) {
|
||||
return await this.PermissionOrgByUser(req, system, "CREATE", profileId);
|
||||
}
|
||||
public async PermissionOrgUserDelete(req: RequestWithUser, system: string, profileId: string) {
|
||||
return await this.PermissionOrgByUser(req, system, "DELETE", profileId);
|
||||
}
|
||||
public async PermissionOrgUserGet(req: RequestWithUser, system: string, profileId: string) {
|
||||
return await this.PermissionOrgByUser(req, system, "GET", profileId);
|
||||
}
|
||||
public async PermissionOrgUserList(req: RequestWithUser, system: string, profileId: string) {
|
||||
return await this.PermissionOrgByUser(req, system, "LIST", profileId);
|
||||
}
|
||||
public async PermissionOrgUserUpdate(req: RequestWithUser, system: string, profileId: string) {
|
||||
return await this.PermissionOrgByUser(req, system, "UPDATE", profileId);
|
||||
}
|
||||
}
|
||||
|
||||
export default CheckAuth;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue