permission ทะเบียนประวัติขรก.+ลูกจ้าง

This commit is contained in:
Bright 2024-08-08 17:15:21 +07:00
parent be7f719fd5
commit 9f5987d968
44 changed files with 191 additions and 75 deletions

View file

@ -19,7 +19,6 @@ import {
import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status";
import HttpSuccess from "../interfaces/http-success";
import { AppDataSource } from "../database/data-source";
import {
CreateProfileEmployeeAssessment,
@ -29,7 +28,7 @@ import {
import { ProfileAssessmentHistory } from "../entities/ProfileAssessmentHistory";
import { ProfileEmployee } from "../entities/ProfileEmployee";
import { RequestWithUser } from "../middlewares/user";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/assessments")
@Tags("ProfileEmployeeAssessments")
@Security("bearerAuth")
@ -149,6 +148,7 @@ export class ProfileAssessmentsEmployeeController extends Controller {
@Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeAssessment,
) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
}
@ -178,6 +178,7 @@ export class ProfileAssessmentsEmployeeController extends Controller {
@Request() req: RequestWithUser,
@Path() assessmentId: string,
) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -198,7 +199,8 @@ export class ProfileAssessmentsEmployeeController extends Controller {
}
@Delete("{assessmentId}")
public async deleteProfileAssessment(@Path() assessmentId: string) {
public async deleteProfileAssessment(@Path() assessmentId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY_EMP");
await this.profileAssessmentsHistoryRepository.delete({
profileAssessmentId: assessmentId,
});