role เมนู ข้าราชการ กทม. สามัญ

This commit is contained in:
AdisakKanthawilang 2024-08-22 17:25:25 +07:00
parent edad154826
commit 4b42b896fa
22 changed files with 307 additions and 157 deletions

View file

@ -91,7 +91,8 @@ export class ProfileEducationsController extends Controller {
},
],
})
public async detailProfileEducation(@Path() profileId: string) {
public async detailProfileEducation(@Path() profileId: string, @Request() req: RequestWithUser) {
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
const getProfileEducation = await this.profileEducationRepo.findBy({ profileId });
if (!getProfileEducation) {
throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
@ -166,7 +167,11 @@ export class ProfileEducationsController extends Controller {
},
],
})
public async getProfileEducationHistory(@Path() educationId: string) {
public async getProfileEducationHistory(@Path() educationId: string, @Request() req: RequestWithUser) {
const _record = await this.profileEducationRepo.findOneBy({ id: educationId });
if (_record) {
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_OFFICER", _record.profileId);
}
const record = await this.profileEducationHistoryRepo.findBy({
profileEducationId: educationId,
});
@ -181,15 +186,15 @@ export class ProfileEducationsController extends Controller {
@Request() req: RequestWithUser,
@Body() body: CreateProfileEducation,
) {
await new permission().PermissionCreate(req, "SYS_REGISTRY_OFFICER");
if (!body.profileId) {
throw new HttpError(HttpStatus.BAD_REQUEST, "กรุณากรอก profileId");
}
const profile = await this.profileRepo.findOneBy({ id: body.profileId });
if (!profile) {
throw new HttpError(HttpStatus.BAD_REQUEST, "ไม่พบ profile ดังกล่าว");
}
await new permission().PermissionOrgUserCreate(req, "SYS_REGISTRY_OFFICER", profile.id);
const data = new ProfileEducation();
const meta = {
@ -216,9 +221,9 @@ export class ProfileEducationsController extends Controller {
@Request() req: RequestWithUser,
@Path() educationId: string,
) {
await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER");
const record = await this.profileEducationRepo.findOneBy({ id: educationId });
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
const history = new ProfileEducationHistory();
@ -246,7 +251,10 @@ export class ProfileEducationsController extends Controller {
@Path() educationId: string,
@Request() req: RequestWithUser,
) {
await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER");
const record = await this.profileEducationRepo.findOneBy({ id: educationId });
if (record) {
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", record.profileId);
}
await this.profileEducationHistoryRepo.delete({
profileEducationId: educationId,
});