chore: add manaual refer for ticket of super admin
This commit is contained in:
+3
-3
@@ -7,13 +7,13 @@ import { ConfigModule } from "@nestjs/config";
|
|||||||
import { ThrottlerModule } from "@nestjs/throttler";
|
import { ThrottlerModule } from "@nestjs/throttler";
|
||||||
import { TypeOrmModule } from "@nestjs/typeorm";
|
import { TypeOrmModule } from "@nestjs/typeorm";
|
||||||
import { MailerModule } from "@nestjs-modules/mailer";
|
import { MailerModule } from "@nestjs-modules/mailer";
|
||||||
import { TelegrafModule } from "nestjs-telegraf";
|
// import { TelegrafModule } from "nestjs-telegraf";
|
||||||
|
|
||||||
import { bullMqConfig } from "./configs/bullmq.config";
|
import { bullMqConfig } from "./configs/bullmq.config";
|
||||||
import { cacheConfig } from "./configs/cache.config";
|
import { cacheConfig } from "./configs/cache.config";
|
||||||
import { mailerConfig } from "./configs/mailer.config";
|
import { mailerConfig } from "./configs/mailer.config";
|
||||||
import { rateLimitConfig } from "./configs/rateLimit.config";
|
import { rateLimitConfig } from "./configs/rateLimit.config";
|
||||||
import { telegrafConfig } from "./configs/telegraf.config";
|
// import { telegrafConfig } from "./configs/telegraf.config";
|
||||||
import { databaseConfigs } from "./configs/typeorm.config";
|
import { databaseConfigs } from "./configs/typeorm.config";
|
||||||
import { HTTPLogger } from "./core/middlewares/logger.middleware";
|
import { HTTPLogger } from "./core/middlewares/logger.middleware";
|
||||||
import { AddressModule } from "./modules/address/address.module";
|
import { AddressModule } from "./modules/address/address.module";
|
||||||
@@ -42,7 +42,7 @@ import { WalletsModule } from "./modules/wallets/wallets.module";
|
|||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
TelegrafModule.forRootAsync(telegrafConfig()),
|
// TelegrafModule.forRootAsync(telegrafConfig()),
|
||||||
MailerModule.forRootAsync(mailerConfig()),
|
MailerModule.forRootAsync(mailerConfig()),
|
||||||
BullModule.forRootAsync(bullMqConfig()),
|
BullModule.forRootAsync(bullMqConfig()),
|
||||||
ThrottlerModule.forRootAsync(rateLimitConfig()),
|
ThrottlerModule.forRootAsync(rateLimitConfig()),
|
||||||
|
|||||||
@@ -102,6 +102,9 @@ export const enum UserMessage {
|
|||||||
REAL_DATA_NOT_FOUND = "اطلاعات حقیقی یافت نشد",
|
REAL_DATA_NOT_FOUND = "اطلاعات حقیقی یافت نشد",
|
||||||
REGISTRATION_NAME_EXIST = "نام ثبت قبلا ثبت شده است",
|
REGISTRATION_NAME_EXIST = "نام ثبت قبلا ثبت شده است",
|
||||||
ADDRESS_NOT_FOUND = "آدرس یافت نشد",
|
ADDRESS_NOT_FOUND = "آدرس یافت نشد",
|
||||||
|
ADMIN_ID_REQUIRED = "شناسه ادمین مورد نیاز است",
|
||||||
|
INVALID_ADMIN_ID = "شناسه ادمین نامعتبر است",
|
||||||
|
ADMIN_ID_SHOULD_BE_UUID = "شناسه ادمین باید یک UUID باشد",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum CommonMessage {
|
export const enum CommonMessage {
|
||||||
@@ -273,6 +276,7 @@ export const enum TicketMessageEnum {
|
|||||||
SERVICE_NOT_FOUND = "سرویس مورد نظر یافت نشد",
|
SERVICE_NOT_FOUND = "سرویس مورد نظر یافت نشد",
|
||||||
TICKET_NOT_ASSIGNED = "تیکت به کارشناسی اختصاص داده نشده است",
|
TICKET_NOT_ASSIGNED = "تیکت به کارشناسی اختصاص داده نشده است",
|
||||||
TICKET_NOT_ASSIGNED_TO_USER = "تیکت به شما اختصاص داده نشده است",
|
TICKET_NOT_ASSIGNED_TO_USER = "تیکت به شما اختصاص داده نشده است",
|
||||||
|
REFERRED = "REFERRED",
|
||||||
}
|
}
|
||||||
|
|
||||||
export const enum WalletMessage {
|
export const enum WalletMessage {
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ export function databaseConfigs(): TypeOrmModuleAsyncOptions {
|
|||||||
username: configService.getOrThrow<string>("DB_USER"),
|
username: configService.getOrThrow<string>("DB_USER"),
|
||||||
password: configService.getOrThrow<string>("DB_PASS"),
|
password: configService.getOrThrow<string>("DB_PASS"),
|
||||||
autoLoadEntities: true,
|
autoLoadEntities: true,
|
||||||
synchronize: configService.getOrThrow<string>("NODE_ENV") == "production" ? false : true,
|
synchronize: configService.getOrThrow<string>("NODE_ENV") == "production" ? false : false,
|
||||||
logging: configService.getOrThrow<string>("NODE_ENV") == "production" ? false : true,
|
logging: configService.getOrThrow<string>("NODE_ENV") == "production" ? false : true,
|
||||||
migrationsTableName: "typeorm_migrations",
|
migrationsTableName: "typeorm_migrations",
|
||||||
migrationsRun: false,
|
migrationsRun: false,
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ export class Invoice extends BaseEntity {
|
|||||||
tax: Decimal;
|
tax: Decimal;
|
||||||
|
|
||||||
@Column({ type: "decimal", precision: 16, scale: 2, nullable: true, transformer: new DecimalTransformer() })
|
@Column({ type: "decimal", precision: 16, scale: 2, nullable: true, transformer: new DecimalTransformer() })
|
||||||
lateFee?: Decimal;
|
lateFee: Decimal | null;
|
||||||
|
|
||||||
//---------------------------------------------
|
//---------------------------------------------
|
||||||
|
|
||||||
@@ -44,7 +44,7 @@ export class Invoice extends BaseEntity {
|
|||||||
items: InvoiceItem[];
|
items: InvoiceItem[];
|
||||||
|
|
||||||
@ManyToOne(() => Discount, (discount) => discount.invoices, { nullable: true, onDelete: "RESTRICT" })
|
@ManyToOne(() => Discount, (discount) => discount.invoices, { nullable: true, onDelete: "RESTRICT" })
|
||||||
discount?: Discount;
|
discount: Discount | null;
|
||||||
|
|
||||||
get isOverdue(): boolean {
|
get isOverdue(): boolean {
|
||||||
return this.status === InvoiceStatus.PENDING && new Date() > this.dueDate;
|
return this.status === InvoiceStatus.PENDING && new Date() > this.dueDate;
|
||||||
|
|||||||
@@ -619,12 +619,12 @@ export class InvoicesService {
|
|||||||
|
|
||||||
let discountAmount: Decimal;
|
let discountAmount: Decimal;
|
||||||
if (discount.type === DiscountType.PERCENTAGE) {
|
if (discount.type === DiscountType.PERCENTAGE) {
|
||||||
discountAmount = invoice.originalPrice.mul(discount.value).div(100);
|
discountAmount = new Decimal(invoice.originalPrice).mul(discount.value).div(100);
|
||||||
} else {
|
} else {
|
||||||
discountAmount = new Decimal(discount.value);
|
discountAmount = new Decimal(discount.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
invoice.totalPrice = invoice.originalPrice.sub(discountAmount);
|
invoice.totalPrice = new Decimal(invoice.originalPrice).sub(discountAmount);
|
||||||
invoice.discount = discount;
|
invoice.discount = discount;
|
||||||
|
|
||||||
await queryRunner.manager.save(invoice);
|
await queryRunner.manager.save(invoice);
|
||||||
@@ -655,9 +655,9 @@ export class InvoicesService {
|
|||||||
if (!invoice.originalPrice) throw new BadRequestException(InvoiceMessage.ORIGINAL_PRICE_NOT_FOUND);
|
if (!invoice.originalPrice) throw new BadRequestException(InvoiceMessage.ORIGINAL_PRICE_NOT_FOUND);
|
||||||
|
|
||||||
invoice.totalPrice = invoice.originalPrice;
|
invoice.totalPrice = invoice.originalPrice;
|
||||||
invoice.discount = undefined;
|
invoice.discount = null;
|
||||||
|
|
||||||
await queryRunner.manager.save(invoice);
|
await queryRunner.manager.save(this.invoiceRepository.target, invoice);
|
||||||
await queryRunner.commitTransaction();
|
await queryRunner.commitTransaction();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { ApiProperty } from "@nestjs/swagger";
|
||||||
|
import { IsNotEmpty, IsUUID } from "class-validator";
|
||||||
|
|
||||||
|
import { UserMessage } from "../../../common/enums/message.enum";
|
||||||
|
|
||||||
|
export class ReferTicketDto {
|
||||||
|
@IsNotEmpty({ message: UserMessage.ADMIN_ID_REQUIRED })
|
||||||
|
@IsUUID("4", { message: UserMessage.ADMIN_ID_SHOULD_BE_UUID })
|
||||||
|
@ApiProperty({ description: "admin id", example: "123e4567-e89b-12d3-a456-426614174000" })
|
||||||
|
adminId: string;
|
||||||
|
}
|
||||||
@@ -12,6 +12,7 @@ import { PaginationUtils } from "../../utils/providers/pagination.utils";
|
|||||||
import { CreateTicketCategoryDto } from "../DTO/create-ticket-category.dto";
|
import { CreateTicketCategoryDto } from "../DTO/create-ticket-category.dto";
|
||||||
import { CreateTicketMessageDto } from "../DTO/create-ticket-message.dto";
|
import { CreateTicketMessageDto } from "../DTO/create-ticket-message.dto";
|
||||||
import { CreateTicketDto } from "../DTO/create-ticket.dto";
|
import { CreateTicketDto } from "../DTO/create-ticket.dto";
|
||||||
|
import { ReferTicketDto } from "../DTO/refer-ticket.dto";
|
||||||
import { SearchTicketCategoryDto } from "../DTO/search-ticket-category.dto";
|
import { SearchTicketCategoryDto } from "../DTO/search-ticket-category.dto";
|
||||||
import { SearchTicketQueryDto } from "../DTO/search-ticket-query.dto";
|
import { SearchTicketQueryDto } from "../DTO/search-ticket-query.dto";
|
||||||
import { UpdateTicketCategoryDto } from "../DTO/update-ticket-category.dto";
|
import { UpdateTicketCategoryDto } from "../DTO/update-ticket-category.dto";
|
||||||
@@ -23,7 +24,6 @@ import { TicketStatus } from "../enums/ticket-status.enum";
|
|||||||
import { TicketCategoryRepository } from "../repositories/tickets-category.repository";
|
import { TicketCategoryRepository } from "../repositories/tickets-category.repository";
|
||||||
import { TicketMessagesRepository } from "../repositories/tickets-message.repository";
|
import { TicketMessagesRepository } from "../repositories/tickets-message.repository";
|
||||||
import { TicketsRepository } from "../repositories/tickets.repository";
|
import { TicketsRepository } from "../repositories/tickets.repository";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class TicketsService {
|
export class TicketsService {
|
||||||
private readonly logger = new Logger(TicketsService.name);
|
private readonly logger = new Logger(TicketsService.name);
|
||||||
@@ -58,13 +58,11 @@ export class TicketsService {
|
|||||||
.loadRelationCountAndMap("category.usersCount", "group.users");
|
.loadRelationCountAndMap("category.usersCount", "group.users");
|
||||||
|
|
||||||
if (queryDto.isActive !== undefined) {
|
if (queryDto.isActive !== undefined) {
|
||||||
queryBuilder.andWhere("category.isActive = :isActive", {
|
queryBuilder.andWhere("category.isActive = :isActive", { isActive: queryDto.isActive === 1 });
|
||||||
isActive: queryDto.isActive === 1,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (queryDto.q) {
|
if (queryDto.q) {
|
||||||
queryBuilder.where("category.title LIKE :q", { q: `%${queryDto.q}%` });
|
queryBuilder.where("category.title ILIKE :q", { q: `%${queryDto.q}%` });
|
||||||
}
|
}
|
||||||
|
|
||||||
const [categories, count] = await queryBuilder.skip(skip).take(limit).getManyAndCount();
|
const [categories, count] = await queryBuilder.skip(skip).take(limit).getManyAndCount();
|
||||||
@@ -276,8 +274,6 @@ export class TicketsService {
|
|||||||
if (ticket.status === TicketStatus.CLOSED) throw new BadRequestException(TicketMessageEnum.TICKET_CLOSED);
|
if (ticket.status === TicketStatus.CLOSED) throw new BadRequestException(TicketMessageEnum.TICKET_CLOSED);
|
||||||
|
|
||||||
const isSuperAdmin = await this.usersService.isSuperAdmin(userId);
|
const isSuperAdmin = await this.usersService.isSuperAdmin(userId);
|
||||||
console.log(isSuperAdmin);
|
|
||||||
console.log(ticket.assignedTo);
|
|
||||||
if (isAdmin && !isSuperAdmin && ticket.assignedTo?.id !== userId)
|
if (isAdmin && !isSuperAdmin && ticket.assignedTo?.id !== userId)
|
||||||
throw new BadRequestException(TicketMessageEnum.TICKET_NOT_ASSIGNED_TO_USER);
|
throw new BadRequestException(TicketMessageEnum.TICKET_NOT_ASSIGNED_TO_USER);
|
||||||
|
|
||||||
@@ -355,6 +351,50 @@ export class TicketsService {
|
|||||||
message: TicketMessageEnum.CLOSED,
|
message: TicketMessageEnum.CLOSED,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
//******************************** */
|
||||||
|
async referTicket(ticketId: string, userId: string, referDto: ReferTicketDto) {
|
||||||
|
const queryRunner = this.dataSource.createQueryRunner();
|
||||||
|
|
||||||
|
try {
|
||||||
|
await queryRunner.connect();
|
||||||
|
await queryRunner.startTransaction();
|
||||||
|
|
||||||
|
const isSuperAdmin = await this.usersService.isSuperAdmin(userId);
|
||||||
|
if (!isSuperAdmin) throw new BadRequestException(TicketMessageEnum.TICKET_NOT_ASSIGNED_TO_USER);
|
||||||
|
|
||||||
|
const ticket = await this.ticketsRepository.findTicketById(ticketId);
|
||||||
|
if (!ticket) throw new BadRequestException(TicketMessageEnum.TICKET_NOT_FOUND);
|
||||||
|
|
||||||
|
const admin = await this.usersService.findOneByIdWithQueryRunner(referDto.adminId, queryRunner);
|
||||||
|
|
||||||
|
ticket.assignedTo = admin;
|
||||||
|
await queryRunner.manager.save(this.ticketsRepository.target, ticket);
|
||||||
|
|
||||||
|
await this.notificationsService.createAssignTicketNotificationForAdmin(
|
||||||
|
admin.id,
|
||||||
|
{
|
||||||
|
ticketId: ticket.numericId.toString(),
|
||||||
|
subject: ticket.subject,
|
||||||
|
date: ticket.createdAt,
|
||||||
|
userPhone: ticket.user.phone,
|
||||||
|
userEmail: ticket.user.email,
|
||||||
|
user: `${ticket.user.firstName} ${ticket.user.lastName}`,
|
||||||
|
},
|
||||||
|
queryRunner,
|
||||||
|
);
|
||||||
|
|
||||||
|
await queryRunner.commitTransaction();
|
||||||
|
return {
|
||||||
|
message: TicketMessageEnum.REFERRED,
|
||||||
|
ticket,
|
||||||
|
};
|
||||||
|
} catch (error) {
|
||||||
|
await queryRunner.rollbackTransaction();
|
||||||
|
throw error;
|
||||||
|
} finally {
|
||||||
|
await queryRunner.release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//******************************** */
|
//******************************** */
|
||||||
|
|
||||||
@@ -375,7 +415,6 @@ export class TicketsService {
|
|||||||
|
|
||||||
//***************************** */
|
//***************************** */
|
||||||
private async assignTicketAndNotify(ticket: Ticket, ticketCategory: TicketCategory, user: User, queryRunner: QueryRunner) {
|
private async assignTicketAndNotify(ticket: Ticket, ticketCategory: TicketCategory, user: User, queryRunner: QueryRunner) {
|
||||||
// const assignedUser = await this.autoAssignUser(ticketCategory);
|
|
||||||
const assignedUser = await this.referralService.assignAdmin(ticketCategory.group);
|
const assignedUser = await this.referralService.assignAdmin(ticketCategory.group);
|
||||||
//
|
//
|
||||||
ticket.assignedTo = assignedUser;
|
ticket.assignedTo = assignedUser;
|
||||||
|
|||||||
@@ -4,26 +4,26 @@ import { ApiOperation, ApiTags } from "@nestjs/swagger";
|
|||||||
import { CreateTicketCategoryDto } from "./DTO/create-ticket-category.dto";
|
import { CreateTicketCategoryDto } from "./DTO/create-ticket-category.dto";
|
||||||
import { CreateTicketMessageDto } from "./DTO/create-ticket-message.dto";
|
import { CreateTicketMessageDto } from "./DTO/create-ticket-message.dto";
|
||||||
import { CreateTicketDto } from "./DTO/create-ticket.dto";
|
import { CreateTicketDto } from "./DTO/create-ticket.dto";
|
||||||
|
import { ReferTicketDto } from "./DTO/refer-ticket.dto";
|
||||||
import { SearchTicketCategoryDto } from "./DTO/search-ticket-category.dto";
|
import { SearchTicketCategoryDto } from "./DTO/search-ticket-category.dto";
|
||||||
import { SearchTicketQueryDto } from "./DTO/search-ticket-query.dto";
|
import { SearchTicketQueryDto } from "./DTO/search-ticket-query.dto";
|
||||||
import { UpdateTicketCategoryDto } from "./DTO/update-ticket-category.dto";
|
import { UpdateTicketCategoryDto } from "./DTO/update-ticket-category.dto";
|
||||||
import { TicketsService } from "./providers/tickets.service";
|
import { TicketsService } from "./providers/tickets.service";
|
||||||
|
import { AdminRoute } from "../../common/decorators/admin.decorator";
|
||||||
import { AuthGuards } from "../../common/decorators/auth-guard.decorator";
|
import { AuthGuards } from "../../common/decorators/auth-guard.decorator";
|
||||||
import { Pagination } from "../../common/decorators/pagination.decorator";
|
|
||||||
import { PermissionsDec } from "../../common/decorators/permission.decorator";
|
import { PermissionsDec } from "../../common/decorators/permission.decorator";
|
||||||
import { UserDec } from "../../common/decorators/user.decorator";
|
import { UserDec } from "../../common/decorators/user.decorator";
|
||||||
import { ParamDto } from "../../common/DTO/param.dto";
|
import { ParamDto } from "../../common/DTO/param.dto";
|
||||||
import { PermissionEnum } from "../users/enums/permission.enum";
|
import { PermissionEnum } from "../users/enums/permission.enum";
|
||||||
|
|
||||||
@Controller("tickets")
|
@Controller("tickets")
|
||||||
@ApiTags("Tickets")
|
@ApiTags("Tickets")
|
||||||
|
@AuthGuards()
|
||||||
export class TicketsController {
|
export class TicketsController {
|
||||||
constructor(private readonly ticketsService: TicketsService) {}
|
constructor(private readonly ticketsService: TicketsService) {}
|
||||||
|
|
||||||
//----------------- ticket categories -------------------
|
//----------------- ticket categories -------------------
|
||||||
|
|
||||||
@ApiOperation({ summary: "Create ticket category => admin route" })
|
@ApiOperation({ summary: "Create ticket category => admin route" })
|
||||||
@AuthGuards()
|
|
||||||
@PermissionsDec(PermissionEnum.TICKETS)
|
@PermissionsDec(PermissionEnum.TICKETS)
|
||||||
@Post("category")
|
@Post("category")
|
||||||
createTicketCategory(@Body() createDto: CreateTicketCategoryDto) {
|
createTicketCategory(@Body() createDto: CreateTicketCategoryDto) {
|
||||||
@@ -31,7 +31,6 @@ export class TicketsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation({ summary: "Update ticket category => admin route" })
|
@ApiOperation({ summary: "Update ticket category => admin route" })
|
||||||
@AuthGuards()
|
|
||||||
@PermissionsDec(PermissionEnum.TICKETS)
|
@PermissionsDec(PermissionEnum.TICKETS)
|
||||||
@Patch("category/:id")
|
@Patch("category/:id")
|
||||||
updateCategory(@Param() paramDto: ParamDto, @Body() updateCategoryDto: UpdateTicketCategoryDto) {
|
updateCategory(@Param() paramDto: ParamDto, @Body() updateCategoryDto: UpdateTicketCategoryDto) {
|
||||||
@@ -39,7 +38,6 @@ export class TicketsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation({ summary: "Get ticket categories " })
|
@ApiOperation({ summary: "Get ticket categories " })
|
||||||
@AuthGuards()
|
|
||||||
@Get("categories")
|
@Get("categories")
|
||||||
// @PermissionsDec(PermissionEnum.TICKETS)
|
// @PermissionsDec(PermissionEnum.TICKETS)
|
||||||
getTicketCategories() {
|
getTicketCategories() {
|
||||||
@@ -47,8 +45,7 @@ export class TicketsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation({ summary: "Get ticket categories list => admin route" })
|
@ApiOperation({ summary: "Get ticket categories list => admin route" })
|
||||||
@Pagination()
|
@AdminRoute()
|
||||||
@AuthGuards()
|
|
||||||
@PermissionsDec(PermissionEnum.TICKETS)
|
@PermissionsDec(PermissionEnum.TICKETS)
|
||||||
@Get("categories-list")
|
@Get("categories-list")
|
||||||
getCategoriesList(@Query() queryDto: SearchTicketCategoryDto) {
|
getCategoriesList(@Query() queryDto: SearchTicketCategoryDto) {
|
||||||
@@ -56,7 +53,7 @@ export class TicketsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation({ summary: "toggle status of categories => admin route" })
|
@ApiOperation({ summary: "toggle status of categories => admin route" })
|
||||||
@AuthGuards()
|
@AdminRoute()
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@PermissionsDec(PermissionEnum.TICKETS)
|
@PermissionsDec(PermissionEnum.TICKETS)
|
||||||
@Post("category/toggle-status/:id")
|
@Post("category/toggle-status/:id")
|
||||||
@@ -67,31 +64,26 @@ export class TicketsController {
|
|||||||
//----------------- ticket and ticket messages -------------------
|
//----------------- ticket and ticket messages -------------------
|
||||||
|
|
||||||
@ApiOperation({ summary: "create ticket ==> user route" })
|
@ApiOperation({ summary: "create ticket ==> user route" })
|
||||||
@AuthGuards()
|
|
||||||
@Post()
|
@Post()
|
||||||
createTicket(@Body() createDto: CreateTicketDto, @UserDec("id") userId: string) {
|
createTicket(@Body() createDto: CreateTicketDto, @UserDec("id") userId: string) {
|
||||||
return this.ticketsService.createTicket(createDto, userId);
|
return this.ticketsService.createTicket(createDto, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation({ summary: "Get all tickets of user ==> user route" })
|
@ApiOperation({ summary: "Get all tickets of user ==> user route" })
|
||||||
@AuthGuards()
|
|
||||||
@Pagination()
|
|
||||||
@Get()
|
@Get()
|
||||||
getTickets(@Query() queryDto: SearchTicketQueryDto, @UserDec("id") userId: string) {
|
getTickets(@Query() queryDto: SearchTicketQueryDto, @UserDec("id") userId: string) {
|
||||||
return this.ticketsService.getTickets(queryDto, userId);
|
return this.ticketsService.getTickets(queryDto, userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation({ summary: "Get all tickets ==> admin route" })
|
@ApiOperation({ summary: "Get all tickets ==> admin route" })
|
||||||
@AuthGuards()
|
@AdminRoute()
|
||||||
@PermissionsDec(PermissionEnum.TICKETS)
|
@PermissionsDec(PermissionEnum.TICKETS)
|
||||||
@Pagination()
|
|
||||||
@Get("admin")
|
@Get("admin")
|
||||||
getAllTickets(@Query() queryDto: SearchTicketQueryDto, @UserDec("id") adminId: string) {
|
getAllTickets(@Query() queryDto: SearchTicketQueryDto, @UserDec("id") adminId: string) {
|
||||||
return this.ticketsService.getTicketForAdmin(queryDto, adminId);
|
return this.ticketsService.getTicketForAdmin(queryDto, adminId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation({ summary: "create ticket messages" })
|
@ApiOperation({ summary: "create ticket messages" })
|
||||||
@AuthGuards()
|
|
||||||
@Post(":id/messages")
|
@Post(":id/messages")
|
||||||
createTicketMessage(
|
createTicketMessage(
|
||||||
@Param() paramDto: ParamDto,
|
@Param() paramDto: ParamDto,
|
||||||
@@ -103,17 +95,23 @@ export class TicketsController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation({ summary: "Get all ticket messages of user" })
|
@ApiOperation({ summary: "Get all ticket messages of user" })
|
||||||
@AuthGuards()
|
|
||||||
@Get(":id/messages")
|
@Get(":id/messages")
|
||||||
getTicketMessages(@Param() paramDto: ParamDto, @UserDec("id") userId: string, @UserDec("isAdmin") isAdmin: boolean) {
|
getTicketMessages(@Param() paramDto: ParamDto, @UserDec("id") userId: string, @UserDec("isAdmin") isAdmin: boolean) {
|
||||||
return this.ticketsService.getTicketMessages(paramDto.id, userId, isAdmin);
|
return this.ticketsService.getTicketMessages(paramDto.id, userId, isAdmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiOperation({ summary: "close ticket by user or admin" })
|
@ApiOperation({ summary: "close ticket by user or admin" })
|
||||||
@AuthGuards()
|
|
||||||
@HttpCode(HttpStatus.OK)
|
@HttpCode(HttpStatus.OK)
|
||||||
@Post(":id/close")
|
@Post(":id/close")
|
||||||
closedTicketByUser(@Param() paramDto: ParamDto, @UserDec("id") userId: string, @UserDec("isAdmin") isAdmin: boolean) {
|
closedTicketByUser(@Param() paramDto: ParamDto, @UserDec("id") userId: string, @UserDec("isAdmin") isAdmin: boolean) {
|
||||||
return this.ticketsService.closeTicketByUser(paramDto.id, userId, isAdmin);
|
return this.ticketsService.closeTicketByUser(paramDto.id, userId, isAdmin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation({ summary: "referer ticket ==> admin route" })
|
||||||
|
@AdminRoute()
|
||||||
|
@PermissionsDec(PermissionEnum.TICKETS)
|
||||||
|
@Post(":id/refer")
|
||||||
|
referTicket(@Param() paramDto: ParamDto, @UserDec("id") userId: string, @Body() referDto: ReferTicketDto) {
|
||||||
|
return this.ticketsService.referTicket(paramDto.id, userId, referDto);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user