Add new page module and services; refactor existing entities

- Introduced a new page module with associated services.
- Refactored TypeORM entities in user and workspace modules.
This commit is contained in:
Philipinho
2023-08-22 19:48:57 +01:00
parent c0b2bc1f57
commit f11f9f6210
14 changed files with 282 additions and 52 deletions

View File

@@ -0,0 +1,88 @@
import {
Entity,
PrimaryGeneratedColumn,
Column,
CreateDateColumn,
UpdateDateColumn,
ManyToOne,
JoinColumn,
OneToMany,
DeleteDateColumn,
} from 'typeorm';
import { User } from '../../user/entities/user.entity';
import { Workspace } from '../../workspace/entities/workspace.entity';
@Entity('pages')
export class Page {
@PrimaryGeneratedColumn('uuid')
id: string;
@Column({ length: 500, nullable: true })
title: string;
@Column({ type: 'text', nullable: true })
content: string;
@Column({ type: 'text', nullable: true })
html: string;
@Column({ type: 'jsonb', nullable: true })
json: any;
@Column({ nullable: true })
slug: string;
@Column({ nullable: true })
icon: string;
@Column({ nullable: true })
coverPhoto: string;
@Column({ length: 255, nullable: true })
editor: string;
@Column({ length: 255, nullable: true })
shareId: string;
@Column({ type: 'uuid', nullable: true })
parentPageId: string;
@Column()
creatorId: string;
@ManyToOne(() => User)
@JoinColumn({ name: 'creatorId' })
creator: User;
@Column()
workspaceId: string;
@ManyToOne(() => Workspace, { onDelete: 'CASCADE' })
@JoinColumn({ name: 'workspaceId' })
workspace: Workspace;
@Column({ type: 'boolean', default: false })
isLocked: boolean;
@Column({ length: 255, nullable: true })
status: string;
@Column({ type: 'date', nullable: true })
publishedAt: string;
@CreateDateColumn()
createdAt: Date;
@UpdateDateColumn()
updatedAt: Date;
@DeleteDateColumn({ nullable: true })
deletedAt: Date;
@ManyToOne(() => Page, (page) => page.childPages)
@JoinColumn({ name: 'parentPageId' })
parentPage: Page;
@OneToMany(() => Page, (page) => page.parentPage, { onDelete: 'CASCADE' })
childPages: Page[];
}