chore: discount module
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
import { Column, Entity, JoinColumn, OneToOne, Unique } from "typeorm";
|
||||
|
||||
import { User } from "./user.entity";
|
||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||
|
||||
@Unique(["user"])
|
||||
@Entity()
|
||||
export class LegalUser extends BaseEntity {
|
||||
@Column({ nullable: true })
|
||||
economicCode: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
registrationId: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
nationalId: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
number: string;
|
||||
|
||||
@OneToOne(() => User, (user) => user.legalUser, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
user: User;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
import { Column, Entity, JoinColumn, OneToOne, Unique } from "typeorm";
|
||||
|
||||
import { User } from "./user.entity";
|
||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||
import { GenderType } from "../enums/gender-type.enum";
|
||||
|
||||
@Unique(["user"])
|
||||
@Entity()
|
||||
export class RealUser extends BaseEntity {
|
||||
@Column({
|
||||
type: "enum",
|
||||
enum: GenderType,
|
||||
nullable: true,
|
||||
})
|
||||
gender: GenderType;
|
||||
|
||||
@Column({ nullable: true })
|
||||
fatherName: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
nationality: string;
|
||||
|
||||
@OneToOne(() => User, (user) => user.realUser, { onDelete: "CASCADE" })
|
||||
@JoinColumn()
|
||||
user: User;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
import { Column, Entity, ManyToOne, Unique } from "typeorm";
|
||||
|
||||
import { User } from "./user.entity";
|
||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||
import { FinancialType } from "../enums/financial-type.enum";
|
||||
|
||||
@Unique(["user", "type"])
|
||||
@Entity()
|
||||
export class UserFinancial extends BaseEntity {
|
||||
@Column({
|
||||
type: "enum",
|
||||
enum: FinancialType,
|
||||
default: FinancialType.REAL,
|
||||
})
|
||||
type: FinancialType;
|
||||
|
||||
@Column({ nullable: true })
|
||||
economicCode: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
registrationId: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
nationalId: string;
|
||||
|
||||
@Column({ nullable: true })
|
||||
number: string;
|
||||
|
||||
@ManyToOne(() => User, (user) => user.userFinancials)
|
||||
user: User;
|
||||
}
|
||||
@@ -1,12 +1,14 @@
|
||||
import { Exclude } from "class-transformer";
|
||||
import { Column, Entity, ManyToMany, ManyToOne, OneToMany, OneToOne } from "typeorm";
|
||||
|
||||
import { LegalUser } from "./legal-user.entity";
|
||||
import { RealUser } from "./real-user.entity";
|
||||
import { Role } from "./role.entity";
|
||||
import { UserFinancial } from "./user-financial.entity";
|
||||
import { UserGroup } from "./user-group.entity";
|
||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||
import { UserAnnouncement } from "../../announcements/entities/user-announcement.entity";
|
||||
import { Criticism } from "../../criticisms/entities/criticism.entity";
|
||||
import { Discount } from "../../discounts/entities/discount.entity";
|
||||
import { Invoice } from "../../invoices/entities/invoice.entity";
|
||||
import { LearningProgress } from "../../learnings/entities/learning-progress.entity";
|
||||
import { Notification } from "../../notifications/entities/notification.entity";
|
||||
@@ -84,8 +86,14 @@ export class User extends BaseEntity {
|
||||
@OneToMany(() => LearningProgress, (learningProgress) => learningProgress.learning)
|
||||
learningProgress: LearningProgress[];
|
||||
|
||||
@OneToMany(() => UserFinancial, (userFinancial) => userFinancial.user)
|
||||
userFinancials: UserFinancial[];
|
||||
@ManyToMany(() => Discount, (discount) => discount.subscriptionPlans)
|
||||
discounts: Discount[];
|
||||
|
||||
@OneToOne(() => RealUser, (realUser) => realUser.user, { cascade: true, nullable: true })
|
||||
realUser: RealUser;
|
||||
|
||||
@OneToOne(() => LegalUser, (legalUser) => legalUser.user, { cascade: true, nullable: true })
|
||||
legalUser: LegalUser;
|
||||
}
|
||||
|
||||
// @ManyToMany(() => DanakService, (danakService) => danakService.users)
|
||||
|
||||
Reference in New Issue
Block a user