From 7d88a4020d7757110ceb4287167eafecaf1b0ecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=A7=81Ash=C3=BB=EA=A7=82?= <30575805+Ashu11-A@users.noreply.github.com> Date: Wed, 29 May 2024 16:43:24 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=86=95=20Add=20new=20information=20to=20t?= =?UTF-8?q?he=20Ticket=20table=20in=20Database?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/tickets/src/entity/Ticket.entry.ts | 137 +++++++++++++++++++-- 1 file changed, 126 insertions(+), 11 deletions(-) diff --git a/plugins/tickets/src/entity/Ticket.entry.ts b/plugins/tickets/src/entity/Ticket.entry.ts index 506da7e8..813b3142 100644 --- a/plugins/tickets/src/entity/Ticket.entry.ts +++ b/plugins/tickets/src/entity/Ticket.entry.ts @@ -1,6 +1,57 @@ import { BaseEntity, Column, CreateDateColumn, Entity, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm' import Guild from './Guild.entry' +export interface User { + name: string + displayName: string + id: string +} + +export interface History { + role: string + user: { + id: string + name: string + } + message: { + id: string + content: string + } + date: Date + deleted: boolean +} + +export interface Message { + channelId: string + messageId: string +} + +export interface TicketCategories { + title: string + emoji: string +} + +export interface Voice { + id: string + messageId: string +} + +export interface TicketType { + ownerId: string + title?: string + description?: string + closed: boolean + channelId: string + messageId: string + claim?: Message + voice?: Voice + category: TicketCategories + team: User[] + users: User[] + history: History[] + messages: Message[] +} + @Entity({ name: 'tickets' }) export default class Ticket extends BaseEntity { @PrimaryGeneratedColumn() @@ -10,8 +61,11 @@ export default class Ticket extends BaseEntity { guild!: Guild @Column() - owner!: string + ownerId!: string + @Column({ nullable: true }) + title!: string + @Column({ nullable: true }) description!: string @@ -23,16 +77,77 @@ export default class Ticket extends BaseEntity { @Column() messageId!: string - // claim?: Claim - // voice?: { - // id: string - // messageId: string - // } - // users: User[] - // team: User[] - // category: TicketCategories - // messages: Messages[] - // history: History[] + + @Column({ + type: 'simple-json', + nullable: true, + transformer: { + to(value: string): string { return JSON.stringify(value) }, + from(value: string): Message { return JSON.parse(value) }, + } + }) + claim!: Message + + @Column({ + type: 'simple-json', + nullable: true, + transformer: { + to(value: string): string { return JSON.stringify(value) }, + from(value: string): Voice { return JSON.parse(value) }, + } + }) + voice!: Voice + + @Column({ + type: 'simple-json', + nullable: true, + transformer: { + to(value: string): string { return JSON.stringify(value) }, + from(value: string): User[] { return JSON.parse(value) }, + } + }) + users!: User[] + + @Column({ + type: 'simple-json', + nullable: true, + transformer: { + to(value: string): string { return JSON.stringify(value) }, + from(value: string): User[] { return JSON.parse(value) }, + } + }) + team!: User[] + + @Column({ + type: 'simple-json', + nullable: true, + transformer: { + to(value: string): string { return JSON.stringify(value) }, + from(value: string): TicketCategories { return JSON.parse(value) }, + } + }) + category!: TicketCategories + + @Column({ + type: 'simple-json', + nullable: true, + transformer: { + to(value: string): string { return JSON.stringify(value) }, + from(value: string): Message[] { return JSON.parse(value) }, + } + }) + messages!: Message[] + + @Column({ + type: 'simple-json', + nullable: true, + transformer: { + to(value: string): string { return JSON.stringify(value) }, + from(value: string): History[] { return JSON.parse(value) }, + } + }) + history!: History[] + @UpdateDateColumn() updateAt!: Date @CreateDateColumn()