mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-18 03:39:29 +00:00
changed contacts routes to typescript
This commit is contained in:
45
backend/src/models/Contact.ts
Normal file
45
backend/src/models/Contact.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import {
|
||||
Table,
|
||||
Column,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
Model,
|
||||
DataType,
|
||||
PrimaryKey,
|
||||
AutoIncrement,
|
||||
AllowNull,
|
||||
Unique,
|
||||
Default
|
||||
} from "sequelize-typescript";
|
||||
|
||||
@Table
|
||||
class Contact extends Model<Contact> {
|
||||
@PrimaryKey
|
||||
@AutoIncrement
|
||||
@Column
|
||||
id: number;
|
||||
|
||||
@Column(DataType.STRING)
|
||||
name: string;
|
||||
|
||||
@AllowNull(false)
|
||||
@Unique
|
||||
@Column
|
||||
number: string;
|
||||
|
||||
@AllowNull(false)
|
||||
@Default("")
|
||||
@Column
|
||||
email: string;
|
||||
|
||||
@Column
|
||||
profilePicUrl: string;
|
||||
|
||||
@CreatedAt
|
||||
createdAt: Date;
|
||||
|
||||
@UpdatedAt
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export default Contact;
|
||||
@@ -4,16 +4,17 @@ import {
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
Model,
|
||||
DataType,
|
||||
PrimaryKey
|
||||
} from "sequelize-typescript";
|
||||
|
||||
@Table
|
||||
class Setting extends Model<Setting> {
|
||||
@PrimaryKey
|
||||
@Column
|
||||
@Column(DataType.STRING)
|
||||
key: string;
|
||||
|
||||
@Column
|
||||
@Column(DataType.STRING)
|
||||
value: string;
|
||||
|
||||
@CreatedAt
|
||||
|
||||
36
backend/src/models/Ticket.ts
Normal file
36
backend/src/models/Ticket.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import {
|
||||
Table,
|
||||
Column,
|
||||
CreatedAt,
|
||||
UpdatedAt,
|
||||
Model,
|
||||
DataType,
|
||||
PrimaryKey
|
||||
} from "sequelize-typescript";
|
||||
|
||||
@Table
|
||||
class Ticket extends Model<Ticket> {
|
||||
@PrimaryKey
|
||||
@Column(DataType.NUMBER)
|
||||
id: number;
|
||||
|
||||
@Column({ defaultValue: "pending" })
|
||||
status: string;
|
||||
|
||||
// @Column({ allowNull: false, unique: true })
|
||||
// userId: string;
|
||||
|
||||
@Column(DataType.VIRTUAL)
|
||||
unreadMessages: string;
|
||||
|
||||
@Column(DataType.STRING)
|
||||
lastMessage: string;
|
||||
|
||||
@CreatedAt
|
||||
createdAt: Date;
|
||||
|
||||
@UpdatedAt
|
||||
updatedAt: Date;
|
||||
}
|
||||
|
||||
export default Ticket;
|
||||
@@ -7,20 +7,23 @@ import {
|
||||
DataType,
|
||||
BeforeCreate,
|
||||
BeforeUpdate,
|
||||
PrimaryKey
|
||||
PrimaryKey,
|
||||
AutoIncrement,
|
||||
Default
|
||||
} from "sequelize-typescript";
|
||||
import { hash, compare } from "bcryptjs";
|
||||
|
||||
@Table
|
||||
class User extends Model<User> {
|
||||
@PrimaryKey
|
||||
@AutoIncrement
|
||||
@Column
|
||||
id: number;
|
||||
|
||||
@Column
|
||||
name: string;
|
||||
|
||||
@Column(DataType.STRING)
|
||||
@Column
|
||||
email: string;
|
||||
|
||||
@Column(DataType.VIRTUAL)
|
||||
@@ -29,9 +32,8 @@ class User extends Model<User> {
|
||||
@Column
|
||||
passwordHash: string;
|
||||
|
||||
@Column({
|
||||
defaultValue: "admin"
|
||||
})
|
||||
@Default("admin")
|
||||
@Column
|
||||
profile: string;
|
||||
|
||||
@CreatedAt
|
||||
@@ -48,10 +50,7 @@ class User extends Model<User> {
|
||||
}
|
||||
};
|
||||
|
||||
public checkPassword = async (
|
||||
// maybe not work like this.
|
||||
password: string
|
||||
): Promise<boolean> => {
|
||||
public checkPassword = async (password: string): Promise<boolean> => {
|
||||
return compare(password, this.getDataValue("passwordHash"));
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user