Sửa lỗi người nhận được liên kết chia sẻ không xem được nội dung Tour
This commit is contained in:
Vendored
+45
-36
@@ -157,6 +157,49 @@ AuthController = __decorate([
|
||||
(0, common_1.Controller)('auth'),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService, jwt_1.JwtService])
|
||||
], AuthController);
|
||||
let PublicTourController = class PublicTourController {
|
||||
constructor(prisma) {
|
||||
this.prisma = prisma;
|
||||
}
|
||||
async getPublicTourDetails(id) {
|
||||
const tour = await this.prisma.tour.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
participants: {
|
||||
include: {
|
||||
user: {
|
||||
select: { id: true, name: true, email: true }
|
||||
}
|
||||
}
|
||||
},
|
||||
photos: true,
|
||||
legs: {
|
||||
orderBy: { sequence: 'asc' },
|
||||
include: {
|
||||
locations: {
|
||||
orderBy: { plannedStart: 'asc' },
|
||||
include: { _count: { select: { comments: true } } }
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!tour)
|
||||
throw new common_1.NotFoundException(`Không tìm thấy Tour`);
|
||||
return tour;
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Get)(':id/public'),
|
||||
__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], PublicTourController.prototype, "getPublicTourDetails", null);
|
||||
PublicTourController = __decorate([
|
||||
(0, common_1.Controller)('tours'),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService])
|
||||
], PublicTourController);
|
||||
let TourController = class TourController {
|
||||
constructor(prisma) {
|
||||
this.prisma = prisma;
|
||||
@@ -374,33 +417,6 @@ let TourController = class TourController {
|
||||
}
|
||||
});
|
||||
}
|
||||
async getPublicTourDetails(id) {
|
||||
const tour = await this.prisma.tour.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
participants: {
|
||||
include: {
|
||||
user: {
|
||||
select: { id: true, name: true, email: true }
|
||||
}
|
||||
}
|
||||
},
|
||||
photos: true,
|
||||
legs: {
|
||||
orderBy: { sequence: 'asc' },
|
||||
include: {
|
||||
locations: {
|
||||
orderBy: { plannedStart: 'asc' },
|
||||
include: { _count: { select: { comments: true } } }
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
if (!tour)
|
||||
throw new common_1.NotFoundException(`Không tìm thấy Tour`);
|
||||
return tour;
|
||||
}
|
||||
async getTourDetails(id) {
|
||||
const tour = await this.prisma.tour.findUnique({
|
||||
where: { id },
|
||||
@@ -677,13 +693,6 @@ __decorate([
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], TourController.prototype, "getPublicTours", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)(':id/public'),
|
||||
__param(0, (0, common_1.Param)('id', common_1.ParseUUIDPipe)),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], TourController.prototype, "getPublicTourDetails", null);
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard, rbac_middleware_1.TourRoleGuard),
|
||||
(0, common_1.Get)(':id'),
|
||||
@@ -1131,6 +1140,7 @@ __decorate([
|
||||
__metadata("design:returntype", Promise)
|
||||
], CommentController.prototype, "getComments", null);
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
||||
(0, common_1.Post)(':locationId/comments'),
|
||||
__param(0, (0, common_1.Param)('locationId', common_1.ParseUUIDPipe)),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
@@ -1141,7 +1151,6 @@ __decorate([
|
||||
], CommentController.prototype, "addComment", null);
|
||||
CommentController = __decorate([
|
||||
(0, common_1.Controller)('locations'),
|
||||
(0, common_1.UseGuards)(jwt_auth_guard_1.JwtAuthGuard),
|
||||
__metadata("design:paramtypes", [prisma_service_1.PrismaService,
|
||||
CommentGateway])
|
||||
], CommentController);
|
||||
@@ -1155,7 +1164,7 @@ AppModule = __decorate([
|
||||
signOptions: { expiresIn: '1d' },
|
||||
}),
|
||||
],
|
||||
controllers: [AppController, AuthController, TourController, UserController, RoutingController, LegController, LocationController, CommentController],
|
||||
controllers: [AppController, AuthController, PublicTourController, TourController, UserController, RoutingController, LegController, LocationController, CommentController],
|
||||
providers: [prisma_service_1.PrismaService, jwt_strategy_1.JwtStrategy, rbac_middleware_1.TourRoleGuard, jwt_auth_guard_1.JwtAuthGuard, admin_guard_1.AdminGuard, CommentGateway],
|
||||
exports: [prisma_service_1.PrismaService]
|
||||
})
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+37
-31
@@ -103,6 +103,40 @@ class AuthController {
|
||||
}
|
||||
}
|
||||
|
||||
@Controller('tours') // Controller mới để xử lý các tour công khai
|
||||
class PublicTourController {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
|
||||
@Get(':id/public')
|
||||
async getPublicTourDetails(@Param('id', ParseUUIDPipe) id: string) {
|
||||
const tour = await this.prisma.tour.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
participants: {
|
||||
include: {
|
||||
user: {
|
||||
select: { id: true, name: true, email: true }
|
||||
}
|
||||
}
|
||||
},
|
||||
photos: true,
|
||||
legs: {
|
||||
orderBy: { sequence: 'asc' },
|
||||
include: {
|
||||
locations: {
|
||||
orderBy: { plannedStart: 'asc' },
|
||||
include: { _count: { select: { comments: true } } }
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!tour) throw new NotFoundException(`Không tìm thấy Tour`);
|
||||
return tour;
|
||||
}
|
||||
}
|
||||
|
||||
@Controller('tours')
|
||||
class TourController {
|
||||
constructor(private prisma: PrismaService) {}
|
||||
@@ -376,35 +410,6 @@ class TourController {
|
||||
});
|
||||
}
|
||||
|
||||
@Get(':id/public')
|
||||
async getPublicTourDetails(@Param('id', ParseUUIDPipe) id: string) {
|
||||
const tour = await this.prisma.tour.findUnique({
|
||||
where: { id },
|
||||
include: {
|
||||
participants: {
|
||||
include: {
|
||||
user: {
|
||||
select: { id: true, name: true, email: true }
|
||||
}
|
||||
}
|
||||
},
|
||||
photos: true,
|
||||
legs: {
|
||||
orderBy: { sequence: 'asc' },
|
||||
include: {
|
||||
locations: {
|
||||
orderBy: { plannedStart: 'asc' },
|
||||
include: { _count: { select: { comments: true } } }
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
if (!tour) throw new NotFoundException(`Không tìm thấy Tour`);
|
||||
return tour;
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard, TourRoleGuard)
|
||||
@Get(':id')
|
||||
async getTourDetails(@Param('id', ParseUUIDPipe) id: string) {
|
||||
@@ -933,7 +938,6 @@ export class CommentGateway implements OnGatewayConnection {
|
||||
}
|
||||
|
||||
@Controller('locations')
|
||||
@UseGuards(JwtAuthGuard)
|
||||
class CommentController {
|
||||
constructor(
|
||||
private prisma: PrismaService,
|
||||
@@ -941,6 +945,7 @@ class CommentController {
|
||||
) {}
|
||||
|
||||
@Get(':locationId/comments')
|
||||
// Cho phép khách xem bình luận mà không cần đăng nhập
|
||||
async getComments(@Param('locationId', ParseUUIDPipe) locationId: string) {
|
||||
return this.prisma.comment.findMany({
|
||||
where: { locationId },
|
||||
@@ -951,6 +956,7 @@ class CommentController {
|
||||
});
|
||||
}
|
||||
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Post(':locationId/comments')
|
||||
async addComment(
|
||||
@Param('locationId', ParseUUIDPipe) locationId: string,
|
||||
@@ -990,7 +996,7 @@ class CommentController {
|
||||
signOptions: { expiresIn: '1d' },
|
||||
}) as any,
|
||||
],
|
||||
controllers: [AppController, AuthController, TourController, UserController, RoutingController, LegController, LocationController, CommentController],
|
||||
controllers: [AppController, AuthController, PublicTourController, TourController, UserController, RoutingController, LegController, LocationController, CommentController],
|
||||
providers: [PrismaService, JwtStrategy, TourRoleGuard, JwtAuthGuard, AdminGuard, CommentGateway],
|
||||
exports: [PrismaService]
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user