role เมนู ข้าราชการ กทม. สามัญ
This commit is contained in:
parent
edad154826
commit
4b42b896fa
22 changed files with 307 additions and 157 deletions
|
|
@ -74,7 +74,8 @@ export class ProfileTrainingController extends Controller {
|
|||
},
|
||||
],
|
||||
})
|
||||
public async getTraining(@Path() profileId: string) {
|
||||
public async getTraining(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const record = await this.trainingRepo.findBy({ profileId });
|
||||
return new HttpSuccess(record);
|
||||
}
|
||||
|
|
@ -130,7 +131,11 @@ export class ProfileTrainingController extends Controller {
|
|||
},
|
||||
],
|
||||
})
|
||||
public async trainingHistory(@Path() trainingId: string) {
|
||||
public async trainingHistory(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const record = await this.trainingHistoryRepo.findBy({
|
||||
profileTrainingId: trainingId,
|
||||
});
|
||||
|
|
@ -139,16 +144,15 @@ export class ProfileTrainingController extends Controller {
|
|||
|
||||
@Post()
|
||||
public async newTraining(@Request() req: RequestWithUser, @Body() body: CreateProfileTraining) {
|
||||
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 ProfileTraining();
|
||||
|
||||
|
|
@ -176,10 +180,9 @@ export class ProfileTrainingController extends Controller {
|
|||
@Body() body: UpdateProfileTraining,
|
||||
@Path() trainingId: string,
|
||||
) {
|
||||
await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER");
|
||||
const record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
|
||||
const history = new ProfileTrainingHistory();
|
||||
|
||||
|
|
@ -201,7 +204,10 @@ export class ProfileTrainingController extends Controller {
|
|||
|
||||
@Delete("{trainingId}")
|
||||
public async deleteTraining(@Path() trainingId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER");
|
||||
const _record = await this.trainingRepo.findOneBy({ id: trainingId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
await this.trainingHistoryRepo.delete({
|
||||
profileTrainingId: trainingId,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue