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

@ -22,12 +22,11 @@ import {
import HttpSuccess from "../interfaces/http-success";
import HttpStatus from "../interfaces/http-status";
import HttpError from "../interfaces/http-error";
import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile";
import { LeaveType } from "../entities/LeaveType";
import { Brackets } from "typeorm";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/leave")
@Tags("ProfileLeave")
@Security("bearerAuth")
@ -248,6 +247,7 @@ export class ProfileLeaveController extends Controller {
@Post()
public async newLeave(@Request() req: RequestWithUser, @Body() body: CreateProfileLeave) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
}
@ -286,6 +286,7 @@ export class ProfileLeaveController extends Controller {
@Body() body: UpdateProfileLeave,
@Path() leaveId: string,
) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const record = await this.leaveRepo.findOneBy({ id: leaveId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -311,7 +312,8 @@ export class ProfileLeaveController extends Controller {
}
@Delete("{leaveId}")
public async deleteLeave(@Path() leaveId: string) {
public async deleteLeave(@Path() leaveId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY");
await this.leaveHistoryRepo.delete({
profileLeaveId: leaveId,
});