128 lines
4.6 KiB
TypeScript
Executable File
128 lines
4.6 KiB
TypeScript
Executable File
import { Exclude } from "class-transformer";
|
|
import { Column, Entity, JoinTable, ManyToMany, OneToMany, OneToOne } from "typeorm";
|
|
|
|
import { LegalUser } from "./legal-user.entity";
|
|
import { RealUser } from "./real-user.entity";
|
|
import { Role } from "./role.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 { DanakServiceReview } from "../../danak-services/entities/danak-service-review.entity";
|
|
import { Discount } from "../../discounts/entities/discount.entity";
|
|
import { UsageDiscount } from "../../discounts/entities/usage-discount.entity";
|
|
import { Invoice } from "../../invoices/entities/invoice.entity";
|
|
import { LearningProgress } from "../../learnings/entities/learning-progress.entity";
|
|
import { Notification } from "../../notifications/entities/notification.entity";
|
|
import { Payment } from "../../payments/entities/payment.entity";
|
|
import { UserSetting } from "../../settings/entities/user-setting.entity";
|
|
import { UserQuickAccess } from "../../subscriptions/entities/user-quick-access.entity";
|
|
import { UserSubscription } from "../../subscriptions/entities/user-subscription.entity";
|
|
import { TicketMessage } from "../../tickets/entities/ticket-message.entity";
|
|
import { Ticket } from "../../tickets/entities/ticket.entity";
|
|
import { Wallet } from "../../wallets/entities/wallet.entity";
|
|
import { FinancialType } from "../enums/financial-type.enum";
|
|
|
|
@Entity()
|
|
export class User extends BaseEntity {
|
|
@Column({ type: "varchar", length: 150, nullable: true })
|
|
email: string;
|
|
|
|
@Column({ type: "varchar", length: 11, unique: true, nullable: false })
|
|
phone: string;
|
|
|
|
@Column({ type: "varchar", length: 50, unique: true, nullable: true })
|
|
userName: string;
|
|
|
|
@Exclude()
|
|
@Column({ type: "varchar", length: 150 })
|
|
password: string;
|
|
|
|
@Column({ type: "varchar", length: 150 })
|
|
firstName: string;
|
|
|
|
@Column({ type: "varchar", length: 200 })
|
|
lastName: string;
|
|
|
|
@Column({ type: "varchar", length: 12, nullable: true })
|
|
birthDate: string;
|
|
|
|
@Column({ type: "varchar", length: 100, unique: true, nullable: true })
|
|
nationalCode: string | null;
|
|
|
|
@Column({ type: "varchar", length: 100, nullable: true })
|
|
profilePic: string;
|
|
|
|
@Column({ type: "boolean", default: false })
|
|
emailVerified: boolean;
|
|
|
|
@Column({ type: "enum", enum: FinancialType, nullable: true, default: null })
|
|
financialType: FinancialType | null;
|
|
|
|
//-----------------------------------------
|
|
|
|
@ManyToMany(() => Role, (role) => role.users)
|
|
@JoinTable({ name: "user_role_relation" })
|
|
roles: Role[];
|
|
|
|
@ManyToMany(() => UserGroup, (group) => group.users)
|
|
groups: UserGroup[];
|
|
|
|
//---------------------------------------
|
|
|
|
@OneToMany(() => DanakServiceReview, (danakServiceReview) => danakServiceReview.user)
|
|
reviews: DanakServiceReview[];
|
|
|
|
@OneToMany(() => Ticket, (ticket) => ticket.user)
|
|
tickets: Ticket[];
|
|
|
|
@OneToMany(() => TicketMessage, (ticketMessage) => ticketMessage.author)
|
|
ticketMessage: TicketMessage[];
|
|
|
|
@OneToMany(() => Criticism, (criticism) => criticism.user)
|
|
criticisms: Criticism[];
|
|
|
|
@OneToMany(() => UserSetting, (settings) => settings.user, { nullable: false })
|
|
settings: UserSetting;
|
|
|
|
@OneToOne(() => Wallet, (wallet) => wallet.user)
|
|
wallet: Wallet;
|
|
|
|
@OneToMany(() => Payment, (payment) => payment.user)
|
|
payments: Payment[];
|
|
|
|
@OneToMany(() => Notification, (notification) => notification.recipient)
|
|
notifications: Notification[];
|
|
|
|
@OneToMany(() => UserSubscription, (subscription) => subscription.user)
|
|
subscriptions: UserSubscription[];
|
|
|
|
@OneToMany(() => Invoice, (invoice) => invoice.user)
|
|
invoices: Invoice[];
|
|
|
|
@OneToMany(() => LearningProgress, (learningProgress) => learningProgress.learning)
|
|
learningProgress: LearningProgress[];
|
|
|
|
@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(() => UsageDiscount, (usageDiscount) => usageDiscount.users)
|
|
usageDiscounts: UsageDiscount[];
|
|
|
|
@OneToMany(() => UserAnnouncement, (userAnnouncement) => userAnnouncement.user)
|
|
userAnnouncements: UserAnnouncement[];
|
|
|
|
@OneToMany(() => UserQuickAccess, (quickAccess) => quickAccess.user)
|
|
quickAccesses: UserQuickAccess[];
|
|
}
|
|
|
|
// @ManyToMany(() => DanakService, (danakService) => danakService.users)
|
|
// @JoinTable()
|
|
// danakServices: DanakService[];
|