role เมนู ลูกจ้างประจำ กทม.

This commit is contained in:
AdisakKanthawilang 2024-08-23 16:28:31 +07:00
parent 359d22beec
commit 7237c68cb8
23 changed files with 327 additions and 155 deletions

View file

@ -67,7 +67,8 @@ export class ProfileCertificateEmployeeController extends Controller {
},
],
})
public async getCertificate(@Path() profileEmployeeId: string) {
public async getCertificate(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const record = await this.certificateRepo.findBy({ profileEmployeeId });
return new HttpSuccess(record);
}
@ -109,7 +110,11 @@ export class ProfileCertificateEmployeeController extends Controller {
},
],
})
public async certificateHistory(@Path() certificateId: string) {
public async certificateHistory(@Path() certificateId: string, @Request() req: RequestWithUser) {
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
}
const record = await this.certificateHistoryRepo.findBy({
profileCertificateId: certificateId,
});
@ -121,16 +126,15 @@ export class ProfileCertificateEmployeeController extends Controller {
@Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeCertificate,
) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_EMP");
if (!body.profileEmployeeId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileEmployeeId");
}
const profile = await this.profileEmployeeRepo.findOneBy({ id: body.profileEmployeeId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_EMP", profile.id);
const data = new ProfileCertificate();
@ -158,10 +162,9 @@ export class ProfileCertificateEmployeeController extends Controller {
@Body() body: UpdateProfileCertificate,
@Path() certificateId: string,
) {
await new permission().PermissionUpdate(req, "SYS_REGISTRY_EMP");
const record = await this.certificateRepo.findOneBy({ id: certificateId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId);
const history = new ProfileCertificateHistory();
@ -186,7 +189,10 @@ export class ProfileCertificateEmployeeController extends Controller {
@Delete("{certificateId}")
public async deleteCertificate(@Path() certificateId: string, @Request() req: RequestWithUser) {
await new permission().PermissionDelete(req, "SYS_REGISTRY_EMP");
const _record = await this.certificateRepo.findOneBy({ id: certificateId });
if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
}
await this.certificateHistoryRepo.delete({
profileCertificateId: certificateId,
});