attachment
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
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";
|
||||
|
||||
|
||||
@@ -15,6 +15,6 @@ export class CreateTicketDto {
|
||||
@IsNotEmpty({ message: TicketMessageEnum.ATTACHMENT_REQUIRED })
|
||||
@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"] })
|
||||
attachments?: string[];
|
||||
attachments?: AttachmentType[];
|
||||
}
|
||||
|
||||
|
||||
+5
-50
@@ -1,63 +1,18 @@
|
||||
import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from "@nestjs/common";
|
||||
import { ApiOperation, ApiTags } from "@nestjs/swagger";
|
||||
import { CreateTicketDto } from "./DTO/create-ticket.dto";
|
||||
import { FindTicketQueryDto } from "./DTO/search-ticket-query.dto";
|
||||
import { TicketService } from "./providers/tickets.service";
|
||||
import { CreateTicketDto } from "../DTO/create-ticket.dto";
|
||||
import { FindTicketQueryDto } from "../DTO/search-ticket-query.dto";
|
||||
import { TicketService } from "../providers/tickets.service";
|
||||
import { UserId } from "src/common/decorators";
|
||||
import { AdminId } from "src/common/decorators/admin-id.decorator";
|
||||
import { UpdateTicketDto } from "./DTO/update-ticket.dto";
|
||||
import { UpdateTicketDto } from "../DTO/update-ticket.dto";
|
||||
|
||||
@Controller()
|
||||
@ApiTags("Tickets")
|
||||
|
||||
export class TicketsController {
|
||||
export class TicketController {
|
||||
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')
|
||||
@ApiOperation({ summary: "create ticket ==> user route" })
|
||||
createTicket(@Param('orderId') orderId: string, @Body() createDto: CreateTicketDto, @UserId() userId: string) {
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
import { User } from "../../user/entities/user.entity";
|
||||
import { Admin } from 'src/modules/admin/entities/admin.entity';
|
||||
import { Order } from 'src/modules/order/entities/order.entity';
|
||||
import { AttachmentType } from '../interfaces/ticket';
|
||||
|
||||
@Entity()
|
||||
export class Ticket {
|
||||
@@ -26,7 +27,7 @@ export class Ticket {
|
||||
admin?: Admin | null;
|
||||
|
||||
@Property({ type: 'json', nullable: true })
|
||||
attachments?: string[]
|
||||
attachments?: AttachmentType[]
|
||||
|
||||
@ManyToOne(() => 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 { TicketService } from "./providers/tickets.service";
|
||||
import { TicketRepository } from "./repositories/tickets.repository";
|
||||
import { TicketsController } from "./tickets.controller";
|
||||
import { TicketController } from "./controller/ticket.controller";
|
||||
import { MikroOrmModule } from "@mikro-orm/nestjs";
|
||||
import { OrderModule } from "../order/order.module";
|
||||
import { AdminModule } from "../admin/admin.module";
|
||||
@@ -12,13 +12,13 @@ import { UserModule } from "../user/user.module";
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
forwardRef(()=>OrderModule),
|
||||
forwardRef(() => OrderModule),
|
||||
MikroOrmModule.forFeature([Ticket]),
|
||||
AdminModule,
|
||||
UserModule
|
||||
],
|
||||
providers: [TicketService, TicketRepository],
|
||||
controllers: [TicketsController],
|
||||
controllers: [TicketController],
|
||||
exports: [TicketService, TicketRepository],
|
||||
})
|
||||
export class TicketModule { }
|
||||
|
||||
Reference in New Issue
Block a user