fix(build): resolve linter and tsconfig project service errors, guarantee dist/main existence in start-dev
Deploy Canina / deploy (push) Has been cancelled
Deploy Canina / deploy (push) Has been cancelled
This commit is contained in:
1 parent
a291fa0c4a
commit
6362750dea
50 files changed
+12128
-10959
No files matched your search
@@ -1,28 +1,51 @@
|
||||
import { IsString, IsNotEmpty, IsOptional, IsEnum, IsArray } from 'class-validator';
|
||||
import {
|
||||
IsString,
|
||||
IsNotEmpty,
|
||||
IsOptional,
|
||||
IsEnum,
|
||||
IsArray,
|
||||
} from 'class-validator';
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
|
||||
export class CreateTicketDto {
|
||||
@ApiProperty({ description: 'موضوع تیکت یا عنوان مشاوره', example: 'مشاوره مصرف مکمل کانینوکال' })
|
||||
@ApiProperty({
|
||||
description: 'موضوع تیکت یا عنوان مشاوره',
|
||||
example: 'مشاوره مصرف مکمل کانینوکال',
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
subject: string;
|
||||
|
||||
@ApiProperty({ description: 'متن پیام یا شرح وضعیت', example: 'سگ من ۵ ماهشه و میخواستم بدونم...' })
|
||||
@ApiProperty({
|
||||
description: 'متن پیام یا شرح وضعیت',
|
||||
example: 'سگ من ۵ ماهشه و میخواستم بدونم...',
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
message: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'دستهبندی تیکت', example: 'VET_CONSULTATION', enum: ['VET_CONSULTATION', 'ORDER_SUPPORT', 'PRODUCT_INQUIRY', 'GENERAL'] })
|
||||
@ApiPropertyOptional({
|
||||
description: 'دستهبندی تیکت',
|
||||
example: 'VET_CONSULTATION',
|
||||
enum: ['VET_CONSULTATION', 'ORDER_SUPPORT', 'PRODUCT_INQUIRY', 'GENERAL'],
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
category?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'اولویت تیکت', example: 'MEDIUM', enum: ['LOW', 'MEDIUM', 'HIGH', 'URGENT'] })
|
||||
@ApiPropertyOptional({
|
||||
description: 'اولویت تیکت',
|
||||
example: 'MEDIUM',
|
||||
enum: ['LOW', 'MEDIUM', 'HIGH', 'URGENT'],
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
priority?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'شناسه حیوان خانگی مرتبط (اختیاری)', example: '9a8f4171-86bb-4236-9d6d-e4bc60255156' })
|
||||
@ApiPropertyOptional({
|
||||
description: 'شناسه حیوان خانگی مرتبط (اختیاری)',
|
||||
example: '9a8f4171-86bb-4236-9d6d-e4bc60255156',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
petId?: string;
|
||||
@@ -34,7 +57,10 @@ export class CreateTicketDto {
|
||||
}
|
||||
|
||||
export class ReplyTicketDto {
|
||||
@ApiProperty({ description: 'متن پاسخ تیکت', example: 'با سلام، دوز مصرفی پیشنهادی...' })
|
||||
@ApiProperty({
|
||||
description: 'متن پاسخ تیکت',
|
||||
example: 'با سلام، دوز مصرفی پیشنهادی...',
|
||||
})
|
||||
@IsString()
|
||||
@IsNotEmpty()
|
||||
message: string;
|
||||
@@ -44,19 +70,28 @@ export class ReplyTicketDto {
|
||||
@IsString()
|
||||
attachment?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'تغییر وضعیت تیکت (توسط ادمین)', enum: ['OPEN', 'IN_PROGRESS', 'ANSWERED', 'CLOSED'] })
|
||||
@ApiPropertyOptional({
|
||||
description: 'تغییر وضعیت تیکت (توسط ادمین)',
|
||||
enum: ['OPEN', 'IN_PROGRESS', 'ANSWERED', 'CLOSED'],
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
status?: string;
|
||||
}
|
||||
|
||||
export class AdminUpdateTicketDto {
|
||||
@ApiPropertyOptional({ description: 'وضعیت جدید تیکت', enum: ['OPEN', 'IN_PROGRESS', 'ANSWERED', 'CLOSED'] })
|
||||
@ApiPropertyOptional({
|
||||
description: 'وضعیت جدید تیکت',
|
||||
enum: ['OPEN', 'IN_PROGRESS', 'ANSWERED', 'CLOSED'],
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
status?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'اولویت تیکت', enum: ['LOW', 'MEDIUM', 'HIGH', 'URGENT'] })
|
||||
@ApiPropertyOptional({
|
||||
description: 'اولویت تیکت',
|
||||
enum: ['LOW', 'MEDIUM', 'HIGH', 'URGENT'],
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
priority?: string;
|
||||
|
||||
@@ -15,17 +15,25 @@ export class TicketQueryDto {
|
||||
@IsNumber()
|
||||
limit?: number = 15;
|
||||
|
||||
@ApiPropertyOptional({ description: 'فیلتر بر اساس وضعیت', enum: ['OPEN', 'IN_PROGRESS', 'ANSWERED', 'CLOSED'] })
|
||||
@ApiPropertyOptional({
|
||||
description: 'فیلتر بر اساس وضعیت',
|
||||
enum: ['OPEN', 'IN_PROGRESS', 'ANSWERED', 'CLOSED'],
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
status?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'فیلتر بر اساس دستهبندی', enum: ['VET_CONSULTATION', 'ORDER_SUPPORT', 'PRODUCT_INQUIRY', 'GENERAL'] })
|
||||
@ApiPropertyOptional({
|
||||
description: 'فیلتر بر اساس دستهبندی',
|
||||
enum: ['VET_CONSULTATION', 'ORDER_SUPPORT', 'PRODUCT_INQUIRY', 'GENERAL'],
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
category?: string;
|
||||
|
||||
@ApiPropertyOptional({ description: 'جستجو در موضوع، شماره تیکت یا مشخصات کاربر' })
|
||||
@ApiPropertyOptional({
|
||||
description: 'جستجو در موضوع، شماره تیکت یا مشخصات کاربر',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsString()
|
||||
search?: string;
|
||||
|
||||
@@ -10,7 +10,11 @@ import {
|
||||
Req,
|
||||
} from '@nestjs/common';
|
||||
import { TicketsService } from './tickets.service';
|
||||
import { CreateTicketDto, ReplyTicketDto, AdminUpdateTicketDto } from './dto/create-ticket.dto';
|
||||
import {
|
||||
CreateTicketDto,
|
||||
ReplyTicketDto,
|
||||
AdminUpdateTicketDto,
|
||||
} from './dto/create-ticket.dto';
|
||||
import { TicketQueryDto } from './dto/ticket-query.dto';
|
||||
import { JwtAuthGuard } from '../auth/jwt-auth.guard';
|
||||
import { RolesGuard } from '../common/guards/roles.guard';
|
||||
@@ -22,7 +26,9 @@ import {
|
||||
ApiOkResponse,
|
||||
} from '@nestjs/swagger';
|
||||
|
||||
@ApiTags('Tickets & Vet Consultation - تیکتینگ، پشتیبانی و مشاوره آنلاین دامپزشک')
|
||||
@ApiTags(
|
||||
'Tickets & Vet Consultation - تیکتینگ، پشتیبانی و مشاوره آنلاین دامپزشک',
|
||||
)
|
||||
@Controller('tickets')
|
||||
export class TicketsController {
|
||||
constructor(private readonly ticketsService: TicketsService) {}
|
||||
@@ -30,7 +36,9 @@ export class TicketsController {
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@ApiBearerAuth()
|
||||
@Post()
|
||||
@ApiOperation({ summary: 'ثبت تیکت جدید یا درخواست مشاوره دامپزشک توسط کاربر' })
|
||||
@ApiOperation({
|
||||
summary: 'ثبت تیکت جدید یا درخواست مشاوره دامپزشک توسط کاربر',
|
||||
})
|
||||
async createTicket(
|
||||
@Req() req: { user: { id: string } },
|
||||
@Body() dto: CreateTicketDto,
|
||||
|
||||
@@ -6,7 +6,11 @@ import {
|
||||
Logger,
|
||||
} from '@nestjs/common';
|
||||
import { PrismaService } from '../prisma/prisma.service';
|
||||
import { CreateTicketDto, ReplyTicketDto, AdminUpdateTicketDto } from './dto/create-ticket.dto';
|
||||
import {
|
||||
CreateTicketDto,
|
||||
ReplyTicketDto,
|
||||
AdminUpdateTicketDto,
|
||||
} from './dto/create-ticket.dto';
|
||||
import { TicketQueryDto } from './dto/ticket-query.dto';
|
||||
import { Prisma } from '@prisma/client';
|
||||
|
||||
@@ -31,7 +35,8 @@ export class TicketsService {
|
||||
}
|
||||
|
||||
const ticketNumber = this.generateTicketNumber();
|
||||
const senderName = `${user.firstName || ''} ${user.lastName || ''}`.trim() || user.mobile;
|
||||
const senderName =
|
||||
`${user.firstName || ''} ${user.lastName || ''}`.trim() || user.mobile;
|
||||
|
||||
const ticket = await this.prisma.ticket.create({
|
||||
data: {
|
||||
@@ -62,7 +67,8 @@ export class TicketsService {
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: 'تیکت شما با موفقیت ثبت شد و به زودی توسط کارشناسان پاسخ داده میشود.',
|
||||
message:
|
||||
'تیکت شما با موفقیت ثبت شد و به زودی توسط کارشناسان پاسخ داده میشود.',
|
||||
data: ticket,
|
||||
};
|
||||
}
|
||||
@@ -91,7 +97,11 @@ export class TicketsService {
|
||||
/**
|
||||
* 3. Get single ticket details
|
||||
*/
|
||||
async getTicketDetails(ticketId: string, userId?: string, isAdmin: boolean = false) {
|
||||
async getTicketDetails(
|
||||
ticketId: string,
|
||||
userId?: string,
|
||||
isAdmin: boolean = false,
|
||||
) {
|
||||
const ticket = await this.prisma.ticket.findUnique({
|
||||
where: { id: ticketId },
|
||||
include: {
|
||||
@@ -148,13 +158,21 @@ export class TicketsService {
|
||||
throw new ForbiddenException('شما دسترسی به این تیکت را ندارید');
|
||||
}
|
||||
|
||||
const sender = await this.prisma.user.findUnique({ where: { id: senderId } });
|
||||
const senderRole = isAdmin ? (sender?.role.includes('Doctor') ? 'VET_DOCTOR' : 'ADMIN') : 'USER';
|
||||
const sender = await this.prisma.user.findUnique({
|
||||
where: { id: senderId },
|
||||
});
|
||||
const senderRole = isAdmin
|
||||
? sender?.role.includes('Doctor')
|
||||
? 'VET_DOCTOR'
|
||||
: 'ADMIN'
|
||||
: 'USER';
|
||||
const senderName = isAdmin
|
||||
? `${sender?.firstName || 'پشتیبان'} ${sender?.lastName || 'کنینا'}`.trim()
|
||||
: `${sender?.firstName || ''} ${sender?.lastName || ''}`.trim() || sender?.mobile || 'کاربر';
|
||||
: `${sender?.firstName || ''} ${sender?.lastName || ''}`.trim() ||
|
||||
sender?.mobile ||
|
||||
'کاربر';
|
||||
|
||||
const newStatus = isAdmin ? (dto.status || 'ANSWERED') : 'IN_PROGRESS';
|
||||
const newStatus = isAdmin ? dto.status || 'ANSWERED' : 'IN_PROGRESS';
|
||||
|
||||
const [newMessage] = await this.prisma.$transaction([
|
||||
this.prisma.ticketMessage.create({
|
||||
|
||||
Reference in new issue
Block a user