This commit is contained in:
fro1991
2025-10-18 01:23:09 +07:00
parent dd81a28d4e
commit 16bc4cd34d
8 changed files with 340 additions and 0 deletions

View File

@ -57,11 +57,20 @@ export class TrxCustomerAccount {
@CreateDateColumn()
created_at: Date;
@Column({ nullable: true, length: 256 })
created_by: string;
@Column({ nullable: true })
@UpdateDateColumn()
updated_at: Date;
@Column({ nullable: true, length: 256 })
updated_by: string;
@Column({ nullable: true })
@DeleteDateColumn()
deleted_at: Date;
@Column({ nullable: true, length: 256 })
deleted_by: string;
}

View File

@ -0,0 +1,77 @@
import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
import { Status } from "../types/status";
import { TrxCostType, TrxCustomerType } from "../types/trx";
import { TrxCustomer } from "./trx_customers";
@Entity("trx_customer_cost", { schema: "trx" })
export class TrxCustomerCost {
@PrimaryGeneratedColumn("uuid")
id: string;
@ManyToOne(() => TrxCustomer, { onDelete: "RESTRICT" })
@JoinColumn()
customer: TrxCustomer;
@Column({
nullable: false,
length: 4096,
})
type: TrxCostType;
@Column({
nullable: false,
type: "float8",
})
min_amount: number;
@Column({
nullable: false,
type: "float8",
})
max_amount: number;
@Column({
nullable: false,
type: "float8",
})
percentage: number;
@Column({
nullable: true,
type: "float8",
})
min_cost: number;
@Column({
nullable: true,
type: "float8",
})
max_cost: number;
@Column({
nullable: false,
length: 64,
})
status: Status;
@Column()
@CreateDateColumn()
created_at: Date;
@Column({ nullable: true, length: 256 })
created_by: string;
@Column({ nullable: true })
@UpdateDateColumn()
updated_at: Date;
@Column({ nullable: true, length: 256 })
updated_by: string;
@Column({ nullable: true })
@DeleteDateColumn()
deleted_at: Date;
@Column({ nullable: true, length: 256 })
deleted_by: string;
}

View File

@ -0,0 +1,63 @@
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, JoinColumn, ManyToOne } from "typeorm";
import { ActivityType } from "../types/action";
import { TrxCustomerUser } from "./trx_customer_users";
@Entity("trx_customer_user_activities", { schema: "trx" })
export class TrxCustomerUserActivity {
@PrimaryGeneratedColumn("uuid")
id: string;
@ManyToOne(() => TrxCustomerUser, { onDelete: "NO ACTION", nullable: false })
@JoinColumn()
user: TrxCustomerUser;
@Index()
@Column({
type: "uuid",
})
refresh_token: string;
@Index()
@Column({
nullable: false,
length: 512,
})
module: string;
@Column({
nullable: false,
length: 2048,
})
description: string;
@Column({
nullable: true,
length: 1,
})
action: ActivityType;
@Column({
nullable: false,
length: 2048,
})
url: String;
@Column({
type: "text",
nullable: true,
})
data_body: String;
@Column()
@CreateDateColumn()
created_at: Date;
@Column({ nullable: true })
@UpdateDateColumn()
updated_at: Date;
@Column({ nullable: true })
@DeleteDateColumn()
deleted_at: Date;
}

View File

@ -0,0 +1,64 @@
import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index } from "typeorm";
@Entity("trx_customer_user_refresh_tokens", { schema: "trx" })
export class TrxCustomerUserRefreshToken {
@PrimaryGeneratedColumn("uuid")
refresh_token: string;
@Index()
@Column({
type: "uuid",
})
id_user: string;
@Column({
nullable: false,
length: 4096,
})
user_agent: string;
@Column({
nullable: true,
length: 128,
})
os: string;
@Column({
nullable: true,
length: 256,
})
device: string;
@Column({
nullable: true,
length: 64,
})
platform: string;
@Column({
nullable: true,
length: 64,
})
browser: string;
@Column({
nullable: true,
length: 32,
})
remote_addr: string;
@Column("timestamp")
expired_at: Date;
@Column()
@CreateDateColumn()
created_at: Date;
@Column({ nullable: true })
@UpdateDateColumn()
updated_at: Date;
@Column({ nullable: true })
@DeleteDateColumn()
deleted_at: Date;
}

View File

@ -0,0 +1,105 @@
import bcrypt from "bcryptjs";
import { Column, CreateDateColumn, DeleteDateColumn, Entity, Index, JoinTable, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
import { Status } from "../types/status";
import { TrxCustomer } from "./trx_customers";
@Entity("trx_customer_users", { schema: "trx" })
export class TrxCustomerUser {
@PrimaryGeneratedColumn("uuid")
id: string;
@ManyToOne(() => TrxCustomer, { onDelete: "RESTRICT" })
@JoinTable()
customer: TrxCustomer;
@Column({
nullable: false,
unique: true,
length: 64,
})
email: string;
@Column({
nullable: false,
unique: true,
length: 256,
})
phone: string;
@Column({
nullable: false,
length: 64,
select: false,
})
password: string;
@Column({
nullable: false,
unique: true,
length: 64,
})
username: string;
@Column({
nullable: false,
length: 64,
unique: false,
})
name: string;
@Column({
nullable: false,
length: 256,
})
file: string;
@Column({
type: "jsonb",
nullable: true,
})
level: string[];
@Index()
@Column({
nullable: true,
type: "uuid",
select: false,
})
reset_token: string;
@Column({
nullable: false,
length: 64,
})
status: Status;
@Column()
@CreateDateColumn()
created_at: Date;
@Column({ nullable: true, length: 256 })
created_by: string;
@Column({ nullable: true })
@UpdateDateColumn()
updated_at: Date;
@Column({ nullable: true, length: 256 })
updated_by: string;
@Column({ nullable: true })
@DeleteDateColumn()
deleted_at: Date;
@Column({ nullable: true, length: 256 })
deleted_by: string;
hashPassword() {
this.password = bcrypt.hashSync(this.password, 8);
}
checkIfPasswordMatch(unencryptedPassword: string) {
return bcrypt.compareSync(unencryptedPassword, this.password);
}
}

View File

@ -53,6 +53,18 @@ export class TrxCustomer {
})
pic_email: string;
@Column({
nullable: false,
length: 256,
})
pic_file: string;
@Column({
nullable: false,
length: 256,
})
cover: string;
@Column({
nullable: false,
length: 256,

View File

@ -45,4 +45,8 @@ export * from "../entity/trx_partner_users";
export * from "../entity/trx_customers";
export * from "../entity/trx_customer_accounts";
export * from "../entity/trx_customer_users";
export * from "../entity/trx_customer_user_refresh_tokens";
export * from "../entity/trx_customer_user_activities";
export * from "../entity/trx_customer_costs";
export * from "../types/trx";

View File

@ -3,6 +3,12 @@ export enum TrxCustomerType {
"business" = "business",
}
export enum TrxCostType {
"domestic" = "domestic",
"remittance" = "remittance",
"swift" = "swift",
}
export enum TrxTransactionStatus {
"verify" = "verify",
"open" = "open",