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

@ -20,7 +20,7 @@ import HttpError from "../interfaces/http-error";
import { ProfileHonorHistory } from "../entities/ProfileHonorHistory";
import { RequestWithUser } from "../middlewares/user";
import { ProfileEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/honor")
@Tags("ProfileEmployeeHonor")
@Security("bearerAuth")
@ -138,6 +138,7 @@ export class ProfileHonorEmployeeController extends Controller {
@Post()
public async newHonor(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeHonor) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
}
@ -170,6 +171,7 @@ export class ProfileHonorEmployeeController extends Controller {
@Body() body: UpdateProfileHonor,
@Path() honorId: string,
) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.honorRepo.findOneBy({ id: honorId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -188,7 +190,8 @@ export class ProfileHonorEmployeeController extends Controller {
}
@Delete("{honorId}")
public async deleteTraning(@Path() honorId: string) {
public async deleteTraning(@Path() honorId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY_EMP");
await this.honorHistoryRepo.delete({
profileHonorId: honorId,
});