role เมนู ข้าราชการ กทม. สามัญ
This commit is contained in:
parent
edad154826
commit
4b42b896fa
22 changed files with 307 additions and 157 deletions
|
|
@ -160,7 +160,8 @@ export class ProfileLeaveController extends Controller {
|
|||
},
|
||||
},
|
||||
})
|
||||
public async getLeave(@Path() profileId: string) {
|
||||
public async getLeave(@Path() profileId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionOrgUserGet(req, "SYS_REGISTRY_OFFICER", profileId);
|
||||
const record = await this.leaveRepo.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileId },
|
||||
|
|
@ -237,7 +238,11 @@ export class ProfileLeaveController extends Controller {
|
|||
},
|
||||
],
|
||||
})
|
||||
public async leaveHistory(@Path() leaveId: string) {
|
||||
public async leaveHistory(@Path() leaveId: string, @Request() req: RequestWithUser) {
|
||||
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserList(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
const record = await this.leaveHistoryRepo.find({
|
||||
relations: { leaveType: true },
|
||||
where: { profileLeaveId: leaveId },
|
||||
|
|
@ -247,16 +252,16 @@ export class ProfileLeaveController extends Controller {
|
|||
|
||||
@Post()
|
||||
public async newLeave(@Request() req: RequestWithUser, @Body() body: CreateProfileLeave) {
|
||||
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 leaveType = await this.leaveTypeRepository.findOne({
|
||||
where: { id: body.leaveTypeId },
|
||||
});
|
||||
|
|
@ -290,10 +295,9 @@ export class ProfileLeaveController extends Controller {
|
|||
@Body() body: UpdateProfileLeave,
|
||||
@Path() leaveId: string,
|
||||
) {
|
||||
await new permission().PermissionUpdate(req, "SYS_REGISTRY_OFFICER");
|
||||
const record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||
|
||||
if (!record) throw new HttpError(HttpStatus.NOT_FOUND, "ไม่พบข้อมูล");
|
||||
await new permission().PermissionOrgUserUpdate(req, "SYS_REGISTRY_OFFICER", record.profileId);
|
||||
|
||||
const leaveType = await this.leaveTypeRepository.findOne({
|
||||
where: { id: body.leaveTypeId },
|
||||
|
|
@ -322,7 +326,10 @@ export class ProfileLeaveController extends Controller {
|
|||
|
||||
@Delete("{leaveId}")
|
||||
public async deleteLeave(@Path() leaveId: string, @Request() req: RequestWithUser) {
|
||||
await new permission().PermissionDelete(req, "SYS_REGISTRY_OFFICER");
|
||||
const _record = await this.leaveRepo.findOneBy({ id: leaveId });
|
||||
if (_record) {
|
||||
await new permission().PermissionOrgUserDelete(req, "SYS_REGISTRY_OFFICER", _record.profileId);
|
||||
}
|
||||
await this.leaveHistoryRepo.delete({
|
||||
profileLeaveId: leaveId,
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue