-
Notifications
You must be signed in to change notification settings - Fork 106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: update job listing feature #623
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -48,4 +48,14 @@ export class JobsController { | |||||||||||||
async delete(@Param('id') id: string) { | ||||||||||||||
return this.jobService.delete(id); | ||||||||||||||
} | ||||||||||||||
|
||||||||||||||
@UseGuards(JobGuard) | ||||||||||||||
@Patch('/:id') | ||||||||||||||
@ApiOperation({ summary: 'Update a job' }) | ||||||||||||||
@ApiResponse({ status: 200, description: 'Job updated successfully' }) | ||||||||||||||
@ApiResponse({ status: 403, description: 'You do not have permission to perform this action' }) | ||||||||||||||
@ApiResponse({ status: 404, description: 'Job not found' }) | ||||||||||||||
async update(@Param('id') id: string, @Body() updateJobDto: Partial<JobDto>) { | ||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add UUID validation pipe to ensure id is of type UUID string. |
||||||||||||||
return this.jobService.update(id, updateJobDto); | ||||||||||||||
} | ||||||||||||||
Comment on lines
+58
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -69,6 +69,27 @@ export class JobsService { | |||||
data: job, | ||||||
}; | ||||||
} | ||||||
|
||||||
async update(id: string, updateJobDto: Partial<JobDto>) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const job = await this.jobRepository.findOne({ where: { id } }); | ||||||
if (!job) { | ||||||
throw new NotFoundException({ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use provided custom http exception handler |
||||||
status_code: 404, | ||||||
status: 'Not found Exception', | ||||||
message: 'Job not found', | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Better to use constants where possible. This makes code cleaner and maintainable |
||||||
}); | ||||||
} | ||||||
|
||||||
Object.assign(job, updateJobDto); | ||||||
const updatedJob = await this.jobRepository.save(job); | ||||||
|
||||||
return { | ||||||
data: updatedJob, | ||||||
message: 'Job details updated successfully', | ||||||
status_code: 200, | ||||||
}; | ||||||
} | ||||||
|
||||||
async delete(jobId: string) { | ||||||
// Check if listing exists | ||||||
const job = await this.jobRepository.findOne({ | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for the forward slash