role
This commit is contained in:
parent
75ed79f722
commit
23df3da9b0
7 changed files with 65 additions and 25 deletions
|
|
@ -29,6 +29,8 @@ import HttpError from "../interfaces/http-error";
|
|||
import { Not } from "typeorm";
|
||||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||
import { KpiRole } from "../entities/kpiRole";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import permission from "../interfaces/permission";
|
||||
|
||||
@Route("api/v1/kpi/user/achievement/role")
|
||||
@Tags("KpiUserRole")
|
||||
|
|
@ -53,8 +55,9 @@ export class KpiUserRoleController extends Controller {
|
|||
async createKpiUserRole(
|
||||
@Body()
|
||||
requestBody: CreateKpiUserRole,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionCreate(request, "SYS_KPI_LIST");
|
||||
const chkUserEvaluation = await this.kpiUserEvaluationRepository.findOne({
|
||||
where: { id: requestBody.kpiUserEvaluationId },
|
||||
});
|
||||
|
|
@ -111,8 +114,9 @@ export class KpiUserRoleController extends Controller {
|
|||
async editKpiUserRole(
|
||||
@Path() id: string,
|
||||
@Body() requestBody: UpdateKpiUserRole,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_KPI_LIST");
|
||||
const kpiUserRole = await this.kpiUserRoleRepository.findOne({ where: { id } });
|
||||
if (!kpiUserRole) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานตามหน้าที่ความรับผิดชอบหลักนี้");
|
||||
|
|
@ -165,7 +169,8 @@ export class KpiUserRoleController extends Controller {
|
|||
* @param {string} id Id ตำแหน่ง
|
||||
*/
|
||||
@Delete("{id}")
|
||||
async deleteKpiUserRole(@Path() id: string) {
|
||||
async deleteKpiUserRole(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionDelete(request, "SYS_KPI_LIST");
|
||||
const delKpiUserRole = await this.kpiUserRoleRepository.findOne({ where: { id } });
|
||||
if (!delKpiUserRole) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานตามหน้าที่ความรับผิดชอบหลักนี้");
|
||||
|
|
@ -277,8 +282,9 @@ export class KpiUserRoleController extends Controller {
|
|||
@Post("point")
|
||||
async CreateKpiUserRolePoint(
|
||||
@Body() requestBody: KpiUserRoleDataPoint[],
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionCreate(request, "SYS_KPI_LIST");
|
||||
for (const item of requestBody) {
|
||||
const kpiUserRole = await this.kpiUserRoleRepository.findOne({
|
||||
where: { id: item.id },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue