review
This commit is contained in:
@@ -118,13 +118,21 @@ export class ReviewController {
|
|||||||
return this.reviewService.update(id, userId, updateReviewDto, true);
|
return this.reviewService.update(id, userId, updateReviewDto, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@UseGuards(AdminAuthGuard)
|
||||||
|
@ApiBearerAuth()
|
||||||
|
@Get('admin/reviews/:id')
|
||||||
|
@ApiOperation({ summary: 'review detail' })
|
||||||
|
@ApiParam({ name: 'id', required: true })
|
||||||
|
reviewDetail(@Param('id') reviewId: string, @RestId() restaurantId: string) {
|
||||||
|
return this.reviewService.findById(reviewId, restaurantId);
|
||||||
|
}
|
||||||
|
|
||||||
@UseGuards(AdminAuthGuard)
|
@UseGuards(AdminAuthGuard)
|
||||||
@ApiBearerAuth()
|
@ApiBearerAuth()
|
||||||
@Patch('admin/reviews/:id/status')
|
@Patch('admin/reviews/:id/status')
|
||||||
@ApiOperation({ summary: 'Change review status (pending, approved, rejected)' })
|
@ApiOperation({ summary: 'Change review status (pending, approved, rejected)' })
|
||||||
@ApiParam({ name: 'id', required: true })
|
@ApiParam({ name: 'id', required: true })
|
||||||
@ApiBody({ type: ChangeStatusDto })
|
@ApiBody({ type: ChangeStatusDto })
|
||||||
@ApiOkResponse({ description: 'Review status updated successfully' })
|
|
||||||
changeStatus(
|
changeStatus(
|
||||||
@Param('id') reviewId: string,
|
@Param('id') reviewId: string,
|
||||||
@Body() changeStatusDto: ChangeStatusDto,
|
@Body() changeStatusDto: ChangeStatusDto,
|
||||||
|
|||||||
@@ -99,8 +99,11 @@ export class ReviewService {
|
|||||||
return this.reviewRepository.findAllPaginated({ ...restDto, restId: restaurant.id });
|
return this.reviewRepository.findAllPaginated({ ...restDto, restId: restaurant.id });
|
||||||
}
|
}
|
||||||
|
|
||||||
async findById(id: string): Promise<Review> {
|
async findById(id: string, restaurantId: string): Promise<Review> {
|
||||||
const review = await this.reviewRepository.findOne({ id }, { populate: ['food', 'user', 'order'] });
|
const review = await this.reviewRepository.findOne(
|
||||||
|
{ id, order: { restaurant: { id: restaurantId } } },
|
||||||
|
{ populate: ['food', 'user', 'order'] },
|
||||||
|
);
|
||||||
if (!review) {
|
if (!review) {
|
||||||
throw new NotFoundException(ReviewMessage.NOT_FOUND);
|
throw new NotFoundException(ReviewMessage.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user