Skip to content

Commit

Permalink
🆕 Add new information to the Ticket table in Database
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashu11-A committed May 29, 2024
1 parent 09fe19f commit 7d88a40
Showing 1 changed file with 126 additions and 11 deletions.
137 changes: 126 additions & 11 deletions plugins/tickets/src/entity/Ticket.entry.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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

Expand All @@ -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()
Expand Down

0 comments on commit 7d88a40

Please sign in to comment.