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

@ -24,7 +24,7 @@ import { RequestWithUser } from "../middlewares/user";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status"; import HttpStatus from "../interfaces/http-status";
import HttpSuccess from "../interfaces/http-success"; import HttpSuccess from "../interfaces/http-success";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/ability") @Route("api/v1/org/profile/ability")
@Tags("ProfileAbility") @Tags("ProfileAbility")
@Security("bearerAuth") @Security("bearerAuth")
@ -133,6 +133,7 @@ export class ProfileAbilityController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileAbility, @Body() body: CreateProfileAbility,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
if (!body.profileId) { if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -163,6 +164,7 @@ export class ProfileAbilityController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Path() abilityId: string, @Path() abilityId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); const record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -184,7 +186,8 @@ export class ProfileAbilityController extends Controller {
} }
@Delete("{abilityId}") @Delete("{abilityId}")
public async deleteProfileAbility(@Path() abilityId: string) { public async deleteProfileAbility(@Path() abilityId: string, @Request() req: RequestWithUser,) {
await new permission().PermissionDelete(req,"SYS_REGISTRY");
await this.profileAbilityHistoryRepo.delete({ await this.profileAbilityHistoryRepo.delete({
profileAbilityId: abilityId, profileAbilityId: abilityId,
}); });

View file

@ -26,7 +26,7 @@ import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status"; import HttpStatus from "../interfaces/http-status";
import HttpSuccess from "../interfaces/http-success"; import HttpSuccess from "../interfaces/http-success";
import { ProfileEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/ability") @Route("api/v1/org/profile-employee/ability")
@Tags("ProfileAbilityEmployee") @Tags("ProfileAbilityEmployee")
@Security("bearerAuth") @Security("bearerAuth")
@ -136,6 +136,7 @@ export class ProfileAbilityEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileAbilityEmployee, @Body() body: CreateProfileAbilityEmployee,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
} }
@ -166,6 +167,7 @@ export class ProfileAbilityEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Path() abilityId: string, @Path() abilityId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.profileAbilityRepo.findOneBy({ id: abilityId }); const record = await this.profileAbilityRepo.findOneBy({ id: abilityId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -187,7 +189,8 @@ export class ProfileAbilityEmployeeController extends Controller {
} }
@Delete("{abilityId}") @Delete("{abilityId}")
public async deleteProfileAbility(@Path() abilityId: string) { public async deleteProfileAbility(@Path() abilityId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY_EMP");
await this.profileAbilityHistoryRepo.delete({ await this.profileAbilityHistoryRepo.delete({
profileAbilityId: abilityId, profileAbilityId: abilityId,
}); });

View file

@ -26,7 +26,7 @@ import { AppDataSource } from "../database/data-source";
import { Province } from "../entities/Province"; import { Province } from "../entities/Province";
import { District } from "../entities/District"; import { District } from "../entities/District";
import { SubDistrict } from "../entities/SubDistrict"; import { SubDistrict } from "../entities/SubDistrict";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/address") @Route("api/v1/org/profile/address")
@Tags("ProfileAddress") @Tags("ProfileAddress")
@Security("bearerAuth") @Security("bearerAuth")
@ -182,6 +182,7 @@ export class ProfileAddressController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Path() profileId: string, @Path() profileId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const record = await this.profileRepo.findOneBy({ id: profileId }); const record = await this.profileRepo.findOneBy({ id: profileId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");

View file

@ -27,7 +27,7 @@ import { Province } from "../entities/Province";
import { District } from "../entities/District"; import { District } from "../entities/District";
import { SubDistrict } from "../entities/SubDistrict"; import { SubDistrict } from "../entities/SubDistrict";
import { ProfileEmployee, UpdateProfileAddressEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee, UpdateProfileAddressEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/address") @Route("api/v1/org/profile-employee/address")
@Tags("ProfileAddressEmployee") @Tags("ProfileAddressEmployee")
@Security("bearerAuth") @Security("bearerAuth")
@ -183,6 +183,7 @@ export class ProfileAddressEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Path() profileId: string, @Path() profileId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.profileEmployeeRepo.findOneBy({ id: profileId }); const record = await this.profileEmployeeRepo.findOneBy({ id: profileId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");

View file

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

View file

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

View file

@ -6,7 +6,7 @@ import HttpError from "../interfaces/http-error";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile"; import { Profile } from "../entities/Profile";
import { CreateProfileAvatar, ProfileAvatar } from "../entities/ProfileAvatar"; import { CreateProfileAvatar, ProfileAvatar } from "../entities/ProfileAvatar";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/avatar") @Route("api/v1/org/profile/avatar")
@Tags("ProfileAvatar") @Tags("ProfileAvatar")
@Security("bearerAuth") @Security("bearerAuth")
@ -63,6 +63,7 @@ export class ProfileAvatarController extends Controller {
@Post() @Post()
public async newAvatar(@Request() req: RequestWithUser, @Body() body: CreateProfileAvatar) { public async newAvatar(@Request() req: RequestWithUser, @Body() body: CreateProfileAvatar) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
const profile = await this.profileRepository.findOne({ const profile = await this.profileRepository.findOne({
where: { id: body.profileId }, where: { id: body.profileId },
}); });
@ -113,7 +114,8 @@ export class ProfileAvatarController extends Controller {
} }
@Delete("{avatarId}") @Delete("{avatarId}")
public async deleteAvatar(@Path() avatarId: string) { public async deleteAvatar(@Path() avatarId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY");
const result = await this.avatarRepository.delete({ id: avatarId }); const result = await this.avatarRepository.delete({ id: avatarId });
if (result.affected == undefined || result.affected <= 0) { if (result.affected == undefined || result.affected <= 0) {

View file

@ -6,7 +6,7 @@ import HttpError from "../interfaces/http-error";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { CreateProfileEmployeeAvatar, ProfileAvatar } from "../entities/ProfileAvatar"; import { CreateProfileEmployeeAvatar, ProfileAvatar } from "../entities/ProfileAvatar";
import { ProfileEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/avatar") @Route("api/v1/org/profile-employee/avatar")
@Tags("ProfileAvatar") @Tags("ProfileAvatar")
@Security("bearerAuth") @Security("bearerAuth")
@ -54,6 +54,7 @@ export class ProfileAvatarEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeAvatar, @Body() body: CreateProfileEmployeeAvatar,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
const profile = await this.profileRepository.findOne({ const profile = await this.profileRepository.findOne({
where: { id: body.profileEmployeeId }, where: { id: body.profileEmployeeId },
}); });
@ -104,7 +105,8 @@ export class ProfileAvatarEmployeeController extends Controller {
} }
@Delete("{avatarId}") @Delete("{avatarId}")
public async deleteAvatarEmployee(@Path() avatarId: string) { public async deleteAvatarEmployee(@Path() avatarId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY_EMP");
const result = await this.avatarRepository.delete({ id: avatarId }); const result = await this.avatarRepository.delete({ id: avatarId });
if (result.affected == undefined || result.affected <= 0) { if (result.affected == undefined || result.affected <= 0) {

View file

@ -24,7 +24,7 @@ import HttpError from "../interfaces/http-error";
import { ProfileCertificateHistory } from "../entities/ProfileCertificateHistory"; import { ProfileCertificateHistory } from "../entities/ProfileCertificateHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile"; import { Profile } from "../entities/Profile";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/certificate") @Route("api/v1/org/profile/certificate")
@Tags("ProfileCertificate") @Tags("ProfileCertificate")
@Security("bearerAuth") @Security("bearerAuth")
@ -122,6 +122,7 @@ export class ProfileCertificateController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileCertificate, @Body() body: CreateProfileCertificate,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
if (!body.profileId) { if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -154,6 +155,7 @@ export class ProfileCertificateController extends Controller {
@Body() body: UpdateProfileCertificate, @Body() body: UpdateProfileCertificate,
@Path() certificateId: string, @Path() certificateId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const record = await this.certificateRepo.findOneBy({ id: certificateId }); const record = await this.certificateRepo.findOneBy({ id: certificateId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -175,7 +177,8 @@ export class ProfileCertificateController extends Controller {
} }
@Delete("{certificateId}") @Delete("{certificateId}")
public async deleteCertificate(@Path() certificateId: string) { public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY");
await this.certificateHistoryRepo.delete({ await this.certificateHistoryRepo.delete({
profileCertificateId: certificateId, profileCertificateId: certificateId,
}); });

View file

@ -24,7 +24,7 @@ import HttpError from "../interfaces/http-error";
import { ProfileCertificateHistory } from "../entities/ProfileCertificateHistory"; import { ProfileCertificateHistory } from "../entities/ProfileCertificateHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { ProfileEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/certificate") @Route("api/v1/org/profile-employee/certificate")
@Tags("ProfileEmployeeCertificate") @Tags("ProfileEmployeeCertificate")
@Security("bearerAuth") @Security("bearerAuth")
@ -121,6 +121,7 @@ export class ProfileCertificateEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeCertificate, @Body() body: CreateProfileEmployeeCertificate,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
} }
@ -153,6 +154,7 @@ export class ProfileCertificateEmployeeController extends Controller {
@Body() body: UpdateProfileCertificate, @Body() body: UpdateProfileCertificate,
@Path() certificateId: string, @Path() certificateId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.certificateRepo.findOneBy({ id: certificateId }); const record = await this.certificateRepo.findOneBy({ id: certificateId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -174,7 +176,8 @@ export class ProfileCertificateEmployeeController extends Controller {
} }
@Delete("{certificateId}") @Delete("{certificateId}")
public async deleteCertificate(@Path() certificateId: string) { public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY_EMP");
await this.certificateHistoryRepo.delete({ await this.certificateHistoryRepo.delete({
profileCertificateId: certificateId, profileCertificateId: certificateId,
}); });

View file

@ -26,7 +26,7 @@ import {
} from "../entities/ProfileChangeName"; } from "../entities/ProfileChangeName";
import CallAPI from "../interfaces/call-api"; import CallAPI from "../interfaces/call-api";
import { updateName } from "../keycloak"; import { updateName } from "../keycloak";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/changeName") @Route("api/v1/org/profile/changeName")
@Tags("ProfileChangeName") @Tags("ProfileChangeName")
@Security("bearerAuth") @Security("bearerAuth")
@ -119,6 +119,7 @@ export class ProfileChangeNameController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileChangeName, @Body() body: CreateProfileChangeName,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
if (!body.profileId) { if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -164,6 +165,7 @@ export class ProfileChangeNameController extends Controller {
@Body() body: UpdateProfileChangeName, @Body() body: UpdateProfileChangeName,
@Path() changeNameId: string, @Path() changeNameId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const record = await this.changeNameRepository.findOneBy({ id: changeNameId }); const record = await this.changeNameRepository.findOneBy({ id: changeNameId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -212,7 +214,8 @@ export class ProfileChangeNameController extends Controller {
} }
@Delete("{changeNameId}") @Delete("{changeNameId}")
public async deleteTraning(@Path() changeNameId: string) { public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser,) {
await new permission().PermissionDelete(req,"SYS_REGISTRY");
await this.changeNameHistoryRepository.delete({ await this.changeNameHistoryRepository.delete({
profileChangeNameId: changeNameId, profileChangeNameId: changeNameId,
}); });

View file

@ -26,7 +26,7 @@ import {
UpdateProfileChangeName, UpdateProfileChangeName,
} from "../entities/ProfileChangeName"; } from "../entities/ProfileChangeName";
import { ProfileEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/changeName") @Route("api/v1/org/profile-employee/changeName")
@Tags("ProfileChangeNameEmployee") @Tags("ProfileChangeNameEmployee")
@Security("bearerAuth") @Security("bearerAuth")
@ -119,6 +119,7 @@ export class ProfileChangeNameEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileChangeNameEmployee, @Body() body: CreateProfileChangeNameEmployee,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
} }
@ -156,6 +157,7 @@ export class ProfileChangeNameEmployeeController extends Controller {
@Body() body: UpdateProfileChangeName, @Body() body: UpdateProfileChangeName,
@Path() changeNameId: string, @Path() changeNameId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.changeNameRepository.findOneBy({ id: changeNameId }); const record = await this.changeNameRepository.findOneBy({ id: changeNameId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -196,7 +198,8 @@ export class ProfileChangeNameEmployeeController extends Controller {
} }
@Delete("{changeNameId}") @Delete("{changeNameId}")
public async deleteTraning(@Path() changeNameId: string) { public async deleteTraning(@Path() changeNameId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY_EMP");
await this.changeNameHistoryRepository.delete({ await this.changeNameHistoryRepository.delete({
profileChangeNameId: changeNameId, profileChangeNameId: changeNameId,
}); });

View file

@ -25,6 +25,7 @@ import {
UpdateProfileChildren, UpdateProfileChildren,
} from "../entities/ProfileChildren"; } from "../entities/ProfileChildren";
import Extension from "../interfaces/extension"; import Extension from "../interfaces/extension";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/family/children") @Route("api/v1/org/profile/family/children")
@Tags("ProfileChildren") @Tags("ProfileChildren")
@Security("bearerAuth") @Security("bearerAuth")
@ -64,6 +65,7 @@ export class ProfileChildrenController extends Controller {
@Post() @Post()
public async newChildren(@Request() req: RequestWithUser, @Body() body: CreateProfileChildren) { public async newChildren(@Request() req: RequestWithUser, @Body() body: CreateProfileChildren) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
const profile = await this.profileRepository.findOneBy({ id: body.profileId }); const profile = await this.profileRepository.findOneBy({ id: body.profileId });
if (!profile) { if (!profile) {
@ -106,6 +108,7 @@ export class ProfileChildrenController extends Controller {
@Body() body: UpdateProfileChildren, @Body() body: UpdateProfileChildren,
@Path() childrenId: string, @Path() childrenId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const record = await this.childrenRepository.findOneBy({ id: childrenId }); const record = await this.childrenRepository.findOneBy({ id: childrenId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -132,7 +135,8 @@ export class ProfileChildrenController extends Controller {
} }
@Delete("{childrenId}") @Delete("{childrenId}")
public async deleteTraning(@Path() childrenId: string) { public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser,) {
await new permission().PermissionDelete(req,"SYS_REGISTRY");
await this.childrenHistoryRepository.delete({ await this.childrenHistoryRepository.delete({
profileChildrenId: childrenId, profileChildrenId: childrenId,
}); });

View file

@ -27,6 +27,7 @@ import {
} from "../entities/ProfileChildren"; } from "../entities/ProfileChildren";
import { ProfileEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee } from "../entities/ProfileEmployee";
import Extension from "../interfaces/extension"; import Extension from "../interfaces/extension";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/family/children") @Route("api/v1/org/profile-employee/family/children")
@Tags("ProfileChildren") @Tags("ProfileChildren")
@Security("bearerAuth") @Security("bearerAuth")
@ -69,6 +70,7 @@ export class ProfileChildrenEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileChildrenEmployee, @Body() body: CreateProfileChildrenEmployee,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
const profile = await this.profileRepository.findOneBy({ id: body.profileEmployeeId }); const profile = await this.profileRepository.findOneBy({ id: body.profileEmployeeId });
if (!profile) { if (!profile) {
@ -113,6 +115,7 @@ export class ProfileChildrenEmployeeController extends Controller {
@Body() body: UpdateProfileChildren, @Body() body: UpdateProfileChildren,
@Path() childrenId: string, @Path() childrenId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.childrenRepository.findOneBy({ id: childrenId }); const record = await this.childrenRepository.findOneBy({ id: childrenId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -141,7 +144,8 @@ export class ProfileChildrenEmployeeController extends Controller {
} }
@Delete("{childrenId}") @Delete("{childrenId}")
public async deleteTraning(@Path() childrenId: string) { public async deleteTraning(@Path() childrenId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY_EMP");
await this.childrenHistoryRepository.delete({ await this.childrenHistoryRepository.delete({
profileChildrenId: childrenId, profileChildrenId: childrenId,
}); });

View file

@ -59,7 +59,7 @@ import { ProfileInsignia } from "../entities/ProfileInsignia";
import { ProfileDisciplineHistory } from "../entities/ProfileDisciplineHistory"; import { ProfileDisciplineHistory } from "../entities/ProfileDisciplineHistory";
import { ProfileLeave } from "../entities/ProfileLeave"; import { ProfileLeave } from "../entities/ProfileLeave";
import { updateName } from "../keycloak"; import { updateName } from "../keycloak";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile") @Route("api/v1/org/profile")
@Tags("Profile") @Tags("Profile")
@Security("bearerAuth") @Security("bearerAuth")
@ -2250,6 +2250,7 @@ export class ProfileController extends Controller {
@Path() id: string, @Path() id: string,
@Body() body: UpdateProfile, @Body() body: UpdateProfile,
) { ) {
await new permission().PermissionUpdate(request,"SYS_REGISTRY");
const exists = const exists =
!!body.citizenId && !!body.citizenId &&
(await this.profileRepo.findOne({ (await this.profileRepo.findOne({

View file

@ -24,7 +24,7 @@ import {
ProfileDiscipline, ProfileDiscipline,
UpdateProfileDiscipline, UpdateProfileDiscipline,
} from "../entities/ProfileDiscipline"; } from "../entities/ProfileDiscipline";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/discipline") @Route("api/v1/org/profile/discipline")
@Tags("ProfileDiscipline") @Tags("ProfileDiscipline")
@Security("bearerAuth") @Security("bearerAuth")
@ -124,6 +124,7 @@ export class ProfileDisciplineController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileDiscipline, @Body() body: CreateProfileDiscipline,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
if (!body.profileId) { if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -156,6 +157,7 @@ export class ProfileDisciplineController extends Controller {
@Body() body: UpdateProfileDiscipline, @Body() body: UpdateProfileDiscipline,
@Path() disciplineId: string, @Path() disciplineId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const record = await this.disciplineRepository.findOneBy({ id: disciplineId }); const record = await this.disciplineRepository.findOneBy({ id: disciplineId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -177,7 +179,8 @@ export class ProfileDisciplineController extends Controller {
} }
@Delete("{disciplineId}") @Delete("{disciplineId}")
public async deleteDiscipline(@Path() disciplineId: string) { public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY");
await this.disciplineHistoryRepository.delete({ await this.disciplineHistoryRepository.delete({
profileDisciplineId: disciplineId, profileDisciplineId: disciplineId,
}); });

View file

@ -24,7 +24,7 @@ import {
UpdateProfileDiscipline, UpdateProfileDiscipline,
} from "../entities/ProfileDiscipline"; } from "../entities/ProfileDiscipline";
import { ProfileEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/discipline") @Route("api/v1/org/profile-employee/discipline")
@Tags("ProfileDisciplineEmployee") @Tags("ProfileDisciplineEmployee")
@Security("bearerAuth") @Security("bearerAuth")
@ -115,6 +115,7 @@ export class ProfileDisciplineEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeDiscipline, @Body() body: CreateProfileEmployeeDiscipline,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -147,6 +148,7 @@ export class ProfileDisciplineEmployeeController extends Controller {
@Body() body: UpdateProfileDiscipline, @Body() body: UpdateProfileDiscipline,
@Path() disciplineId: string, @Path() disciplineId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.disciplineRepository.findOneBy({ id: disciplineId }); const record = await this.disciplineRepository.findOneBy({ id: disciplineId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -168,7 +170,8 @@ export class ProfileDisciplineEmployeeController extends Controller {
} }
@Delete("{disciplineId}") @Delete("{disciplineId}")
public async deleteDiscipline(@Path() disciplineId: string) { public async deleteDiscipline(@Path() disciplineId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY_EMP");
await this.disciplineHistoryRepository.delete({ await this.disciplineHistoryRepository.delete({
profileDisciplineId: disciplineId, profileDisciplineId: disciplineId,
}); });

View file

@ -20,7 +20,7 @@ import { ProfileDutyHistory } from "../entities/ProfileDutyHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile"; import { Profile } from "../entities/Profile";
import { CreateProfileDuty, ProfileDuty, UpdateProfileDuty } from "../entities/ProfileDuty"; import { CreateProfileDuty, ProfileDuty, UpdateProfileDuty } from "../entities/ProfileDuty";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/duty") @Route("api/v1/org/profile/duty")
@Tags("ProfileDuty") @Tags("ProfileDuty")
@Security("bearerAuth") @Security("bearerAuth")
@ -128,6 +128,7 @@ export class ProfileDutyController extends Controller {
@Post() @Post()
public async newDuty(@Request() req: RequestWithUser, @Body() body: CreateProfileDuty) { public async newDuty(@Request() req: RequestWithUser, @Body() body: CreateProfileDuty) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
if (!body.profileId) { if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -160,6 +161,7 @@ export class ProfileDutyController extends Controller {
@Body() body: UpdateProfileDuty, @Body() body: UpdateProfileDuty,
@Path() dutyId: string, @Path() dutyId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const record = await this.dutyRepository.findOneBy({ id: dutyId }); const record = await this.dutyRepository.findOneBy({ id: dutyId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -178,7 +180,8 @@ export class ProfileDutyController extends Controller {
} }
@Delete("{dutyId}") @Delete("{dutyId}")
public async deleteDuty(@Path() dutyId: string) { public async deleteDuty(@Path() dutyId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY");
await this.dutyHistoryRepository.delete({ await this.dutyHistoryRepository.delete({
profileDutyId: dutyId, profileDutyId: dutyId,
}); });

View file

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

View file

@ -30,7 +30,7 @@ import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile"; import { Profile } from "../entities/Profile";
import { ProfileEducationHistory } from "../entities/ProfileEducationHistory"; import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
import { AppDataSource } from "../database/data-source"; import { AppDataSource } from "../database/data-source";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/educations") @Route("api/v1/org/profile/educations")
@Tags("ProfileEducations") @Tags("ProfileEducations")
@Security("bearerAuth") @Security("bearerAuth")
@ -181,6 +181,7 @@ export class ProfileEducationsController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEducation, @Body() body: CreateProfileEducation,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
if (!body.profileId) { if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -211,6 +212,7 @@ export class ProfileEducationsController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Path() educationId: string, @Path() educationId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const record = await this.profileEducationRepo.findOneBy({ id: educationId }); const record = await this.profileEducationRepo.findOneBy({ id: educationId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -232,7 +234,8 @@ export class ProfileEducationsController extends Controller {
} }
@Delete("{educationId}") @Delete("{educationId}")
public async deleteProfileEducation(@Path() educationId: string) { public async deleteProfileEducation(@Path() educationId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY");
await this.profileEducationHistoryRepo.delete({ await this.profileEducationHistoryRepo.delete({
profileEducationId: educationId, profileEducationId: educationId,
}); });

View file

@ -16,11 +16,9 @@ import {
Patch, Patch,
Example, Example,
} from "tsoa"; } from "tsoa";
import HttpSuccess from "../interfaces/http-success"; import HttpSuccess from "../interfaces/http-success";
import HttpError from "../interfaces/http-error"; import HttpError from "../interfaces/http-error";
import HttpStatus from "../interfaces/http-status"; import HttpStatus from "../interfaces/http-status";
import { import {
ProfileEducation, ProfileEducation,
CreateProfileEducation, CreateProfileEducation,
@ -32,7 +30,7 @@ import { Profile } from "../entities/Profile";
import { ProfileEducationHistory } from "../entities/ProfileEducationHistory"; import { ProfileEducationHistory } from "../entities/ProfileEducationHistory";
import { AppDataSource } from "../database/data-source"; import { AppDataSource } from "../database/data-source";
import { ProfileEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/educations") @Route("api/v1/org/profile-employee/educations")
@Tags("ProfileEducationsEmployee") @Tags("ProfileEducationsEmployee")
@Security("bearerAuth") @Security("bearerAuth")
@ -185,6 +183,7 @@ export class ProfileEducationsEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEducationEmployee, @Body() body: CreateProfileEducationEmployee,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
} }
@ -215,6 +214,7 @@ export class ProfileEducationsEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Path() educationId: string, @Path() educationId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.profileEducationRepo.findOneBy({ id: educationId }); const record = await this.profileEducationRepo.findOneBy({ id: educationId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -236,7 +236,8 @@ export class ProfileEducationsEmployeeController extends Controller {
} }
@Delete("{educationId}") @Delete("{educationId}")
public async deleteProfileEducation(@Path() educationId: string) { public async deleteProfileEducation(@Path() educationId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY_EMP");
await this.profileEducationHistoryRepo.delete({ await this.profileEducationHistoryRepo.delete({
profileEducationId: educationId, profileEducationId: educationId,
}); });

View file

@ -65,7 +65,7 @@ import CallAPI from "../interfaces/call-api";
import { EmployeePosition } from "../entities/EmployeePosition"; import { EmployeePosition } from "../entities/EmployeePosition";
import { ProfileInsignia } from "../entities/ProfileInsignia"; import { ProfileInsignia } from "../entities/ProfileInsignia";
import { ProfileLeave } from "../entities/ProfileLeave"; import { ProfileLeave } from "../entities/ProfileLeave";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee") @Route("api/v1/org/profile-employee")
@Tags("ProfileEmployee") @Tags("ProfileEmployee")
@Security("bearerAuth") @Security("bearerAuth")
@ -576,6 +576,7 @@ export class ProfileEmployeeController extends Controller {
*/ */
@Post() @Post()
async createProfile(@Body() body: CreateProfileEmployee, @Request() request: RequestWithUser) { async createProfile(@Body() body: CreateProfileEmployee, @Request() request: RequestWithUser) {
await new permission().PermissionCreate(request,"SYS_REGISTRY_EMP");
if (await this.profileRepo.findOneBy({ citizenId: body.citizenId })) { if (await this.profileRepo.findOneBy({ citizenId: body.citizenId })) {
throw new HttpError( throw new HttpError(
HttpStatus.INTERNAL_SERVER_ERROR, HttpStatus.INTERNAL_SERVER_ERROR,
@ -628,6 +629,7 @@ export class ProfileEmployeeController extends Controller {
@Path() id: string, @Path() id: string,
@Body() body: UpdateProfileEmployee, @Body() body: UpdateProfileEmployee,
) { ) {
await new permission().PermissionUpdate(request,"SYS_REGISTRY_EMP");
const exists = const exists =
!!body.citizenId && !!body.citizenId &&
(await this.profileRepo.findOne({ (await this.profileRepo.findOne({
@ -690,7 +692,8 @@ export class ProfileEmployeeController extends Controller {
* @param {string} id Id * @param {string} id Id
*/ */
@Delete("{id}") @Delete("{id}")
async deleteProfile(@Path() id: string) { async deleteProfile(@Path() id: string, @Request() request: RequestWithUser,) {
await new permission().PermissionDelete(request,"SYS_REGISTRY_EMP");
const result = await this.profileRepo.findOne({ where: { id: id } }); const result = await this.profileRepo.findOne({ where: { id: id } });
if (!result) { if (!result) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");

View file

@ -25,6 +25,7 @@ import {
} from "../entities/ProfileFamilyCouple"; } from "../entities/ProfileFamilyCouple";
import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory"; import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory";
import Extension from "../interfaces/extension"; import Extension from "../interfaces/extension";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/family/couple") @Route("api/v1/org/profile/family/couple")
@Tags("ProfileFamilyCouple") @Tags("ProfileFamilyCouple")
@Security("bearerAuth") @Security("bearerAuth")
@ -219,6 +220,7 @@ export class ProfileFamilyCoupleController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileFamilyCouple, @Body() body: CreateProfileFamilyCouple,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
const familyCouple = Object.assign(new ProfileFamilyCouple(), body); const familyCouple = Object.assign(new ProfileFamilyCouple(), body);
if (!familyCouple) { if (!familyCouple) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -265,6 +267,7 @@ export class ProfileFamilyCoupleController extends Controller {
@Body() body: UpdateProfileFamilyCouple, @Body() body: UpdateProfileFamilyCouple,
@Path() profileId: string, @Path() profileId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const familyCouple = await this.ProfileFamilyCouple.findOneBy({ profileId: profileId }); const familyCouple = await this.ProfileFamilyCouple.findOneBy({ profileId: profileId });
if (!familyCouple) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!familyCouple) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");

View file

@ -21,6 +21,7 @@ import { ProfileEmployee } from "../entities/ProfileEmployee";
import { ProfileFamilyCouple, CreateProfileEmployeeFamilyCouple, UpdateProfileFamilyCouple } from "../entities/ProfileFamilyCouple"; import { ProfileFamilyCouple, CreateProfileEmployeeFamilyCouple, UpdateProfileFamilyCouple } from "../entities/ProfileFamilyCouple";
import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory"; import { ProfileFamilyCoupleHistory } from "../entities/ProfileFamilyCoupleHistory";
import Extension from "../interfaces/extension"; import Extension from "../interfaces/extension";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/family/couple") @Route("api/v1/org/profile-employee/family/couple")
@Tags("ProfileEmployeeFamilyCouple") @Tags("ProfileEmployeeFamilyCouple")
@Security("bearerAuth") @Security("bearerAuth")
@ -215,6 +216,7 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeFamilyCouple, @Body() body: CreateProfileEmployeeFamilyCouple,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
const familyCouple = Object.assign(new ProfileFamilyCouple(), body); const familyCouple = Object.assign(new ProfileFamilyCouple(), body);
if (!familyCouple) { if (!familyCouple) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -261,6 +263,7 @@ export class ProfileFamilyCoupleEmployeeController extends Controller {
@Body() body: UpdateProfileFamilyCouple, @Body() body: UpdateProfileFamilyCouple,
@Path() profileEmployeeId: string, @Path() profileEmployeeId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const familyCouple = await this.ProfileFamilyCouple.findOneBy({ const familyCouple = await this.ProfileFamilyCouple.findOneBy({
profileEmployeeId: profileEmployeeId, profileEmployeeId: profileEmployeeId,
}); });

View file

@ -25,6 +25,7 @@ import {
} from "../entities/ProfileFamilyFather"; } from "../entities/ProfileFamilyFather";
import { ProfileFamilyFatherHistory } from "../entities/ProfileFamilyFatherHistory"; import { ProfileFamilyFatherHistory } from "../entities/ProfileFamilyFatherHistory";
import Extension from "../interfaces/extension"; import Extension from "../interfaces/extension";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/family/father") @Route("api/v1/org/profile/family/father")
@Tags("ProfileFamilyFather") @Tags("ProfileFamilyFather")
@Security("bearerAuth") @Security("bearerAuth")
@ -205,6 +206,7 @@ export class ProfileFamilyFatherController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileFamilyFather, @Body() body: CreateProfileFamilyFather,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
const familyFather = Object.assign(new ProfileFamilyFather(), body); const familyFather = Object.assign(new ProfileFamilyFather(), body);
if (!familyFather) { if (!familyFather) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -245,6 +247,7 @@ export class ProfileFamilyFatherController extends Controller {
@Body() body: UpdateProfileFamilyFather, @Body() body: UpdateProfileFamilyFather,
@Path() profileId: string, @Path() profileId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const familyFather = await this.ProfileFamilyFather.findOneBy({ profileId: profileId }); const familyFather = await this.ProfileFamilyFather.findOneBy({ profileId: profileId });
if (!familyFather) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!familyFather) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");

View file

@ -25,6 +25,7 @@ import {
} from "../entities/ProfileFamilyFather"; } from "../entities/ProfileFamilyFather";
import { ProfileFamilyFatherHistory } from "../entities/ProfileFamilyFatherHistory"; import { ProfileFamilyFatherHistory } from "../entities/ProfileFamilyFatherHistory";
import Extension from "../interfaces/extension"; import Extension from "../interfaces/extension";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/family/father") @Route("api/v1/org/profile-employee/family/father")
@Tags("ProfileEmployeeFamilyFather") @Tags("ProfileEmployeeFamilyFather")
@Security("bearerAuth") @Security("bearerAuth")
@ -205,6 +206,7 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeFamilyFather, @Body() body: CreateProfileEmployeeFamilyFather,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
const familyFather = Object.assign(new ProfileFamilyFather(), body); const familyFather = Object.assign(new ProfileFamilyFather(), body);
if (!familyFather) { if (!familyFather) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -245,6 +247,7 @@ export class ProfileFamilyFatherEmployeeController extends Controller {
@Body() body: UpdateProfileFamilyFather, @Body() body: UpdateProfileFamilyFather,
@Path() profileEmployeeId: string, @Path() profileEmployeeId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const familyFather = await this.ProfileFamilyFather.findOneBy({ const familyFather = await this.ProfileFamilyFather.findOneBy({
profileEmployeeId: profileEmployeeId, profileEmployeeId: profileEmployeeId,
}); });

View file

@ -25,6 +25,7 @@ import {
} from "../entities/ProfileFamilyMother"; } from "../entities/ProfileFamilyMother";
import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory"; import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory";
import Extension from "../interfaces/extension"; import Extension from "../interfaces/extension";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/family/mother") @Route("api/v1/org/profile/family/mother")
@Tags("ProfileFamilyMother") @Tags("ProfileFamilyMother")
@Security("bearerAuth") @Security("bearerAuth")
@ -205,6 +206,7 @@ export class ProfileFamilyMotherController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileFamilyMother, @Body() body: CreateProfileFamilyMother,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
const familyMother = Object.assign(new ProfileFamilyMother(), body); const familyMother = Object.assign(new ProfileFamilyMother(), body);
if (!familyMother) { if (!familyMother) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -245,6 +247,7 @@ export class ProfileFamilyMotherController extends Controller {
@Body() body: UpdateProfileFamilyMother, @Body() body: UpdateProfileFamilyMother,
@Path() profileId: string, @Path() profileId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const familyMother = await this.ProfileFamilyMother.findOneBy({ profileId: profileId }); const familyMother = await this.ProfileFamilyMother.findOneBy({ profileId: profileId });
if (!familyMother) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!familyMother) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");

View file

@ -21,6 +21,7 @@ import { ProfileEmployee } from "../entities/ProfileEmployee";
import { ProfileFamilyMother, CreateProfileEmployeeFamilyMother, UpdateProfileFamilyMother } from "../entities/ProfileFamilyMother"; import { ProfileFamilyMother, CreateProfileEmployeeFamilyMother, UpdateProfileFamilyMother } from "../entities/ProfileFamilyMother";
import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory"; import { ProfileFamilyMotherHistory } from "../entities/ProfileFamilyMotherHistory";
import Extension from "../interfaces/extension"; import Extension from "../interfaces/extension";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/family/mother") @Route("api/v1/org/profile-employee/family/mother")
@Tags("ProfileEmployeeFamilyMother") @Tags("ProfileEmployeeFamilyMother")
@Security("bearerAuth") @Security("bearerAuth")
@ -201,6 +202,7 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeFamilyMother, @Body() body: CreateProfileEmployeeFamilyMother,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
const familyMother = Object.assign(new ProfileFamilyMother(), body); const familyMother = Object.assign(new ProfileFamilyMother(), body);
if (!familyMother) { if (!familyMother) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -241,6 +243,7 @@ export class ProfileFamilyMotherEmployeeController extends Controller {
@Body() body: UpdateProfileFamilyMother, @Body() body: UpdateProfileFamilyMother,
@Path() profileEmployeeId: string, @Path() profileEmployeeId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const familyMother = await this.ProfileFamilyMother.findOneBy({ const familyMother = await this.ProfileFamilyMother.findOneBy({
profileEmployeeId: profileEmployeeId, profileEmployeeId: profileEmployeeId,
}); });

View file

@ -9,7 +9,7 @@ import { ProfileGovernment, UpdateProfileGovernment } from "../entities/ProfileG
import { Position } from "../entities/Position"; import { Position } from "../entities/Position";
import { PosMaster } from "../entities/PosMaster"; import { PosMaster } from "../entities/PosMaster";
import { calculateAge, calculateRetireDate } from "../interfaces/utils"; import { calculateAge, calculateRetireDate } from "../interfaces/utils";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/government") @Route("api/v1/org/profile/government")
@Tags("ProfileGovernment") @Tags("ProfileGovernment")
@Security("bearerAuth") @Security("bearerAuth")
@ -293,6 +293,7 @@ export class ProfileGovernmentHistoryController extends Controller {
@Body() body: UpdateProfileGovernment, @Body() body: UpdateProfileGovernment,
@Path() profileId: string, @Path() profileId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const record = await this.profileRepo.findOne({ const record = await this.profileRepo.findOne({
where: { id: profileId }, where: { id: profileId },
}); });

View file

@ -26,7 +26,7 @@ import {
import { EmployeePosition } from "../entities/EmployeePosition"; import { EmployeePosition } from "../entities/EmployeePosition";
import { EmployeePosMaster } from "../entities/EmployeePosMaster"; import { EmployeePosMaster } from "../entities/EmployeePosMaster";
import { calculateAge, calculateRetireDate } from "../interfaces/utils"; import { calculateAge, calculateRetireDate } from "../interfaces/utils";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/government") @Route("api/v1/org/profile-employee/government")
@Tags("ProfileEmployeeGovernment") @Tags("ProfileEmployeeGovernment")
@Security("bearerAuth") @Security("bearerAuth")
@ -288,6 +288,7 @@ export class ProfileGovernmentEmployeeController extends Controller {
@Body() body: UpdateProfileGovernment, @Body() body: UpdateProfileGovernment,
@Path() profileEmployeeId: string, @Path() profileEmployeeId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.profileEmployeeRepo.findOne({ const record = await this.profileEmployeeRepo.findOne({
where: { id: profileEmployeeId }, where: { id: profileEmployeeId },
}); });

View file

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

View file

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

View file

@ -25,7 +25,7 @@ import { ProfileInsigniaHistory } from "../entities/ProfileInsigniaHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile"; import { Profile } from "../entities/Profile";
import { Insignia } from "../entities/Insignia"; import { Insignia } from "../entities/Insignia";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/insignia") @Route("api/v1/org/profile/insignia")
@Tags("ProfileInsignia") @Tags("ProfileInsignia")
@Security("bearerAuth") @Security("bearerAuth")
@ -166,6 +166,7 @@ export class ProfileInsigniaController extends Controller {
@Post() @Post()
public async newInsignia(@Request() req: RequestWithUser, @Body() body: CreateProfileInsignia) { public async newInsignia(@Request() req: RequestWithUser, @Body() body: CreateProfileInsignia) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
if (!body.profileId) { if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -205,6 +206,7 @@ export class ProfileInsigniaController extends Controller {
@Body() body: UpdateProfileInsignia, @Body() body: UpdateProfileInsignia,
@Path() insigniaId: string, @Path() insigniaId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const record = await this.insigniaRepo.findOneBy({ id: insigniaId }); const record = await this.insigniaRepo.findOneBy({ id: insigniaId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -230,7 +232,8 @@ export class ProfileInsigniaController extends Controller {
} }
@Delete("{insigniaId}") @Delete("{insigniaId}")
public async deleteInsignia(@Path() insigniaId: string) { public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY");
await this.insigniaHistoryRepo.delete({ await this.insigniaHistoryRepo.delete({
profileInsigniaId: insigniaId, profileInsigniaId: insigniaId,
}); });

View file

@ -25,7 +25,7 @@ import { ProfileInsigniaHistory } from "../entities/ProfileInsigniaHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { ProfileEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee } from "../entities/ProfileEmployee";
import { Insignia } from "../entities/Insignia"; import { Insignia } from "../entities/Insignia";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/insignia") @Route("api/v1/org/profile-employee/insignia")
@Tags("ProfileEmployeeInsignia") @Tags("ProfileEmployeeInsignia")
@Security("bearerAuth") @Security("bearerAuth")
@ -166,6 +166,7 @@ export class ProfileInsigniaEmployeeController extends Controller {
@Post() @Post()
public async newInsignia(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeInsignia) { public async newInsignia(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeInsignia) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
} }
@ -205,6 +206,7 @@ export class ProfileInsigniaEmployeeController extends Controller {
@Body() body: UpdateProfileInsignia, @Body() body: UpdateProfileInsignia,
@Path() insigniaId: string, @Path() insigniaId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.insigniaRepo.findOneBy({ id: insigniaId }); const record = await this.insigniaRepo.findOneBy({ id: insigniaId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -230,7 +232,8 @@ export class ProfileInsigniaEmployeeController extends Controller {
} }
@Delete("{insigniaId}") @Delete("{insigniaId}")
public async deleteInsignia(@Path() insigniaId: string) { public async deleteInsignia(@Path() insigniaId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY_EMP");
await this.insigniaHistoryRepo.delete({ await this.insigniaHistoryRepo.delete({
profileInsigniaId: insigniaId, profileInsigniaId: insigniaId,
}); });

View file

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

View file

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

View file

@ -20,7 +20,7 @@ import { ProfileNopaidHistory } from "../entities/ProfileNopaidHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile"; import { Profile } from "../entities/Profile";
import { CreateProfileNopaid, ProfileNopaid, UpdateProfileNopaid } from "../entities/ProfileNopaid"; import { CreateProfileNopaid, ProfileNopaid, UpdateProfileNopaid } from "../entities/ProfileNopaid";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/nopaid") @Route("api/v1/org/profile/nopaid")
@Tags("ProfileNopaid") @Tags("ProfileNopaid")
@Security("bearerAuth") @Security("bearerAuth")
@ -96,6 +96,7 @@ export class ProfileNopaidController extends Controller {
@Post() @Post()
public async newNopaid(@Request() req: RequestWithUser, @Body() body: CreateProfileNopaid) { public async newNopaid(@Request() req: RequestWithUser, @Body() body: CreateProfileNopaid) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
if (!body.profileId) { if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -128,6 +129,7 @@ export class ProfileNopaidController extends Controller {
@Body() body: UpdateProfileNopaid, @Body() body: UpdateProfileNopaid,
@Path() nopaidId: string, @Path() nopaidId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const record = await this.nopaidRepository.findOneBy({ id: nopaidId }); const record = await this.nopaidRepository.findOneBy({ id: nopaidId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -149,7 +151,8 @@ export class ProfileNopaidController extends Controller {
} }
@Delete("{nopaidId}") @Delete("{nopaidId}")
public async deleteNopaid(@Path() nopaidId: string) { public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY");
await this.nopaidHistoryRepository.delete({ await this.nopaidHistoryRepository.delete({
profileNopaidId: nopaidId, profileNopaidId: nopaidId,
}); });

View file

@ -24,7 +24,7 @@ import {
ProfileNopaid, ProfileNopaid,
UpdateProfileNopaid, UpdateProfileNopaid,
} from "../entities/ProfileNopaid"; } from "../entities/ProfileNopaid";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/nopaid") @Route("api/v1/org/profile-employee/nopaid")
@Tags("ProfileNopaid") @Tags("ProfileNopaid")
@Security("bearerAuth") @Security("bearerAuth")
@ -67,6 +67,7 @@ export class ProfileNopaidEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeNopaid, @Body() body: CreateProfileEmployeeNopaid,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -99,6 +100,7 @@ export class ProfileNopaidEmployeeController extends Controller {
@Body() body: UpdateProfileNopaid, @Body() body: UpdateProfileNopaid,
@Path() nopaidId: string, @Path() nopaidId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.nopaidRepository.findOneBy({ id: nopaidId }); const record = await this.nopaidRepository.findOneBy({ id: nopaidId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -120,7 +122,8 @@ export class ProfileNopaidEmployeeController extends Controller {
} }
@Delete("{nopaidId}") @Delete("{nopaidId}")
public async deleteNopaid(@Path() nopaidId: string) { public async deleteNopaid(@Path() nopaidId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY_EMP");
await this.nopaidHistoryRepository.delete({ await this.nopaidHistoryRepository.delete({
profileNopaidId: nopaidId, profileNopaidId: nopaidId,
}); });

View file

@ -20,7 +20,7 @@ import { ProfileOtherHistory } from "../entities/ProfileOtherHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile"; import { Profile } from "../entities/Profile";
import { CreateProfileOther, ProfileOther, UpdateProfileOther } from "../entities/ProfileOther"; import { CreateProfileOther, ProfileOther, UpdateProfileOther } from "../entities/ProfileOther";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/other") @Route("api/v1/org/profile/other")
@Tags("ProfileOther") @Tags("ProfileOther")
@Security("bearerAuth") @Security("bearerAuth")
@ -93,6 +93,7 @@ export class ProfileOtherController extends Controller {
@Post() @Post()
public async newOther(@Request() req: RequestWithUser, @Body() body: CreateProfileOther) { public async newOther(@Request() req: RequestWithUser, @Body() body: CreateProfileOther) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
if (!body.profileId) { if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -125,6 +126,7 @@ export class ProfileOtherController extends Controller {
@Body() body: UpdateProfileOther, @Body() body: UpdateProfileOther,
@Path() otherId: string, @Path() otherId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const record = await this.otherRepository.findOneBy({ id: otherId }); const record = await this.otherRepository.findOneBy({ id: otherId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -146,7 +148,8 @@ export class ProfileOtherController extends Controller {
} }
@Delete("{otherId}") @Delete("{otherId}")
public async deleteOther(@Path() otherId: string) { public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY");
await this.otherHistoryRepository.delete({ await this.otherHistoryRepository.delete({
profileOtherId: otherId, profileOtherId: otherId,
}); });

View file

@ -24,7 +24,7 @@ import {
ProfileOther, ProfileOther,
UpdateProfileOther, UpdateProfileOther,
} from "../entities/ProfileOther"; } from "../entities/ProfileOther";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/other") @Route("api/v1/org/profile-employee/other")
@Tags("ProfileOther") @Tags("ProfileOther")
@Security("bearerAuth") @Security("bearerAuth")
@ -64,6 +64,7 @@ export class ProfileOtherEmployeeController extends Controller {
@Post() @Post()
public async newOther(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeOther) { public async newOther(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeOther) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -96,6 +97,7 @@ export class ProfileOtherEmployeeController extends Controller {
@Body() body: UpdateProfileOther, @Body() body: UpdateProfileOther,
@Path() otherId: string, @Path() otherId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.otherRepository.findOneBy({ id: otherId }); const record = await this.otherRepository.findOneBy({ id: otherId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -117,7 +119,8 @@ export class ProfileOtherEmployeeController extends Controller {
} }
@Delete("{otherId}") @Delete("{otherId}")
public async deleteOther(@Path() otherId: string) { public async deleteOther(@Path() otherId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY_EMP");
await this.otherHistoryRepository.delete({ await this.otherHistoryRepository.delete({
profileOtherId: otherId, profileOtherId: otherId,
}); });

View file

@ -21,7 +21,7 @@ import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile"; import { Profile } from "../entities/Profile";
import { LessThan, MoreThan } from "typeorm"; import { LessThan, MoreThan } from "typeorm";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/salary") @Route("api/v1/org/profile/salary")
@Tags("ProfileSalary") @Tags("ProfileSalary")
@Security("bearerAuth") @Security("bearerAuth")
@ -140,6 +140,7 @@ export class ProfileSalaryController extends Controller {
@Post() @Post()
public async newSalary(@Request() req: RequestWithUser, @Body() body: CreateProfileSalary) { public async newSalary(@Request() req: RequestWithUser, @Body() body: CreateProfileSalary) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
if (!body.profileId) { if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -178,6 +179,7 @@ export class ProfileSalaryController extends Controller {
@Body() body: UpdateProfileSalary, @Body() body: UpdateProfileSalary,
@Path() salaryId: string, @Path() salaryId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const record = await this.salaryRepo.findOneBy({ id: salaryId }); const record = await this.salaryRepo.findOneBy({ id: salaryId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -196,7 +198,8 @@ export class ProfileSalaryController extends Controller {
} }
@Delete("{salaryId}") @Delete("{salaryId}")
public async deleteSalary(@Path() salaryId: string) { public async deleteSalary(@Path() salaryId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY");
await this.salaryHistoryRepo.delete({ await this.salaryHistoryRepo.delete({
profileSalaryId: salaryId, profileSalaryId: salaryId,
}); });

View file

@ -25,7 +25,7 @@ import { ProfileSalaryHistory } from "../entities/ProfileSalaryHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { ProfileEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee } from "../entities/ProfileEmployee";
import { LessThan, MoreThan } from "typeorm"; import { LessThan, MoreThan } from "typeorm";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/salary") @Route("api/v1/org/profile-employee/salary")
@Tags("ProfileSalary") @Tags("ProfileSalary")
@Security("bearerAuth") @Security("bearerAuth")
@ -69,6 +69,7 @@ export class ProfileSalaryEmployeeController extends Controller {
@Request() req: RequestWithUser, @Request() req: RequestWithUser,
@Body() body: CreateProfileSalaryEmployee, @Body() body: CreateProfileSalaryEmployee,
) { ) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
} }
@ -107,6 +108,7 @@ export class ProfileSalaryEmployeeController extends Controller {
@Body() body: UpdateProfileSalaryEmployee, @Body() body: UpdateProfileSalaryEmployee,
@Path() salaryId: string, @Path() salaryId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.salaryRepo.findOneBy({ id: salaryId }); const record = await this.salaryRepo.findOneBy({ id: salaryId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -125,7 +127,8 @@ export class ProfileSalaryEmployeeController extends Controller {
} }
@Delete("{salaryId}") @Delete("{salaryId}")
public async deleteSalaryEmployee(@Path() salaryId: string) { public async deleteSalaryEmployee(@Path() salaryId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY_EMP");
await this.salaryHistoryRepo.delete({ await this.salaryHistoryRepo.delete({
profileSalaryId: salaryId, profileSalaryId: salaryId,
}); });

View file

@ -24,7 +24,7 @@ import HttpError from "../interfaces/http-error";
import { ProfileTrainingHistory } from "../entities/ProfileTrainingHistory"; import { ProfileTrainingHistory } from "../entities/ProfileTrainingHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { Profile } from "../entities/Profile"; import { Profile } from "../entities/Profile";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile/training") @Route("api/v1/org/profile/training")
@Tags("ProfileTraining") @Tags("ProfileTraining")
@Security("bearerAuth") @Security("bearerAuth")
@ -139,6 +139,7 @@ export class ProfileTrainingController extends Controller {
@Post() @Post()
public async newTraining(@Request() req: RequestWithUser, @Body() body: CreateProfileTraining) { public async newTraining(@Request() req: RequestWithUser, @Body() body: CreateProfileTraining) {
await new permission().PermissionCreate(req,"SYS_REGISTRY");
if (!body.profileId) { if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
} }
@ -171,6 +172,7 @@ export class ProfileTrainingController extends Controller {
@Body() body: UpdateProfileTraining, @Body() body: UpdateProfileTraining,
@Path() trainingId: string, @Path() trainingId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY");
const record = await this.trainingRepo.findOneBy({ id: trainingId }); const record = await this.trainingRepo.findOneBy({ id: trainingId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -189,7 +191,8 @@ export class ProfileTrainingController extends Controller {
} }
@Delete("{trainingId}") @Delete("{trainingId}")
public async deleteTraining(@Path() trainingId: string) { public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY");
await this.trainingHistoryRepo.delete({ await this.trainingHistoryRepo.delete({
profileTrainingId: trainingId, profileTrainingId: trainingId,
}); });

View file

@ -24,7 +24,7 @@ import HttpError from "../interfaces/http-error";
import { ProfileTrainingHistory } from "../entities/ProfileTrainingHistory"; import { ProfileTrainingHistory } from "../entities/ProfileTrainingHistory";
import { RequestWithUser } from "../middlewares/user"; import { RequestWithUser } from "../middlewares/user";
import { ProfileEmployee } from "../entities/ProfileEmployee"; import { ProfileEmployee } from "../entities/ProfileEmployee";
import permission from "../interfaces/permission";
@Route("api/v1/org/profile-employee/training") @Route("api/v1/org/profile-employee/training")
@Tags("ProfileEmployeeTraining") @Tags("ProfileEmployeeTraining")
@Security("bearerAuth") @Security("bearerAuth")
@ -139,6 +139,7 @@ export class ProfileTrainingEmployeeController extends Controller {
@Post() @Post()
public async newTraining(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeTraining) { public async newTraining(@Request() req: RequestWithUser, @Body() body: CreateProfileEmployeeTraining) {
await new permission().PermissionCreate(req,"SYS_REGISTRY_EMP");
if (!body.profileEmployeeId) { if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId"); throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
} }
@ -171,6 +172,7 @@ export class ProfileTrainingEmployeeController extends Controller {
@Body() body: UpdateProfileTraining, @Body() body: UpdateProfileTraining,
@Path() trainingId: string, @Path() trainingId: string,
) { ) {
await new permission().PermissionUpdate(req,"SYS_REGISTRY_EMP");
const record = await this.trainingRepo.findOneBy({ id: trainingId }); const record = await this.trainingRepo.findOneBy({ id: trainingId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล"); if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -189,7 +191,8 @@ export class ProfileTrainingEmployeeController extends Controller {
} }
@Delete("{trainingId}") @Delete("{trainingId}")
public async deleteTraining(@Path() trainingId: string) { public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req,"SYS_REGISTRY_EMP");
await this.trainingHistoryRepo.delete({ await this.trainingHistoryRepo.delete({
profileTrainingId: trainingId, profileTrainingId: trainingId,
}); });