review
This commit is contained in:
@@ -4,6 +4,7 @@ import { CreateReviewDto } from '../dto/create-review.dto';
|
||||
import { UpdateReviewDto } from '../dto/update-review.dto';
|
||||
import { FindReviewsDto, FindRestuarantReviewsDto } from '../dto/find-reviews.dto';
|
||||
import { ChangeStatusDto } from '../dto/change-status.dto';
|
||||
import { ReplyReviewDto } from '../dto/reply-review.dto';
|
||||
import {
|
||||
ApiTags,
|
||||
ApiOperation,
|
||||
@@ -18,6 +19,7 @@ import {
|
||||
import { AuthGuard } from 'src/modules/auth/guards/auth.guard';
|
||||
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
|
||||
import { UserId } from 'src/common/decorators/user-id.decorator';
|
||||
import { AdminId } from 'src/common/decorators/admin-id.decorator';
|
||||
import { RestId } from 'src/common/decorators/rest-id.decorator';
|
||||
import { ReviewStatus } from '../enums/review-status.enum';
|
||||
import { Permissions } from 'src/common/decorators/permissions.decorator';
|
||||
@@ -114,7 +116,7 @@ export class ReviewController {
|
||||
@ApiQuery({ name: 'orderBy', required: false, type: String })
|
||||
@ApiQuery({ name: 'order', required: false, enum: ['asc', 'desc'] })
|
||||
findAllAdmin(@Query() dto: FindReviewsDto, @RestId() restId: string) {
|
||||
return this.reviewService.findAll({ ...dto, restId: restId });
|
||||
return this.reviewService.findAll({ ...dto, topLevel: true, restId: restId });
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@@ -135,7 +137,7 @@ export class ReviewController {
|
||||
@ApiOperation({ summary: 'review detail' })
|
||||
@ApiParam({ name: 'id', required: true })
|
||||
reviewDetail(@Param('id') reviewId: string, @RestId() restaurantId: string) {
|
||||
return this.reviewService.findById(reviewId, restaurantId);
|
||||
return this.reviewService.findWithReplies(reviewId, restaurantId);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@@ -153,6 +155,33 @@ export class ReviewController {
|
||||
return this.reviewService.changeStatus(reviewId, changeStatusDto.status, restaurantId);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Permissions(Permission.MANAGE_REVIEWS)
|
||||
@Post('admin/reviews/:id/reply')
|
||||
@ApiOperation({ summary: 'Create or update restaurant reply to a review' })
|
||||
@ApiParam({ name: 'id', required: true, description: 'Parent review ID' })
|
||||
@ApiBody({ type: ReplyReviewDto })
|
||||
@ApiOkResponse({ description: 'The created or updated reply' })
|
||||
reply(
|
||||
@Param('id') reviewId: string,
|
||||
@Body() replyReviewDto: ReplyReviewDto,
|
||||
@RestId() restaurantId: string,
|
||||
@AdminId() adminId: string,
|
||||
) {
|
||||
return this.reviewService.reply(reviewId, restaurantId, adminId, replyReviewDto);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Permissions(Permission.MANAGE_REVIEWS)
|
||||
@Delete('admin/reviews/:id/reply')
|
||||
@ApiOperation({ summary: 'Delete restaurant reply to a review' })
|
||||
@ApiParam({ name: 'id', required: true, description: 'Parent review ID' })
|
||||
removeReply(@Param('id') reviewId: string, @RestId() restaurantId: string) {
|
||||
return this.reviewService.removeReply(reviewId, restaurantId);
|
||||
}
|
||||
|
||||
@UseGuards(AdminAuthGuard)
|
||||
@Permissions(Permission.MANAGE_REVIEWS)
|
||||
@ApiBearerAuth()
|
||||
|
||||
Reference in New Issue
Block a user