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

@ -78,7 +78,8 @@ export class ProfileAssessmentsEmployeeController extends Controller {
},
],
})
public async detailProfileAssessments(@Path() profileEmployeeId: string) {
public async detailProfileAssessments(@Path() profileEmployeeId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", profileEmployeeId);
const getProfileAssessments = await this.profileAssessmentsRepository.findBy({
profileEmployeeId,
});
@ -131,11 +132,14 @@ export class ProfileAssessmentsEmployeeController extends Controller {
},
],
})
public async getProfileAssessmentsHistory(@Path() assessmentId: string) {
public async getProfileAssessmentsHistory(@Path() assessmentId: string, @Request() req: RequestWithUser) {
const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
if (_record) {
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_EMP", _record.profileId);
}
const record = await this.profileAssessmentsHistoryRepository.findBy({
profileAssessmentId: assessmentId,
});
if (!record) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
}
@ -148,15 +152,15 @@ export class ProfileAssessmentsEmployeeController extends Controller {
@Request() req: RequestWithUser,
@Body() body: CreateProfileEmployeeAssessment,
) {
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 ProfileAssessment();
const meta = {
@ -182,9 +186,9 @@ export class ProfileAssessmentsEmployeeController extends Controller {
@Request() req: RequestWithUser,
@Path() assessmentId: string,
) {
await new permission().PermissionUpdate(req, "SYS_REGISTRY_EMP");
const record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_EMP", record.profileEmployeeId);
const history = new ProfileAssessmentHistory();
@ -212,7 +216,10 @@ export class ProfileAssessmentsEmployeeController extends Controller {
@Path() assessmentId: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionDelete(req, "SYS_REGISTRY_EMP");
const _record = await this.profileAssessmentsRepository.findOneBy({ id: assessmentId });
if (_record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_EMP", _record.profileEmployeeId);
}
await this.profileAssessmentsHistoryRepository.delete({
profileAssessmentId: assessmentId,
});