update: add new field for subscription of user when purchased
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
import { Column, Entity, Index, JoinTable, ManyToMany, ManyToOne, OneToMany } from "typeorm";
|
||||
import { Column, Entity, Index, ManyToOne, OneToMany } from "typeorm";
|
||||
|
||||
import { UserAnnouncement } from "./user-announcement.entity";
|
||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||
import { DanakService } from "../../danak-services/entities/danak-service.entity";
|
||||
import { UserGroup } from "../../users/entities/user-group.entity";
|
||||
import { User } from "../../users/entities/user.entity";
|
||||
|
||||
@Entity()
|
||||
@Index(["isPublic", "createdAt"])
|
||||
@@ -15,30 +13,22 @@ export class Announcement extends BaseEntity {
|
||||
@Column({ type: "text" })
|
||||
content: string;
|
||||
|
||||
@Column({ type: "timestamp", default: null, nullable: true })
|
||||
publishAt: Date;
|
||||
@Column({ type: "timestamp", nullable: true, default: null })
|
||||
publishAt: Date | null;
|
||||
|
||||
//TODO: Add customer here
|
||||
@ManyToOne(() => DanakService, (service) => service.announcements, { eager: true, onDelete: "CASCADE" })
|
||||
service: DanakService;
|
||||
targetService: DanakService;
|
||||
|
||||
@Column({ type: "boolean", default: false })
|
||||
isImportant: boolean;
|
||||
|
||||
@ManyToMany(() => UserGroup, (group) => group.announcements)
|
||||
targetGroups: UserGroup[];
|
||||
@OneToMany(() => UserAnnouncement, (userAnnouncement) => userAnnouncement.announcement)
|
||||
userAnnouncements: UserAnnouncement[];
|
||||
|
||||
@Column({ default: false })
|
||||
@Column({ type: "boolean", default: false })
|
||||
isPublic: boolean;
|
||||
|
||||
isPublicAnnouncement(): boolean {
|
||||
return this.isPublic;
|
||||
}
|
||||
|
||||
@ManyToMany(() => User, (user) => user.announcements)
|
||||
@JoinTable({ name: "announcement_users" })
|
||||
users: User[];
|
||||
|
||||
@OneToMany(() => UserAnnouncement, (userAnnouncement) => userAnnouncement.announcement)
|
||||
userAnnouncements: UserAnnouncement[];
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Column, Entity, JoinColumn, ManyToOne } from "typeorm";
|
||||
import { Column, Entity, ManyToOne } from "typeorm";
|
||||
|
||||
import { Announcement } from "./announcement.entity";
|
||||
import { BaseEntity } from "../../../common/entities/base.entity";
|
||||
@@ -7,11 +7,9 @@ import { User } from "../../users/entities/user.entity"; // Assuming you have a
|
||||
@Entity()
|
||||
export class UserAnnouncement extends BaseEntity {
|
||||
@ManyToOne(() => User, (user) => user.userAnnouncements, { onDelete: "CASCADE" })
|
||||
@JoinColumn({ name: "userId" })
|
||||
user: User;
|
||||
|
||||
@ManyToOne(() => Announcement, (announcement) => announcement.userAnnouncements, { onDelete: "CASCADE" })
|
||||
@JoinColumn({ name: "announcementId" })
|
||||
announcement: Announcement;
|
||||
|
||||
@Column({ type: "boolean", default: false })
|
||||
|
||||
Reference in New Issue
Block a user