106 lines
1.6 KiB
TypeScript
106 lines
1.6 KiB
TypeScript
import {
|
|
Table,
|
|
Column,
|
|
CreatedAt,
|
|
UpdatedAt,
|
|
Model,
|
|
PrimaryKey,
|
|
ForeignKey,
|
|
BelongsTo,
|
|
HasMany,
|
|
HasOne,
|
|
AutoIncrement,
|
|
Default,
|
|
DataType
|
|
} from "sequelize-typescript";
|
|
|
|
import Contact from "./Contact";
|
|
import Message from "./Message";
|
|
import Queue from "./Queue";
|
|
import User from "./User";
|
|
import Whatsapp from "./Whatsapp";
|
|
|
|
import SchedulingNotify from "./SchedulingNotify";
|
|
import StatusChatEnd from "./StatusChatEnd";
|
|
|
|
@Table
|
|
class Ticket extends Model<Ticket> {
|
|
@PrimaryKey
|
|
@AutoIncrement
|
|
@Column
|
|
id: number;
|
|
|
|
@Column({ defaultValue: "pending" })
|
|
status: string;
|
|
|
|
@Column
|
|
unreadMessages: number;
|
|
|
|
@Column
|
|
lastMessage: string;
|
|
|
|
@Default(false)
|
|
@Column
|
|
isGroup: boolean;
|
|
|
|
@Default(false)
|
|
@Column
|
|
isRemote: boolean;
|
|
|
|
@Default(false)
|
|
@Column
|
|
remoteDone: boolean;
|
|
|
|
@ForeignKey(() => StatusChatEnd)
|
|
@Column
|
|
statusChatEndId: number;
|
|
|
|
@Column
|
|
statusChatEnd: string;
|
|
|
|
@Column
|
|
phoneNumberId: string;
|
|
|
|
@CreatedAt
|
|
createdAt: Date;
|
|
|
|
@UpdatedAt
|
|
updatedAt: Date;
|
|
|
|
@ForeignKey(() => User)
|
|
@Column
|
|
userId: number;
|
|
|
|
@BelongsTo(() => User)
|
|
user: User;
|
|
|
|
@ForeignKey(() => Contact)
|
|
@Column
|
|
contactId: number;
|
|
|
|
@BelongsTo(() => Contact)
|
|
contact: Contact;
|
|
|
|
@ForeignKey(() => Whatsapp)
|
|
@Column
|
|
whatsappId: number;
|
|
|
|
@BelongsTo(() => Whatsapp)
|
|
whatsapp: Whatsapp;
|
|
|
|
@ForeignKey(() => Queue)
|
|
@Column
|
|
queueId: number;
|
|
|
|
@BelongsTo(() => Queue)
|
|
queue: Queue;
|
|
|
|
@HasMany(() => Message)
|
|
messages: Message[];
|
|
|
|
@HasMany(() => SchedulingNotify)
|
|
schedulingNotify: SchedulingNotify[];
|
|
}
|
|
|
|
export default Ticket;
|