role
This commit is contained in:
parent
75ed79f722
commit
23df3da9b0
7 changed files with 65 additions and 25 deletions
|
|
@ -27,6 +27,8 @@ import HttpError from "../interfaces/http-error";
|
|||
import { KpiUserEvaluation } from "../entities/kpiUserEvaluation";
|
||||
import { KpiSpecial } from "../entities/kpiSpecial";
|
||||
import { Not } from "typeorm";
|
||||
import { RequestWithUser } from "../middlewares/user";
|
||||
import permission from "../interfaces/permission";
|
||||
|
||||
@Route("api/v1/kpi/user/achievement/special")
|
||||
@Tags("KpiUserSpecial")
|
||||
|
|
@ -51,8 +53,9 @@ export class KpiUserSpecialController extends Controller {
|
|||
async createKpiUserSpecial(
|
||||
@Body()
|
||||
requestBody: CreateKpiUserSpecial,
|
||||
@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 },
|
||||
});
|
||||
|
|
@ -122,8 +125,9 @@ export class KpiUserSpecialController extends Controller {
|
|||
async editKpiUserSpecial(
|
||||
@Path() id: string,
|
||||
@Body() requestBody: UpdateKpiUserSpecial,
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionUpdate(request, "SYS_KPI_LIST");
|
||||
const kpiUserSpecial = await this.kpiUserSpecialRepository.findOne({ where: { id } });
|
||||
if (!kpiUserSpecial) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานที่ได้รับมอบหมายพิเศษนี้");
|
||||
|
|
@ -188,7 +192,8 @@ export class KpiUserSpecialController extends Controller {
|
|||
*
|
||||
*/
|
||||
@Delete("{id}")
|
||||
async deleteKpiUserSpecial(@Path() id: string) {
|
||||
async deleteKpiUserSpecial(@Path() id: string, @Request() request: RequestWithUser) {
|
||||
await new permission().PermissionDelete(request, "SYS_KPI_LIST");
|
||||
const delKpiUserSpecial = await this.kpiUserSpecialRepository.findOne({ where: { id } });
|
||||
if (!delKpiUserSpecial) {
|
||||
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลงานที่ได้รับมอบหมายพิเศษนี้");
|
||||
|
|
@ -310,8 +315,9 @@ export class KpiUserSpecialController extends Controller {
|
|||
@Post("point")
|
||||
async CreateKpiUserSpecialPoint(
|
||||
@Body() requestBody: KpiUserSpecialDataPoint[],
|
||||
@Request() request: { user: Record<string, any> },
|
||||
@Request() request: RequestWithUser,
|
||||
) {
|
||||
await new permission().PermissionCreate(request, "SYS_KPI_LIST");
|
||||
for (const item of requestBody) {
|
||||
const kpiUserSpecial = await this.kpiUserSpecialRepository.findOne({
|
||||
where: { id: item.id },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue