fix: sửa lỗi hiển thị logo trên trang pdf

This commit is contained in:
2026-06-20 17:02:26 +07:00
parent e34d197dd0
commit ae97f061e8
21 changed files with 978 additions and 328 deletions
+85 -16
View File
@@ -498,11 +498,14 @@ class PublicTourController {
expenses: {
include: {
location: { select: { name: true, plannedStart: true } },
paidBy: { select: { name: true } }
paidBy: { select: { id: true, name: true } }
}
},
locations: {
orderBy: { plannedStart: 'asc' },
orderBy: [
{ plannedStart: { sort: 'asc', nulls: 'last' } },
{ createdAt: 'asc' }
],
include: { _count: { select: { comments: true } } }
},
},
@@ -896,7 +899,10 @@ class TourController {
orderBy: { sequence: 'asc' },
include: {
locations: {
orderBy: { plannedStart: 'asc' },
orderBy: [
{ plannedStart: { sort: 'asc', nulls: 'last' } },
{ createdAt: 'asc' }
],
include: { _count: { select: { comments: true } } }
}
}
@@ -933,11 +939,14 @@ class TourController {
expenses: {
include: {
location: { select: { name: true, plannedStart: true } },
paidBy: { select: { name: true } }
paidBy: { select: { id: true, name: true } }
}
},
locations: {
orderBy: { plannedStart: 'asc' },
orderBy: [
{ plannedStart: { sort: 'asc', nulls: 'last' } },
{ createdAt: 'asc' }
],
include: { _count: { select: { comments: true } } }
},
},
@@ -1003,6 +1012,58 @@ class TourController {
});
}
@Roles(ParticipantRole.OWNER, ParticipantRole.MANAGER, ParticipantRole.MEMBER, ParticipantRole.MEMBER_NO_FINANCE, ParticipantRole.VIEWER_ONLY)
@UseGuards(JwtAuthGuard, TourRoleGuard)
@Patch(':tourId/members/:userId')
async updateMemberCounts(
@Param('tourId', ParseUUIDPipe) tourId: string,
@Param('userId', ParseUUIDPipe) userId: string,
@Body() body: { adultCount?: number; childCount?: number; role?: string },
@Req() req: any
) {
const isSelf = req.user.id === userId;
// Tìm quyền hạn của người gửi yêu cầu trong tour này
const requesterParticipation = await this.prisma.tourParticipant.findUnique({
where: { tourId_userId: { tourId, userId: req.user.id } },
});
const canManage = requesterParticipation?.role === 'OWNER' || requesterParticipation?.role === 'MANAGER';
if (!canManage && !isSelf) {
throw new ForbiddenException('Bạn không có quyền chỉnh sửa thông tin thành viên này.');
}
const data: any = {};
if (body.adultCount !== undefined) {
if (body.adultCount < 1) throw new BadRequestException('Số lượng người lớn tối thiểu là 1.');
data.adultCount = Number(body.adultCount);
}
if (body.childCount !== undefined) {
if (body.childCount < 0) throw new BadRequestException('Số lượng trẻ em không được âm.');
data.childCount = Number(body.childCount);
}
if (body.role !== undefined && canManage) {
const validRoles = ['OWNER', 'MANAGER', 'MEMBER', 'MEMBER_NO_FINANCE', 'VIEWER_ONLY'] as const;
if (validRoles.includes(body.role as any)) {
data.role = body.role;
}
}
// Xóa cache liên quan
await Promise.all([
this.cacheManager.del(`user-role:${userId}:${tourId}`),
this.cacheManager.del(tourId),
this.cacheManager.del(`/api/v1/tours/${tourId}`),
this.cacheManager.del(`/api/v1/tours/${tourId}/public`),
]);
return this.prisma.tourParticipant.update({
where: { tourId_userId: { tourId, userId } },
data,
include: { user: { select: { id: true, name: true, email: true } } },
});
}
@Roles(ParticipantRole.OWNER, ParticipantRole.MANAGER) // Only owner/manager can view join requests
@UseGuards(JwtAuthGuard, TourRoleGuard)
@Get(':tourId/join-requests')
@@ -1449,7 +1510,10 @@ class RoutingController {
tourId: currentLeg.tourId,
sequence: currentLeg.sequence - 1
},
include: { locations: { orderBy: { plannedStart: 'asc' } } }
include: { locations: { orderBy: [
{ plannedStart: { sort: 'asc', nulls: 'last' } },
{ createdAt: 'asc' }
] } }
});
if (prevLeg?.locations?.length) {
@@ -1526,7 +1590,10 @@ class RoutingController {
const updatedLocations = await this.prisma.location.findMany({
where: { legId },
orderBy: { plannedStart: 'asc' }
orderBy: [
{ plannedStart: { sort: 'asc', nulls: 'last' } },
{ createdAt: 'asc' }
]
});
if (req.tourId) {
@@ -1779,18 +1846,20 @@ class UserController {
constructor(private prisma: PrismaService) {}
@Get()
@UseGuards(AdminGuard)
async getAllUsers(@Req() req: any, @Query('q') q?: string) {
const currentUserId = req.user?.id;
const users = await this.prisma.user.findMany({
where: q
? {
OR: [
{ name: { contains: q, mode: 'insensitive' as any } },
{ email: { contains: q, mode: 'insensitive' as any } },
],
}
: undefined,
where: {
isAnonymous: false,
...(q
? {
OR: [
{ name: { contains: q, mode: 'insensitive' as any } },
{ email: { contains: q, mode: 'insensitive' as any } },
],
}
: {}),
},
select: { id: true, email: true, name: true, isAdmin: true, isBlocked: true, createdAt: true, phone: true, address: true }
});
return users.filter((u: any) => u.id !== currentUserId);