attachment
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
import { ApiProperty } from "@nestjs/swagger";
|
import { ApiProperty } from "@nestjs/swagger";
|
||||||
import { IsNotEmpty, IsOptional, IsString, IsUUID, IsUrl, Length } from "class-validator";
|
import { IsNotEmpty, IsOptional, IsString, IsUrl, Length } from "class-validator";
|
||||||
|
import { AttachmentType } from "../interfaces/ticket";
|
||||||
import { TicketMessageEnum } from "../../../common/enums/message.enum";
|
import { TicketMessageEnum } from "../../../common/enums/message.enum";
|
||||||
|
|
||||||
|
|
||||||
@@ -15,6 +15,6 @@ export class CreateTicketDto {
|
|||||||
@IsNotEmpty({ message: TicketMessageEnum.ATTACHMENT_REQUIRED })
|
@IsNotEmpty({ message: TicketMessageEnum.ATTACHMENT_REQUIRED })
|
||||||
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { each: true, message: TicketMessageEnum.ATTACHMENT_SHOULD_BE_URL })
|
@IsUrl({ protocols: ["http", "https"], require_protocol: true }, { each: true, message: TicketMessageEnum.ATTACHMENT_SHOULD_BE_URL })
|
||||||
@ApiProperty({ description: "attachment url", example: ["https://example.com/test.png"] })
|
@ApiProperty({ description: "attachment url", example: ["https://example.com/test.png"] })
|
||||||
attachments?: string[];
|
attachments?: AttachmentType[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-50
@@ -1,63 +1,18 @@
|
|||||||
import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from "@nestjs/common";
|
import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from "@nestjs/common";
|
||||||
import { ApiOperation, ApiTags } from "@nestjs/swagger";
|
import { ApiOperation, ApiTags } from "@nestjs/swagger";
|
||||||
import { CreateTicketDto } from "./DTO/create-ticket.dto";
|
import { CreateTicketDto } from "../DTO/create-ticket.dto";
|
||||||
import { FindTicketQueryDto } from "./DTO/search-ticket-query.dto";
|
import { FindTicketQueryDto } from "../DTO/search-ticket-query.dto";
|
||||||
import { TicketService } from "./providers/tickets.service";
|
import { TicketService } from "../providers/tickets.service";
|
||||||
import { UserId } from "src/common/decorators";
|
import { UserId } from "src/common/decorators";
|
||||||
import { AdminId } from "src/common/decorators/admin-id.decorator";
|
import { AdminId } from "src/common/decorators/admin-id.decorator";
|
||||||
import { UpdateTicketDto } from "./DTO/update-ticket.dto";
|
import { UpdateTicketDto } from "../DTO/update-ticket.dto";
|
||||||
|
|
||||||
@Controller()
|
@Controller()
|
||||||
@ApiTags("Tickets")
|
@ApiTags("Tickets")
|
||||||
|
|
||||||
export class TicketsController {
|
export class TicketController {
|
||||||
constructor(private readonly ticketsService: TicketService) { }
|
constructor(private readonly ticketsService: TicketService) { }
|
||||||
|
|
||||||
//----------------- ticket categories -------------------
|
|
||||||
|
|
||||||
// @ApiOperation({ summary: "Create ticket category => admin route" })
|
|
||||||
// @PermissionsDec(PermissionEnum.TICKETS)
|
|
||||||
// @Post("category")
|
|
||||||
// createTicketCategory(@Body() createDto: CreateTicketCategoryDto, @UserIpAndHeaders() userIpAndHeaders: IUserIpAndHeaders) {
|
|
||||||
// return this.ticketsService.createTicketCategory(createDto, userIpAndHeaders);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @ApiOperation({ summary: "Update ticket category => admin route" })
|
|
||||||
// @PermissionsDec(PermissionEnum.TICKETS)
|
|
||||||
// @Patch("category/:id")
|
|
||||||
// updateCategory(
|
|
||||||
// @Param() paramDto: ParamDto,
|
|
||||||
// @Body() updateCategoryDto: UpdateTicketCategoryDto,
|
|
||||||
// @UserIpAndHeaders() userIpAndHeaders: IUserIpAndHeaders,
|
|
||||||
// ) {
|
|
||||||
// return this.ticketsService.updateCategory(paramDto, updateCategoryDto, userIpAndHeaders);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @ApiOperation({ summary: "Get ticket categories " })
|
|
||||||
// @Get("categories")
|
|
||||||
// getTicketCategories() {
|
|
||||||
// return this.ticketsService.getTicketCategories();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @ApiOperation({ summary: "Get ticket categories list => admin route" })
|
|
||||||
// @AdminRoute()
|
|
||||||
// @PermissionsDec(PermissionEnum.TICKETS)
|
|
||||||
// @Get("categories-list")
|
|
||||||
// getCategoriesList(@Query() queryDto: SearchTicketCategoryDto) {
|
|
||||||
// return this.ticketsService.getCategoriesList(queryDto);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// @ApiOperation({ summary: "toggle status of categories => admin route" })
|
|
||||||
// @AdminRoute()
|
|
||||||
// @HttpCode(HttpStatus.OK)
|
|
||||||
// @PermissionsDec(PermissionEnum.TICKETS)
|
|
||||||
// @Post("category/toggle-status/:id")
|
|
||||||
// toggleCategoryStatus(@Param() paramDto: ParamDto, @UserIpAndHeaders() userIpAndHeaders: IUserIpAndHeaders) {
|
|
||||||
// return this.ticketsService.toggleCategoryStatus(paramDto, userIpAndHeaders);
|
|
||||||
// }
|
|
||||||
|
|
||||||
//----------------- ticket and ticket messages -------------------
|
|
||||||
|
|
||||||
@Post('public/ticket/order/:orderId')
|
@Post('public/ticket/order/:orderId')
|
||||||
@ApiOperation({ summary: "create ticket ==> user route" })
|
@ApiOperation({ summary: "create ticket ==> user route" })
|
||||||
createTicket(@Param('orderId') orderId: string, @Body() createDto: CreateTicketDto, @UserId() userId: string) {
|
createTicket(@Param('orderId') orderId: string, @Body() createDto: CreateTicketDto, @UserId() userId: string) {
|
||||||
@@ -8,6 +8,7 @@ import {
|
|||||||
import { User } from "../../user/entities/user.entity";
|
import { User } from "../../user/entities/user.entity";
|
||||||
import { Admin } from 'src/modules/admin/entities/admin.entity';
|
import { Admin } from 'src/modules/admin/entities/admin.entity';
|
||||||
import { Order } from 'src/modules/order/entities/order.entity';
|
import { Order } from 'src/modules/order/entities/order.entity';
|
||||||
|
import { AttachmentType } from '../interfaces/ticket';
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Ticket {
|
export class Ticket {
|
||||||
@@ -26,7 +27,7 @@ export class Ticket {
|
|||||||
admin?: Admin | null;
|
admin?: Admin | null;
|
||||||
|
|
||||||
@Property({ type: 'json', nullable: true })
|
@Property({ type: 'json', nullable: true })
|
||||||
attachments?: string[]
|
attachments?: AttachmentType[]
|
||||||
|
|
||||||
@ManyToOne(() => Order)
|
@ManyToOne(() => Order)
|
||||||
order!: Order
|
order!: Order
|
||||||
|
|||||||
@@ -1 +1,4 @@
|
|||||||
|
export interface AttachmentType {
|
||||||
|
type: string;
|
||||||
|
url: string;
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ import { forwardRef, Module } from "@nestjs/common";
|
|||||||
import { Ticket } from "./entities/ticket.entity";
|
import { Ticket } from "./entities/ticket.entity";
|
||||||
import { TicketService } from "./providers/tickets.service";
|
import { TicketService } from "./providers/tickets.service";
|
||||||
import { TicketRepository } from "./repositories/tickets.repository";
|
import { TicketRepository } from "./repositories/tickets.repository";
|
||||||
import { TicketsController } from "./tickets.controller";
|
import { TicketController } from "./controller/ticket.controller";
|
||||||
import { MikroOrmModule } from "@mikro-orm/nestjs";
|
import { MikroOrmModule } from "@mikro-orm/nestjs";
|
||||||
import { OrderModule } from "../order/order.module";
|
import { OrderModule } from "../order/order.module";
|
||||||
import { AdminModule } from "../admin/admin.module";
|
import { AdminModule } from "../admin/admin.module";
|
||||||
@@ -12,13 +12,13 @@ import { UserModule } from "../user/user.module";
|
|||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [
|
imports: [
|
||||||
forwardRef(()=>OrderModule),
|
forwardRef(() => OrderModule),
|
||||||
MikroOrmModule.forFeature([Ticket]),
|
MikroOrmModule.forFeature([Ticket]),
|
||||||
AdminModule,
|
AdminModule,
|
||||||
UserModule
|
UserModule
|
||||||
],
|
],
|
||||||
providers: [TicketService, TicketRepository],
|
providers: [TicketService, TicketRepository],
|
||||||
controllers: [TicketsController],
|
controllers: [TicketController],
|
||||||
exports: [TicketService, TicketRepository],
|
exports: [TicketService, TicketRepository],
|
||||||
})
|
})
|
||||||
export class TicketModule { }
|
export class TicketModule { }
|
||||||
|
|||||||
Reference in New Issue
Block a user