-
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?
Conversation
Please update the title, all small letters |
async update(@Param('id') id: string, @Body() updateJobDto: Partial<JobDto>) { | ||
return this.jobService.update(id, updateJobDto); | ||
} |
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.
async update(@Param('id') id: string, @Body() updateJobDto: Partial<JobDto>) { | |
return this.jobService.update(id, updateJobDto); | |
} | |
async updateJobById(@Param('id') id: string, @Body() updateJobDto: Partial<JobDto>) { | |
return this.jobService.updateJobById(id, updateJobDto); | |
} |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
async update(id: string, updateJobDto: Partial<JobDto>) { | |
async updateJobById(id: string, updateJobDto: Partial<JobDto>) { |
@@ -48,4 +48,14 @@ export class JobsController { | |||
async delete(@Param('id') id: string) { | |||
return this.jobService.delete(id); | |||
} | |||
|
|||
@UseGuards(JobGuard) | |||
@Patch('/:id') |
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
@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 comment
The reason will be displayed to describe this comment to others. Learn more.
Add UUID validation pipe to ensure id is of type UUID string.
async update(id: string, updateJobDto: Partial<JobDto>) { | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Use provided custom http exception handler
throw new NotFoundException({ | ||
status_code: 404, | ||
status: 'Not found Exception', | ||
message: 'Job not found', |
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.
Better to use constants where possible. This makes code cleaner and maintainable
This PR implements an API endpoint to update job post details, allowing users to modify existing job listings in case of omissions or errors.
Changes
api/v1/jobs/:id
update
methodTechnical Details
Endpoint:
PATCH api/v1/jobs/:id
Authentication: Bearer token required in Authorization header
Request body:
Note: All fields are optional for updates. Only provided fields will be updated.
Successful response (200 OK):
Error response (400 Bad Request):
Testing
update
methodChecklist
api/v1/jobs/:id
update
methodRelated Issues
Closes #158