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 { ProfileDutyHistory } from "../entities/ProfileDutyHistory";
import { RequestWithUser } from "../middlewares/user";
import { ProfileEmployee } from "../entities/ProfileEmployee";
import { CreateProfileEmployeeDuty, ProfileDuty, UpdateProfileDuty } from "../entities/ProfileDuty";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/duty")
@Tags("ProfileEmployeeDuty")
@Security("bearerAuth")
@ -89,6 +89,7 @@ export class ProfileDutyEmployeeController extends Controller {
@Post()
public async newDuty(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeDuty) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
}
@ -121,6 +122,7 @@ export class ProfileDutyEmployeeController extends Controller {
@Body() body: UpdateProfileDuty,
@Path() dutyId: string,
) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.dutyRepository.findOneBy({ id: dutyId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -139,7 +141,8 @@ export class ProfileDutyEmployeeController extends Controller {
}
@Delete("{dutyId}")
public async deleteDuty(@Path() dutyId: string) {
public async deleteDuty(@Path() dutyId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY_EMP");
await this.dutyHistoryRepository.delete({
profileDutyId: dutyId,
});